@molecule/app-feature-image-canvas-angular 0.0.0-stage → 0.0.1-stage
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 +10 -2
- package/dist/helpers.d.ts +75 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +139 -0
- package/dist/helpers.js.map +1 -0
- package/dist/image-canvas.component.d.ts +130 -0
- package/dist/image-canvas.component.d.ts.map +1 -0
- package/dist/image-canvas.component.js +375 -0
- package/dist/image-canvas.component.js.map +1 -0
- package/dist/image-source.d.ts +16 -0
- package/dist/image-source.d.ts.map +1 -0
- package/dist/image-source.js +22 -0
- package/dist/image-source.js.map +1 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +65 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +129 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/package.json +73 -4
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ImageCanvas component (React parity).
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { Component, computed, signal, ViewChild, } from '@angular/core';
|
|
7
|
+
import { useTranslation } from '@molecule/app-angular';
|
|
8
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
9
|
+
import { clamp, clampPan, composeFilterString } from './helpers.js';
|
|
10
|
+
import { isImageElement } from './image-source.js';
|
|
11
|
+
import * as i0 from "@angular/core";
|
|
12
|
+
const _c0 = ["surface"];
|
|
13
|
+
function ImageCanvas_Conditional_2_Template(rf, ctx) { if (rf & 1) {
|
|
14
|
+
i0.ɵɵdomElementStart(0, "p", 4);
|
|
15
|
+
i0.ɵɵtext(1);
|
|
16
|
+
i0.ɵɵdomElementEnd();
|
|
17
|
+
} if (rf & 2) {
|
|
18
|
+
const ctx_r0 = i0.ɵɵnextContext();
|
|
19
|
+
i0.ɵɵclassMap(ctx_r0.noteClasses());
|
|
20
|
+
i0.ɵɵadvance();
|
|
21
|
+
i0.ɵɵtextInterpolate(ctx_r0.loadingLabel());
|
|
22
|
+
} }
|
|
23
|
+
function ImageCanvas_Conditional_3_Template(rf, ctx) { if (rf & 1) {
|
|
24
|
+
i0.ɵɵdomElementStart(0, "p", 5);
|
|
25
|
+
i0.ɵɵtext(1);
|
|
26
|
+
i0.ɵɵdomElementEnd();
|
|
27
|
+
} if (rf & 2) {
|
|
28
|
+
const ctx_r0 = i0.ɵɵnextContext();
|
|
29
|
+
i0.ɵɵclassMap(ctx_r0.noteClasses());
|
|
30
|
+
i0.ɵɵadvance();
|
|
31
|
+
i0.ɵɵtextInterpolate1(" ", ctx_r0.errorLabel(), " ");
|
|
32
|
+
} }
|
|
33
|
+
/**
|
|
34
|
+
* Canvas2D image-editing surface: a source image drawn onto a canvas with a
|
|
35
|
+
* filter chain, pointer-drag panning, wheel zooming, and a `toDataURL()`
|
|
36
|
+
* export handle.
|
|
37
|
+
*
|
|
38
|
+
* The host IS React's root element (`div[mol-image-canvas]`), so the host
|
|
39
|
+
* carries the region role, the aria label, the ClassMap classes and the frame
|
|
40
|
+
* size exactly as React renders them. All user-visible text is translated
|
|
41
|
+
* through the binding's `useTranslation()`.
|
|
42
|
+
*/
|
|
43
|
+
export class ImageCanvas {
|
|
44
|
+
/** Image source: a URL/data-URL string, or an already-loaded `HTMLImageElement`. */
|
|
45
|
+
src;
|
|
46
|
+
/** Filter chain applied to the rendered image. */
|
|
47
|
+
filters;
|
|
48
|
+
/** Zoom factor; values <= 0 fall back to `1`. */
|
|
49
|
+
zoom;
|
|
50
|
+
/** Pan offset in CSS pixels relative to the centre of the canvas. */
|
|
51
|
+
pan;
|
|
52
|
+
/** Fired when the user pans or zooms the canvas. */
|
|
53
|
+
onChange;
|
|
54
|
+
/** Receives the `toDataURL()` handle while the canvas is mounted. */
|
|
55
|
+
exportRef;
|
|
56
|
+
/** Pixel width of the canvas (defaults to `512`). */
|
|
57
|
+
width;
|
|
58
|
+
/** Pixel height of the canvas (defaults to `512`). */
|
|
59
|
+
height;
|
|
60
|
+
/** Extra classes merged onto the root element. */
|
|
61
|
+
className;
|
|
62
|
+
/** The canvas surface, referenced for painting and the export handle. */
|
|
63
|
+
surface;
|
|
64
|
+
/** Reactive translation, read in the injection context. */
|
|
65
|
+
i18n = useTranslation();
|
|
66
|
+
/** The translation function for templates and host bindings. */
|
|
67
|
+
t = this.i18n.t;
|
|
68
|
+
/** The bonded ClassMap (styling tokens resolve at render time). */
|
|
69
|
+
classMap = getClassMap();
|
|
70
|
+
image = signal(null, /* @ts-ignore */
|
|
71
|
+
...(ngDevMode ? [{ debugName: "image" }] : /* istanbul ignore next */ []));
|
|
72
|
+
loadError = signal(null, /* @ts-ignore */
|
|
73
|
+
...(ngDevMode ? [{ debugName: "loadError" }] : /* istanbul ignore next */ []));
|
|
74
|
+
loadToken = 0;
|
|
75
|
+
viewReady = false;
|
|
76
|
+
dragState = { pointerId: null, startX: 0, startY: 0, startPan: { x: 0, y: 0 } };
|
|
77
|
+
/** The region's translated aria label. */
|
|
78
|
+
ariaLabel = computed(() => this.t('imageCanvas.aria.region', {}, { defaultValue: 'Image canvas' }), /* @ts-ignore */
|
|
79
|
+
...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
|
|
80
|
+
/** The canvas's translated aria label. */
|
|
81
|
+
dragLabel = computed(() => this.t('imageCanvas.aria.canvas', {}, { defaultValue: 'Drag to pan, scroll to zoom' }), /* @ts-ignore */
|
|
82
|
+
...(ngDevMode ? [{ debugName: "dragLabel" }] : /* istanbul ignore next */ []));
|
|
83
|
+
/** The translated loading message. */
|
|
84
|
+
loadingLabel = computed(() => this.t('imageCanvas.loading', {}, { defaultValue: 'Loading image…' }), /* @ts-ignore */
|
|
85
|
+
...(ngDevMode ? [{ debugName: "loadingLabel" }] : /* istanbul ignore next */ []));
|
|
86
|
+
/** The translated error message. */
|
|
87
|
+
errorLabel = computed(() => this.t('imageCanvas.error', {}, { defaultValue: 'Image failed to load.' }), /* @ts-ignore */
|
|
88
|
+
...(ngDevMode ? [{ debugName: "errorLabel" }] : /* istanbul ignore next */ []));
|
|
89
|
+
/** `data-loading`: `'true'` until an image arrives (React's expression, flattened). */
|
|
90
|
+
loadingAttr = computed(() => this.image() ? 'false' : this.loadError() ? 'false' : 'true', /* @ts-ignore */
|
|
91
|
+
...(ngDevMode ? [{ debugName: "loadingAttr" }] : /* istanbul ignore next */ []));
|
|
92
|
+
/** `data-error`: `'true'` after a failed load. */
|
|
93
|
+
errorAttr = computed(() => (this.loadError() ? 'true' : 'false'), /* @ts-ignore */
|
|
94
|
+
...(ngDevMode ? [{ debugName: "errorAttr" }] : /* istanbul ignore next */ []));
|
|
95
|
+
/**
|
|
96
|
+
* Seeds the internal image from an element source and starts a URL load —
|
|
97
|
+
* React's `useState` initial value plus its mount effect.
|
|
98
|
+
*/
|
|
99
|
+
ngOnInit() {
|
|
100
|
+
const src = this.src;
|
|
101
|
+
if (typeof src === 'string') {
|
|
102
|
+
this.load(src);
|
|
103
|
+
}
|
|
104
|
+
else if (src !== undefined && isImageElement(src)) {
|
|
105
|
+
this.image.set(src);
|
|
106
|
+
this.loadError.set(null);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Loads a changed `src` and re-paints for every other input change.
|
|
111
|
+
*
|
|
112
|
+
* @param changes - The changed inputs (React's effect dependencies).
|
|
113
|
+
*/
|
|
114
|
+
ngOnChanges(changes) {
|
|
115
|
+
if (!this.viewReady)
|
|
116
|
+
return;
|
|
117
|
+
if (changes['src']) {
|
|
118
|
+
const src = changes['src'].currentValue;
|
|
119
|
+
if (typeof src === 'string')
|
|
120
|
+
this.load(src);
|
|
121
|
+
else if (src !== undefined && isImageElement(src)) {
|
|
122
|
+
this.image.set(src);
|
|
123
|
+
this.loadError.set(null);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
this.paint();
|
|
127
|
+
}
|
|
128
|
+
/** Paints the first frame and hands out the export handle (React's mount effects). */
|
|
129
|
+
ngAfterViewInit() {
|
|
130
|
+
this.viewReady = true;
|
|
131
|
+
this.paint();
|
|
132
|
+
if (this.exportRef) {
|
|
133
|
+
this.exportRef.current = {
|
|
134
|
+
toDataURL: (type, quality) => {
|
|
135
|
+
const canvas = this.surface?.nativeElement;
|
|
136
|
+
if (!canvas)
|
|
137
|
+
return '';
|
|
138
|
+
return canvas.toDataURL(type, quality);
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/** Clears the export handle, as React's `useImperativeHandle` cleanup does. */
|
|
144
|
+
ngOnDestroy() {
|
|
145
|
+
if (this.exportRef)
|
|
146
|
+
this.exportRef.current = null;
|
|
147
|
+
}
|
|
148
|
+
/** The frame's class list (`cm.cn(className)` only, as React composes it). */
|
|
149
|
+
classes() {
|
|
150
|
+
return this.classMap.cn(this.className);
|
|
151
|
+
}
|
|
152
|
+
/** The canvas bitmap width (React's default parameter). */
|
|
153
|
+
widthValue() {
|
|
154
|
+
return this.width ?? 512;
|
|
155
|
+
}
|
|
156
|
+
/** The canvas bitmap height (React's default parameter). */
|
|
157
|
+
heightValue() {
|
|
158
|
+
return this.height ?? 512;
|
|
159
|
+
}
|
|
160
|
+
/** The cursor style: `grab` while `onChange` is provided. */
|
|
161
|
+
cursor() {
|
|
162
|
+
return this.onChange ? 'grab' : 'default';
|
|
163
|
+
}
|
|
164
|
+
/** The loading/error paragraph's class list. */
|
|
165
|
+
noteClasses() {
|
|
166
|
+
return this.classMap.cn(this.classMap.textSize('xs'), this.classMap.sp('p', 2));
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Starts a drag, capturing the pointer for its duration.
|
|
170
|
+
*
|
|
171
|
+
* @param event - The pointerdown event.
|
|
172
|
+
*/
|
|
173
|
+
handlePointerDown(event) {
|
|
174
|
+
const canvas = this.surface?.nativeElement;
|
|
175
|
+
if (!canvas)
|
|
176
|
+
return;
|
|
177
|
+
canvas.setPointerCapture(event.pointerId);
|
|
178
|
+
this.dragState = {
|
|
179
|
+
pointerId: event.pointerId,
|
|
180
|
+
startX: event.clientX,
|
|
181
|
+
startY: event.clientY,
|
|
182
|
+
startPan: { ...this.safePan() },
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Reports the proposed pan while a drag is in progress.
|
|
187
|
+
*
|
|
188
|
+
* @param event - The pointermove event.
|
|
189
|
+
*/
|
|
190
|
+
handlePointerMove(event) {
|
|
191
|
+
const state = this.dragState;
|
|
192
|
+
if (state.pointerId !== event.pointerId)
|
|
193
|
+
return;
|
|
194
|
+
const dx = event.clientX - state.startX;
|
|
195
|
+
const dy = event.clientY - state.startY;
|
|
196
|
+
const image = this.image();
|
|
197
|
+
const next = clampPan({ x: state.startPan.x + dx, y: state.startPan.y + dy }, { width: this.widthValue(), height: this.heightValue() }, image
|
|
198
|
+
? { width: image.naturalWidth, height: image.naturalHeight }
|
|
199
|
+
: { width: this.widthValue(), height: this.heightValue() }, this.safeZoom());
|
|
200
|
+
this.onChange?.({ zoom: this.safeZoom(), pan: next });
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Ends a drag, releasing the capture it took.
|
|
204
|
+
*
|
|
205
|
+
* @param event - The pointerup or pointercancel event.
|
|
206
|
+
*/
|
|
207
|
+
endDrag(event) {
|
|
208
|
+
const state = this.dragState;
|
|
209
|
+
if (state.pointerId !== event.pointerId)
|
|
210
|
+
return;
|
|
211
|
+
const canvas = this.surface?.nativeElement;
|
|
212
|
+
if (canvas && canvas.hasPointerCapture(event.pointerId)) {
|
|
213
|
+
canvas.releasePointerCapture(event.pointerId);
|
|
214
|
+
}
|
|
215
|
+
this.dragState = { pointerId: null, startX: 0, startY: 0, startPan: { x: 0, y: 0 } };
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Reports the zoomed factor for a wheel scroll (negative `deltaY` zooms in).
|
|
219
|
+
*
|
|
220
|
+
* @param event - The wheel event.
|
|
221
|
+
*/
|
|
222
|
+
handleWheel(event) {
|
|
223
|
+
const factor = event.deltaY < 0 ? 1.1 : 1 / 1.1;
|
|
224
|
+
const nextZoom = clamp(this.safeZoom() * factor, 0.05, 32);
|
|
225
|
+
this.onChange?.({ zoom: nextZoom, pan: this.safePan() });
|
|
226
|
+
}
|
|
227
|
+
/** The sanitised zoom factor (React's `safeZoom`). */
|
|
228
|
+
safeZoom() {
|
|
229
|
+
const zoom = this.zoom;
|
|
230
|
+
return zoom !== undefined && Number.isFinite(zoom) && zoom > 0 ? zoom : 1;
|
|
231
|
+
}
|
|
232
|
+
/** The sanitised pan offset (React's `safePan`). */
|
|
233
|
+
safePan() {
|
|
234
|
+
return {
|
|
235
|
+
x: Number.isFinite(this.pan?.x) ? this.pan?.x : 0,
|
|
236
|
+
y: Number.isFinite(this.pan?.y) ? this.pan?.y : 0,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Loads a URL source into an internal image (React's loading effect).
|
|
241
|
+
*
|
|
242
|
+
* @param src - The URL or data URL.
|
|
243
|
+
*/
|
|
244
|
+
load(src) {
|
|
245
|
+
const token = ++this.loadToken;
|
|
246
|
+
this.loadError.set(null);
|
|
247
|
+
const img = new Image();
|
|
248
|
+
img.crossOrigin = 'anonymous';
|
|
249
|
+
img.onload = () => {
|
|
250
|
+
if (token !== this.loadToken)
|
|
251
|
+
return;
|
|
252
|
+
this.image.set(img);
|
|
253
|
+
this.paint();
|
|
254
|
+
};
|
|
255
|
+
img.onerror = () => {
|
|
256
|
+
if (token !== this.loadToken)
|
|
257
|
+
return;
|
|
258
|
+
this.loadError.set(src);
|
|
259
|
+
this.image.set(null);
|
|
260
|
+
this.paint();
|
|
261
|
+
};
|
|
262
|
+
img.src = src;
|
|
263
|
+
}
|
|
264
|
+
/** Re-paints the canvas from the image, viewport and filter chain. */
|
|
265
|
+
paint() {
|
|
266
|
+
const canvas = this.surface?.nativeElement;
|
|
267
|
+
if (!canvas)
|
|
268
|
+
return;
|
|
269
|
+
const ctx = canvas.getContext('2d');
|
|
270
|
+
if (!ctx)
|
|
271
|
+
return;
|
|
272
|
+
const image = this.image();
|
|
273
|
+
const zoom = this.safeZoom();
|
|
274
|
+
const pan = this.safePan();
|
|
275
|
+
const width = this.widthValue();
|
|
276
|
+
const height = this.heightValue();
|
|
277
|
+
ctx.save();
|
|
278
|
+
ctx.clearRect(0, 0, width, height);
|
|
279
|
+
if (!image) {
|
|
280
|
+
ctx.restore();
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
ctx.filter = composeFilterString(this.filters);
|
|
284
|
+
const drawWidth = image.naturalWidth * zoom;
|
|
285
|
+
const drawHeight = image.naturalHeight * zoom;
|
|
286
|
+
const dx = width / 2 - drawWidth / 2 + pan.x;
|
|
287
|
+
const dy = height / 2 - drawHeight / 2 + pan.y;
|
|
288
|
+
ctx.drawImage(image, dx, dy, drawWidth, drawHeight);
|
|
289
|
+
ctx.restore();
|
|
290
|
+
}
|
|
291
|
+
static ɵfac = function ImageCanvas_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ImageCanvas)(); };
|
|
292
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ImageCanvas, selectors: [["div", "mol-image-canvas", ""]], viewQuery: function ImageCanvas_Query(rf, ctx) { if (rf & 1) {
|
|
293
|
+
i0.ɵɵviewQuery(_c0, 5);
|
|
294
|
+
} if (rf & 2) {
|
|
295
|
+
let _t;
|
|
296
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.surface = _t.first);
|
|
297
|
+
} }, hostAttrs: ["role", "region", "data-mol-id", "image-canvas"], hostVars: 11, hostBindings: function ImageCanvas_HostBindings(rf, ctx) { if (rf & 2) {
|
|
298
|
+
i0.ɵɵattribute("aria-label", ctx.ariaLabel());
|
|
299
|
+
i0.ɵɵclassMap(ctx.classes());
|
|
300
|
+
i0.ɵɵstyleProp("display", "inline-block")("width", ctx.widthValue(), "px")("height", ctx.heightValue(), "px")("position", "relative");
|
|
301
|
+
} }, inputs: { src: "src", filters: "filters", zoom: "zoom", pan: "pan", onChange: "onChange", exportRef: "exportRef", width: "width", height: "height", className: "className" }, features: [i0.ɵɵNgOnChangesFeature], decls: 4, vars: 17, consts: [["surface", ""], ["data-mol-id", "image-canvas-surface", 3, "pointerdown", "pointermove", "pointerup", "pointercancel", "wheel"], ["data-mol-id", "image-canvas-loading", 3, "class"], ["data-mol-id", "image-canvas-error", "role", "alert", 3, "class"], ["data-mol-id", "image-canvas-loading"], ["data-mol-id", "image-canvas-error", "role", "alert"]], template: function ImageCanvas_Template(rf, ctx) { if (rf & 1) {
|
|
302
|
+
i0.ɵɵdomElementStart(0, "canvas", 1, 0);
|
|
303
|
+
i0.ɵɵdomListener("pointerdown", function ImageCanvas_Template_canvas_pointerdown_0_listener($event) { return ctx.handlePointerDown($event); })("pointermove", function ImageCanvas_Template_canvas_pointermove_0_listener($event) { return ctx.handlePointerMove($event); })("pointerup", function ImageCanvas_Template_canvas_pointerup_0_listener($event) { return ctx.endDrag($event); })("pointercancel", function ImageCanvas_Template_canvas_pointercancel_0_listener($event) { return ctx.endDrag($event); })("wheel", function ImageCanvas_Template_canvas_wheel_0_listener($event) { return ctx.handleWheel($event); });
|
|
304
|
+
i0.ɵɵdomElementEnd();
|
|
305
|
+
i0.ɵɵconditionalCreate(2, ImageCanvas_Conditional_2_Template, 2, 3, "p", 2);
|
|
306
|
+
i0.ɵɵconditionalCreate(3, ImageCanvas_Conditional_3_Template, 2, 3, "p", 3);
|
|
307
|
+
} if (rf & 2) {
|
|
308
|
+
i0.ɵɵstyleProp("display", "block")("width", ctx.widthValue(), "px")("height", ctx.heightValue(), "px")("cursor", ctx.cursor())("touch-action", "none");
|
|
309
|
+
i0.ɵɵattribute("width", ctx.widthValue())("height", ctx.heightValue())("aria-label", ctx.dragLabel())("data-loading", ctx.loadingAttr())("data-error", ctx.errorAttr());
|
|
310
|
+
i0.ɵɵadvance(2);
|
|
311
|
+
i0.ɵɵconditional(ctx.loadingAttr() === "true" ? 2 : -1);
|
|
312
|
+
i0.ɵɵadvance();
|
|
313
|
+
i0.ɵɵconditional(ctx.loadError() !== null ? 3 : -1);
|
|
314
|
+
} }, encapsulation: 2 });
|
|
315
|
+
}
|
|
316
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ImageCanvas, [{
|
|
317
|
+
type: Component,
|
|
318
|
+
args: [{
|
|
319
|
+
selector: 'div[mol-image-canvas]',
|
|
320
|
+
standalone: true,
|
|
321
|
+
inputs: [
|
|
322
|
+
'src',
|
|
323
|
+
'filters',
|
|
324
|
+
'zoom',
|
|
325
|
+
'pan',
|
|
326
|
+
'onChange',
|
|
327
|
+
'exportRef',
|
|
328
|
+
'width',
|
|
329
|
+
'height',
|
|
330
|
+
'className',
|
|
331
|
+
],
|
|
332
|
+
host: {
|
|
333
|
+
role: 'region',
|
|
334
|
+
'data-mol-id': 'image-canvas',
|
|
335
|
+
'[attr.aria-label]': 'ariaLabel()',
|
|
336
|
+
'[class]': 'classes()',
|
|
337
|
+
'[style.display]': '"inline-block"',
|
|
338
|
+
'[style.width.px]': 'widthValue()',
|
|
339
|
+
'[style.height.px]': 'heightValue()',
|
|
340
|
+
'[style.position]': '"relative"',
|
|
341
|
+
},
|
|
342
|
+
template: `<canvas
|
|
343
|
+
#surface
|
|
344
|
+
[attr.width]="widthValue()"
|
|
345
|
+
[attr.height]="heightValue()"
|
|
346
|
+
[attr.aria-label]="dragLabel()"
|
|
347
|
+
data-mol-id="image-canvas-surface"
|
|
348
|
+
[attr.data-loading]="loadingAttr()"
|
|
349
|
+
[attr.data-error]="errorAttr()"
|
|
350
|
+
[style.display]="'block'"
|
|
351
|
+
[style.width.px]="widthValue()"
|
|
352
|
+
[style.height.px]="heightValue()"
|
|
353
|
+
[style.cursor]="cursor()"
|
|
354
|
+
[style.touch-action]="'none'"
|
|
355
|
+
(pointerdown)="handlePointerDown($event)"
|
|
356
|
+
(pointermove)="handlePointerMove($event)"
|
|
357
|
+
(pointerup)="endDrag($event)"
|
|
358
|
+
(pointercancel)="endDrag($event)"
|
|
359
|
+
(wheel)="handleWheel($event)"
|
|
360
|
+
></canvas>
|
|
361
|
+
@if (loadingAttr() === 'true') {
|
|
362
|
+
<p [class]="noteClasses()" data-mol-id="image-canvas-loading">{{ loadingLabel() }}</p>
|
|
363
|
+
}
|
|
364
|
+
@if (loadError() !== null) {
|
|
365
|
+
<p [class]="noteClasses()" data-mol-id="image-canvas-error" role="alert">
|
|
366
|
+
{{ errorLabel() }}
|
|
367
|
+
</p>
|
|
368
|
+
}`,
|
|
369
|
+
}]
|
|
370
|
+
}], null, { surface: [{
|
|
371
|
+
type: ViewChild,
|
|
372
|
+
args: ['surface']
|
|
373
|
+
}] }); })();
|
|
374
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ImageCanvas, { className: "ImageCanvas", filePath: "image-canvas.component.ts", lineNumber: 90 }); })();
|
|
375
|
+
//# sourceMappingURL=image-canvas.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-canvas.component.js","sourceRoot":"","sources":["../src/image-canvas.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,SAAS,EACT,QAAQ,EAKR,MAAM,EAEN,SAAS,GACV,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;;;;IAyD5C,+BAA8D;IAAA,YAAoB;I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ChB,MAAM,EAAE;oBACN,KAAK;oBACL,SAAS;oBACT,MAAM;oBACN,KAAK;oBACL,UAAU;oBACV,WAAW;oBACX,OAAO;oBACP,QAAQ;oBACR,WAAW;iBACZ;gBACD,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,aAAa,EAAE,cAAc;oBAC7B,mBAAmB,EAAE,aAAa;oBAClC,SAAS,EAAE,WAAW;oBACtB,iBAAiB,EAAE,gBAAgB;oBACnC,kBAAkB,EAAE,cAAc;oBAClC,mBAAmB,EAAE,eAAe;oBACpC,kBAAkB,EAAE,YAAY;iBACjC;gBACD,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;MA0BN;aACL;;kBAsBE,SAAS;mBAAC,SAAS;;kFArBT,WAAW"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal source guard of the Angular Canvas2D image-editing surface: whether
|
|
3
|
+
* the `src` prop is an already-loaded element rather than a URL string.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Determine whether a `src` prop is an `HTMLImageElement` instance. The
|
|
9
|
+
* constructor is tested at call time so jsdom's `HTMLImageElement` shim
|
|
10
|
+
* works in tests.
|
|
11
|
+
*
|
|
12
|
+
* @param src - The `src` value to inspect.
|
|
13
|
+
* @returns `true` if `src` is an `HTMLImageElement`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isImageElement(src: string | HTMLImageElement): src is HTMLImageElement;
|
|
16
|
+
//# sourceMappingURL=image-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-source.d.ts","sourceRoot":"","sources":["../src/image-source.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,GAAG,GAAG,IAAI,gBAAgB,CAItF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal source guard of the Angular Canvas2D image-editing surface: whether
|
|
3
|
+
* the `src` prop is an already-loaded element rather than a URL string.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Determine whether a `src` prop is an `HTMLImageElement` instance. The
|
|
9
|
+
* constructor is tested at call time so jsdom's `HTMLImageElement` shim
|
|
10
|
+
* works in tests.
|
|
11
|
+
*
|
|
12
|
+
* @param src - The `src` value to inspect.
|
|
13
|
+
* @returns `true` if `src` is an `HTMLImageElement`.
|
|
14
|
+
*/
|
|
15
|
+
export function isImageElement(src) {
|
|
16
|
+
if (typeof src === 'string')
|
|
17
|
+
return false;
|
|
18
|
+
if (typeof HTMLImageElement === 'undefined')
|
|
19
|
+
return false;
|
|
20
|
+
return src instanceof HTMLImageElement;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=image-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-source.js","sourceRoot":"","sources":["../src/image-source.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAAC,GAA8B;IAC3D,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IACzC,IAAI,OAAO,gBAAgB,KAAK,WAAW;QAAE,OAAO,KAAK,CAAA;IACzD,OAAO,GAAG,YAAY,gBAAgB,CAAA;AACxC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Angular Canvas2D image-editing surface.
|
|
3
|
+
*
|
|
4
|
+
* Exports `<div mol-image-canvas>` — the Angular counterpart of
|
|
5
|
+
* `@molecule/app-feature-image-canvas-react` with the same props and the same
|
|
6
|
+
* DOM: an image rendered onto a canvas with a filter chain (brightness,
|
|
7
|
+
* contrast, saturation, hue, sepia, grayscale, blur, sharpen), pointer-drag
|
|
8
|
+
* panning, wheel zooming, and a `toDataURL()` export handle, plus the
|
|
9
|
+
* framework-free `clamp`, `composeFilterString`, `screenToCanvas` and
|
|
10
|
+
* `clampPan` helpers.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { Component, signal } from '@angular/core'
|
|
15
|
+
* import {
|
|
16
|
+
* ImageCanvas,
|
|
17
|
+
* type ImageCanvasExportHandle,
|
|
18
|
+
* } from '@molecule/app-feature-image-canvas-angular'
|
|
19
|
+
*
|
|
20
|
+
* @Component({
|
|
21
|
+
* selector: 'app-editor',
|
|
22
|
+
* standalone: true,
|
|
23
|
+
* imports: [ImageCanvas],
|
|
24
|
+
* template: `
|
|
25
|
+
* <div
|
|
26
|
+
* mol-image-canvas
|
|
27
|
+
* [src]="'/photo.jpg'"
|
|
28
|
+
* [filters]="filters"
|
|
29
|
+
* [zoom]="zoom()"
|
|
30
|
+
* [pan]="pan()"
|
|
31
|
+
* [onChange]="applyView"
|
|
32
|
+
* [exportRef]="exportRef"
|
|
33
|
+
* ></div>
|
|
34
|
+
* `,
|
|
35
|
+
* })
|
|
36
|
+
* export class Editor {
|
|
37
|
+
* protected readonly zoom = signal(1)
|
|
38
|
+
* protected readonly pan = signal({ x: 0, y: 0 })
|
|
39
|
+
* protected readonly filters = { brightness: 1.1, contrast: 1.2, sepia: 0.3 }
|
|
40
|
+
* protected readonly exportRef: { current: ImageCanvasExportHandle | null } = { current: null }
|
|
41
|
+
*
|
|
42
|
+
* protected readonly applyView = (next: { zoom: number; pan: { x: number; y: number } }) => {
|
|
43
|
+
* this.zoom.set(next.zoom)
|
|
44
|
+
* this.pan.set(next.pan)
|
|
45
|
+
* }
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @remarks
|
|
50
|
+
* - The host element IS the React root: `div[mol-image-canvas]` carries
|
|
51
|
+
* `role="region"`, the aria label, the ClassMap classes and the pixel frame
|
|
52
|
+
* size. An attribute selector is used so the host is a plain `<div>`.
|
|
53
|
+
* - Pan / zoom interaction is CONTROLLED-ONLY: pointer-drag and wheel events
|
|
54
|
+
* call `onChange` with the proposed `{ zoom, pan }` and never mutate
|
|
55
|
+
* internal state.
|
|
56
|
+
* - Requires a bonded ClassMap and i18n provider.
|
|
57
|
+
* - URL sources load with `crossOrigin="anonymous"` so `toDataURL()` is never
|
|
58
|
+
* blocked by a tainted canvas.
|
|
59
|
+
*
|
|
60
|
+
* @module
|
|
61
|
+
*/
|
|
62
|
+
export * from './helpers.js';
|
|
63
|
+
export * from './image-canvas.component.js';
|
|
64
|
+
export * from './types.js';
|
|
65
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAEH,cAAc,cAAc,CAAA;AAC5B,cAAc,6BAA6B,CAAA;AAC3C,cAAc,YAAY,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Angular Canvas2D image-editing surface.
|
|
3
|
+
*
|
|
4
|
+
* Exports `<div mol-image-canvas>` — the Angular counterpart of
|
|
5
|
+
* `@molecule/app-feature-image-canvas-react` with the same props and the same
|
|
6
|
+
* DOM: an image rendered onto a canvas with a filter chain (brightness,
|
|
7
|
+
* contrast, saturation, hue, sepia, grayscale, blur, sharpen), pointer-drag
|
|
8
|
+
* panning, wheel zooming, and a `toDataURL()` export handle, plus the
|
|
9
|
+
* framework-free `clamp`, `composeFilterString`, `screenToCanvas` and
|
|
10
|
+
* `clampPan` helpers.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { Component, signal } from '@angular/core'
|
|
15
|
+
* import {
|
|
16
|
+
* ImageCanvas,
|
|
17
|
+
* type ImageCanvasExportHandle,
|
|
18
|
+
* } from '@molecule/app-feature-image-canvas-angular'
|
|
19
|
+
*
|
|
20
|
+
* @Component({
|
|
21
|
+
* selector: 'app-editor',
|
|
22
|
+
* standalone: true,
|
|
23
|
+
* imports: [ImageCanvas],
|
|
24
|
+
* template: `
|
|
25
|
+
* <div
|
|
26
|
+
* mol-image-canvas
|
|
27
|
+
* [src]="'/photo.jpg'"
|
|
28
|
+
* [filters]="filters"
|
|
29
|
+
* [zoom]="zoom()"
|
|
30
|
+
* [pan]="pan()"
|
|
31
|
+
* [onChange]="applyView"
|
|
32
|
+
* [exportRef]="exportRef"
|
|
33
|
+
* ></div>
|
|
34
|
+
* `,
|
|
35
|
+
* })
|
|
36
|
+
* export class Editor {
|
|
37
|
+
* protected readonly zoom = signal(1)
|
|
38
|
+
* protected readonly pan = signal({ x: 0, y: 0 })
|
|
39
|
+
* protected readonly filters = { brightness: 1.1, contrast: 1.2, sepia: 0.3 }
|
|
40
|
+
* protected readonly exportRef: { current: ImageCanvasExportHandle | null } = { current: null }
|
|
41
|
+
*
|
|
42
|
+
* protected readonly applyView = (next: { zoom: number; pan: { x: number; y: number } }) => {
|
|
43
|
+
* this.zoom.set(next.zoom)
|
|
44
|
+
* this.pan.set(next.pan)
|
|
45
|
+
* }
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @remarks
|
|
50
|
+
* - The host element IS the React root: `div[mol-image-canvas]` carries
|
|
51
|
+
* `role="region"`, the aria label, the ClassMap classes and the pixel frame
|
|
52
|
+
* size. An attribute selector is used so the host is a plain `<div>`.
|
|
53
|
+
* - Pan / zoom interaction is CONTROLLED-ONLY: pointer-drag and wheel events
|
|
54
|
+
* call `onChange` with the proposed `{ zoom, pan }` and never mutate
|
|
55
|
+
* internal state.
|
|
56
|
+
* - Requires a bonded ClassMap and i18n provider.
|
|
57
|
+
* - URL sources load with `crossOrigin="anonymous"` so `toDataURL()` is never
|
|
58
|
+
* blocked by a tainted canvas.
|
|
59
|
+
*
|
|
60
|
+
* @module
|
|
61
|
+
*/
|
|
62
|
+
export * from './helpers.js';
|
|
63
|
+
export * from './image-canvas.component.js';
|
|
64
|
+
export * from './types.js';
|
|
65
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAEH,cAAc,cAAc,CAAA;AAC5B,cAAc,6BAA6B,CAAA;AAC3C,cAAc,YAAY,CAAA"}
|