@kaeawc/auto-mobile 0.0.91 → 0.0.93
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/dist/build-info.json +12 -12
- package/dist/schemas/README.md +16 -0
- package/dist/schemas/prototype-icon-names.json +302 -0
- package/dist/schemas/test-plan.schema.json +370 -52
- package/dist/src/chunk-00167wan.js +55 -0
- package/dist/src/chunk-0jrrsnc9.js +6 -0
- package/dist/src/chunk-0n6swkwg.js +5 -0
- package/dist/src/chunk-0qsy1qsx.js +57 -0
- package/dist/src/chunk-11m8wj8j.js +237 -0
- package/dist/src/chunk-1p7xf5kb.js +5 -0
- package/dist/src/chunk-23p5f095.js +4 -0
- package/dist/src/chunk-26k317v5.js +5 -0
- package/dist/src/chunk-284ptqa4.js +7 -0
- package/dist/src/chunk-28re4xrg.js +4 -0
- package/dist/src/chunk-2f9rkmhx.js +5 -0
- package/dist/src/chunk-2fxdh48t.js +4 -0
- package/dist/src/chunk-2tbdrbt6.js +4 -0
- package/dist/src/chunk-2tqzq5qh.js +971 -0
- package/dist/src/chunk-32gvv9b4.js +21 -0
- package/dist/src/chunk-3f3t1x97.js +8 -0
- package/dist/src/chunk-3fspkbc7.js +4 -0
- package/dist/src/chunk-3qwrzxh0.js +11 -0
- package/dist/src/chunk-3sy6ahhz.js +26 -0
- package/dist/src/chunk-3vg455e6.js +4 -0
- package/dist/src/chunk-3xkpk44w.js +5 -0
- package/dist/src/chunk-3y6eykz9.js +4 -0
- package/dist/src/chunk-49bsqdx3.js +4 -0
- package/dist/src/chunk-4hw3665t.js +42 -0
- package/dist/src/chunk-58wzr3mt.js +5 -0
- package/dist/src/chunk-5d2hft6c.js +5 -0
- package/dist/src/chunk-5s645vr4.js +4 -0
- package/dist/src/chunk-5snsn9cf.js +4 -0
- package/dist/src/chunk-5tm9mn47.js +54 -0
- package/dist/src/chunk-5zc77a5t.js +4 -0
- package/dist/src/chunk-64j0majr.js +19 -0
- package/dist/src/chunk-65y8v4td.js +17 -0
- package/dist/src/chunk-6awz7vhq.js +5 -0
- package/dist/src/chunk-6bznss4t.js +8 -0
- package/dist/src/chunk-6ep7f5ge.js +4 -0
- package/dist/src/chunk-6pg7bqck.js +4 -0
- package/dist/src/chunk-6wt9rgjf.js +5 -0
- package/dist/src/chunk-6xmss8er.js +8 -0
- package/dist/src/chunk-710rxz9y.js +5 -0
- package/dist/src/chunk-7cs2da62.js +5 -0
- package/dist/src/chunk-7g103b54.js +4 -0
- package/dist/src/chunk-7j5vj4pa.js +4 -0
- package/dist/src/chunk-7rz9898k.js +5 -0
- package/dist/src/chunk-7tw8x05v.js +4 -0
- package/dist/src/chunk-7zy586cb.js +4 -0
- package/dist/src/chunk-8037tzzj.js +5 -0
- package/dist/src/chunk-84nanf8s.js +5 -0
- package/dist/src/chunk-8g1922rp.js +10 -0
- package/dist/src/chunk-8gvwcv2p.js +4 -0
- package/dist/src/chunk-8ph29g99.js +4 -0
- package/dist/src/chunk-8thrmfat.js +4 -0
- package/dist/src/chunk-8zgzzs7k.js +78 -0
- package/dist/src/chunk-97b1zmaq.js +4 -0
- package/dist/src/chunk-9fth9ayh.js +4 -0
- package/dist/src/chunk-9j6anhjr.js +4 -0
- package/dist/src/chunk-aabchzxk.js +9 -0
- package/dist/src/chunk-ayp07wbb.js +4 -0
- package/dist/src/chunk-bfjwqk8q.js +4 -0
- package/dist/src/chunk-bfw6125s.js +5 -0
- package/dist/src/chunk-bnhscm2n.js +4 -0
- package/dist/src/chunk-bxmsax22.js +5 -0
- package/dist/src/chunk-c1vs4g1n.js +4 -0
- package/dist/src/chunk-ct3e7yng.js +4 -0
- package/dist/src/chunk-cyy71ggq.js +5 -0
- package/dist/src/chunk-ddzkz92z.js +4 -0
- package/dist/src/chunk-dgrbdpb7.js +9 -0
- package/dist/src/chunk-drdz8hee.js +5 -0
- package/dist/src/chunk-e98dqnc9.js +145 -0
- package/dist/src/chunk-eersndy7.js +5 -0
- package/dist/src/chunk-eggq53ks.js +4 -0
- package/dist/src/chunk-f2dya7cs.js +4 -0
- package/dist/src/chunk-fbakd6cw.js +4 -0
- package/dist/src/chunk-fgb98zjj.js +5 -0
- package/dist/src/chunk-fmpad823.js +5 -0
- package/dist/src/chunk-g04bwyj3.js +4 -0
- package/dist/src/chunk-g0xr8zw0.js +4 -0
- package/dist/src/chunk-g3rjs80x.js +4 -0
- package/dist/src/chunk-g78rtrfv.js +4 -0
- package/dist/src/chunk-g7tmjbkt.js +5 -0
- package/dist/src/chunk-gabgv3y5.js +4 -0
- package/dist/src/chunk-gmr45m8f.js +4 -0
- package/dist/src/chunk-gsyfebqj.js +4 -0
- package/dist/src/chunk-h5rpn9wr.js +247 -0
- package/dist/src/chunk-hb1x7v55.js +4 -0
- package/dist/src/chunk-hrfytkxh.js +168 -0
- package/dist/src/chunk-j4yjzbak.js +4 -0
- package/dist/src/chunk-jd6a5v6p.js +5 -0
- package/dist/src/chunk-jh6vhqzx.js +5 -0
- package/dist/src/chunk-kn5spq15.js +4 -0
- package/dist/src/chunk-m94qs0f0.js +4 -0
- package/dist/src/chunk-mjrps0ac.js +7 -0
- package/dist/src/chunk-n03dmn5q.js +5 -0
- package/dist/src/chunk-n72qhwd9.js +4 -0
- package/dist/src/chunk-ndt1ccxm.js +71 -0
- package/dist/src/chunk-nr6y0n4y.js +5 -0
- package/dist/src/chunk-pcsen2vs.js +4 -0
- package/dist/src/chunk-ppfr0b8h.js +4 -0
- package/dist/src/chunk-q10bdnat.js +4 -0
- package/dist/src/chunk-q9xmq595.js +4 -0
- package/dist/src/chunk-qcxzr2my.js +5 -0
- package/dist/src/chunk-qf6nynk6.js +7 -0
- package/dist/src/chunk-qyqypn28.js +5 -0
- package/dist/src/chunk-r2epb56s.js +4 -0
- package/dist/src/chunk-r5bxavdx.js +311 -0
- package/dist/src/chunk-r6z1eztj.js +18 -0
- package/dist/src/chunk-r7bpkgff.js +4 -0
- package/dist/src/chunk-r8jf3d92.js +4 -0
- package/dist/src/chunk-rbpdk7m0.js +5 -0
- package/dist/src/chunk-rc0dbypm.js +4 -0
- package/dist/src/chunk-rhcty4ms.js +4 -0
- package/dist/src/chunk-rpvckv3p.js +4 -0
- package/dist/src/chunk-rqc9ap3x.js +4 -0
- package/dist/src/chunk-rvvy1bte.js +7 -0
- package/dist/src/chunk-ry0mz41y.js +4 -0
- package/dist/src/chunk-s3jc6cwp.js +5 -0
- package/dist/src/chunk-sfv61xjb.js +6 -0
- package/dist/src/chunk-t6bfvfkg.js +4 -0
- package/dist/src/chunk-t6c8akcm.js +5 -0
- package/dist/src/chunk-t7w8rctc.js +4 -0
- package/dist/src/chunk-thbh3jew.js +5 -0
- package/dist/src/chunk-v2wd4n3e.js +5 -0
- package/dist/src/chunk-v6pya0dm.js +5 -0
- package/dist/src/chunk-vy3bwm1d.js +17 -0
- package/dist/src/chunk-w3vs79ex.js +27 -0
- package/dist/src/chunk-w4zga19f.js +4 -0
- package/dist/src/chunk-w5b2jwk3.js +14 -0
- package/dist/src/chunk-w7hkv422.js +5 -0
- package/dist/src/chunk-waqwcjyn.js +4 -0
- package/dist/src/chunk-wbh8spm5.js +20 -0
- package/dist/src/chunk-wyrkw6hw.js +5 -0
- package/dist/src/chunk-xa73x2cx.js +5 -0
- package/dist/src/chunk-xgan0qqp.js +4 -0
- package/dist/src/chunk-y2vs6jwg.js +4 -0
- package/dist/src/chunk-yattm52s.js +4 -0
- package/dist/src/chunk-yb97j25b.js +6 -0
- package/dist/src/chunk-ybbtagbt.js +5 -0
- package/dist/src/chunk-ycaj2sgf.js +9 -0
- package/dist/src/chunk-yf7ympyz.js +325 -0
- package/dist/src/chunk-yjawdzk8.js +4 -0
- package/dist/src/chunk-z637nqg8.js +11 -0
- package/dist/src/chunk-zgja5f3p.js +6 -0
- package/dist/src/chunk-zs1sghs9.js +4 -0
- package/dist/src/daemon/processEntry.js +4 -0
- package/dist/src/index.js +4 -2843
- package/dist/src/runtime/bunRuntimeGuard.js +4 -0
- package/dist/src/utils/workers/iosBundleExtractWorker.js +2 -3
- package/ios/CameraPosterInjection/Injection/CameraPosterInjection.m +466 -0
- package/package.json +7 -6
- package/schemas/README.md +16 -0
- package/schemas/prototype-icon-names.json +302 -0
- package/schemas/test-plan.schema.json +370 -52
- package/node_modules/@borewit/text-codec/README.md +0 -87
- package/node_modules/@jimp/diff/node_modules/pixelmatch/README.md +0 -110
- package/node_modules/@jimp/diff/node_modules/pixelmatch/node_modules/pngjs/README.md +0 -433
- package/node_modules/@jimp/file-ops/dist/browser/index.js +0 -8
- package/node_modules/@jimp/js-png/README.md +0 -35
- package/node_modules/@jimp/js-png/src/__image_snapshots__/index-node-test-ts-png-should-use-png-options-1-snap.png +0 -0
- package/node_modules/@jimp/js-png/src/output.png +0 -0
- package/node_modules/@jimp/js-png/vitest.config.browser.mjs +0 -3
- package/node_modules/@jimp/plugin-resize/README.md +0 -12
- package/node_modules/@jimp/plugin-resize/vitest.config.browser.mjs +0 -3
- package/node_modules/@tokenizer/inflate/README.md +0 -114
- package/node_modules/@tokenizer/token/README.md +0 -19
- package/node_modules/await-to-js/README.md +0 -82
- package/node_modules/debug/README.md +0 -481
- package/node_modules/exif-parser/README.md +0 -83
- package/node_modules/file-type/readme.md +0 -667
- package/node_modules/ieee754/README.md +0 -51
- package/node_modules/mime/README.md +0 -178
- package/node_modules/ms/readme.md +0 -59
- package/node_modules/parse-bmfont-xml/README.md +0 -74
- package/node_modules/parse-bmfont-xml/lib/browser.js +0 -85
- package/node_modules/parse-bmfont-xml/node_modules/xml2js/README.md +0 -507
- package/node_modules/pngjs/README.md +0 -287
- package/node_modules/sax/README.md +0 -228
- package/node_modules/strtok3/README.md +0 -795
- package/node_modules/tinycolor2/README.md +0 -492
- package/node_modules/tinycolor2/cjs/test.js +0 -2191
- package/node_modules/tinycolor2/cjs/test_template.js +0 -26
- package/node_modules/tinycolor2/deno_asserts@0.168.0.mjs +0 -807
- package/node_modules/tinycolor2/esm/test.js +0 -2189
- package/node_modules/tinycolor2/esm/test_template.js +0 -24
- package/node_modules/tinycolor2/tinycolor.js +0 -1191
- package/node_modules/token-types/README.md +0 -160
- package/node_modules/uint8array-extras/readme.md +0 -318
- package/node_modules/xml-parse-from-string/README.md +0 -35
- package/node_modules/xmlbuilder/README.md +0 -86
- package/node_modules/zod/README.md +0 -208
- package/node_modules/zod/v4/locales/ar.d.cts +0 -4
- package/node_modules/zod/v4/locales/ar.d.ts +0 -4
- package/node_modules/zod/v4/locales/az.d.cts +0 -4
- package/node_modules/zod/v4/locales/az.d.ts +0 -4
- package/node_modules/zod/v4/locales/be.d.cts +0 -4
- package/node_modules/zod/v4/locales/be.d.ts +0 -4
- package/node_modules/zod/v4/locales/ca.d.cts +0 -4
- package/node_modules/zod/v4/locales/ca.d.ts +0 -4
- package/node_modules/zod/v4/locales/cs.d.cts +0 -4
- package/node_modules/zod/v4/locales/cs.d.ts +0 -4
- package/node_modules/zod/v4/locales/de.d.cts +0 -4
- package/node_modules/zod/v4/locales/de.d.ts +0 -4
- package/node_modules/zod/v4/locales/en.d.cts +0 -5
- package/node_modules/zod/v4/locales/en.d.ts +0 -5
- package/node_modules/zod/v4/locales/eo.d.cts +0 -5
- package/node_modules/zod/v4/locales/eo.d.ts +0 -5
- package/node_modules/zod/v4/locales/es.d.cts +0 -4
- package/node_modules/zod/v4/locales/es.d.ts +0 -4
- package/node_modules/zod/v4/locales/fa.d.cts +0 -4
- package/node_modules/zod/v4/locales/fa.d.ts +0 -4
- package/node_modules/zod/v4/locales/fi.d.cts +0 -4
- package/node_modules/zod/v4/locales/fi.d.ts +0 -4
- package/node_modules/zod/v4/locales/fr-CA.d.cts +0 -4
- package/node_modules/zod/v4/locales/fr-CA.d.ts +0 -4
- package/node_modules/zod/v4/locales/fr.d.cts +0 -4
- package/node_modules/zod/v4/locales/fr.d.ts +0 -4
- package/node_modules/zod/v4/locales/he.d.cts +0 -4
- package/node_modules/zod/v4/locales/he.d.ts +0 -4
- package/node_modules/zod/v4/locales/hu.d.cts +0 -4
- package/node_modules/zod/v4/locales/hu.d.ts +0 -4
- package/node_modules/zod/v4/locales/id.d.cts +0 -4
- package/node_modules/zod/v4/locales/id.d.ts +0 -4
- package/node_modules/zod/v4/locales/index.d.cts +0 -39
- package/node_modules/zod/v4/locales/index.d.ts +0 -39
- package/node_modules/zod/v4/locales/it.d.cts +0 -4
- package/node_modules/zod/v4/locales/it.d.ts +0 -4
- package/node_modules/zod/v4/locales/ja.d.cts +0 -4
- package/node_modules/zod/v4/locales/ja.d.ts +0 -4
- package/node_modules/zod/v4/locales/kh.d.cts +0 -4
- package/node_modules/zod/v4/locales/kh.d.ts +0 -4
- package/node_modules/zod/v4/locales/ko.d.cts +0 -4
- package/node_modules/zod/v4/locales/ko.d.ts +0 -4
- package/node_modules/zod/v4/locales/mk.d.cts +0 -4
- package/node_modules/zod/v4/locales/mk.d.ts +0 -4
- package/node_modules/zod/v4/locales/ms.d.cts +0 -4
- package/node_modules/zod/v4/locales/ms.d.ts +0 -4
- package/node_modules/zod/v4/locales/nl.d.cts +0 -4
- package/node_modules/zod/v4/locales/nl.d.ts +0 -4
- package/node_modules/zod/v4/locales/no.d.cts +0 -4
- package/node_modules/zod/v4/locales/no.d.ts +0 -4
- package/node_modules/zod/v4/locales/ota.d.cts +0 -4
- package/node_modules/zod/v4/locales/ota.d.ts +0 -4
- package/node_modules/zod/v4/locales/pl.d.cts +0 -4
- package/node_modules/zod/v4/locales/pl.d.ts +0 -4
- package/node_modules/zod/v4/locales/ps.d.cts +0 -4
- package/node_modules/zod/v4/locales/ps.d.ts +0 -4
- package/node_modules/zod/v4/locales/pt.d.cts +0 -4
- package/node_modules/zod/v4/locales/pt.d.ts +0 -4
- package/node_modules/zod/v4/locales/ru.d.cts +0 -4
- package/node_modules/zod/v4/locales/ru.d.ts +0 -4
- package/node_modules/zod/v4/locales/sl.d.cts +0 -4
- package/node_modules/zod/v4/locales/sl.d.ts +0 -4
- package/node_modules/zod/v4/locales/sv.d.cts +0 -4
- package/node_modules/zod/v4/locales/sv.d.ts +0 -4
- package/node_modules/zod/v4/locales/ta.d.cts +0 -4
- package/node_modules/zod/v4/locales/ta.d.ts +0 -4
- package/node_modules/zod/v4/locales/th.d.cts +0 -4
- package/node_modules/zod/v4/locales/th.d.ts +0 -4
- package/node_modules/zod/v4/locales/tr.d.cts +0 -5
- package/node_modules/zod/v4/locales/tr.d.ts +0 -5
- package/node_modules/zod/v4/locales/ua.d.cts +0 -4
- package/node_modules/zod/v4/locales/ua.d.ts +0 -4
- package/node_modules/zod/v4/locales/ur.d.cts +0 -4
- package/node_modules/zod/v4/locales/ur.d.ts +0 -4
- package/node_modules/zod/v4/locales/vi.d.cts +0 -4
- package/node_modules/zod/v4/locales/vi.d.ts +0 -4
- package/node_modules/zod/v4/locales/zh-CN.d.cts +0 -4
- package/node_modules/zod/v4/locales/zh-CN.d.ts +0 -4
- package/node_modules/zod/v4/locales/zh-TW.d.cts +0 -4
- package/node_modules/zod/v4/locales/zh-TW.d.ts +0 -4
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
 [](https://codecov.io/gh/pngjs/pngjs) [](http://badge.fury.io/js/pngjs)
|
|
2
|
-
|
|
3
|
-
# pngjs
|
|
4
|
-
|
|
5
|
-
Simple PNG encoder/decoder for Node.js with no dependencies.
|
|
6
|
-
|
|
7
|
-
Based on the original [pngjs](https://github.com/niegowski/node-pngjs) with the follow enhancements.
|
|
8
|
-
|
|
9
|
-
- Support for reading 1,2,4 & 16 bit files
|
|
10
|
-
- Support for reading interlace files
|
|
11
|
-
- Support for reading `tTRNS` transparent colours
|
|
12
|
-
- Support for writing colortype 0 (grayscale), colortype 2 (RGB), colortype 4 (grayscale alpha) and colortype 6 (RGBA)
|
|
13
|
-
- Sync interface as well as async
|
|
14
|
-
- API compatible with pngjs and node-pngjs
|
|
15
|
-
|
|
16
|
-
Known lack of support for:
|
|
17
|
-
|
|
18
|
-
- Extended PNG e.g. Animation
|
|
19
|
-
- Writing in colortype 3 (indexed color)
|
|
20
|
-
|
|
21
|
-
# Table of Contents
|
|
22
|
-
|
|
23
|
-
- [Requirements](#requirements)
|
|
24
|
-
- [Comparison Table](#comparison-table)
|
|
25
|
-
- [Tests](#tests)
|
|
26
|
-
- [Installation](#installation)
|
|
27
|
-
- [Browser](#browser)
|
|
28
|
-
- [Example](#example)
|
|
29
|
-
- [Async API](#async-api)
|
|
30
|
-
- [Sync API](#sync-api)
|
|
31
|
-
- [Changelog](#changelog)
|
|
32
|
-
|
|
33
|
-
# Comparison Table
|
|
34
|
-
|
|
35
|
-
| Name | Forked From | Sync | Async | 16 Bit | 1/2/4 Bit | Interlace | Gamma | Encodes | Tested |
|
|
36
|
-
| ------------- | ----------- | ---- | ----- | ------ | --------- | --------- | ------ | ------- | ------ |
|
|
37
|
-
| pngjs | | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
|
|
38
|
-
| node-png | pngjs | No | Yes | No | No | No | Hidden | Yes | Manual |
|
|
39
|
-
| png-coder | pngjs | No | Yes | Yes | No | No | Hidden | Yes | Manual |
|
|
40
|
-
| pngparse | | No | Yes | No | Yes | No | No | No | Yes |
|
|
41
|
-
| pngparse-sync | pngparse | Yes | No | No | Yes | No | No | No | Yes |
|
|
42
|
-
| png-async | | No | Yes | No | No | No | No | Yes | Yes |
|
|
43
|
-
| png-js | | No | Yes | No | No | No | No | No | No |
|
|
44
|
-
|
|
45
|
-
Native C++ node decoders:
|
|
46
|
-
|
|
47
|
-
- png
|
|
48
|
-
- png-sync (sync version of above)
|
|
49
|
-
- pixel-png
|
|
50
|
-
- png-img
|
|
51
|
-
|
|
52
|
-
# Tests
|
|
53
|
-
|
|
54
|
-
Tested using [PNG Suite](http://www.schaik.com/pngsuite/). We read every file into pngjs, output it in standard 8bit colour, synchronously and asynchronously, then compare the original with the newly saved images.
|
|
55
|
-
|
|
56
|
-
To run the tests, fetch the repo (tests are not distributed via npm) and install with `npm i`, run `npm test`.
|
|
57
|
-
|
|
58
|
-
The only thing not converted is gamma correction - this is because multiple vendors will do gamma correction differently, so the tests will have different results on different browsers.
|
|
59
|
-
|
|
60
|
-
# Installation
|
|
61
|
-
|
|
62
|
-
```
|
|
63
|
-
$ npm install pngjs --save
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
# Browser
|
|
67
|
-
|
|
68
|
-
The package has been build with a [Browserify](browserify.org) version (`npm run browserify`) and you can use the browser version by including in your code:
|
|
69
|
-
|
|
70
|
-
```
|
|
71
|
-
import { PNG } from 'pngjs/browser';
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
# Example
|
|
75
|
-
|
|
76
|
-
```js
|
|
77
|
-
var fs = require("fs"),
|
|
78
|
-
PNG = require("pngjs").PNG;
|
|
79
|
-
|
|
80
|
-
fs.createReadStream("in.png")
|
|
81
|
-
.pipe(
|
|
82
|
-
new PNG({
|
|
83
|
-
filterType: 4,
|
|
84
|
-
})
|
|
85
|
-
)
|
|
86
|
-
.on("parsed", function () {
|
|
87
|
-
for (var y = 0; y < this.height; y++) {
|
|
88
|
-
for (var x = 0; x < this.width; x++) {
|
|
89
|
-
var idx = (this.width * y + x) << 2;
|
|
90
|
-
|
|
91
|
-
// invert color
|
|
92
|
-
this.data[idx] = 255 - this.data[idx];
|
|
93
|
-
this.data[idx + 1] = 255 - this.data[idx + 1];
|
|
94
|
-
this.data[idx + 2] = 255 - this.data[idx + 2];
|
|
95
|
-
|
|
96
|
-
// and reduce opacity
|
|
97
|
-
this.data[idx + 3] = this.data[idx + 3] >> 1;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
this.pack().pipe(fs.createWriteStream("out.png"));
|
|
102
|
-
});
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
For more examples see `examples` folder.
|
|
106
|
-
|
|
107
|
-
# Async API
|
|
108
|
-
|
|
109
|
-
As input any color type is accepted (grayscale, rgb, palette, grayscale with alpha, rgb with alpha) but 8 bit per sample (channel) is the only supported bit depth. Interlaced mode is not supported.
|
|
110
|
-
|
|
111
|
-
## Class: PNG
|
|
112
|
-
|
|
113
|
-
`PNG` is readable and writable `Stream`.
|
|
114
|
-
|
|
115
|
-
### Options
|
|
116
|
-
|
|
117
|
-
- `width` - use this with `height` if you want to create png from scratch
|
|
118
|
-
- `height` - as above
|
|
119
|
-
- `checkCRC` - whether parser should be strict about checksums in source stream (default: `true`)
|
|
120
|
-
- `deflateChunkSize` - chunk size used for deflating data chunks, this should be power of 2 and must not be less than 256 and more than 32\*1024 (default: 32 kB)
|
|
121
|
-
- `deflateLevel` - compression level for deflate (default: 9)
|
|
122
|
-
- `deflateStrategy` - compression strategy for deflate (default: 3)
|
|
123
|
-
- `deflateFactory` - deflate stream factory (default: `zlib.createDeflate`)
|
|
124
|
-
- `filterType` - png filtering method for scanlines (default: -1 => auto, accepts array of numbers 0-4)
|
|
125
|
-
- `colorType` - the output colorType - see constants. 0 = grayscale, no alpha, 2 = color, no alpha, 4 = grayscale & alpha, 6 = color & alpha. Default currently 6, but in the future may calculate best mode.
|
|
126
|
-
- `inputColorType` - the input colorType - see constants. Default is 6 (RGBA)
|
|
127
|
-
- `bitDepth` - the bitDepth of the output, 8 or 16 bits. Input data is expected to have this bit depth.
|
|
128
|
-
16 bit data is expected in the system endianness (Default: 8)
|
|
129
|
-
- `inputHasAlpha` - whether the input bitmap has 4 bytes per pixel (rgb and alpha) or 3 (rgb - no alpha).
|
|
130
|
-
- `bgColor` - an object containing red, green, and blue values between 0 and 255
|
|
131
|
-
that is used when packing a PNG if alpha is not to be included (default: 255,255,255)
|
|
132
|
-
|
|
133
|
-
### Event "metadata"
|
|
134
|
-
|
|
135
|
-
`function(metadata) { }`
|
|
136
|
-
Image's header has been parsed, metadata contains this information:
|
|
137
|
-
|
|
138
|
-
- `width` image size in pixels
|
|
139
|
-
- `height` image size in pixels
|
|
140
|
-
- `palette` image is paletted
|
|
141
|
-
- `color` image is not grayscale
|
|
142
|
-
- `alpha` image contains alpha channel
|
|
143
|
-
- `interlace` image is interlaced
|
|
144
|
-
|
|
145
|
-
### Event: "parsed"
|
|
146
|
-
|
|
147
|
-
`function(data) { }`
|
|
148
|
-
Input image has been completely parsed, `data` is complete and ready for modification.
|
|
149
|
-
|
|
150
|
-
### Event: "error"
|
|
151
|
-
|
|
152
|
-
`function(error) { }`
|
|
153
|
-
|
|
154
|
-
### png.parse(data, [callback])
|
|
155
|
-
|
|
156
|
-
Parses PNG file data. Can be `String` or `Buffer`. Alternatively you can stream data to instance of PNG.
|
|
157
|
-
|
|
158
|
-
Optional `callback` is once called on `error` or `parsed`. The callback gets
|
|
159
|
-
two arguments `(err, data)`.
|
|
160
|
-
|
|
161
|
-
Returns `this` for method chaining.
|
|
162
|
-
|
|
163
|
-
#### Example
|
|
164
|
-
|
|
165
|
-
```js
|
|
166
|
-
new PNG({ filterType: 4 }).parse(imageData, function (error, data) {
|
|
167
|
-
console.log(error, data);
|
|
168
|
-
});
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
### png.pack()
|
|
172
|
-
|
|
173
|
-
Starts converting data to PNG file Stream.
|
|
174
|
-
|
|
175
|
-
Returns `this` for method chaining.
|
|
176
|
-
|
|
177
|
-
### png.bitblt(dst, sx, sy, w, h, dx, dy)
|
|
178
|
-
|
|
179
|
-
Helper for image manipulation, copies a rectangle of pixels from current (i.e. the source) image (`sx`, `sy`, `w`, `h`) to `dst` image (at `dx`, `dy`).
|
|
180
|
-
|
|
181
|
-
Returns `this` for method chaining.
|
|
182
|
-
|
|
183
|
-
For example, the following code copies the top-left 100x50 px of `in.png` into dst and writes it to `out.png`:
|
|
184
|
-
|
|
185
|
-
```js
|
|
186
|
-
var dst = new PNG({ width: 100, height: 50 });
|
|
187
|
-
fs.createReadStream("in.png")
|
|
188
|
-
.pipe(new PNG())
|
|
189
|
-
.on("parsed", function () {
|
|
190
|
-
this.bitblt(dst, 0, 0, 100, 50, 0, 0);
|
|
191
|
-
dst.pack().pipe(fs.createWriteStream("out.png"));
|
|
192
|
-
});
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
### Property: adjustGamma()
|
|
196
|
-
|
|
197
|
-
Helper that takes data and adjusts it to be gamma corrected. Note that it is not 100% reliable with transparent colours because that requires knowing the background colour the bitmap is rendered on to.
|
|
198
|
-
|
|
199
|
-
In tests against PNG suite it compared 100% with chrome on all 8 bit and below images. On IE there were some differences.
|
|
200
|
-
|
|
201
|
-
The following example reads a file, adjusts the gamma (which sets the gamma to 0) and writes it out again, effectively removing any gamma correction from the image.
|
|
202
|
-
|
|
203
|
-
```js
|
|
204
|
-
fs.createReadStream("in.png")
|
|
205
|
-
.pipe(new PNG())
|
|
206
|
-
.on("parsed", function () {
|
|
207
|
-
this.adjustGamma();
|
|
208
|
-
this.pack().pipe(fs.createWriteStream("out.png"));
|
|
209
|
-
});
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
### Property: width
|
|
213
|
-
|
|
214
|
-
Width of image in pixels
|
|
215
|
-
|
|
216
|
-
### Property: height
|
|
217
|
-
|
|
218
|
-
Height of image in pixels
|
|
219
|
-
|
|
220
|
-
### Property: data
|
|
221
|
-
|
|
222
|
-
Buffer of image pixel data. Every pixel consists 4 bytes: R, G, B, A (opacity).
|
|
223
|
-
|
|
224
|
-
### Property: gamma
|
|
225
|
-
|
|
226
|
-
Gamma of image (0 if not specified)
|
|
227
|
-
|
|
228
|
-
## Packing a PNG and removing alpha (RGBA to RGB)
|
|
229
|
-
|
|
230
|
-
When removing the alpha channel from an image, there needs to be a background color to correctly
|
|
231
|
-
convert each pixel's transparency to the appropriate RGB value. By default, pngjs will flatten
|
|
232
|
-
the image against a white background. You can override this in the options:
|
|
233
|
-
|
|
234
|
-
```js
|
|
235
|
-
var fs = require("fs"),
|
|
236
|
-
PNG = require("pngjs").PNG;
|
|
237
|
-
|
|
238
|
-
fs.createReadStream("in.png")
|
|
239
|
-
.pipe(
|
|
240
|
-
new PNG({
|
|
241
|
-
colorType: 2,
|
|
242
|
-
bgColor: {
|
|
243
|
-
red: 0,
|
|
244
|
-
green: 255,
|
|
245
|
-
blue: 0,
|
|
246
|
-
},
|
|
247
|
-
})
|
|
248
|
-
)
|
|
249
|
-
.on("parsed", function () {
|
|
250
|
-
this.pack().pipe(fs.createWriteStream("out.png"));
|
|
251
|
-
});
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
# Sync API
|
|
255
|
-
|
|
256
|
-
## PNG.sync
|
|
257
|
-
|
|
258
|
-
### PNG.sync.read(buffer)
|
|
259
|
-
|
|
260
|
-
Take a buffer and returns a PNG image. The properties on the image include the meta data and `data` as per the async API above.
|
|
261
|
-
|
|
262
|
-
```
|
|
263
|
-
var data = fs.readFileSync('in.png');
|
|
264
|
-
var png = PNG.sync.read(data);
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
### PNG.sync.write(png)
|
|
268
|
-
|
|
269
|
-
Take a PNG image and returns a buffer. The properties on the image include the meta data and `data` as per the async API above.
|
|
270
|
-
|
|
271
|
-
```
|
|
272
|
-
var data = fs.readFileSync('in.png');
|
|
273
|
-
var png = PNG.sync.read(data);
|
|
274
|
-
var options = { colorType: 6 };
|
|
275
|
-
var buffer = PNG.sync.write(png, options);
|
|
276
|
-
fs.writeFileSync('out.png', buffer);
|
|
277
|
-
```
|
|
278
|
-
|
|
279
|
-
### PNG.adjustGamma(src)
|
|
280
|
-
|
|
281
|
-
Adjusts the gamma of a sync image. See the async adjustGamma.
|
|
282
|
-
|
|
283
|
-
```
|
|
284
|
-
var data = fs.readFileSync('in.png');
|
|
285
|
-
var png = PNG.sync.read(data);
|
|
286
|
-
PNG.adjustGamma(png);
|
|
287
|
-
```
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
# sax js
|
|
2
|
-
|
|
3
|
-
A sax-style parser for XML and HTML.
|
|
4
|
-
|
|
5
|
-
Designed with [node](http://nodejs.org/) in mind, but should work fine in
|
|
6
|
-
the browser or other CommonJS implementations.
|
|
7
|
-
|
|
8
|
-
## What This Is
|
|
9
|
-
|
|
10
|
-
* A very simple tool to parse through an XML string.
|
|
11
|
-
* A stepping stone to a streaming HTML parser.
|
|
12
|
-
* A handy way to deal with RSS and other mostly-ok-but-kinda-broken XML
|
|
13
|
-
docs.
|
|
14
|
-
|
|
15
|
-
## What This Is (probably) Not
|
|
16
|
-
|
|
17
|
-
* An HTML Parser - That's a fine goal, but this isn't it. It's just
|
|
18
|
-
XML.
|
|
19
|
-
* A DOM Builder - You can use it to build an object model out of XML,
|
|
20
|
-
but it doesn't do that out of the box.
|
|
21
|
-
* XSLT - No DOM = no querying.
|
|
22
|
-
* 100% Compliant with (some other SAX implementation) - Most SAX
|
|
23
|
-
implementations are in Java and do a lot more than this does.
|
|
24
|
-
* An XML Validator - It does a little validation when in strict mode, but
|
|
25
|
-
not much.
|
|
26
|
-
* A Schema-Aware XSD Thing - Schemas are an exercise in fetishistic
|
|
27
|
-
masochism.
|
|
28
|
-
* A DTD-aware Thing - Fetching DTDs is a much bigger job.
|
|
29
|
-
|
|
30
|
-
## Regarding `<!DOCTYPE`s and `<!ENTITY`s
|
|
31
|
-
|
|
32
|
-
The parser will handle the basic XML entities in text nodes and attribute
|
|
33
|
-
values: `& < > ' "`. It's possible to define additional
|
|
34
|
-
entities in XML by putting them in the DTD. This parser doesn't do anything
|
|
35
|
-
with that. If you want to listen to the `ondoctype` event, and then fetch
|
|
36
|
-
the doctypes, and read the entities and add them to `parser.ENTITIES`, then
|
|
37
|
-
be my guest.
|
|
38
|
-
|
|
39
|
-
Unknown entities will fail in strict mode, and in loose mode, will pass
|
|
40
|
-
through unmolested.
|
|
41
|
-
|
|
42
|
-
## Usage
|
|
43
|
-
|
|
44
|
-
```javascript
|
|
45
|
-
var sax = require("./lib/sax"),
|
|
46
|
-
strict = true, // set to false for html-mode
|
|
47
|
-
parser = sax.parser(strict);
|
|
48
|
-
|
|
49
|
-
parser.onerror = function (e) {
|
|
50
|
-
// an error happened.
|
|
51
|
-
};
|
|
52
|
-
parser.ontext = function (t) {
|
|
53
|
-
// got some text. t is the string of text.
|
|
54
|
-
};
|
|
55
|
-
parser.onopentag = function (node) {
|
|
56
|
-
// opened a tag. node has "name" and "attributes"
|
|
57
|
-
};
|
|
58
|
-
parser.onattribute = function (attr) {
|
|
59
|
-
// an attribute. attr has "name" and "value"
|
|
60
|
-
};
|
|
61
|
-
parser.onend = function () {
|
|
62
|
-
// parser stream is done, and ready to have more stuff written to it.
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
parser.write('<xml>Hello, <who name="world">world</who>!</xml>').close();
|
|
66
|
-
|
|
67
|
-
// stream usage
|
|
68
|
-
// takes the same options as the parser
|
|
69
|
-
var saxStream = require("sax").createStream(strict, options)
|
|
70
|
-
saxStream.on("error", function (e) {
|
|
71
|
-
// unhandled errors will throw, since this is a proper node
|
|
72
|
-
// event emitter.
|
|
73
|
-
console.error("error!", e)
|
|
74
|
-
// clear the error
|
|
75
|
-
this._parser.error = null
|
|
76
|
-
this._parser.resume()
|
|
77
|
-
})
|
|
78
|
-
saxStream.on("opentag", function (node) {
|
|
79
|
-
// same object as above
|
|
80
|
-
})
|
|
81
|
-
// pipe is supported, and it's readable/writable
|
|
82
|
-
// same chunks coming in also go out.
|
|
83
|
-
fs.createReadStream("file.xml")
|
|
84
|
-
.pipe(saxStream)
|
|
85
|
-
.pipe(fs.createWriteStream("file-copy.xml"))
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
## Arguments
|
|
90
|
-
|
|
91
|
-
Pass the following arguments to the parser function. All are optional.
|
|
92
|
-
|
|
93
|
-
`strict` - Boolean. Whether or not to be a jerk. Default: `false`.
|
|
94
|
-
|
|
95
|
-
`opt` - Object bag of settings regarding string formatting. All default to `false`.
|
|
96
|
-
|
|
97
|
-
Settings supported:
|
|
98
|
-
|
|
99
|
-
* `trim` - Boolean. Whether or not to trim text and comment nodes.
|
|
100
|
-
* `normalize` - Boolean. If true, then turn any whitespace into a single
|
|
101
|
-
space.
|
|
102
|
-
* `lowercase` - Boolean. If true, then lowercase tag names and attribute names
|
|
103
|
-
in loose mode, rather than uppercasing them.
|
|
104
|
-
* `xmlns` - Boolean. If true, then namespaces are supported.
|
|
105
|
-
* `position` - Boolean. If false, then don't track line/col/position.
|
|
106
|
-
* `strictEntities` - Boolean. If true, only parse [predefined XML
|
|
107
|
-
entities](http://www.w3.org/TR/REC-xml/#sec-predefined-ent)
|
|
108
|
-
(`&`, `'`, `>`, `<`, and `"`)
|
|
109
|
-
* `unquotedAttributeValues` - Boolean. If true, then unquoted
|
|
110
|
-
attribute values are allowed. Defaults to `false` when `strict`
|
|
111
|
-
is true, `true` otherwise.
|
|
112
|
-
|
|
113
|
-
## Methods
|
|
114
|
-
|
|
115
|
-
`write` - Write bytes onto the stream. You don't have to do this all at
|
|
116
|
-
once. You can keep writing as much as you want.
|
|
117
|
-
|
|
118
|
-
`close` - Close the stream. Once closed, no more data may be written until
|
|
119
|
-
it is done processing the buffer, which is signaled by the `end` event.
|
|
120
|
-
|
|
121
|
-
`resume` - To gracefully handle errors, assign a listener to the `error`
|
|
122
|
-
event. Then, when the error is taken care of, you can call `resume` to
|
|
123
|
-
continue parsing. Otherwise, the parser will not continue while in an error
|
|
124
|
-
state.
|
|
125
|
-
|
|
126
|
-
## Members
|
|
127
|
-
|
|
128
|
-
At all times, the parser object will have the following members:
|
|
129
|
-
|
|
130
|
-
`line`, `column`, `position` - Indications of the position in the XML
|
|
131
|
-
document where the parser currently is looking.
|
|
132
|
-
|
|
133
|
-
`startTagPosition` - Indicates the position where the current tag starts.
|
|
134
|
-
|
|
135
|
-
`closed` - Boolean indicating whether or not the parser can be written to.
|
|
136
|
-
If it's `true`, then wait for the `ready` event to write again.
|
|
137
|
-
|
|
138
|
-
`strict` - Boolean indicating whether or not the parser is a jerk.
|
|
139
|
-
|
|
140
|
-
`opt` - Any options passed into the constructor.
|
|
141
|
-
|
|
142
|
-
`tag` - The current tag being dealt with.
|
|
143
|
-
|
|
144
|
-
And a bunch of other stuff that you probably shouldn't touch.
|
|
145
|
-
|
|
146
|
-
## Events
|
|
147
|
-
|
|
148
|
-
All events emit with a single argument. To listen to an event, assign a
|
|
149
|
-
function to `on<eventname>`. Functions get executed in the this-context of
|
|
150
|
-
the parser object. The list of supported events are also in the exported
|
|
151
|
-
`EVENTS` array.
|
|
152
|
-
|
|
153
|
-
When using the stream interface, assign handlers using the EventEmitter
|
|
154
|
-
`on` function in the normal fashion.
|
|
155
|
-
|
|
156
|
-
`error` - Indication that something bad happened. The error will be hanging
|
|
157
|
-
out on `parser.error`, and must be deleted before parsing can continue. By
|
|
158
|
-
listening to this event, you can keep an eye on that kind of stuff. Note:
|
|
159
|
-
this happens *much* more in strict mode. Argument: instance of `Error`.
|
|
160
|
-
|
|
161
|
-
`text` - Text node. Argument: string of text.
|
|
162
|
-
|
|
163
|
-
`doctype` - The `<!DOCTYPE` declaration. Argument: doctype string.
|
|
164
|
-
|
|
165
|
-
`processinginstruction` - Stuff like `<?xml foo="blerg" ?>`. Argument:
|
|
166
|
-
object with `name` and `body` members. Attributes are not parsed, as
|
|
167
|
-
processing instructions have implementation dependent semantics.
|
|
168
|
-
|
|
169
|
-
`sgmldeclaration` - Random SGML declarations. Stuff like `<!ENTITY p>`
|
|
170
|
-
would trigger this kind of event. This is a weird thing to support, so it
|
|
171
|
-
might go away at some point. SAX isn't intended to be used to parse SGML,
|
|
172
|
-
after all.
|
|
173
|
-
|
|
174
|
-
`opentagstart` - Emitted immediately when the tag name is available,
|
|
175
|
-
but before any attributes are encountered. Argument: object with a
|
|
176
|
-
`name` field and an empty `attributes` set. Note that this is the
|
|
177
|
-
same object that will later be emitted in the `opentag` event.
|
|
178
|
-
|
|
179
|
-
`opentag` - An opening tag. Argument: object with `name` and `attributes`.
|
|
180
|
-
In non-strict mode, tag names are uppercased, unless the `lowercase`
|
|
181
|
-
option is set. If the `xmlns` option is set, then it will contain
|
|
182
|
-
namespace binding information on the `ns` member, and will have a
|
|
183
|
-
`local`, `prefix`, and `uri` member.
|
|
184
|
-
|
|
185
|
-
`closetag` - A closing tag. In loose mode, tags are auto-closed if their
|
|
186
|
-
parent closes. In strict mode, well-formedness is enforced. Note that
|
|
187
|
-
self-closing tags will have `closeTag` emitted immediately after `openTag`.
|
|
188
|
-
Argument: tag name.
|
|
189
|
-
|
|
190
|
-
`attribute` - An attribute node. Argument: object with `name` and `value`.
|
|
191
|
-
In non-strict mode, attribute names are uppercased, unless the `lowercase`
|
|
192
|
-
option is set. If the `xmlns` option is set, it will also contains namespace
|
|
193
|
-
information.
|
|
194
|
-
|
|
195
|
-
`comment` - A comment node. Argument: the string of the comment.
|
|
196
|
-
|
|
197
|
-
`opencdata` - The opening tag of a `<![CDATA[` block.
|
|
198
|
-
|
|
199
|
-
`cdata` - The text of a `<![CDATA[` block. Since `<![CDATA[` blocks can get
|
|
200
|
-
quite large, this event may fire multiple times for a single block, if it
|
|
201
|
-
is broken up into multiple `write()`s. Argument: the string of random
|
|
202
|
-
character data.
|
|
203
|
-
|
|
204
|
-
`closecdata` - The closing tag (`]]>`) of a `<![CDATA[` block.
|
|
205
|
-
|
|
206
|
-
`opennamespace` - If the `xmlns` option is set, then this event will
|
|
207
|
-
signal the start of a new namespace binding.
|
|
208
|
-
|
|
209
|
-
`closenamespace` - If the `xmlns` option is set, then this event will
|
|
210
|
-
signal the end of a namespace binding.
|
|
211
|
-
|
|
212
|
-
`end` - Indication that the closed stream has ended.
|
|
213
|
-
|
|
214
|
-
`ready` - Indication that the stream has reset, and is ready to be written
|
|
215
|
-
to.
|
|
216
|
-
|
|
217
|
-
`noscript` - In non-strict mode, `<script>` tags trigger a `"script"`
|
|
218
|
-
event, and their contents are not checked for special xml characters.
|
|
219
|
-
If you pass `noscript: true`, then this behavior is suppressed.
|
|
220
|
-
|
|
221
|
-
## Reporting Problems
|
|
222
|
-
|
|
223
|
-
It's best to write a failing test if you find an issue. I will always
|
|
224
|
-
accept pull requests with failing tests if they demonstrate intended
|
|
225
|
-
behavior, but it is very hard to figure out what issue you're describing
|
|
226
|
-
without a test. Writing a test is also the best way for you yourself
|
|
227
|
-
to figure out if you really understand the issue you think you have with
|
|
228
|
-
sax-js.
|