@nodetool-ai/image-editor 0.8.5 → 0.8.7
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 +39 -0
- package/dist/.nodetool-build-stamp +1 -1
- package/dist/psd/encoder.d.ts +63 -0
- package/dist/psd/encoder.d.ts.map +1 -0
- package/dist/psd/encoder.js +392 -0
- package/dist/psd/encoder.js.map +1 -0
- package/dist/psd/index.d.ts +8 -0
- package/dist/psd/index.d.ts.map +1 -0
- package/dist/psd/index.js +8 -0
- package/dist/psd/index.js.map +1 -0
- package/dist/psd/sketch.d.ts +59 -0
- package/dist/psd/sketch.d.ts.map +1 -0
- package/dist/psd/sketch.js +120 -0
- package/dist/psd/sketch.js.map +1 -0
- package/dist/raster/selection.d.ts.map +1 -1
- package/dist/raster/selection.js +9 -1
- package/dist/raster/selection.js.map +1 -1
- package/dist/render/compose.d.ts +59 -0
- package/dist/render/compose.d.ts.map +1 -0
- package/dist/render/compose.js +231 -0
- package/dist/render/compose.js.map +1 -0
- package/dist/render/document.d.ts +79 -0
- package/dist/render/document.d.ts.map +1 -0
- package/dist/render/document.js +211 -0
- package/dist/render/document.js.map +1 -0
- package/dist/render/index.d.ts +12 -0
- package/dist/render/index.d.ts.map +1 -0
- package/dist/render/index.js +12 -0
- package/dist/render/index.js.map +1 -0
- package/dist/render/normalize.d.ts +31 -0
- package/dist/render/normalize.d.ts.map +1 -0
- package/dist/render/normalize.js +228 -0
- package/dist/render/normalize.js.map +1 -0
- package/dist/render/types.d.ts +127 -0
- package/dist/render/types.d.ts.map +1 -0
- package/dist/render/types.js +10 -0
- package/dist/render/types.js.map +1 -0
- package/package.json +16 -1
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-neutral shapes for compositing a sketch document.
|
|
3
|
+
*
|
|
4
|
+
* Structural on purpose, like `painting/surface.ts`: the web editor's `Layer`
|
|
5
|
+
* and `SketchDocument` satisfy them, and so does a document parsed from JSON
|
|
6
|
+
* once it has gone through {@link normalizeRenderDocument}. This package
|
|
7
|
+
* compiles without the DOM lib, so the canvas types are declared here too.
|
|
8
|
+
*/
|
|
9
|
+
import type { PaintContext2D, PaintSurface } from "../painting/surface.js";
|
|
10
|
+
export interface RenderPoint {
|
|
11
|
+
readonly x: number;
|
|
12
|
+
readonly y: number;
|
|
13
|
+
}
|
|
14
|
+
export type RenderQuad = readonly [
|
|
15
|
+
RenderPoint,
|
|
16
|
+
RenderPoint,
|
|
17
|
+
RenderPoint,
|
|
18
|
+
RenderPoint
|
|
19
|
+
];
|
|
20
|
+
/** TRS around the raster's center. Rotation is in radians. */
|
|
21
|
+
export interface RenderAffineTransform {
|
|
22
|
+
readonly kind: "affine";
|
|
23
|
+
readonly x: number;
|
|
24
|
+
readonly y: number;
|
|
25
|
+
readonly scaleX: number;
|
|
26
|
+
readonly scaleY: number;
|
|
27
|
+
readonly rotation: number;
|
|
28
|
+
}
|
|
29
|
+
export type RenderQuadMode = "distort" | "skew" | "perspective" | "mesh-warp";
|
|
30
|
+
/** Document-space corners: top-left, top-right, bottom-right, bottom-left. */
|
|
31
|
+
export interface RenderQuadTransform {
|
|
32
|
+
readonly kind: "quad";
|
|
33
|
+
readonly mode: RenderQuadMode;
|
|
34
|
+
readonly quad: RenderQuad;
|
|
35
|
+
}
|
|
36
|
+
export type RenderLayerTransform = RenderAffineTransform | RenderQuadTransform;
|
|
37
|
+
export interface RenderBounds {
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
width: number;
|
|
41
|
+
height: number;
|
|
42
|
+
}
|
|
43
|
+
export type RenderLayerType = "raster" | "mask" | "group" | "vector";
|
|
44
|
+
export type RenderImageFit = "fill" | "contain" | "cover";
|
|
45
|
+
export interface RenderImageReference {
|
|
46
|
+
uri: string;
|
|
47
|
+
/** Omitted: the image is drawn at its natural size from the layer origin. */
|
|
48
|
+
objectFit?: RenderImageFit;
|
|
49
|
+
}
|
|
50
|
+
export interface BrightnessContrastEffect {
|
|
51
|
+
type: "brightness_contrast";
|
|
52
|
+
enabled: boolean;
|
|
53
|
+
params: {
|
|
54
|
+
brightness: number;
|
|
55
|
+
contrast: number;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export interface HueSaturationEffect {
|
|
59
|
+
type: "hue_saturation";
|
|
60
|
+
enabled: boolean;
|
|
61
|
+
params: {
|
|
62
|
+
hueDegrees: number;
|
|
63
|
+
saturation: number;
|
|
64
|
+
lightness: number;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export interface ExposureEffect {
|
|
68
|
+
type: "exposure";
|
|
69
|
+
enabled: boolean;
|
|
70
|
+
params: {
|
|
71
|
+
exposureStops: number;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/** The non-destructive effects the editor evaluates, in stack order. */
|
|
75
|
+
export type RenderLayerEffect = BrightnessContrastEffect | HueSaturationEffect | ExposureEffect;
|
|
76
|
+
/** The fields of a layer that decide its pixels. */
|
|
77
|
+
export interface RenderLayer {
|
|
78
|
+
id: string;
|
|
79
|
+
name: string;
|
|
80
|
+
type: RenderLayerType;
|
|
81
|
+
visible: boolean;
|
|
82
|
+
opacity: number;
|
|
83
|
+
blendMode: string;
|
|
84
|
+
alphaLock: boolean;
|
|
85
|
+
collapsed?: boolean;
|
|
86
|
+
/** `ntlayer:<base64 JSON>` or a legacy bare image locator. */
|
|
87
|
+
data: string | null;
|
|
88
|
+
imageReference?: RenderImageReference | null;
|
|
89
|
+
transform: RenderLayerTransform;
|
|
90
|
+
contentBounds: RenderBounds;
|
|
91
|
+
parentId?: string | null;
|
|
92
|
+
effects: RenderLayerEffect[];
|
|
93
|
+
}
|
|
94
|
+
export interface RenderDocument {
|
|
95
|
+
canvas: {
|
|
96
|
+
width: number;
|
|
97
|
+
height: number;
|
|
98
|
+
backgroundColor?: string;
|
|
99
|
+
};
|
|
100
|
+
layers: RenderLayer[];
|
|
101
|
+
maskLayerId: string | null;
|
|
102
|
+
}
|
|
103
|
+
/** The Canvas2D members the compositor calls beyond the paint core's. */
|
|
104
|
+
export interface RenderContext2D extends PaintContext2D {
|
|
105
|
+
filter: string;
|
|
106
|
+
moveTo(x: number, y: number): void;
|
|
107
|
+
lineTo(x: number, y: number): void;
|
|
108
|
+
closePath(): void;
|
|
109
|
+
clip(): void;
|
|
110
|
+
/**
|
|
111
|
+
* HOLDOUT (anti-slop/no-unknown-parameters): see `PaintContext2D.drawImage`.
|
|
112
|
+
* The compositor draws back surfaces and images the same host produced.
|
|
113
|
+
*/
|
|
114
|
+
drawImage(image: unknown, dx: number, dy: number): void;
|
|
115
|
+
drawImage(image: unknown, dx: number, dy: number, dw: number, dh: number): void;
|
|
116
|
+
drawImage(image: unknown, sx: number, sy: number, sw: number, sh: number, dx: number, dy: number, dw: number, dh: number): void;
|
|
117
|
+
}
|
|
118
|
+
/** An off-screen bitmap the compositor draws into. */
|
|
119
|
+
export interface RenderSurface extends PaintSurface {
|
|
120
|
+
getContext(contextId: "2d"): RenderContext2D | null;
|
|
121
|
+
}
|
|
122
|
+
/** A decoded image the host can draw. */
|
|
123
|
+
export interface RenderImage {
|
|
124
|
+
width: number;
|
|
125
|
+
height: number;
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/render/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3E,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,UAAU,GAAG,SAAS;IAChC,WAAW;IACX,WAAW;IACX,WAAW;IACX,WAAW;CACZ,CAAC;AAEF,8DAA8D;AAC9D,MAAM,WAAW,qBAAqB;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,SAAQ,cAAc;IACrD,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,SAAS,IAAI,IAAI,CAAC;IAClB,IAAI,IAAI,IAAI,CAAC;IACb;;;OAGG;IACH,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IACxD,SAAS,CACP,KAAK,EAAE,OAAO,EACd,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,GACT,IAAI,CAAC;IACR,SAAS,CACP,KAAK,EAAE,OAAO,EACd,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,GACT,IAAI,CAAC;CACT;AAED,sDAAsD;AACtD,MAAM,WAAW,aAAc,SAAQ,YAAY;IACjD,UAAU,CAAC,SAAS,EAAE,IAAI,GAAG,eAAe,GAAG,IAAI,CAAC;CACrD;AAED,yCAAyC;AACzC,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-neutral shapes for compositing a sketch document.
|
|
3
|
+
*
|
|
4
|
+
* Structural on purpose, like `painting/surface.ts`: the web editor's `Layer`
|
|
5
|
+
* and `SketchDocument` satisfy them, and so does a document parsed from JSON
|
|
6
|
+
* once it has gone through {@link normalizeRenderDocument}. This package
|
|
7
|
+
* compiles without the DOM lib, so the canvas types are declared here too.
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/render/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nodetool-ai/image-editor",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.7",
|
|
4
4
|
"description": "Shared image-editor types, dependency hashing, seeded layer templates, the paint core, and host-neutral raster ops",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
"test:watch": "node ../../scripts/run-vitest.mjs",
|
|
16
16
|
"lint": "node ../../scripts/run-tsc.mjs --noEmit"
|
|
17
17
|
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@nodetool-ai/protocol": "0.8.7"
|
|
20
|
+
},
|
|
18
21
|
"devDependencies": {
|
|
19
22
|
"typescript": "npm:@typescript/typescript6@6.0.2",
|
|
20
23
|
"vitest": "^5.0.1"
|
|
@@ -43,6 +46,18 @@
|
|
|
43
46
|
"types": "./dist/raster/index.d.ts",
|
|
44
47
|
"import": "./dist/raster/index.js",
|
|
45
48
|
"default": "./dist/raster/index.js"
|
|
49
|
+
},
|
|
50
|
+
"./render.js": {
|
|
51
|
+
"nodetool-dev": "./src/render/index.ts",
|
|
52
|
+
"types": "./dist/render/index.d.ts",
|
|
53
|
+
"import": "./dist/render/index.js",
|
|
54
|
+
"default": "./dist/render/index.js"
|
|
55
|
+
},
|
|
56
|
+
"./psd.js": {
|
|
57
|
+
"nodetool-dev": "./src/psd/index.ts",
|
|
58
|
+
"types": "./dist/psd/index.d.ts",
|
|
59
|
+
"import": "./dist/psd/index.js",
|
|
60
|
+
"default": "./dist/psd/index.js"
|
|
46
61
|
}
|
|
47
62
|
},
|
|
48
63
|
"license": "MIT",
|