@codingfactory/mediables-vue 2.11.0 → 2.13.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/{PixiFrameExporter-apC6SqIv.cjs → PixiFrameExporter-BnAievFi.cjs} +2 -2
- package/dist/{PixiFrameExporter-apC6SqIv.cjs.map → PixiFrameExporter-BnAievFi.cjs.map} +1 -1
- package/dist/{PixiFrameExporter-D9swI3PO.js → PixiFrameExporter-DwbBy1Iu.js} +2 -2
- package/dist/{PixiFrameExporter-D9swI3PO.js.map → PixiFrameExporter-DwbBy1Iu.js.map} +1 -1
- package/dist/components/ImageEditorModal.vue.d.ts +9 -2
- package/dist/composables/useImageEditorModal.d.ts +1262 -86
- package/dist/composables/useRadialMenu.d.ts +1 -1
- package/dist/editor-BoDU3YXD.js +10862 -0
- package/dist/editor-BoDU3YXD.js.map +1 -0
- package/dist/editor-D-cJRASf.cjs +2 -0
- package/dist/editor-D-cJRASf.cjs.map +1 -0
- package/dist/{index-BFYtEc-Y.js → index-BGC4rPDc.js} +16370 -14565
- package/dist/index-BGC4rPDc.js.map +1 -0
- package/dist/index-CljyFIEv.cjs +357 -0
- package/dist/index-CljyFIEv.cjs.map +1 -0
- package/dist/mediables-vanilla.cjs +1 -1
- package/dist/mediables-vanilla.mjs +1 -1
- package/dist/mediables-vue.cjs +1 -1
- package/dist/mediables-vue.mjs +2 -2
- package/dist/style.css +1 -1
- package/dist/types/editor.d.ts +212 -27
- package/dist/vanilla-editor/VanillaImageEditor.d.ts +18 -0
- package/dist/vanilla-editor/VanillaImageEditorV2.d.ts +16 -0
- package/dist/vanilla-editor/core/EventEmitter.d.ts +12 -0
- package/dist/vanilla-editor/core/State.d.ts +98 -0
- package/dist/vanilla-editor/filters/categories.d.ts +69 -0
- package/dist/vanilla-editor/icons/icons.d.ts +42 -0
- package/dist/vanilla-editor/index.d.ts +342 -0
- package/dist/vanilla-editor/presets/index.d.ts +114 -0
- package/dist/vanilla-editor/renderer/CropManager.d.ts +140 -0
- package/dist/vanilla-editor/renderer/FilterManager.d.ts +132 -0
- package/dist/vanilla-editor/renderer/PixiRenderer.d.ts +274 -0
- package/dist/vanilla-editor/renderer/RemoveBgManager.d.ts +108 -0
- package/dist/vanilla-editor/styles/editor-v2.css +1366 -0
- package/dist/vanilla-editor/styles/editor.css +1403 -0
- package/dist/vanilla-editor/ui/ActiveFiltersPanel.d.ts +93 -0
- package/dist/vanilla-editor/ui/CategoryCarousel.d.ts +66 -0
- package/dist/vanilla-editor/ui/CropControls.d.ts +65 -0
- package/dist/vanilla-editor/ui/FilterAdjustments.d.ts +93 -0
- package/dist/vanilla-editor/ui/FilterCarousel.d.ts +74 -0
- package/dist/vanilla-editor/ui/MobileActiveFilters.d.ts +21 -0
- package/dist/vanilla-editor/ui/MobileFilterDrawer.d.ts +79 -0
- package/dist/vanilla-editor/ui/Toolbar.d.ts +35 -0
- package/dist/vanilla-editor/ui/UIBuilder.d.ts +87 -0
- package/dist/vanilla-editor/ui-v2/ActiveFiltersStack.d.ts +16 -0
- package/dist/vanilla-editor/ui-v2/BackgroundPanel.d.ts +16 -0
- package/dist/vanilla-editor/ui-v2/BottomDrawer.d.ts +55 -0
- package/dist/vanilla-editor/ui-v2/CategoryTabs.d.ts +21 -0
- package/dist/vanilla-editor/ui-v2/FilterControlsView.d.ts +16 -0
- package/dist/vanilla-editor/ui-v2/FilterListView.d.ts +32 -0
- package/dist/vanilla-editor/ui-v2/LayerStackPanel.d.ts +30 -0
- package/dist/vanilla-editor/ui-v2/MobileActiveChips.d.ts +23 -0
- package/dist/vanilla-editor/ui-v2/MobileNavigation.d.ts +51 -0
- package/dist/vanilla-editor/ui-v2/SplitPanelLayout.d.ts +70 -0
- package/dist/vanilla-editor/ui-v2/TextPanel.d.ts +58 -0
- package/dist/vanilla-exports.d.ts +9 -0
- package/package.json +3 -2
- package/dist/editor-BTwIhrcA.cjs +0 -2
- package/dist/editor-BTwIhrcA.cjs.map +0 -1
- package/dist/editor-CYj5y5bp.js +0 -8893
- package/dist/editor-CYj5y5bp.js.map +0 -1
- package/dist/index-BFYtEc-Y.js.map +0 -1
- package/dist/index-CAPdRZVb.cjs +0 -357
- package/dist/index-CAPdRZVb.cjs.map +0 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
export class FilterManager extends EventEmitter {
|
|
2
|
+
constructor(state: any, pixiRenderer: any);
|
|
3
|
+
state: any;
|
|
4
|
+
renderer: any;
|
|
5
|
+
instances: {};
|
|
6
|
+
_filterRegistry: Object | null;
|
|
7
|
+
/**
|
|
8
|
+
* Set the filter registry (from mediables/filters)
|
|
9
|
+
* @param {Object} registry - { getFilter, getAllFilters, getFiltersByCategory }
|
|
10
|
+
*/
|
|
11
|
+
setRegistry(registry: Object): void;
|
|
12
|
+
/**
|
|
13
|
+
* Get filter definition by ID
|
|
14
|
+
* @param {string} filterId
|
|
15
|
+
* @returns {Object|null}
|
|
16
|
+
*/
|
|
17
|
+
getFilterDef(filterId: string): Object | null;
|
|
18
|
+
/**
|
|
19
|
+
* Get all filters
|
|
20
|
+
* @returns {Array}
|
|
21
|
+
*/
|
|
22
|
+
getAllFilters(): any[];
|
|
23
|
+
/**
|
|
24
|
+
* Get filters by category
|
|
25
|
+
* Maps UI category names to registry category names
|
|
26
|
+
* @param {string} category - UI category ID
|
|
27
|
+
* @returns {Array}
|
|
28
|
+
*/
|
|
29
|
+
getFiltersByCategory(category: string): any[];
|
|
30
|
+
/**
|
|
31
|
+
* Normalize UI values from various input types
|
|
32
|
+
* @param {*} value
|
|
33
|
+
* @returns {*}
|
|
34
|
+
*/
|
|
35
|
+
_normalizeValue(value: any): any;
|
|
36
|
+
/**
|
|
37
|
+
* Get a deep property from an object.
|
|
38
|
+
* Returns undefined if any segment along the path is missing.
|
|
39
|
+
* @param {Object} target
|
|
40
|
+
* @param {string} path
|
|
41
|
+
* @returns {*}
|
|
42
|
+
*/
|
|
43
|
+
_getDeepProp(target: Object, path: string): any;
|
|
44
|
+
/**
|
|
45
|
+
* Set a deep property on an object
|
|
46
|
+
* @param {Object} target
|
|
47
|
+
* @param {string} path
|
|
48
|
+
* @param {*} value
|
|
49
|
+
*/
|
|
50
|
+
_setDeepProp(target: Object, path: string, value: any): void;
|
|
51
|
+
/**
|
|
52
|
+
* Initialize filter values from definition defaults.
|
|
53
|
+
* Seeds BOTH defaultParams (e.g. colorStops) and control defaults so that
|
|
54
|
+
* filters with dynamic parameters not backed by a static control still have
|
|
55
|
+
* their state populated.
|
|
56
|
+
* @param {string} filterId
|
|
57
|
+
*/
|
|
58
|
+
initializeValues(filterId: string, expectedLayerId?: undefined): void;
|
|
59
|
+
/**
|
|
60
|
+
* Reset all filter values to their defaults (unconditionally).
|
|
61
|
+
* Resets BOTH defaultParams and control defaults.
|
|
62
|
+
* @param {string} filterId
|
|
63
|
+
*/
|
|
64
|
+
resetValues(filterId: string, expectedLayerId?: undefined): void;
|
|
65
|
+
/**
|
|
66
|
+
* Toggle a filter on/off
|
|
67
|
+
* @param {string} filterId
|
|
68
|
+
* @param {boolean} enabled
|
|
69
|
+
*/
|
|
70
|
+
toggle(filterId: string, enabled: boolean, expectedLayerId?: undefined): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Update a filter control value.
|
|
73
|
+
*
|
|
74
|
+
* The `controlId` may be either a static control id (from def.controls) or a
|
|
75
|
+
* dynamic path (e.g. 'colorStops[0].color') produced by a filter's
|
|
76
|
+
* getDynamicControls(). Static control ids are stored in state keyed by the
|
|
77
|
+
* control id. Dynamic paths are NOT stored as flat path keys — instead, we
|
|
78
|
+
* apply them to the live instance and then sync the filter's serializable
|
|
79
|
+
* params back into state, so recreation via applyFilters() rebuilds from
|
|
80
|
+
* the canonical shape (e.g. a colorStops array, not 'colorStops[0].color').
|
|
81
|
+
*
|
|
82
|
+
* Returns true when the filter was updated in-place. Returns false when the
|
|
83
|
+
* caller should invoke applyFilters() to recreate the filter from state —
|
|
84
|
+
* this happens when the property target is a method (which would be
|
|
85
|
+
* silently corrupted by a direct write) or when the property doesn't exist.
|
|
86
|
+
*
|
|
87
|
+
* @param {string} filterId
|
|
88
|
+
* @param {string} controlId - Static control id or dynamic property path
|
|
89
|
+
* @param {*} value
|
|
90
|
+
* @returns {boolean} True if updated in-place, false if caller must recreate
|
|
91
|
+
*/
|
|
92
|
+
updateValue(filterId: string, controlId: string, value: any, expectedLayerId?: undefined): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Perform a filter action (e.g. addColorStop, removeColorStop) and sync
|
|
95
|
+
* any resulting state changes back into State.js before recreating the
|
|
96
|
+
* filter. Without this sync, recreation via applyFilters() would rebuild
|
|
97
|
+
* from stale state and undo the action.
|
|
98
|
+
*
|
|
99
|
+
* @param {string} filterId
|
|
100
|
+
* @param {string} action - Action name understood by filter.updateUIParam
|
|
101
|
+
*/
|
|
102
|
+
performFilterAction(filterId: string, action: string, expectedLayerId?: undefined): boolean;
|
|
103
|
+
_matchesExpectedFilterLayer(expectedLayerId: any): boolean;
|
|
104
|
+
_layerDocument(): any;
|
|
105
|
+
_sourceDimensionsForLayer(layer: any, context?: {}): {
|
|
106
|
+
width: number;
|
|
107
|
+
height: number;
|
|
108
|
+
};
|
|
109
|
+
_paramsForFilterState(def: any, filterState: any, dimensions: any): any;
|
|
110
|
+
createFiltersForLayer(layer: any, context?: {}): any[];
|
|
111
|
+
/**
|
|
112
|
+
* Apply all active filters to the sprite
|
|
113
|
+
*
|
|
114
|
+
* This method recreates all filter instances on each call to ensure
|
|
115
|
+
* PIXI v8's filter pipeline correctly processes changes.
|
|
116
|
+
*/
|
|
117
|
+
applyFilters(): void;
|
|
118
|
+
/**
|
|
119
|
+
* Reset all filters.
|
|
120
|
+
* IMPORTANT: Only clears filter instances and sprite.filters.
|
|
121
|
+
* Does NOT touch baseTexture/originalTexture/sprite — that would
|
|
122
|
+
* destroy any applied crop, which is a separate concern.
|
|
123
|
+
*/
|
|
124
|
+
resetAll(expectedLayerId?: undefined): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Get a filter instance
|
|
127
|
+
* @param {string} filterId
|
|
128
|
+
* @returns {Object|null}
|
|
129
|
+
*/
|
|
130
|
+
getInstance(filterId: string): Object | null;
|
|
131
|
+
}
|
|
132
|
+
import { EventEmitter } from '../core/EventEmitter.js';
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
export class PixiRenderer extends EventEmitter {
|
|
2
|
+
app: any;
|
|
3
|
+
sprite: any;
|
|
4
|
+
originalTexture: any;
|
|
5
|
+
baseTexture: any;
|
|
6
|
+
fitScale: number;
|
|
7
|
+
zoom: number;
|
|
8
|
+
_container: HTMLElement | null;
|
|
9
|
+
_lastExportDimensions: {
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
} | null;
|
|
13
|
+
/** @type {Promise<boolean>|null} Resolves when mount() finishes */
|
|
14
|
+
_mountPromise: Promise<boolean> | null;
|
|
15
|
+
_mountToken: number;
|
|
16
|
+
_destroyed: boolean;
|
|
17
|
+
_layerDocument: any;
|
|
18
|
+
_layerDisplayObjects: Map<any, any>;
|
|
19
|
+
_renderableLayerIds: any[];
|
|
20
|
+
_loadedTextureUrl: string | null;
|
|
21
|
+
_layerRenderToken: number;
|
|
22
|
+
_layerFilterFactory: any;
|
|
23
|
+
/**
|
|
24
|
+
* Whether the renderer is fully initialized and ready for use.
|
|
25
|
+
* @returns {boolean}
|
|
26
|
+
*/
|
|
27
|
+
get isReady(): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Get CSS size of the canvas (for proper coordinate mapping).
|
|
30
|
+
* Accesses renderer.canvas directly to avoid PIXI Application's
|
|
31
|
+
* canvas getter which throws when renderer is undefined.
|
|
32
|
+
*/
|
|
33
|
+
_getCssSize(): {
|
|
34
|
+
w: any;
|
|
35
|
+
h: any;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Force render the stage
|
|
39
|
+
*/
|
|
40
|
+
render(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Wait for the next animation frame, with a timeout fallback for environments
|
|
43
|
+
* where the frame callback never arrives while the editor is open.
|
|
44
|
+
* @param {number} timeoutMs
|
|
45
|
+
* @returns {Promise<void>}
|
|
46
|
+
*/
|
|
47
|
+
_waitForNextFrame(timeoutMs?: number): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Calculate fit scale for a texture
|
|
50
|
+
* @param {PIXI.Texture} tex
|
|
51
|
+
* @returns {number}
|
|
52
|
+
*/
|
|
53
|
+
getFitScaleFor(tex: PIXI.Texture): number;
|
|
54
|
+
/**
|
|
55
|
+
* Apply view transform (position and scale) to sprite
|
|
56
|
+
*/
|
|
57
|
+
applyViewTransform(opts?: {}): void;
|
|
58
|
+
/**
|
|
59
|
+
* Set zoom level
|
|
60
|
+
* @param {number} z - Zoom level (0.1 to 8)
|
|
61
|
+
* @param {Object} opts - Options
|
|
62
|
+
*/
|
|
63
|
+
setZoom(z: number, opts?: Object): void;
|
|
64
|
+
/**
|
|
65
|
+
* Fit image to screen
|
|
66
|
+
*/
|
|
67
|
+
fitToScreen(): void;
|
|
68
|
+
/**
|
|
69
|
+
* Mount PIXI application to container
|
|
70
|
+
* @param {HTMLElement} container
|
|
71
|
+
* @param {number} backgroundColor
|
|
72
|
+
* @param {Object} [options]
|
|
73
|
+
* @param {number} [options.backgroundAlpha=1] - 0 makes the canvas transparent
|
|
74
|
+
* so a host-rendered background (e.g. CSS checkerboard) shows through.
|
|
75
|
+
*/
|
|
76
|
+
mount(container: HTMLElement, backgroundColor?: number, options?: {
|
|
77
|
+
backgroundAlpha?: number | undefined;
|
|
78
|
+
}): Promise<boolean | undefined>;
|
|
79
|
+
/**
|
|
80
|
+
* Load an image texture
|
|
81
|
+
* @param {string} imageUrl - URL, data URL, or blob URL of the image
|
|
82
|
+
* @param {Object} [options]
|
|
83
|
+
* @param {() => boolean} [options.isCurrent] - Returns false when this load
|
|
84
|
+
* has been superseded and must not mutate the renderer.
|
|
85
|
+
*/
|
|
86
|
+
loadTexture(imageUrl: string, options?: {
|
|
87
|
+
isCurrent?: (() => boolean) | undefined;
|
|
88
|
+
}): Promise<boolean>;
|
|
89
|
+
/**
|
|
90
|
+
* Render a v2 layer document in preview order. The existing subject sprite
|
|
91
|
+
* remains the filter/crop target; auxiliary layers are synced to its preview
|
|
92
|
+
* geometry until arbitrary per-layer transforms are introduced.
|
|
93
|
+
* @param {Object|null} document
|
|
94
|
+
* @returns {Promise<boolean>}
|
|
95
|
+
*/
|
|
96
|
+
renderLayerDocument(document: Object | null): Promise<boolean>;
|
|
97
|
+
getRenderableLayerIds(): any[];
|
|
98
|
+
setLayerFilterFactory(factory: any): void;
|
|
99
|
+
applyLayerFilters(document?: any): boolean;
|
|
100
|
+
_isSubjectLayer(layer: any): boolean;
|
|
101
|
+
_layerSupportsImageFilters(layer: any): boolean;
|
|
102
|
+
_layerOpacity(layer: any): number;
|
|
103
|
+
_applyLayerFilterInstances(displayObject: any, layer: any, context?: {}): void;
|
|
104
|
+
_createDisplayObjectForLayer(PIXI: any, layer: any): Promise<any>;
|
|
105
|
+
_isTextLayer(layer: any): boolean;
|
|
106
|
+
_normalizeTextBox(layer: any): {
|
|
107
|
+
x: any;
|
|
108
|
+
y: any;
|
|
109
|
+
width: any;
|
|
110
|
+
height: any;
|
|
111
|
+
};
|
|
112
|
+
_clampNumber(value: any, min: any, max: any, fallback: any): any;
|
|
113
|
+
_supportedTextFontFamily(value: any): string;
|
|
114
|
+
_supportedTextColor(value: any, fallback?: string): string;
|
|
115
|
+
_textBlendMode(layer: any): any;
|
|
116
|
+
_textContentForLayer(layer: any): string;
|
|
117
|
+
_textStyleForLayer(layer: any, scale?: number, wordWrapWidth?: number, options?: {}): {
|
|
118
|
+
fontFamily: string;
|
|
119
|
+
fontSize: number;
|
|
120
|
+
fontWeight: number;
|
|
121
|
+
fontStyle: any;
|
|
122
|
+
fill: any;
|
|
123
|
+
align: any;
|
|
124
|
+
lineHeight: number;
|
|
125
|
+
letterSpacing: number;
|
|
126
|
+
wordWrap: boolean;
|
|
127
|
+
wordWrapWidth: number;
|
|
128
|
+
breakWords: boolean;
|
|
129
|
+
};
|
|
130
|
+
_normalizeTextFontWeight(value: any): number;
|
|
131
|
+
_textEffectsForLayer(layer: any): {
|
|
132
|
+
stroke: {
|
|
133
|
+
enabled: boolean;
|
|
134
|
+
color: string;
|
|
135
|
+
width: any;
|
|
136
|
+
};
|
|
137
|
+
shadow: {
|
|
138
|
+
enabled: boolean;
|
|
139
|
+
color: string;
|
|
140
|
+
alpha: any;
|
|
141
|
+
blur: any;
|
|
142
|
+
distance: any;
|
|
143
|
+
angle: number;
|
|
144
|
+
};
|
|
145
|
+
glow: {
|
|
146
|
+
enabled: boolean;
|
|
147
|
+
color: string;
|
|
148
|
+
alpha: any;
|
|
149
|
+
blur: any;
|
|
150
|
+
};
|
|
151
|
+
backdrop: {
|
|
152
|
+
enabled: boolean;
|
|
153
|
+
color: string;
|
|
154
|
+
opacity: any;
|
|
155
|
+
padding: any;
|
|
156
|
+
radius: any;
|
|
157
|
+
blur: any;
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
_createTextBlurFilter(PIXI: any, amount: any): any;
|
|
161
|
+
_textEffectPadding(effects: any, scale: any): number;
|
|
162
|
+
_createTextDisplayObjectForLayer(PIXI: any, layer: any): any;
|
|
163
|
+
_createTextPrimitive(PIXI: any, layer: any): any;
|
|
164
|
+
_createSubjectDisplayObjectForLayer(PIXI: any, layer: any): Promise<any>;
|
|
165
|
+
_createImageDisplayObjectForLayer(PIXI: any, layer: any): Promise<any>;
|
|
166
|
+
_backgroundFillForLayer(layer: any): any;
|
|
167
|
+
_backgroundColorForLayer(layer: any): any;
|
|
168
|
+
_sourceUrlForLayerSource(source: any): string | null;
|
|
169
|
+
_textureForLayerSource(PIXI: any, source: any): Promise<any>;
|
|
170
|
+
_createBackgroundSprite(PIXI: any, texture: any, fit?: string): any;
|
|
171
|
+
_createGradientTexture(PIXI: any, fill: any, width: any, height: any): any;
|
|
172
|
+
_backgroundBlurAmount(layer: any): number;
|
|
173
|
+
_applyLayerEffects(PIXI: any, displayObject: any, layer: any): void;
|
|
174
|
+
_syncLayerDisplayObjects(): void;
|
|
175
|
+
_syncLayerDisplayObject(layer: any, displayObject: any): void;
|
|
176
|
+
_fillTextEffectGraphics(graphics: any, color: any, alpha?: number): void;
|
|
177
|
+
_syncTextEffectPrimitive(PIXI: any, primitive: any, layer: any, effects: any, kind: any, scale: any, width: any, effectMask: any): void;
|
|
178
|
+
_syncTextBackdrop(PIXI: any, backdrop: any, effects: any, scale: any, width: any, height: any, effectMask: any): void;
|
|
179
|
+
_fitTextDisplayObjectToRect(displayObject: any, layer: any, rect: any): void;
|
|
180
|
+
_fitDisplayObjectToRect(displayObject: any, layer: any, rect: any): void;
|
|
181
|
+
_destroyLayerDisplayObjects(): void;
|
|
182
|
+
_destroyTransientDisplayObject(displayObject: any): void;
|
|
183
|
+
/**
|
|
184
|
+
* Normalize degrees to the 0..360 range.
|
|
185
|
+
* @param {number} degrees
|
|
186
|
+
* @returns {number}
|
|
187
|
+
*/
|
|
188
|
+
_normalizeDegrees(degrees: number): number;
|
|
189
|
+
/**
|
|
190
|
+
* Calculate the axis-aligned bounds for a rotated rectangle.
|
|
191
|
+
* @param {number} width
|
|
192
|
+
* @param {number} height
|
|
193
|
+
* @param {number} degrees
|
|
194
|
+
* @returns {{ width: number, height: number }}
|
|
195
|
+
*/
|
|
196
|
+
getRotatedBounds(width: number, height: number, degrees: number): {
|
|
197
|
+
width: number;
|
|
198
|
+
height: number;
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* Permanently rotate the working texture. This keeps crop math simple:
|
|
202
|
+
* after rotation, sprite coordinates and texture dimensions both describe
|
|
203
|
+
* the visible image exactly.
|
|
204
|
+
*
|
|
205
|
+
* @param {number} degrees Clockwise degrees to add to the working texture.
|
|
206
|
+
* @returns {boolean}
|
|
207
|
+
*/
|
|
208
|
+
rotateBy(degrees: number): boolean;
|
|
209
|
+
/**
|
|
210
|
+
* Export the current image with filters applied.
|
|
211
|
+
*
|
|
212
|
+
* @param {string} format - 'png' or 'jpeg'
|
|
213
|
+
* @param {number} quality - Quality for jpeg (0-1)
|
|
214
|
+
* @param {number} maxEdge - Maximum edge size in pixels (0 for original)
|
|
215
|
+
* @param {boolean} dontUpscale - Don't upscale smaller images
|
|
216
|
+
* @param {number} [maxPixels=0] - Max total pixel count (width*height). 0 disables.
|
|
217
|
+
* Backend API often limits payload size (blowglass caps at 8M pixels); set this
|
|
218
|
+
* to keep the export under that cap while preserving aspect ratio.
|
|
219
|
+
* @returns {string|null} Data URL
|
|
220
|
+
*/
|
|
221
|
+
exportImage(format?: string, quality?: number, maxEdge?: number, dontUpscale?: boolean, maxPixels?: number): string | null;
|
|
222
|
+
/**
|
|
223
|
+
* Get the actual export dimensions at the current filter state.
|
|
224
|
+
*
|
|
225
|
+
* When an export has been performed, returns the exact trimmed dimensions
|
|
226
|
+
* from that export. Otherwise falls back to source texture size plus a
|
|
227
|
+
* rough filter-padding estimate — the real dimensions are only known for
|
|
228
|
+
* certain after exportImage() runs the bbox scan.
|
|
229
|
+
*
|
|
230
|
+
* @returns {{ width: number, height: number }}
|
|
231
|
+
*/
|
|
232
|
+
getExportDimensions(): {
|
|
233
|
+
width: number;
|
|
234
|
+
height: number;
|
|
235
|
+
};
|
|
236
|
+
/**
|
|
237
|
+
* Export the current image as a Blob with correct dimensions.
|
|
238
|
+
* @param {string} format - 'png' or 'jpeg'
|
|
239
|
+
* @param {number} quality - Quality for jpeg (0-1)
|
|
240
|
+
* @param {{ maxPixels?: number, maxEdge?: number, dontUpscale?: boolean }} [options]
|
|
241
|
+
* @returns {Promise<{ blob: Blob, width: number, height: number } | null>}
|
|
242
|
+
*/
|
|
243
|
+
exportBlob(format?: string, quality?: number, options?: {
|
|
244
|
+
maxPixels?: number;
|
|
245
|
+
maxEdge?: number;
|
|
246
|
+
dontUpscale?: boolean;
|
|
247
|
+
}): Promise<{
|
|
248
|
+
blob: Blob;
|
|
249
|
+
width: number;
|
|
250
|
+
height: number;
|
|
251
|
+
} | null>;
|
|
252
|
+
/**
|
|
253
|
+
* Resize renderer to container
|
|
254
|
+
* @param {HTMLElement} container
|
|
255
|
+
*/
|
|
256
|
+
resizeTo(container: HTMLElement): void;
|
|
257
|
+
/**
|
|
258
|
+
* Set background color
|
|
259
|
+
* @param {number} color - Hex color
|
|
260
|
+
*/
|
|
261
|
+
setBackgroundColor(color: number): void;
|
|
262
|
+
/**
|
|
263
|
+
* Load an image URL into an HTMLImageElement.
|
|
264
|
+
* Handles blob:, data:, and http(s): URLs.
|
|
265
|
+
* @param {string} url
|
|
266
|
+
* @returns {Promise<HTMLImageElement|null>}
|
|
267
|
+
*/
|
|
268
|
+
_loadImageElement(url: string): Promise<HTMLImageElement | null>;
|
|
269
|
+
/**
|
|
270
|
+
* Clean up and destroy
|
|
271
|
+
*/
|
|
272
|
+
destroy(): void;
|
|
273
|
+
}
|
|
274
|
+
import { EventEmitter } from '../core/EventEmitter.js';
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Background Removal Manager for the vanilla image editor
|
|
3
|
+
* Handles communication with the background removal service
|
|
4
|
+
*/
|
|
5
|
+
export class RemoveBgManager {
|
|
6
|
+
/**
|
|
7
|
+
* Create a new RemoveBgManager
|
|
8
|
+
* @param {Object} options
|
|
9
|
+
* @param {string} [options.endpoint] - API endpoint for uploaded preview background removal
|
|
10
|
+
* @param {string} [options.optionsEndpoint] - API endpoint for background-removal capability/options
|
|
11
|
+
* @param {string} [options.savedEndpoint] - API endpoint template for saved-media removal
|
|
12
|
+
* @param {string} [options.fallbackEndpoint] - Fallback endpoint if primary fails
|
|
13
|
+
*/
|
|
14
|
+
constructor(options?: {
|
|
15
|
+
endpoint?: string | undefined;
|
|
16
|
+
optionsEndpoint?: string | undefined;
|
|
17
|
+
savedEndpoint?: string | undefined;
|
|
18
|
+
fallbackEndpoint?: string | undefined;
|
|
19
|
+
});
|
|
20
|
+
_endpoint: string;
|
|
21
|
+
_optionsEndpoint: string;
|
|
22
|
+
_savedEndpoint: string;
|
|
23
|
+
_fallbackEndpoint: string | null;
|
|
24
|
+
_activeControllers: Set<any>;
|
|
25
|
+
_createAbortController(): AbortController | null;
|
|
26
|
+
_releaseAbortController(controller: any): void;
|
|
27
|
+
cancelActiveRequests(reason?: string): number;
|
|
28
|
+
/**
|
|
29
|
+
* Build a stable preview request so callers can stale-guard the response.
|
|
30
|
+
* @param {string|Blob} imageData
|
|
31
|
+
* @param {Object} options
|
|
32
|
+
* @returns {Promise<Object>}
|
|
33
|
+
*/
|
|
34
|
+
preparePreviewRequest(imageData: string | Blob, options?: Object): Promise<Object>;
|
|
35
|
+
/**
|
|
36
|
+
* @param {string|Blob} imageData
|
|
37
|
+
* @returns {Promise<string>}
|
|
38
|
+
*/
|
|
39
|
+
computeImageDataHash(imageData: string | Blob): Promise<string>;
|
|
40
|
+
/**
|
|
41
|
+
* Remove background from an image
|
|
42
|
+
* @param {string} imageData - Data URL or Blob of the image
|
|
43
|
+
* @param {Object} options
|
|
44
|
+
* @param {string} [options.tier='balanced'] - Quality tier: 'fast', 'balanced', 'best'
|
|
45
|
+
* @param {string} [options.model] - Explicit model name (overrides tier)
|
|
46
|
+
* @param {boolean} [options.alpha_matting=false] - Enable alpha matting for edge refinement
|
|
47
|
+
* @param {number} [options.alpha_f=10] - Alpha matting foreground threshold
|
|
48
|
+
* @param {number} [options.alpha_fr=15] - Alpha matting foreground radius
|
|
49
|
+
* @param {number} [options.alpha_erode_size=10] - Alpha matting erode size
|
|
50
|
+
* @returns {Promise<{dataUrl: string, model: string, processMs: string}>}
|
|
51
|
+
*/
|
|
52
|
+
removeBackground(imageData: string, options?: {
|
|
53
|
+
tier?: string | undefined;
|
|
54
|
+
model?: string | undefined;
|
|
55
|
+
alpha_matting?: boolean | undefined;
|
|
56
|
+
alpha_f?: number | undefined;
|
|
57
|
+
alpha_fr?: number | undefined;
|
|
58
|
+
alpha_erode_size?: number | undefined;
|
|
59
|
+
}): Promise<{
|
|
60
|
+
dataUrl: string;
|
|
61
|
+
model: string;
|
|
62
|
+
processMs: string;
|
|
63
|
+
}>;
|
|
64
|
+
/**
|
|
65
|
+
* Remove the background from a persisted editor-document layer.
|
|
66
|
+
* @param {Object} options
|
|
67
|
+
* @param {string} options.targetMediaUuid
|
|
68
|
+
* @param {string} options.operationId
|
|
69
|
+
* @param {string} options.documentId
|
|
70
|
+
* @param {string} options.documentRevisionId
|
|
71
|
+
* @param {string} options.targetLayerId
|
|
72
|
+
* @param {string} options.expectedSourceHash
|
|
73
|
+
* @param {string} [options.tier]
|
|
74
|
+
* @returns {Promise<Object>}
|
|
75
|
+
*/
|
|
76
|
+
removeSavedMediaBackground(options: {
|
|
77
|
+
targetMediaUuid: string;
|
|
78
|
+
operationId: string;
|
|
79
|
+
documentId: string;
|
|
80
|
+
documentRevisionId: string;
|
|
81
|
+
targetLayerId: string;
|
|
82
|
+
expectedSourceHash: string;
|
|
83
|
+
tier?: string | undefined;
|
|
84
|
+
}): Promise<Object>;
|
|
85
|
+
/**
|
|
86
|
+
* Convert a data URL to a Blob
|
|
87
|
+
* @param {string} dataUrl
|
|
88
|
+
* @returns {Promise<Blob>}
|
|
89
|
+
*/
|
|
90
|
+
_dataUrlToBlob(dataUrl: string): Promise<Blob>;
|
|
91
|
+
/**
|
|
92
|
+
* Convert a Blob to a data URL
|
|
93
|
+
* @param {Blob} blob
|
|
94
|
+
* @returns {Promise<string>}
|
|
95
|
+
*/
|
|
96
|
+
_blobToDataUrl(blob: Blob): Promise<string>;
|
|
97
|
+
/**
|
|
98
|
+
* Check if the background removal service is available
|
|
99
|
+
* @returns {Promise<boolean>}
|
|
100
|
+
*/
|
|
101
|
+
isAvailable(): Promise<boolean>;
|
|
102
|
+
/**
|
|
103
|
+
* @returns {Promise<Object>}
|
|
104
|
+
*/
|
|
105
|
+
getOptions(): Promise<Object>;
|
|
106
|
+
_uuid(): string;
|
|
107
|
+
_sha256Hex(blob: any): Promise<string>;
|
|
108
|
+
}
|