limbo-component 4.4.0 → 4.5.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/dist/limbo.cjs.js +1 -1
- package/dist/limbo.cjs.map +1 -1
- package/dist/limbo.css +1 -1
- package/dist/limbo.es.js +160 -146
- package/dist/limbo.es.map +1 -1
- package/dist/limbo.min.js +1 -1
- package/dist/limbo.min.js.map +1 -1
- package/dist/limbo.umd.js +1 -1
- package/dist/limbo.umd.js.map +1 -1
- package/dist/types/src/App.d.ts +2 -1
- package/dist/types/src/App.d.ts.map +1 -1
- package/dist/types/src/components/CropperTab.d.ts +2 -1
- package/dist/types/src/components/CropperTab.d.ts.map +1 -1
- package/dist/types/src/components/CropperView.d.ts +2 -1
- package/dist/types/src/components/CropperView.d.ts.map +1 -1
- package/dist/types/src/components/FilterPanel.d.ts +11 -0
- package/dist/types/src/components/FilterPanel.d.ts.map +1 -0
- package/dist/types/src/core/ConfigManager.d.ts +2 -0
- package/dist/types/src/core/ConfigManager.d.ts.map +1 -1
- package/dist/types/src/hooks/useImageFilters.d.ts +23 -0
- package/dist/types/src/hooks/useImageFilters.d.ts.map +1 -0
- package/dist/types/src/utils/i18n.d.ts +520 -0
- package/dist/types/src/utils/i18n.d.ts.map +1 -1
- package/dist/types/src/utils/imageFilters.d.ts +132 -0
- package/dist/types/src/utils/imageFilters.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a validated 6-digit hex color + alpha (0..1) to an `rgba()` CSS color string.
|
|
3
|
+
*
|
|
4
|
+
* @param {*} hex
|
|
5
|
+
* @param {number} alpha - 0..1
|
|
6
|
+
* @param {string} fallback - Fallback hex color if `hex` fails validation (T-10-02).
|
|
7
|
+
* @returns {string}
|
|
8
|
+
*/
|
|
9
|
+
export function hexToRgba(hex: any, alpha: number, fallback: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Return a fresh, independent deep clone of the canonical neutral filter state (IMGFLT-07).
|
|
12
|
+
*
|
|
13
|
+
* Never returns a shared reference — mutating the result never affects
|
|
14
|
+
* `NEUTRAL_FILTER_STATE` nor any other call's result.
|
|
15
|
+
*
|
|
16
|
+
* @returns {object} A new neutral filter state object (JSON-serializable).
|
|
17
|
+
*/
|
|
18
|
+
export function getNeutralFilterState(): object;
|
|
19
|
+
/**
|
|
20
|
+
* Build the shared CSS `<filter-function-list>` string consumed identically by
|
|
21
|
+
* `style.filter` (preview) and `ctx.filter` (Canvas bake) — D-08.
|
|
22
|
+
*
|
|
23
|
+
* Basic adjustments (brightness/contrast/saturate) are clamped to -100..100 and mapped
|
|
24
|
+
* to 0%..200% with neutral at 0 → 100% (D-11). Presets (IMGFLT-03) stack after the basics
|
|
25
|
+
* (D-07). Opacity is clamped to 0..100 and mapped directly (D-12). Non-numeric input
|
|
26
|
+
* degrades to neutral before interpolation (ASVS V5 / T-10-01).
|
|
27
|
+
*
|
|
28
|
+
* @param {object} filters - Filter state (see module interfaces contract).
|
|
29
|
+
* @returns {string} CSS filter string, e.g. "brightness(120%) contrast(100%) saturate(100%) sepia(100%) opacity(100%)".
|
|
30
|
+
*/
|
|
31
|
+
export function buildFilterString(filters: object): string;
|
|
32
|
+
/**
|
|
33
|
+
* Build the CSS `linear-gradient()` string used as a preview overlay (IMGFLT-04).
|
|
34
|
+
*
|
|
35
|
+
* Returns `null` when the gradient is disabled. Colors are validated as 6-digit hex
|
|
36
|
+
* before composing (T-10-02); the gradient opacity (0..100, D-12) is applied as alpha.
|
|
37
|
+
*
|
|
38
|
+
* NOTE: This is preview-only. `ctx.createLinearGradient()` (Phase 11 bake) does not
|
|
39
|
+
* accept an angle — use `gradientAngleToCanvasVector()` to convert.
|
|
40
|
+
*
|
|
41
|
+
* @param {object} gradient - { enabled, angle, colorStart, colorEnd, opacity }.
|
|
42
|
+
* @returns {string|null}
|
|
43
|
+
*/
|
|
44
|
+
export function buildGradientCss(gradient: object): string | null;
|
|
45
|
+
/**
|
|
46
|
+
* Convert a CSS gradient angle (0°=up, clockwise, D-16) to a Canvas gradient vector
|
|
47
|
+
* (x0,y0 → x1,y1) suitable for `ctx.createLinearGradient()` (IMGFLT-04, Pitfall 4).
|
|
48
|
+
*
|
|
49
|
+
* CSS and Canvas use incompatible angle/coordinate conventions — this is the single
|
|
50
|
+
* source of truth for that conversion so preview (CSS) and bake (Canvas, Phase 11)
|
|
51
|
+
* never diverge visually.
|
|
52
|
+
*
|
|
53
|
+
* @param {number} angleDeg - CSS gradient angle, 0..360.
|
|
54
|
+
* @param {number} width - Target canvas/image width in px.
|
|
55
|
+
* @param {number} height - Target canvas/image height in px.
|
|
56
|
+
* @returns {{x0: number, y0: number, x1: number, y1: number}}
|
|
57
|
+
*/
|
|
58
|
+
export function gradientAngleToCanvasVector(angleDeg: number, width: number, height: number): {
|
|
59
|
+
x0: number;
|
|
60
|
+
y0: number;
|
|
61
|
+
x1: number;
|
|
62
|
+
y1: number;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Return the total number of non-neutral filters currently active (D-03 badge counter).
|
|
66
|
+
*
|
|
67
|
+
* Each basic adjustment, the preset, the opacity and the gradient count as at most 1
|
|
68
|
+
* each (max 6).
|
|
69
|
+
*
|
|
70
|
+
* @param {object} filters
|
|
71
|
+
* @returns {number}
|
|
72
|
+
*/
|
|
73
|
+
export function countActiveFilters(filters: object): number;
|
|
74
|
+
/**
|
|
75
|
+
* Return whether any filter is currently non-neutral (D-03 badge visibility gate).
|
|
76
|
+
*
|
|
77
|
+
* @param {object} filters
|
|
78
|
+
* @returns {boolean}
|
|
79
|
+
*/
|
|
80
|
+
export function hasActiveFilters(filters: object): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Return human-readable labels (via the provided `t` i18n function) for every
|
|
83
|
+
* currently active filter — used to populate the badge tooltip (D-03, IMGFLT-12).
|
|
84
|
+
*
|
|
85
|
+
* @param {object} filters
|
|
86
|
+
* @param {(key: string) => string} t - i18n translation function.
|
|
87
|
+
* @returns {string[]}
|
|
88
|
+
*/
|
|
89
|
+
export function getActiveFilterLabels(filters: object, t: (key: string) => string): string[];
|
|
90
|
+
/**
|
|
91
|
+
* Apply the shared filter string to a Canvas 2D rendering context (Phase 11 bake).
|
|
92
|
+
*
|
|
93
|
+
* `ctx` is received by parameter — this does not introduce a DOM/global dependency
|
|
94
|
+
* into the module (IMGFLT-11 portability preserved).
|
|
95
|
+
*
|
|
96
|
+
* @param {CanvasRenderingContext2D} ctx
|
|
97
|
+
* @param {object} filters
|
|
98
|
+
* @returns {void}
|
|
99
|
+
*/
|
|
100
|
+
export function applyFiltersToCanvas(ctx: CanvasRenderingContext2D, filters: object): void;
|
|
101
|
+
/**
|
|
102
|
+
* Bake the full filter pipeline (basics/preset/opacity via ctx.filter + gradient overlay)
|
|
103
|
+
* onto a Canvas 2D context — single source of truth reused by generatePreview,
|
|
104
|
+
* processSingleCrop/downloadSingleCrop (con recorte) y handleKeepOriginal (sin recorte),
|
|
105
|
+
* garantizando la paridad WYSIWYG exigida por D-02/D-06 (Phase 11).
|
|
106
|
+
*
|
|
107
|
+
* @param {CanvasRenderingContext2D} ctx
|
|
108
|
+
* @param {CanvasImageSource} image - Fuente a dibujar (HTMLImageElement, HTMLCanvasElement, etc.)
|
|
109
|
+
* @param {{width: number, height: number}} size
|
|
110
|
+
* @param {object} filters
|
|
111
|
+
* @returns {void}
|
|
112
|
+
*/
|
|
113
|
+
export function bakeFiltersToCanvas(ctx: CanvasRenderingContext2D, image: CanvasImageSource, { width, height }: {
|
|
114
|
+
width: number;
|
|
115
|
+
height: number;
|
|
116
|
+
}, filters: object): void;
|
|
117
|
+
export namespace NEUTRAL_FILTER_STATE {
|
|
118
|
+
let brightness: number;
|
|
119
|
+
let contrast: number;
|
|
120
|
+
let saturate: number;
|
|
121
|
+
let preset: any;
|
|
122
|
+
let opacity: number;
|
|
123
|
+
namespace gradient {
|
|
124
|
+
export let enabled: boolean;
|
|
125
|
+
export let angle: number;
|
|
126
|
+
export let colorStart: string;
|
|
127
|
+
export let colorEnd: string;
|
|
128
|
+
let opacity_1: number;
|
|
129
|
+
export { opacity_1 as opacity };
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=imageFilters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imageFilters.d.ts","sourceRoot":"","sources":["../../../../src/utils/imageFilters.js"],"names":[],"mappings":"AA+EA;;;;;;;GAOG;AACH,+BALW,GAAC,SACD,MAAM,YACN,MAAM,GACJ,MAAM,CAQlB;AAYD;;;;;;;GAOG;AACH,yCAFa,MAAM,CAIlB;AAED;;;;;;;;;;;GAWG;AACH,2CAHW,MAAM,GACJ,MAAM,CA+BlB;AAED;;;;;;;;;;;GAWG;AACH,2CAHW,MAAM,GACJ,MAAM,GAAC,IAAI,CAavB;AAED;;;;;;;;;;;;GAYG;AACH,sDALW,MAAM,SACN,MAAM,UACN,MAAM,GACJ;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAC,CAY5D;AAED;;;;;;;;GAQG;AACH,4CAHW,MAAM,GACJ,MAAM,CAWlB;AAED;;;;;GAKG;AACH,0CAHW,MAAM,GACJ,OAAO,CAInB;AAED;;;;;;;GAOG;AACH,+CAJW,MAAM,KACN,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GACrB,MAAM,EAAE,CAWpB;AAED;;;;;;;;;GASG;AACH,0CAJW,wBAAwB,WACxB,MAAM,GACJ,IAAI,CAIhB;AAED;;;;;;;;;;;GAWG;AACH,yCANW,wBAAwB,SACxB,iBAAiB,qBACjB;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAC,WAC/B,MAAM,GACJ,IAAI,CAgBhB"}
|