@molecule/app-feature-image-canvas-svelte 0.0.0-stage → 1.1.0
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 +202 -0
- package/README.md +319 -2
- package/dist/ImageCanvas.svelte +220 -0
- package/dist/ImageCanvas.svelte.d.ts +5 -0
- package/dist/ImageCanvas.svelte.d.ts.map +1 -0
- package/dist/components.d.ts +8 -0
- package/dist/components.d.ts.map +1 -0
- package/dist/components.js +7 -0
- package/dist/helpers.d.ts +75 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +138 -0
- package/dist/image-source.d.ts +16 -0
- package/dist/image-source.d.ts.map +1 -0
- package/dist/image-source.js +21 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +55 -0
- package/dist/types.d.ts +129 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/package.json +75 -4
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the Svelte Canvas2D image-editing surface — the same types
|
|
3
|
+
* `@molecule/app-feature-image-canvas-react` exports.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* A two-dimensional offset, in CSS pixels, applied to the rendered image
|
|
9
|
+
* relative to the centre of the canvas. Positive `x` shifts the image
|
|
10
|
+
* right; positive `y` shifts it down.
|
|
11
|
+
*/
|
|
12
|
+
export interface PanOffset {
|
|
13
|
+
/** Horizontal offset, in CSS pixels. */
|
|
14
|
+
x: number;
|
|
15
|
+
/** Vertical offset, in CSS pixels. */
|
|
16
|
+
y: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Filter parameters applied to the source image before it is rendered to
|
|
20
|
+
* the canvas. Every field is optional — omitted fields disable that
|
|
21
|
+
* filter. Values are clamped at compose time so out-of-range numbers are
|
|
22
|
+
* safe.
|
|
23
|
+
*
|
|
24
|
+
* Implementation note: composition uses the Canvas2D `filter` property
|
|
25
|
+
* (CSS `<filter-function>` syntax). Compose order is preserved.
|
|
26
|
+
*/
|
|
27
|
+
export interface ImageCanvasFilters {
|
|
28
|
+
/**
|
|
29
|
+
* Brightness multiplier. `1` is identity, `0` is black, `2` is twice
|
|
30
|
+
* as bright. Values < 0 are clamped to 0.
|
|
31
|
+
*/
|
|
32
|
+
brightness?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Contrast multiplier. `1` is identity, `0` is fully grey, `2` is
|
|
35
|
+
* twice the contrast. Values < 0 are clamped to 0.
|
|
36
|
+
*/
|
|
37
|
+
contrast?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Saturation multiplier. `1` is identity, `0` is grayscale, `2` is
|
|
40
|
+
* twice as saturated. Values < 0 are clamped to 0.
|
|
41
|
+
*/
|
|
42
|
+
saturation?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Hue rotation in degrees. Normalised modulo 360 — any finite value
|
|
45
|
+
* is accepted.
|
|
46
|
+
*/
|
|
47
|
+
hue?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Sepia amount in `[0, 1]`. `0` disables; `1` applies fully. Values
|
|
50
|
+
* outside the range are clamped.
|
|
51
|
+
*/
|
|
52
|
+
sepia?: number;
|
|
53
|
+
/**
|
|
54
|
+
* Grayscale amount in `[0, 1]`. `0` disables; `1` applies fully.
|
|
55
|
+
* Values outside the range are clamped.
|
|
56
|
+
*/
|
|
57
|
+
grayscale?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Gaussian blur radius in CSS pixels. `0` disables. Negative values
|
|
60
|
+
* are clamped to 0.
|
|
61
|
+
*/
|
|
62
|
+
blur?: number;
|
|
63
|
+
/**
|
|
64
|
+
* Sharpen strength in `[0, 1]`. Approximated as a negative-blur
|
|
65
|
+
* contrast bump using the CSS `contrast()` filter; `0` disables.
|
|
66
|
+
* Values outside the range are clamped.
|
|
67
|
+
*/
|
|
68
|
+
sharpen?: number;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Imperative export handle exposed via `exportRef`. Callers use this to
|
|
72
|
+
* grab the current rendered image (with all filters, zoom, and pan
|
|
73
|
+
* baked in) as a data URL.
|
|
74
|
+
*/
|
|
75
|
+
export interface ImageCanvasExportHandle {
|
|
76
|
+
/**
|
|
77
|
+
* Snapshot the current canvas as a data URL.
|
|
78
|
+
*
|
|
79
|
+
* @param type - Image MIME type. Defaults to `image/png`.
|
|
80
|
+
* @param quality - Lossy quality in `[0, 1]` for `image/jpeg` /
|
|
81
|
+
* `image/webp`. Ignored for `image/png`.
|
|
82
|
+
* @returns A data URL string, or an empty string if the canvas is not
|
|
83
|
+
* yet mounted.
|
|
84
|
+
*/
|
|
85
|
+
toDataURL: (type?: string, quality?: number) => string;
|
|
86
|
+
}
|
|
87
|
+
/** ImageCanvas component props (React's prop names). */
|
|
88
|
+
export interface ImageCanvasProps {
|
|
89
|
+
/**
|
|
90
|
+
* Image source. Either a string (URL or data URL) — which the
|
|
91
|
+
* component loads into an internal `HTMLImageElement` — or an
|
|
92
|
+
* already-loaded `HTMLImageElement` the caller manages.
|
|
93
|
+
*/
|
|
94
|
+
src: string | HTMLImageElement;
|
|
95
|
+
/** Filter chain applied to the rendered image. */
|
|
96
|
+
filters?: ImageCanvasFilters;
|
|
97
|
+
/**
|
|
98
|
+
* Zoom factor. `1` is identity. Values <= 0 fall back to `1`.
|
|
99
|
+
* Defaults to `1`.
|
|
100
|
+
*/
|
|
101
|
+
zoom?: number;
|
|
102
|
+
/**
|
|
103
|
+
* Pan offset in CSS pixels relative to the centre of the canvas.
|
|
104
|
+
* Defaults to `{ x: 0, y: 0 }`.
|
|
105
|
+
*/
|
|
106
|
+
pan?: PanOffset;
|
|
107
|
+
/**
|
|
108
|
+
* Optional callback fired when the user pans or zooms the canvas.
|
|
109
|
+
* Use this for controlled-component patterns.
|
|
110
|
+
*/
|
|
111
|
+
onChange?: (next: {
|
|
112
|
+
zoom: number;
|
|
113
|
+
pan: PanOffset;
|
|
114
|
+
}) => void;
|
|
115
|
+
/**
|
|
116
|
+
* Imperative handle exposing `toDataURL()` for the caller to grab
|
|
117
|
+
* the rendered result.
|
|
118
|
+
*/
|
|
119
|
+
exportRef?: {
|
|
120
|
+
current: ImageCanvasExportHandle | null;
|
|
121
|
+
};
|
|
122
|
+
/** Pixel width of the canvas. Defaults to `512`. */
|
|
123
|
+
width?: number;
|
|
124
|
+
/** Pixel height of the canvas. Defaults to `512`. */
|
|
125
|
+
height?: number;
|
|
126
|
+
/** Extra classes merged onto the root element. */
|
|
127
|
+
className?: string;
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,wCAAwC;IACxC,CAAC,EAAE,MAAM,CAAA;IACT,sCAAsC;IACtC,CAAC,EAAE,MAAM,CAAA;CACV;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;;;;;OAQG;IACH,SAAS,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,MAAM,CAAA;CACvD;AAED,wDAAwD;AACxD,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAA;IAC9B,kDAAkD;IAClD,OAAO,CAAC,EAAE,kBAAkB,CAAA;IAC5B;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,GAAG,CAAC,EAAE,SAAS,CAAA;IACf;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,SAAS,CAAA;KAAE,KAAK,IAAI,CAAA;IAC3D;;;OAGG;IACH,SAAS,CAAC,EAAE;QAAE,OAAO,EAAE,uBAAuB,GAAG,IAAI,CAAA;KAAE,CAAA;IACvD,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB"}
|
package/dist/types.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,77 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-feature-image-canvas-svelte",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Canvas2D image-editing surface — accepts an image source, applies a filter chain (brightness, contrast, saturation, hue, sepia, grayscale, blur, sharpen), supports zoom + pan, exports back to data URL",
|
|
5
|
+
"homepage": "https://www.molecule.dev/packages/app-feature-image-canvas-svelte",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"svelte": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
17
|
+
"svelte": "./dist/index.js",
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"!dist/**/__tests__",
|
|
21
|
+
"!dist/**/*.test.*",
|
|
22
|
+
"!dist/**/*.spec.*",
|
|
23
|
+
"README.md"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "svelte-check --tsconfig ./tsconfig.json --fail-on-warnings && svelte-package --input src --output dist --tsconfig ./tsconfig.json",
|
|
27
|
+
"dev": "svelte-package --input src --output dist --tsconfig ./tsconfig.json --watch",
|
|
28
|
+
"test": "vitest run",
|
|
29
|
+
"test:watch": "vitest"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"molecule",
|
|
33
|
+
"image-canvas",
|
|
34
|
+
"image",
|
|
35
|
+
"canvas",
|
|
36
|
+
"filters",
|
|
37
|
+
"photo-editor",
|
|
38
|
+
"svelte"
|
|
39
|
+
],
|
|
40
|
+
"author": "Molecule Dev, Inc. (https://molecule.dev)",
|
|
41
|
+
"license": "Apache-2.0",
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "https://github.com/molecule-dev/molecule.git",
|
|
45
|
+
"directory": "packages/app/features/feature-image-canvas-svelte"
|
|
46
|
+
},
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=20"
|
|
49
|
+
},
|
|
50
|
+
"bugs": "https://github.com/molecule-dev/molecule/issues",
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"@molecule/app-svelte": "^3.5.0",
|
|
56
|
+
"@molecule/app-ui": "^1.0.1",
|
|
57
|
+
"@molecule/app-ui-svelte": "^1.1.0",
|
|
58
|
+
"svelte": "^5.0.0"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@molecule/app-framework-conformance": "0.0.0",
|
|
62
|
+
"@molecule/app-i18n": "1.2.2",
|
|
63
|
+
"@molecule/app-icons": "1.0.4",
|
|
64
|
+
"@molecule/app-svelte": "3.9.0",
|
|
65
|
+
"@molecule/app-ui": "1.5.0",
|
|
66
|
+
"@molecule/app-ui-svelte": "1.2.1",
|
|
67
|
+
"@sveltejs/package": "3.0.2",
|
|
68
|
+
"@sveltejs/vite-plugin-svelte": "7.1.2",
|
|
69
|
+
"@types/node": "26.6.5",
|
|
70
|
+
"jsdom": "30.1.3",
|
|
71
|
+
"svelte": "5.57.2",
|
|
72
|
+
"svelte-check": "4.7.7",
|
|
73
|
+
"typescript": "6.0.3",
|
|
74
|
+
"vite": "8.3.5",
|
|
75
|
+
"vitest": "4.1.12"
|
|
76
|
+
}
|
|
77
|
+
}
|