html2pdf-accessible 0.0.0-stage → 0.1.5
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/LICENSE +21 -0
- package/README.md +219 -2
- package/THIRD_PARTY_NOTICES.md +15 -0
- package/deps/canvaskit-pdf/CHROMIUM-LICENSE +27 -0
- package/deps/canvaskit-pdf/LICENSE +29 -0
- package/deps/canvaskit-pdf/README.md +35 -0
- package/deps/canvaskit-pdf/THIRD_PARTY_LICENSES.txt +2152 -0
- package/deps/canvaskit-pdf/bin/canvaskit.js +215 -0
- package/deps/canvaskit-pdf/chromium-license-source.json +5 -0
- package/deps/canvaskit-pdf/package.json +22 -0
- package/deps/canvaskit-pdf/pdf_bindings.cpp +179 -0
- package/deps/canvaskit-pdf/provenance.json +37 -0
- package/deps/canvaskit-pdf/types/google-types.d.ts +4948 -0
- package/deps/canvaskit-pdf/types/index.d.ts +48 -0
- package/lib/html2pdf-accessible.cjs.js +3 -0
- package/lib/html2pdf-accessible.cjs.js.LICENSE.txt +14 -0
- package/lib/html2pdf-accessible.cjs.js.map +1 -0
- package/lib/html2pdf-accessible.esm.mjs +3 -0
- package/lib/html2pdf-accessible.esm.mjs.LICENSE.txt +14 -0
- package/lib/html2pdf-accessible.esm.mjs.map +1 -0
- package/lib/html2pdf-accessible.js +3 -0
- package/lib/html2pdf-accessible.js.LICENSE.txt +14 -0
- package/lib/html2pdf-accessible.js.map +1 -0
- package/lib/html2pdf-accessible.min.js +17 -0
- package/lib/html2pdf-accessible.min.js.map +1 -0
- package/lib/types/core/bitwise.d.ts +1 -0
- package/lib/types/core/cache-storage.d.ts +27 -0
- package/lib/types/core/context.d.ts +17 -0
- package/lib/types/core/debugger.d.ts +8 -0
- package/lib/types/core/features.d.ts +12 -0
- package/lib/types/core/logger.d.ts +18 -0
- package/lib/types/core/util.d.ts +1 -0
- package/lib/types/css/IPropertyDescriptor.d.ts +36 -0
- package/lib/types/css/ITypeDescriptor.d.ts +6 -0
- package/lib/types/css/index.d.ts +134 -0
- package/lib/types/css/layout/bounds.d.ts +14 -0
- package/lib/types/css/layout/text.d.ts +13 -0
- package/lib/types/css/property-descriptors/background-clip.d.ts +8 -0
- package/lib/types/css/property-descriptors/background-color.d.ts +2 -0
- package/lib/types/css/property-descriptors/background-image.d.ts +3 -0
- package/lib/types/css/property-descriptors/background-origin.d.ts +8 -0
- package/lib/types/css/property-descriptors/background-position.d.ts +5 -0
- package/lib/types/css/property-descriptors/background-repeat.d.ts +9 -0
- package/lib/types/css/property-descriptors/background-size.d.ts +11 -0
- package/lib/types/css/property-descriptors/border-color.d.ts +5 -0
- package/lib/types/css/property-descriptors/border-radius.d.ts +7 -0
- package/lib/types/css/property-descriptors/border-style.d.ts +12 -0
- package/lib/types/css/property-descriptors/border-width.d.ts +5 -0
- package/lib/types/css/property-descriptors/box-shadow.d.ts +14 -0
- package/lib/types/css/property-descriptors/color.d.ts +2 -0
- package/lib/types/css/property-descriptors/content.d.ts +4 -0
- package/lib/types/css/property-descriptors/counter-increment.d.ts +7 -0
- package/lib/types/css/property-descriptors/counter-reset.d.ts +7 -0
- package/lib/types/css/property-descriptors/direction.d.ts +6 -0
- package/lib/types/css/property-descriptors/display.d.ts +35 -0
- package/lib/types/css/property-descriptors/duration.d.ts +2 -0
- package/lib/types/css/property-descriptors/float.d.ts +9 -0
- package/lib/types/css/property-descriptors/font-family.d.ts +4 -0
- package/lib/types/css/property-descriptors/font-size.d.ts +2 -0
- package/lib/types/css/property-descriptors/font-style.d.ts +7 -0
- package/lib/types/css/property-descriptors/font-variant.d.ts +2 -0
- package/lib/types/css/property-descriptors/font-weight.d.ts +2 -0
- package/lib/types/css/property-descriptors/letter-spacing.d.ts +2 -0
- package/lib/types/css/property-descriptors/line-break.d.ts +6 -0
- package/lib/types/css/property-descriptors/line-height.d.ts +4 -0
- package/lib/types/css/property-descriptors/list-style-image.d.ts +3 -0
- package/lib/types/css/property-descriptors/list-style-position.d.ts +6 -0
- package/lib/types/css/property-descriptors/list-style-type.d.ts +58 -0
- package/lib/types/css/property-descriptors/margin.d.ts +5 -0
- package/lib/types/css/property-descriptors/object-fit.d.ts +10 -0
- package/lib/types/css/property-descriptors/opacity.d.ts +2 -0
- package/lib/types/css/property-descriptors/overflow-wrap.d.ts +6 -0
- package/lib/types/css/property-descriptors/overflow.d.ts +9 -0
- package/lib/types/css/property-descriptors/padding.d.ts +5 -0
- package/lib/types/css/property-descriptors/paint-order.d.ts +8 -0
- package/lib/types/css/property-descriptors/position.d.ts +9 -0
- package/lib/types/css/property-descriptors/quotes.d.ts +8 -0
- package/lib/types/css/property-descriptors/text-align.d.ts +7 -0
- package/lib/types/css/property-descriptors/text-decoration-color.d.ts +2 -0
- package/lib/types/css/property-descriptors/text-decoration-line.d.ts +10 -0
- package/lib/types/css/property-descriptors/text-shadow.d.ts +12 -0
- package/lib/types/css/property-descriptors/text-transform.d.ts +8 -0
- package/lib/types/css/property-descriptors/transform-origin.d.ts +4 -0
- package/lib/types/css/property-descriptors/transform.d.ts +4 -0
- package/lib/types/css/property-descriptors/visibility.d.ts +7 -0
- package/lib/types/css/property-descriptors/webkit-text-stroke-color.d.ts +2 -0
- package/lib/types/css/property-descriptors/webkit-text-stroke-width.d.ts +2 -0
- package/lib/types/css/property-descriptors/word-break.d.ts +7 -0
- package/lib/types/css/property-descriptors/z-index.d.ts +7 -0
- package/lib/types/css/syntax/parser.d.ts +34 -0
- package/lib/types/css/syntax/tokenizer.d.ts +94 -0
- package/lib/types/css/types/angle.d.ts +7 -0
- package/lib/types/css/types/color-calculation.d.ts +3 -0
- package/lib/types/css/types/color-spaces/a98.d.ts +39 -0
- package/lib/types/css/types/color-spaces/p3.d.ts +45 -0
- package/lib/types/css/types/color-spaces/pro-photo.d.ts +45 -0
- package/lib/types/css/types/color-spaces/rec2020.d.ts +45 -0
- package/lib/types/css/types/color-spaces/srgb.d.ts +38 -0
- package/lib/types/css/types/color-utilities.d.ts +108 -0
- package/lib/types/css/types/color.d.ts +8 -0
- package/lib/types/css/types/functions/-prefix-linear-gradient.d.ts +4 -0
- package/lib/types/css/types/functions/-prefix-radial-gradient.d.ts +4 -0
- package/lib/types/css/types/functions/-webkit-gradient.d.ts +4 -0
- package/lib/types/css/types/functions/counter.d.ts +10 -0
- package/lib/types/css/types/functions/gradient.d.ts +7 -0
- package/lib/types/css/types/functions/linear-gradient.d.ts +4 -0
- package/lib/types/css/types/functions/radial-gradient.d.ts +12 -0
- package/lib/types/css/types/image.d.ts +54 -0
- package/lib/types/css/types/index.d.ts +1 -0
- package/lib/types/css/types/length-percentage.d.ts +11 -0
- package/lib/types/css/types/length.d.ts +4 -0
- package/lib/types/css/types/time.d.ts +2 -0
- package/lib/types/dom/document-cloner.d.ts +45 -0
- package/lib/types/dom/element-container.d.ts +20 -0
- package/lib/types/dom/elements/li-element-container.d.ts +6 -0
- package/lib/types/dom/elements/ol-element-container.d.ts +7 -0
- package/lib/types/dom/elements/select-element-container.d.ts +6 -0
- package/lib/types/dom/elements/textarea-element-container.d.ts +6 -0
- package/lib/types/dom/node-parser.d.ts +25 -0
- package/lib/types/dom/replaced-elements/canvas-element-container.d.ts +8 -0
- package/lib/types/dom/replaced-elements/iframe-element-container.d.ts +11 -0
- package/lib/types/dom/replaced-elements/image-element-container.d.ts +8 -0
- package/lib/types/dom/replaced-elements/index.d.ts +4 -0
- package/lib/types/dom/replaced-elements/input-element-container.d.ts +12 -0
- package/lib/types/dom/replaced-elements/pseudo-elements.d.ts +0 -0
- package/lib/types/dom/replaced-elements/svg-element-container.d.ts +8 -0
- package/lib/types/dom/text-container.d.ts +8 -0
- package/lib/types/fonts/font-collection.d.ts +25 -0
- package/lib/types/fonts/font-enumeration.d.ts +5 -0
- package/lib/types/fonts/font-style-mapping.d.ts +3 -0
- package/lib/types/fonts/interfaces.d.ts +27 -0
- package/lib/types/html2canvas.d.ts +10 -0
- package/lib/types/index.d.ts +7 -0
- package/lib/types/invariant.d.ts +1 -0
- package/lib/types/pdf/bookmarks.d.ts +4 -0
- package/lib/types/pdf/canvaskit-loader.d.ts +56 -0
- package/lib/types/pdf/document-structure.d.ts +105 -0
- package/lib/types/pdf/dom-updates.d.ts +6 -0
- package/lib/types/pdf/finalize-structure.d.ts +6 -0
- package/lib/types/pdf/hidden-captions.d.ts +15 -0
- package/lib/types/pdf/html-page-break.d.ts +11 -0
- package/lib/types/pdf/link-annotations.d.ts +8 -0
- package/lib/types/pdf/link-uri.d.ts +2 -0
- package/lib/types/pdf/logical-structure.d.ts +3 -0
- package/lib/types/pdf/pdf-export.d.ts +29 -0
- package/lib/types/pdf/single-html-multi-page.d.ts +14 -0
- package/lib/types/pdf/table-headers.d.ts +6 -0
- package/lib/types/pdf/xmp-metadata.d.ts +5 -0
- package/lib/types/render/background.d.ts +16 -0
- package/lib/types/render/bezier-curve.d.ts +14 -0
- package/lib/types/render/border.d.ts +6 -0
- package/lib/types/render/bound-curves.d.ts +32 -0
- package/lib/types/render/box-sizing.d.ts +4 -0
- package/lib/types/render/canvas/canvas-renderer.d.ts +53 -0
- package/lib/types/render/canvas/foreignobject-renderer.d.ts +11 -0
- package/lib/types/render/effects.d.ts +38 -0
- package/lib/types/render/font-metrics.d.ts +11 -0
- package/lib/types/render/path.d.ts +13 -0
- package/lib/types/render/renderer.d.ts +7 -0
- package/lib/types/render/skia/skia-font.d.ts +27 -0
- package/lib/types/render/skia/skia-renderer.d.ts +69 -0
- package/lib/types/render/stacking-context.d.ts +24 -0
- package/lib/types/render/vector.d.ts +9 -0
- package/lib/wasm/canvaskit-pdf.wasm +0 -0
- package/node_modules/@html2pdf-skia/canvaskit-pdf/CHROMIUM-LICENSE +27 -0
- package/node_modules/@html2pdf-skia/canvaskit-pdf/LICENSE +29 -0
- package/node_modules/@html2pdf-skia/canvaskit-pdf/README.md +35 -0
- package/node_modules/@html2pdf-skia/canvaskit-pdf/THIRD_PARTY_LICENSES.txt +2152 -0
- package/node_modules/@html2pdf-skia/canvaskit-pdf/bin/canvaskit.js +215 -0
- package/node_modules/@html2pdf-skia/canvaskit-pdf/chromium-license-source.json +5 -0
- package/node_modules/@html2pdf-skia/canvaskit-pdf/package.json +22 -0
- package/node_modules/@html2pdf-skia/canvaskit-pdf/pdf_bindings.cpp +179 -0
- package/node_modules/@html2pdf-skia/canvaskit-pdf/provenance.json +37 -0
- package/node_modules/@html2pdf-skia/canvaskit-pdf/types/google-types.d.ts +4948 -0
- package/node_modules/@html2pdf-skia/canvaskit-pdf/types/index.d.ts +48 -0
- package/node_modules/@webgpu/types/LICENSE +26 -0
- package/node_modules/@webgpu/types/README.md +132 -0
- package/node_modules/@webgpu/types/dist/index.d.ts +3426 -0
- package/node_modules/@webgpu/types/package.json +23 -0
- package/package.json +125 -4
- package/scripts/canvaskit/build.cjs +74 -0
- package/scripts/canvaskit/build.py +143 -0
- package/scripts/canvaskit/verify.cjs +82 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@webgpu/types",
|
|
3
|
+
"repository": "gpuweb/types",
|
|
4
|
+
"homepage": "https://github.com/gpuweb/types",
|
|
5
|
+
"bugs": "https://github.com/gpuweb/types/issues",
|
|
6
|
+
"version": "0.1.69",
|
|
7
|
+
"main": "",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"license": "BSD-3-Clause",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist/**/*"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"test": "for t in tests/*/ ; do echo \"\\n======== $t ========\" ; (cd \"$t\" && npm i && npm test); done",
|
|
15
|
+
"build-docs": "cd tsdoc-src && npm ci && npm run build",
|
|
16
|
+
"generate": "node generate.mjs",
|
|
17
|
+
"format": "prettier -w dist/index.d.ts"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"bikeshed-to-ts": "file:third_party/bikeshed-to-ts",
|
|
21
|
+
"prettier": "^2.2.1"
|
|
22
|
+
}
|
|
23
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,127 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "html2pdf-accessible",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"description": "Accessible PDF generation using Skia. Supports vector graphics, text selection, and screen readers.",
|
|
4
|
+
"main": "lib/html2pdf-accessible.cjs.js",
|
|
5
|
+
"module": "lib/html2pdf-accessible.esm.mjs",
|
|
6
|
+
"typings": "lib/types/index.d.ts",
|
|
7
|
+
"browser": "lib/html2pdf-accessible.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./lib/types/index.d.ts",
|
|
11
|
+
"import": "./lib/html2pdf-accessible.esm.mjs",
|
|
12
|
+
"require": "./lib/html2pdf-accessible.cjs.js"
|
|
13
|
+
},
|
|
14
|
+
"./lib/*": "./lib/*",
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
17
|
+
"version": "0.1.5",
|
|
18
|
+
"author": {
|
|
19
|
+
"name": "Mathias Ciarlo",
|
|
20
|
+
"url": "https://github.com/MathiasCiarlo"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"keywords": [
|
|
24
|
+
"html2pdf",
|
|
25
|
+
"pdf",
|
|
26
|
+
"html",
|
|
27
|
+
"accessibility",
|
|
28
|
+
"vector pdf",
|
|
29
|
+
"skia"
|
|
30
|
+
],
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=22.0.0"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"lib/",
|
|
36
|
+
"README.md",
|
|
37
|
+
"LICENSE",
|
|
38
|
+
"THIRD_PARTY_NOTICES.md",
|
|
39
|
+
"deps/canvaskit-pdf/package.json",
|
|
40
|
+
"deps/canvaskit-pdf/bin/canvaskit.js",
|
|
41
|
+
"deps/canvaskit-pdf/types",
|
|
42
|
+
"deps/canvaskit-pdf/LICENSE",
|
|
43
|
+
"deps/canvaskit-pdf/THIRD_PARTY_LICENSES.txt",
|
|
44
|
+
"deps/canvaskit-pdf/provenance.json",
|
|
45
|
+
"deps/canvaskit-pdf/README.md",
|
|
46
|
+
"deps/canvaskit-pdf/pdf_bindings.cpp",
|
|
47
|
+
"deps/canvaskit-pdf/CHROMIUM-LICENSE",
|
|
48
|
+
"deps/canvaskit-pdf/chromium-license-source.json",
|
|
49
|
+
"scripts/canvaskit/"
|
|
50
|
+
],
|
|
51
|
+
"homepage": "https://github.com/MathiasCiarlo/html2pdf-accessible",
|
|
52
|
+
"repository": {
|
|
53
|
+
"type": "git",
|
|
54
|
+
"url": "https://github.com/MathiasCiarlo/html2pdf-accessible.git"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@napi-rs/canvas": "0.1.80",
|
|
58
|
+
"@types/jest": "^29.5.12",
|
|
59
|
+
"@types/node": "^20.14.12",
|
|
60
|
+
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
61
|
+
"@typescript-eslint/parser": "^4.33.0",
|
|
62
|
+
"copy-webpack-plugin": "^13.0.0",
|
|
63
|
+
"eslint": "^7.32.0",
|
|
64
|
+
"eslint-config-prettier": "^9.1.0",
|
|
65
|
+
"eslint-plugin-prettier": "4.2.1",
|
|
66
|
+
"fast-xml-parser": "5.5.7",
|
|
67
|
+
"husky": "^8.0.0",
|
|
68
|
+
"jest": "^29.7.0",
|
|
69
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
70
|
+
"lint-staged": "^15.2.7",
|
|
71
|
+
"mkdirp": "^3.0.1",
|
|
72
|
+
"path-browserify": "^1.0.1",
|
|
73
|
+
"pdfjs-dist": "5.4.296",
|
|
74
|
+
"playwright": "1.63.0",
|
|
75
|
+
"prettier": "^2.3.2",
|
|
76
|
+
"rimraf": "^6.0.1",
|
|
77
|
+
"terser-webpack-plugin": "^5.3.14",
|
|
78
|
+
"ts-jest": "^29.1.5",
|
|
79
|
+
"ts-loader": "^9.5.2",
|
|
80
|
+
"ts-node": "^10.9.2",
|
|
81
|
+
"tslib": "^2.3.0",
|
|
82
|
+
"typescript": "^5.5.4",
|
|
83
|
+
"webpack": "^5.100.0",
|
|
84
|
+
"webpack-cli": "^6.0.1"
|
|
85
|
+
},
|
|
86
|
+
"scripts": {
|
|
87
|
+
"prebuild": "npm run verify:canvaskit && rimraf lib/ && rimraf build/ && mkdirp lib && mkdirp build",
|
|
88
|
+
"build": "webpack --mode=production",
|
|
89
|
+
"prepublishOnly": "npm run build",
|
|
90
|
+
"build:dev": "webpack --mode=development",
|
|
91
|
+
"build:watch": "webpack --mode=development --watch",
|
|
92
|
+
"format": "prettier --write \"{src,tests,scripts}/**/*.ts\"",
|
|
93
|
+
"lint": "eslint src tests scripts *.js --ext .ts,.js,.cjs --max-warnings 0",
|
|
94
|
+
"test": "npm run unittest -- --runInBand && node --test tests/pdf/integration/*.test.cjs && npm run typecheck",
|
|
95
|
+
"unittest": "jest",
|
|
96
|
+
"test:pdf": "npm run build:dev && node scripts/pdf/run.cjs",
|
|
97
|
+
"test:pdf:serve": "node scripts/pdf/server.cjs",
|
|
98
|
+
"typecheck": "tsc --noEmit -p tests/tsconfig.json",
|
|
99
|
+
"test:pdf:visual": "node scripts/pdf/visual.cjs",
|
|
100
|
+
"test:pdf:validate": "node scripts/pdf/validate.cjs",
|
|
101
|
+
"test:pdf:update": "node scripts/pdf/visual.cjs --update",
|
|
102
|
+
"test:package": "node scripts/pdf/package.cjs",
|
|
103
|
+
"lint:changed": "node scripts/lint-changed.cjs",
|
|
104
|
+
"prebuild:dev": "npm run verify:canvaskit && rimraf lib/ && rimraf build/ && mkdirp lib && mkdirp build",
|
|
105
|
+
"build:canvaskit": "node scripts/canvaskit/build.cjs",
|
|
106
|
+
"test:canvaskit:rebuild": "node scripts/canvaskit/build.cjs --check",
|
|
107
|
+
"verify:canvaskit": "node scripts/canvaskit/verify.cjs"
|
|
108
|
+
},
|
|
109
|
+
"dependencies": {
|
|
110
|
+
"@html2pdf-skia/canvaskit-pdf": "file:deps/canvaskit-pdf",
|
|
111
|
+
"@pdf-lib/fontkit": "^1.1.1",
|
|
112
|
+
"@webgpu/types": "0.1.69",
|
|
113
|
+
"css-line-break": "^2.1.0",
|
|
114
|
+
"emoji-regex-xs": "^2.0.1",
|
|
115
|
+
"pdf-lib": "^1.17.1",
|
|
116
|
+
"text-segmentation": "^1.0.3"
|
|
117
|
+
},
|
|
118
|
+
"bundleDependencies": [
|
|
119
|
+
"@html2pdf-skia/canvaskit-pdf"
|
|
120
|
+
],
|
|
121
|
+
"lint-staged": {
|
|
122
|
+
"{src,tests}/**/*.ts": [
|
|
123
|
+
"prettier --write",
|
|
124
|
+
"eslint --fix"
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const path = require("node:path");
|
|
2
|
+
const fs = require("node:fs/promises");
|
|
3
|
+
const { spawnSync } = require("node:child_process");
|
|
4
|
+
const { verify } = require("./verify.cjs");
|
|
5
|
+
const root = path.resolve(__dirname, "../..");
|
|
6
|
+
const image =
|
|
7
|
+
"emscripten/emsdk:4.0.10@sha256:90b757eb11fa9a0e3ce4d2d9f76d932a56018e4accc37b5a28b2783751e60eb7";
|
|
8
|
+
async function build() {
|
|
9
|
+
const result = spawnSync(
|
|
10
|
+
"docker",
|
|
11
|
+
[
|
|
12
|
+
"run",
|
|
13
|
+
"--rm",
|
|
14
|
+
"--mount",
|
|
15
|
+
"type=volume,source=html2pdf-skia-source-build,target=/build",
|
|
16
|
+
"--mount",
|
|
17
|
+
`type=bind,source=${root},target=/work`,
|
|
18
|
+
image,
|
|
19
|
+
"python3",
|
|
20
|
+
"/work/scripts/canvaskit/build.py",
|
|
21
|
+
],
|
|
22
|
+
{ stdio: "inherit" }
|
|
23
|
+
);
|
|
24
|
+
if (result.error) throw result.error;
|
|
25
|
+
if (result.status !== 0) throw new Error("CanvasKit source build failed");
|
|
26
|
+
const output = path.join(root, ".cache/canvaskit-built");
|
|
27
|
+
const target = path.join(root, "deps/canvaskit-pdf");
|
|
28
|
+
if (process.argv.includes("--check")) {
|
|
29
|
+
await verify(output);
|
|
30
|
+
for (const file of [
|
|
31
|
+
"canvaskit.js",
|
|
32
|
+
"canvaskit.wasm",
|
|
33
|
+
"google-types.d.ts",
|
|
34
|
+
"THIRD_PARTY_LICENSES.txt",
|
|
35
|
+
"provenance.json",
|
|
36
|
+
]) {
|
|
37
|
+
const actual = await fs.readFile(path.join(output, file));
|
|
38
|
+
const expected = await fs.readFile(
|
|
39
|
+
path.join(
|
|
40
|
+
target,
|
|
41
|
+
file.endsWith(".wasm") || file.endsWith(".js")
|
|
42
|
+
? "bin"
|
|
43
|
+
: file.endsWith(".d.ts")
|
|
44
|
+
? "types"
|
|
45
|
+
: "",
|
|
46
|
+
file
|
|
47
|
+
)
|
|
48
|
+
);
|
|
49
|
+
if (!actual.equals(expected))
|
|
50
|
+
throw new Error(`Source rebuild differs: ${file}`);
|
|
51
|
+
}
|
|
52
|
+
console.log(
|
|
53
|
+
"Source-rebuilt binaries, types, licenses and provenance match included artifacts"
|
|
54
|
+
);
|
|
55
|
+
} else {
|
|
56
|
+
await fs.mkdir(path.join(target, "bin"), { recursive: true });
|
|
57
|
+
for (const file of ["canvaskit.js", "canvaskit.wasm"])
|
|
58
|
+
await fs.copyFile(
|
|
59
|
+
path.join(output, file),
|
|
60
|
+
path.join(target, "bin", file)
|
|
61
|
+
);
|
|
62
|
+
for (const file of ["provenance.json", "THIRD_PARTY_LICENSES.txt"])
|
|
63
|
+
await fs.copyFile(path.join(output, file), path.join(target, file));
|
|
64
|
+
await fs.copyFile(
|
|
65
|
+
path.join(output, "google-types.d.ts"),
|
|
66
|
+
path.join(target, "types/google-types.d.ts")
|
|
67
|
+
);
|
|
68
|
+
await verify();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
build().catch((error) => {
|
|
72
|
+
console.error(error);
|
|
73
|
+
process.exitCode = 1;
|
|
74
|
+
});
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Build our small PDF bridge with immutable Google Skia sources in Docker."""
|
|
3
|
+
import concurrent.futures
|
|
4
|
+
import hashlib
|
|
5
|
+
import json
|
|
6
|
+
import pathlib
|
|
7
|
+
import runpy
|
|
8
|
+
import shutil
|
|
9
|
+
import subprocess
|
|
10
|
+
import time
|
|
11
|
+
|
|
12
|
+
ROOT = pathlib.Path("/work")
|
|
13
|
+
SKIA = pathlib.Path("/build/skia")
|
|
14
|
+
REVISION = "e2def78fa232884d4aedcf3ad92d4a0dd673b898"
|
|
15
|
+
IMAGE = "emscripten/emsdk:4.0.10@sha256:90b757eb11fa9a0e3ce4d2d9f76d932a56018e4accc37b5a28b2783751e60eb7"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def run(*args, **kwargs):
|
|
19
|
+
subprocess.run(args, check=True, **kwargs)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def digest(path):
|
|
23
|
+
return hashlib.sha256(path.read_bytes()).hexdigest()
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
if not (SKIA / ".git").exists():
|
|
27
|
+
run("git", "clone", "--depth", "1", "--branch", "canvaskit/0.42.0",
|
|
28
|
+
"https://skia.googlesource.com/skia.git", str(SKIA))
|
|
29
|
+
head = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=SKIA, text=True).strip()
|
|
30
|
+
if head != REVISION:
|
|
31
|
+
raise RuntimeError("Unexpected Skia revision: " + head)
|
|
32
|
+
run("git", "config", "--global", "http.version", "HTTP/1.1")
|
|
33
|
+
|
|
34
|
+
# Check cached sources before executing any upstream build tooling.
|
|
35
|
+
run("git", "restore", "--source", REVISION, "--", "modules/canvaskit/BUILD.gn",
|
|
36
|
+
"modules/canvaskit/compile.sh", cwd=SKIA)
|
|
37
|
+
if subprocess.check_output(["git", "diff", "HEAD", "--name-only"], cwd=SKIA, text=True).strip():
|
|
38
|
+
raise RuntimeError("Unexpected modified Google Skia source")
|
|
39
|
+
|
|
40
|
+
# Use Google's checkout implementation, but fetch only libraries needed by the
|
|
41
|
+
# CPU/PDF build and limit parallelism to avoid transient server transport errors.
|
|
42
|
+
sync = runpy.run_path(str(SKIA / "tools/git-sync-deps"))
|
|
43
|
+
deps = sync["parse_file_to_dict"](str(SKIA / "DEPS"))["deps"]
|
|
44
|
+
needed = {"buildtools", "brotli", "freetype", "harfbuzz", "highway", "libjpeg-turbo",
|
|
45
|
+
"libpng", "libwebp", "wuffs", "zlib", "perfetto", "libgrapheme", "expat", "partition_alloc", "icu"}
|
|
46
|
+
selected = {path: value for path, value in deps.items()
|
|
47
|
+
if path.split("/")[-1] in needed}
|
|
48
|
+
if len(selected) != len(needed):
|
|
49
|
+
raise RuntimeError("Skia dependency list changed")
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def checkout(entry):
|
|
53
|
+
path, value = entry
|
|
54
|
+
repo, revision = value.split("@", 1)
|
|
55
|
+
for attempt in range(3):
|
|
56
|
+
try:
|
|
57
|
+
sync["git_checkout_to_directory"]("git", repo, revision,
|
|
58
|
+
str(SKIA / path), True, True)
|
|
59
|
+
actual = subprocess.check_output(["git", "rev-parse", "HEAD"],
|
|
60
|
+
cwd=SKIA / path, text=True).strip()
|
|
61
|
+
expected = subprocess.check_output(["git", "rev-parse", revision + "^{}"],
|
|
62
|
+
cwd=SKIA / path, text=True).strip()
|
|
63
|
+
if actual != expected:
|
|
64
|
+
raise RuntimeError("Dependency revision mismatch: " + path)
|
|
65
|
+
dirty = subprocess.check_output(["git", "status", "--porcelain", "--untracked-files=no"],
|
|
66
|
+
cwd=SKIA / path, text=True).strip()
|
|
67
|
+
if dirty:
|
|
68
|
+
raise RuntimeError("Modified dependency source: " + path)
|
|
69
|
+
return
|
|
70
|
+
except subprocess.CalledProcessError:
|
|
71
|
+
if attempt == 2:
|
|
72
|
+
raise
|
|
73
|
+
time.sleep(2 ** attempt)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
with concurrent.futures.ThreadPoolExecutor(max_workers=4) as pool:
|
|
77
|
+
list(pool.map(checkout, selected.items()))
|
|
78
|
+
|
|
79
|
+
# Restore exactly the files our overlay modifies, even in a cached build volume.
|
|
80
|
+
run("git", "restore", "--source", REVISION, "--", "modules/canvaskit/BUILD.gn",
|
|
81
|
+
"modules/canvaskit/compile.sh", cwd=SKIA)
|
|
82
|
+
if subprocess.check_output(["git", "diff", "--name-only"], cwd=SKIA, text=True).strip():
|
|
83
|
+
raise RuntimeError("Unexpected modified Google Skia source")
|
|
84
|
+
module = SKIA / "modules/canvaskit"
|
|
85
|
+
bridge = ROOT / "deps/canvaskit-pdf/pdf_bindings.cpp"
|
|
86
|
+
shutil.copyfile(bridge, module / "pdf_bindings.cpp")
|
|
87
|
+
build = (module / "BUILD.gn").read_text()
|
|
88
|
+
if build.count(' "canvaskit_bindings.cpp",') != 1:
|
|
89
|
+
raise RuntimeError("CanvasKit build layout changed")
|
|
90
|
+
build = build.replace(' "canvaskit_bindings.cpp",',
|
|
91
|
+
' "canvaskit_bindings.cpp",\n "pdf_bindings.cpp",')
|
|
92
|
+
(module / "BUILD.gn").write_text(build)
|
|
93
|
+
compile_script = (module / "compile.sh").read_text()
|
|
94
|
+
for expected in ["skia_enable_pdf=false", '--args="is_debug=', "-k 10"]:
|
|
95
|
+
if compile_script.count(expected) != 1:
|
|
96
|
+
raise RuntimeError("CanvasKit compile script changed")
|
|
97
|
+
compile_script = compile_script.replace("skia_enable_pdf=false", "skia_enable_pdf=true")
|
|
98
|
+
compile_script = compile_script.replace('--args="is_debug=',
|
|
99
|
+
'--args="skia_emsdk_dir=\\\"/emsdk\\\" is_debug=')
|
|
100
|
+
compile_script = compile_script.replace("-k 10", "-k 1 -j 8")
|
|
101
|
+
(module / "compile.sh").write_text(compile_script)
|
|
102
|
+
run("bash", str(module / "compile.sh"), "cpu", "no_skottie",
|
|
103
|
+
"client_unicode", "no_embedded_font", "no_woff2", "force_tracing", cwd=SKIA)
|
|
104
|
+
|
|
105
|
+
out = ROOT / ".cache/canvaskit-built"
|
|
106
|
+
out.mkdir(parents=True, exist_ok=True)
|
|
107
|
+
for filename in ["canvaskit.js", "canvaskit.wasm"]:
|
|
108
|
+
shutil.copyfile(SKIA / "out/canvaskit_wasm" / filename, out / filename)
|
|
109
|
+
shutil.copyfile(module / "npm_build/types/index.d.ts", out / "google-types.d.ts")
|
|
110
|
+
chromium_license = ROOT / "deps/canvaskit-pdf/CHROMIUM-LICENSE"
|
|
111
|
+
chromium_source = json.loads((ROOT / "deps/canvaskit-pdf/chromium-license-source.json").read_text())
|
|
112
|
+
if digest(chromium_license) != chromium_source["sha256"]:
|
|
113
|
+
raise RuntimeError("Chromium license checksum mismatch")
|
|
114
|
+
notices = []
|
|
115
|
+
for library in sorted(needed - {"buildtools"}):
|
|
116
|
+
folder = SKIA / ("buildtools" if library == "buildtools" else "third_party/externals/" + library)
|
|
117
|
+
files = sorted(set(path for pattern in ["LICENSE*", "COPYING*", "NOTICE*", "README.ijg", "docs/FTL.TXT"]
|
|
118
|
+
for path in folder.glob(pattern) if path.is_file()))
|
|
119
|
+
if library == "partition_alloc":
|
|
120
|
+
notices.append("=== partition_alloc: " + chromium_source["url"] + " ===\n" + chromium_license.read_text())
|
|
121
|
+
continue
|
|
122
|
+
if not files:
|
|
123
|
+
raise RuntimeError("Missing license notice: " + library)
|
|
124
|
+
for path in files:
|
|
125
|
+
notices.append("=== " + str(path.relative_to(SKIA)) + " ===\n" + path.read_text(errors="replace"))
|
|
126
|
+
(out / "THIRD_PARTY_LICENSES.txt").write_text("\n\n".join(notices) + "\n")
|
|
127
|
+
manifest = {
|
|
128
|
+
"skiaRevision": REVISION,
|
|
129
|
+
"skiaRelease": "canvaskit/0.42.0",
|
|
130
|
+
"source": "https://skia.googlesource.com/skia.git",
|
|
131
|
+
"buildImage": IMAGE,
|
|
132
|
+
"bridgeSha256": digest(bridge),
|
|
133
|
+
"buildScriptSha256": digest(pathlib.Path(__file__)),
|
|
134
|
+
"depsSha256": digest(SKIA / "DEPS"),
|
|
135
|
+
"typeDefinitionsSha256": digest(out / "google-types.d.ts"),
|
|
136
|
+
"licensesSha256": digest(out / "THIRD_PARTY_LICENSES.txt"),
|
|
137
|
+
"dependencies": selected,
|
|
138
|
+
"chromiumLicenseSource": chromium_source,
|
|
139
|
+
"artifacts": {filename: digest(out / filename)
|
|
140
|
+
for filename in ["canvaskit.js", "canvaskit.wasm"]},
|
|
141
|
+
}
|
|
142
|
+
(out / "provenance.json").write_text(json.dumps(manifest, indent=2) + "\n")
|
|
143
|
+
print("Built CanvasKit PDF from Google Skia " + REVISION, flush=True)
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
const fs = require("node:fs/promises");
|
|
2
|
+
const path = require("node:path");
|
|
3
|
+
const { createHash } = require("node:crypto");
|
|
4
|
+
const assert = require("node:assert/strict");
|
|
5
|
+
const root = path.resolve(__dirname, "../..");
|
|
6
|
+
const backend = path.join(root, "deps/canvaskit-pdf");
|
|
7
|
+
const digest = (buffer) => createHash("sha256").update(buffer).digest("hex");
|
|
8
|
+
async function verify(output) {
|
|
9
|
+
const manifest = JSON.parse(
|
|
10
|
+
await fs.readFile(path.join(output || backend, "provenance.json"), "utf8")
|
|
11
|
+
);
|
|
12
|
+
assert.equal(
|
|
13
|
+
manifest.skiaRevision,
|
|
14
|
+
"e2def78fa232884d4aedcf3ad92d4a0dd673b898"
|
|
15
|
+
);
|
|
16
|
+
assert.equal(manifest.source, "https://skia.googlesource.com/skia.git");
|
|
17
|
+
assert.equal(
|
|
18
|
+
manifest.buildImage,
|
|
19
|
+
"emscripten/emsdk:4.0.10@sha256:90b757eb11fa9a0e3ce4d2d9f76d932a56018e4accc37b5a28b2783751e60eb7"
|
|
20
|
+
);
|
|
21
|
+
assert.equal(
|
|
22
|
+
digest(await fs.readFile(path.join(backend, "pdf_bindings.cpp"))),
|
|
23
|
+
manifest.bridgeSha256,
|
|
24
|
+
"PDF bridge changed without a source rebuild"
|
|
25
|
+
);
|
|
26
|
+
assert.equal(
|
|
27
|
+
digest(await fs.readFile(path.join(__dirname, "build.py"))),
|
|
28
|
+
manifest.buildScriptSha256,
|
|
29
|
+
"Build script changed without a source rebuild"
|
|
30
|
+
);
|
|
31
|
+
assert.equal(
|
|
32
|
+
digest(
|
|
33
|
+
await fs.readFile(
|
|
34
|
+
path.join(output || path.join(backend, "types"), "google-types.d.ts")
|
|
35
|
+
)
|
|
36
|
+
),
|
|
37
|
+
manifest.typeDefinitionsSha256,
|
|
38
|
+
"Google type definitions differ"
|
|
39
|
+
);
|
|
40
|
+
assert.equal(
|
|
41
|
+
digest(
|
|
42
|
+
await fs.readFile(
|
|
43
|
+
path.join(output || backend, "THIRD_PARTY_LICENSES.txt")
|
|
44
|
+
)
|
|
45
|
+
),
|
|
46
|
+
manifest.licensesSha256,
|
|
47
|
+
"License notices differ"
|
|
48
|
+
);
|
|
49
|
+
const chromium = JSON.parse(
|
|
50
|
+
await fs.readFile(
|
|
51
|
+
path.join(backend, "chromium-license-source.json"),
|
|
52
|
+
"utf8"
|
|
53
|
+
)
|
|
54
|
+
);
|
|
55
|
+
assert.deepEqual(chromium, manifest.chromiumLicenseSource);
|
|
56
|
+
assert.equal(
|
|
57
|
+
digest(await fs.readFile(path.join(backend, "CHROMIUM-LICENSE"))),
|
|
58
|
+
chromium.sha256
|
|
59
|
+
);
|
|
60
|
+
for (const file of ["canvaskit.js", "canvaskit.wasm"]) {
|
|
61
|
+
let artifact = path.join(output || path.join(backend, "bin"), file);
|
|
62
|
+
if (!output && file.endsWith(".wasm")) {
|
|
63
|
+
try {
|
|
64
|
+
await fs.access(artifact);
|
|
65
|
+
} catch {
|
|
66
|
+
artifact = path.join(root, "lib/wasm/canvaskit-pdf.wasm");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
assert.equal(
|
|
70
|
+
digest(await fs.readFile(artifact)),
|
|
71
|
+
manifest.artifacts[file],
|
|
72
|
+
`Artifact checksum mismatch: ${file}`
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
console.log("CanvasKit source manifest and artifact checksums verified");
|
|
76
|
+
}
|
|
77
|
+
module.exports = { verify };
|
|
78
|
+
if (require.main === module)
|
|
79
|
+
verify().catch((error) => {
|
|
80
|
+
console.error(error);
|
|
81
|
+
process.exitCode = 1;
|
|
82
|
+
});
|