@koiosdigital/matrx-render 0.1.3 → 0.1.6
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/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { C as Color16, a as Canvas, W as Widget, b as Color, B as Bounds, D as DrawContext } from './widget-DABrpucj.js';
|
|
2
2
|
export { c as BLACK, T as TRANSPARENT, d as WHITE, e as bounds, f as color16, m as maxFrameCount, g as modInt, p as parseColor } from './widget-DABrpucj.js';
|
|
3
3
|
import { WidgetSpec, RootSpec } from '@koiosdigital/matrx-sdk';
|
|
4
|
-
export { D as DEFAULT_SCREEN_DELAY_MILLIS, F as FrameEncoder, I as Image, W as WebpDecoder, e as encodeWebp, s as setWebpDecoder } from './webp-
|
|
4
|
+
export { D as DEFAULT_SCREEN_DELAY_MILLIS, F as FrameEncoder, I as Image, W as WebpDecoder, e as encodeWebp, s as setWebpDecoder } from './webp-Cq1VWs8C.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* BDF bitmap-font parser — a line-for-line port of zachomedia/go-bdf
|
|
@@ -651,4 +651,17 @@ interface DecodedGif {
|
|
|
651
651
|
declare function isGif(data: Uint8Array): boolean;
|
|
652
652
|
declare function decodeGif(data: Uint8Array): DecodedGif;
|
|
653
653
|
|
|
654
|
-
|
|
654
|
+
/**
|
|
655
|
+
* JPEG decoder (via jpeg-js). Output is straight (non-premultiplied) RGBA,
|
|
656
|
+
* matching decodePng/decodeGif image handoff semantics.
|
|
657
|
+
*/
|
|
658
|
+
interface DecodedJpeg {
|
|
659
|
+
width: number;
|
|
660
|
+
height: number;
|
|
661
|
+
/** Straight RGBA. */
|
|
662
|
+
rgba: Uint8Array;
|
|
663
|
+
}
|
|
664
|
+
declare function isJpeg(data: Uint8Array): boolean;
|
|
665
|
+
declare function decodeJpeg(data: Uint8Array): DecodedJpeg;
|
|
666
|
+
|
|
667
|
+
export { Animation, type BdfFont, Bounds, Box, Canvas, Circle, Color, Color16, Column, type CrossAlign, type Curve, DEFAULT_FONT_FACE, DEFAULT_FRAME_HEIGHT, DEFAULT_FRAME_WIDTH, DEFAULT_MAX_FRAME_COUNT, DEFAULT_ORIGIN, DEFAULT_PLOT_COLOR, type DirectionMode, DrawContext, FILL_DAMP_FACTOR, type FillMode, type Glyph, type Insets, type Keyframe, type MainAlign, Marquee, type Origin, Padding, type PathPoint, PieChart, Plot, PolyLine, type RenderResult, Root, type RoundingMode, Row, Sequence, Stack, Text, type Transform, Transformation, Vector, Widget, WrappedText, applyRounding, buildWidget, cubicBezierCurve, decodeGif, decodeJpeg, decodePng, easeIn, easeInOut, easeOut, encodePng, findKeyframes, getFont, getFontList, interpolateTransforms, isGif, isJpeg, isPng, lerp, linearCurve, lookupGlyph, measureString, parseBdf, parseCurve, processKeyframes, renderRoot, renderText, rescale, wordWrap };
|
package/dist/index.js
CHANGED
|
@@ -889,6 +889,35 @@ function decodeGif(data) {
|
|
|
889
889
|
return { width, height, frames };
|
|
890
890
|
}
|
|
891
891
|
|
|
892
|
+
// src/image/jpeg.ts
|
|
893
|
+
import jpeg from "jpeg-js";
|
|
894
|
+
function isJpeg(data) {
|
|
895
|
+
return data.length > 3 && data[0] === 255 && data[1] === 216;
|
|
896
|
+
}
|
|
897
|
+
function decodeJpeg(data) {
|
|
898
|
+
if (!isJpeg(data)) {
|
|
899
|
+
throw new Error("not a JPEG");
|
|
900
|
+
}
|
|
901
|
+
let decoded;
|
|
902
|
+
try {
|
|
903
|
+
decoded = jpeg.decode(data, {
|
|
904
|
+
useTArray: true,
|
|
905
|
+
formatAsRGBA: true
|
|
906
|
+
});
|
|
907
|
+
} catch (error) {
|
|
908
|
+
throw new Error(`invalid JPEG: ${error.message}`);
|
|
909
|
+
}
|
|
910
|
+
return {
|
|
911
|
+
width: decoded.width,
|
|
912
|
+
height: decoded.height,
|
|
913
|
+
rgba: new Uint8Array(
|
|
914
|
+
decoded.data.buffer,
|
|
915
|
+
decoded.data.byteOffset,
|
|
916
|
+
decoded.data.byteLength
|
|
917
|
+
).slice()
|
|
918
|
+
};
|
|
919
|
+
}
|
|
920
|
+
|
|
892
921
|
// src/image/png.ts
|
|
893
922
|
import { unzlibSync } from "fflate";
|
|
894
923
|
var PNG_SIGNATURE = [137, 80, 78, 71, 13, 10, 26, 10];
|
|
@@ -1195,12 +1224,15 @@ var Image = class {
|
|
|
1195
1224
|
this.imgs = [canvasFromStraight(d.width, d.height, d.rgba)];
|
|
1196
1225
|
} else if (isGif(data)) {
|
|
1197
1226
|
this.initFromGif(data);
|
|
1227
|
+
} else if (isJpeg(data)) {
|
|
1228
|
+
const d = decodeJpeg(data);
|
|
1229
|
+
this.imgs = [canvasFromStraight(d.width, d.height, d.rgba)];
|
|
1198
1230
|
} else if (isPng(data)) {
|
|
1199
1231
|
const d = decodePng(data);
|
|
1200
1232
|
this.imgs = [canvasFromStraight(d.width, d.height, d.rgba)];
|
|
1201
1233
|
} else {
|
|
1202
1234
|
throw new Error(
|
|
1203
|
-
"decoding image data: unsupported format (PNG, GIF and
|
|
1235
|
+
"decoding image data: unsupported format (PNG, GIF, WebP and JPEG are supported; SVG not yet)"
|
|
1204
1236
|
);
|
|
1205
1237
|
}
|
|
1206
1238
|
const w = this.imgs[0].width;
|
|
@@ -2758,6 +2790,7 @@ export {
|
|
|
2758
2790
|
color16,
|
|
2759
2791
|
cubicBezierCurve,
|
|
2760
2792
|
decodeGif,
|
|
2793
|
+
decodeJpeg,
|
|
2761
2794
|
decodePng,
|
|
2762
2795
|
easeIn,
|
|
2763
2796
|
easeInOut,
|
|
@@ -2769,6 +2802,7 @@ export {
|
|
|
2769
2802
|
getFontList,
|
|
2770
2803
|
interpolateTransforms,
|
|
2771
2804
|
isGif,
|
|
2805
|
+
isJpeg,
|
|
2772
2806
|
isPng,
|
|
2773
2807
|
lerp,
|
|
2774
2808
|
linearCurve,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { W as Widget, B as Bounds, D as DrawContext, a as Canvas } from './widget-DABrpucj.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Image — port of pixlet render/image.go. Decodes PNG /
|
|
5
|
-
* WebP (via an injected decoder), scales with nearest-neighbor when
|
|
4
|
+
* Image — port of pixlet render/image.go. Decodes PNG / JPEG / animated
|
|
5
|
+
* GIF / WebP (via an injected decoder), scales with nearest-neighbor when
|
|
6
6
|
* width/height are set (aspect preserved when only one is given), and for
|
|
7
7
|
* animated GIFs replays Go Image.InitFromGIF's frame-composition logic —
|
|
8
8
|
* including its disposal-method quirks — exactly.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
10
|
+
* SVG is not supported yet (M3); it fails with a clear error.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
/** Optional WebP decoder (WASM), injected by the host/runtime. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koiosdigital/matrx-render",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@jsquash/webp": "^1.5.0",
|
|
13
13
|
"fflate": "^0.8.3",
|
|
14
|
-
"
|
|
14
|
+
"jpeg-js": "^0.4.4",
|
|
15
|
+
"@koiosdigital/matrx-sdk": "0.1.6"
|
|
15
16
|
},
|
|
16
17
|
"devDependencies": {
|
|
17
18
|
"@types/node": "^26.1.0",
|