@floegence/floe-webapp-core 0.101.38 → 0.101.41

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.
@@ -0,0 +1,9 @@
1
+ import { type Setter } from 'solid-js';
2
+ import type { GraphViewport } from './types';
3
+ /** A controlled camera: direct input interrupts motion at the currently painted viewport. */
4
+ export declare function createGraphViewport(initial: GraphViewport): {
5
+ viewport: import("solid-js").Accessor<import("..").InfiniteCanvasPoint>;
6
+ setViewport: Setter<import("..").InfiniteCanvasPoint>;
7
+ animateTo: (next: GraphViewport) => void;
8
+ moving: import("solid-js").Accessor<boolean>;
9
+ };
@@ -0,0 +1,36 @@
1
+ import { createSignal as u, onMount as y, onCleanup as f, untrack as M } from "solid-js";
2
+ function F(p) {
3
+ const [s, r] = u(p), [w, i] = u(!1);
4
+ let a = 0, o;
5
+ const n = () => {
6
+ cancelAnimationFrame(a), a = 0, o = void 0, i(!1);
7
+ }, m = (e) => (n(), r(e)), h = (e) => {
8
+ n();
9
+ const t = M(s);
10
+ if (window.matchMedia("(prefers-reduced-motion: reduce)").matches || t.x === e.x && t.y === e.y && t.scale === e.scale) {
11
+ r(e);
12
+ return;
13
+ }
14
+ o = e;
15
+ const g = performance.now();
16
+ i(!0);
17
+ const l = (v) => {
18
+ const d = Math.min(1, (v - g) / 280), c = 1 - Math.pow(1 - d, 3);
19
+ r({
20
+ x: t.x + (e.x - t.x) * c,
21
+ y: t.y + (e.y - t.y) * c,
22
+ scale: t.scale + (e.scale - t.scale) * c
23
+ }), d < 1 ? a = requestAnimationFrame(l) : (r(e), n());
24
+ };
25
+ a = requestAnimationFrame(l);
26
+ };
27
+ return y(() => {
28
+ const e = window.matchMedia("(prefers-reduced-motion: reduce)"), t = () => {
29
+ e.matches && o && m(o);
30
+ };
31
+ e.addEventListener("change", t), f(() => e.removeEventListener("change", t));
32
+ }), f(n), { viewport: s, setViewport: m, animateTo: h, moving: w };
33
+ }
34
+ export {
35
+ F as createGraphViewport
36
+ };
@@ -3,6 +3,12 @@ export type ImageAnnotationSurfaceProps = ImageDimensions & {
3
3
  src: string;
4
4
  label: string;
5
5
  annotation?: ImageAnnotation;
6
+ /** Ordered markers rendered identically in the exported image. */
7
+ annotations?: readonly ImageAnnotation[];
8
+ activeIndex?: number;
9
+ onSelect?: (index: number) => void;
10
+ /** Number used for a new or independently edited annotation. */
11
+ marker?: number;
6
12
  onChange?: (annotation: ImageAnnotation) => void;
7
13
  disabled?: boolean;
8
14
  zoom?: number;
@@ -1,79 +1,79 @@
1
- import { use as H, insert as G, createComponent as N, effect as q, setAttribute as l, setStyleProperty as S, memo as J, className as Q, template as U, delegateEvents as V } from "solid-js/web";
2
- import { createSignal as K, createMemo as Z, onMount as _, onCleanup as p, Show as tt, For as it } from "solid-js";
3
- import { validateImageAnnotation as O, imagePointFromClient as et, imageAnnotationMarkup as nt } from "./imageAnnotation.js";
4
- var rt = /* @__PURE__ */ U("<div data-floe-image-annotation style=width:100%;height:100%;overflow:auto;scrollbar-gutter:stable;overscroll-behavior:contain><div style=display:grid;place-items:center><svg xmlns=http://www.w3.org/2000/svg role=img style=display:block;user-select:none;flex:none><image></image><g data-annotation-target>"), ot = /* @__PURE__ */ U("<svg><rect data-annotation-target fill=white stroke=#111827></svg>", !1, !0, !1);
5
- function lt(e) {
6
- let u, g;
7
- const [z, W] = K({
1
+ import { use as O, insert as U, createComponent as D, effect as X, setAttribute as h, setStyleProperty as M, memo as W, className as _, template as F, delegateEvents as p } from "solid-js/web";
2
+ import { createSignal as j, createMemo as tt, onMount as et, onCleanup as it, For as G, Show as J } from "solid-js";
3
+ import { imageAnnotationMarkup as Q, validateImageAnnotation as Y, imagePointFromClient as nt } from "./imageAnnotation.js";
4
+ var at = /* @__PURE__ */ F("<div data-floe-image-annotation style=width:100%;height:100%;overflow:auto;scrollbar-gutter:stable;overscroll-behavior:contain><div style=display:grid;place-items:center><svg xmlns=http://www.w3.org/2000/svg role=img style=display:block;user-select:none;flex:none><image></image><g data-annotation-target>"), rt = /* @__PURE__ */ F("<svg><g></svg>", !1, !0, !1), ot = /* @__PURE__ */ F("<svg><rect data-annotation-target fill=white stroke=#111827></svg>", !1, !0, !1);
5
+ function ct(e) {
6
+ let v, u;
7
+ const [L, V] = j({
8
8
  width: 1,
9
9
  height: 1
10
- }), [E, y] = K();
11
- let v, f;
12
- const L = () => E() ?? e.annotation, w = Z(() => Math.min(z().width / e.width, z().height / e.height) * Math.max(1, e.zoom ?? 1)), $ = () => e.showAnnotation !== !1 && L() && O(e, L()) ? nt(e, L()) : "";
13
- _(() => {
10
+ }), [N, k] = j();
11
+ let b, f;
12
+ const z = () => N() ?? e.annotation, w = tt(() => Math.min(L().width / e.width, L().height / e.height) * Math.max(1, e.zoom ?? 1)), Z = () => e.showAnnotation !== !1 && z() && Y(e, z()) ? Q(e, z(), e.marker ?? (e.activeIndex !== void 0 ? e.activeIndex + 1 : 1)) : "";
13
+ et(() => {
14
14
  let i = 0;
15
- const o = () => {
15
+ const d = () => {
16
16
  i = 0;
17
- const r = u.clientWidth, c = u.clientHeight;
18
- W((s) => s.width === r && s.height === c ? s : {
19
- width: r,
17
+ const o = v.clientWidth, c = v.clientHeight;
18
+ V((s) => s.width === o && s.height === c ? s : {
19
+ width: o,
20
20
  height: c
21
21
  });
22
- }, n = new ResizeObserver(() => {
23
- i || (i = requestAnimationFrame(o));
22
+ }, a = new ResizeObserver(() => {
23
+ i || (i = requestAnimationFrame(d));
24
24
  });
25
- n.observe(u), o(), p(() => {
26
- n.disconnect(), cancelAnimationFrame(i);
25
+ a.observe(v), d(), it(() => {
26
+ a.disconnect(), cancelAnimationFrame(i);
27
27
  });
28
28
  });
29
- const X = (i, o = !1) => et(e, g.getBoundingClientRect(), {
29
+ const T = (i, d = !1) => nt(e, u.getBoundingClientRect(), {
30
30
  x: i.clientX,
31
31
  y: i.clientY
32
- }, o), m = () => !!e.onChange && !e.disabled && !e.panning, Y = (i) => {
32
+ }, d), m = () => !!e.onChange && !e.disabled && !e.panning, B = (i) => {
33
33
  if (f?.id === i.pointerId) {
34
- u.scrollLeft = f.left + f.x - i.clientX, u.scrollTop = f.top + f.y - i.clientY;
34
+ v.scrollLeft = f.left + f.x - i.clientX, v.scrollTop = f.top + f.y - i.clientY;
35
35
  return;
36
36
  }
37
- const o = v;
38
- if (!o || o.id !== i.pointerId || o.src !== e.src || !m()) return;
39
- const n = X(i, !0);
40
- if (!n) return;
41
- const r = o.original;
42
- if (r && o.corner === void 0) {
43
- const c = r.kind === "rectangle" ? r.width : 0, s = r.kind === "rectangle" ? r.height : 0;
44
- y({
45
- ...r,
46
- x: Math.max(0, Math.min(e.width - c, r.x + n.x - o.start.x)),
47
- y: Math.max(0, Math.min(e.height - s, r.y + n.y - o.start.y))
37
+ const d = b;
38
+ if (!d || d.id !== i.pointerId || d.src !== e.src || !m()) return;
39
+ const a = T(i, !0);
40
+ if (!a) return;
41
+ const o = d.original;
42
+ if (o && d.corner === void 0) {
43
+ const c = o.kind === "rectangle" ? o.width : 0, s = o.kind === "rectangle" ? o.height : 0;
44
+ k({
45
+ ...o,
46
+ x: Math.max(0, Math.min(e.width - c, o.x + a.x - d.start.x)),
47
+ y: Math.max(0, Math.min(e.height - s, o.y + a.y - d.start.y))
48
48
  });
49
49
  } else {
50
- const c = r?.kind === "rectangle" && o.corner !== void 0 ? {
51
- x: r.x + (o.corner % 2 ? 0 : r.width),
52
- y: r.y + (o.corner < 2 ? r.height : 0)
53
- } : o.start, s = Math.abs(n.x - c.x), x = Math.abs(n.y - c.y);
54
- Math.hypot(i.clientX - o.client.x, i.clientY - o.client.y) < 5 && !r ? y({
50
+ const c = o?.kind === "rectangle" && d.corner !== void 0 ? {
51
+ x: o.x + (d.corner % 2 ? 0 : o.width),
52
+ y: o.y + (d.corner < 2 ? o.height : 0)
53
+ } : d.start, s = Math.abs(a.x - c.x), I = Math.abs(a.y - c.y);
54
+ Math.hypot(i.clientX - d.client.x, i.clientY - d.client.y) < 5 && !o ? k({
55
55
  kind: "point",
56
56
  ...c
57
- }) : s > 0 && x > 0 && y({
57
+ }) : s > 0 && I > 0 && k({
58
58
  kind: "rectangle",
59
- x: Math.min(c.x, n.x),
60
- y: Math.min(c.y, n.y),
59
+ x: Math.min(c.x, a.x),
60
+ y: Math.min(c.y, a.y),
61
61
  width: s,
62
- height: x
62
+ height: I
63
63
  });
64
64
  }
65
- }, D = (i, o = !1) => {
65
+ }, E = (i, d = !1) => {
66
66
  if (f?.id === i.pointerId) {
67
- f = void 0, g.hasPointerCapture(i.pointerId) && g.releasePointerCapture(i.pointerId);
67
+ f = void 0, u.hasPointerCapture(i.pointerId) && u.releasePointerCapture(i.pointerId);
68
68
  return;
69
69
  }
70
- const n = v;
71
- if (!n || n.id !== i.pointerId) return;
72
- o || Y(i);
73
- const r = E();
74
- v = void 0, y(void 0), g.hasPointerCapture(i.pointerId) && g.releasePointerCapture(i.pointerId), !o && n.src === e.src && m() && r && O(e, r) && e.onChange?.(r);
75
- }, j = () => {
76
- const i = L();
70
+ const a = b;
71
+ if (!a || a.id !== i.pointerId) return;
72
+ d || B(i);
73
+ const o = N();
74
+ b = void 0, k(void 0), u.hasPointerCapture(i.pointerId) && u.releasePointerCapture(i.pointerId), !d && a.src === e.src && m() && o && Y(e, o) && e.onChange?.(o);
75
+ }, $ = () => {
76
+ const i = z();
77
77
  return i?.kind === "rectangle" ? [{
78
78
  x: i.x,
79
79
  y: i.y
@@ -89,82 +89,107 @@ function lt(e) {
89
89
  }] : [];
90
90
  };
91
91
  return (() => {
92
- var i = rt(), o = i.firstChild, n = o.firstChild, r = n.firstChild, c = r.nextSibling, s = u;
93
- typeof s == "function" ? H(s, i) : u = i, n.$$keydown = (t) => {
92
+ var i = at(), d = i.firstChild, a = d.firstChild, o = a.firstChild, c = o.nextSibling, s = v;
93
+ typeof s == "function" ? O(s, i) : v = i, a.$$keydown = (t) => {
94
94
  if (!m()) return;
95
95
  if (t.key === "Escape") {
96
- v = void 0, y(void 0);
96
+ b = void 0, k(void 0);
97
97
  return;
98
98
  }
99
- const d = {
99
+ const l = {
100
100
  ArrowLeft: [-1, 0],
101
101
  ArrowRight: [1, 0],
102
102
  ArrowUp: [0, -1],
103
103
  ArrowDown: [0, 1]
104
104
  }[t.key];
105
- if (!d && t.key !== "Enter" && t.key !== " ") return;
105
+ if (!l && t.key !== "Enter" && t.key !== " ") return;
106
106
  t.preventDefault();
107
- const h = e.annotation ?? {
107
+ const r = e.annotation ?? {
108
108
  kind: "point",
109
109
  x: e.width / 2,
110
110
  y: e.height / 2
111
- }, a = t.shiftKey ? 10 : 1;
111
+ }, n = t.shiftKey ? 10 : 1;
112
112
  e.onChange?.({
113
- ...h,
114
- x: Math.max(0, Math.min(e.width - (h.kind === "rectangle" ? h.width : 0), h.x + (d?.[0] ?? 0) * a)),
115
- y: Math.max(0, Math.min(e.height - (h.kind === "rectangle" ? h.height : 0), h.y + (d?.[1] ?? 0) * a))
113
+ ...r,
114
+ x: Math.max(0, Math.min(e.width - (r.kind === "rectangle" ? r.width : 0), r.x + (l?.[0] ?? 0) * n)),
115
+ y: Math.max(0, Math.min(e.height - (r.kind === "rectangle" ? r.height : 0), r.y + (l?.[1] ?? 0) * n))
116
116
  });
117
- }, n.addEventListener("lostpointercapture", (t) => D(t, !0)), n.addEventListener("pointercancel", (t) => D(t, !0)), n.$$pointerup = (t) => D(t), n.$$pointermove = Y, n.$$pointerdown = (t) => {
117
+ }, a.addEventListener("lostpointercapture", (t) => E(t, !0)), a.addEventListener("pointercancel", (t) => E(t, !0)), a.$$pointerup = (t) => E(t), a.$$pointermove = B, a.$$pointerdown = (t) => {
118
118
  if (e.panning && t.button === 0 && !f) {
119
119
  f = {
120
120
  id: t.pointerId,
121
121
  x: t.clientX,
122
122
  y: t.clientY,
123
- left: u.scrollLeft,
124
- top: u.scrollTop
125
- }, g.setPointerCapture(t.pointerId), t.preventDefault();
123
+ left: v.scrollLeft,
124
+ top: v.scrollTop
125
+ }, u.setPointerCapture(t.pointerId), t.preventDefault();
126
+ return;
127
+ }
128
+ if (!m() || t.button !== 0 || b) return;
129
+ const l = T(t);
130
+ if (!l) return;
131
+ const r = t.target, n = r.closest("[data-annotation-index]")?.getAttribute("data-annotation-index");
132
+ if (n != null && Number(n) !== e.activeIndex) {
133
+ e.onSelect?.(Number(n)), t.preventDefault();
126
134
  return;
127
135
  }
128
- if (!m() || t.button !== 0 || v) return;
129
- const d = X(t);
130
- if (!d) return;
131
- const h = t.target, a = h.getAttribute("data-corner");
132
- v = {
136
+ const g = r.getAttribute("data-corner");
137
+ b = {
133
138
  id: t.pointerId,
134
- start: d,
139
+ start: l,
135
140
  client: {
136
141
  x: t.clientX,
137
142
  y: t.clientY
138
143
  },
139
144
  src: e.src,
140
- ...h.closest("[data-annotation-target]") ? {
145
+ ...r.closest("[data-annotation-target]") ? {
141
146
  original: e.annotation
142
147
  } : {},
143
- ...a !== null ? {
144
- corner: Number(a)
148
+ ...g !== null ? {
149
+ corner: Number(g)
145
150
  } : {}
146
- }, y(v.original ?? {
151
+ }, k(b.original ?? {
147
152
  kind: "point",
148
- ...d
149
- }), g.setPointerCapture(t.pointerId), g.focus({
153
+ ...l
154
+ }), u.setPointerCapture(t.pointerId), u.focus({
150
155
  preventScroll: !0
151
156
  }), t.preventDefault();
152
157
  };
153
- var x = g;
154
- return typeof x == "function" ? H(x, n) : g = n, G(n, N(tt, {
158
+ var I = u;
159
+ return typeof I == "function" ? O(I, a) : u = a, U(a, D(G, {
160
+ get each() {
161
+ return e.annotations?.slice(0, 99);
162
+ },
163
+ children: (t, l) => D(J, {
164
+ get when() {
165
+ return W(() => e.showAnnotation !== !1 && l() !== e.activeIndex)() && Y(e, t);
166
+ },
167
+ get children() {
168
+ var r = rt();
169
+ return X((n) => {
170
+ var g = l(), x = Q(e, t, l() + 1), y = e.onSelect ? "pointer" : void 0;
171
+ return g !== n.e && h(r, "data-annotation-index", n.e = g), x !== n.t && (r.innerHTML = n.t = x), y !== n.a && M(r, "cursor", n.a = y), n;
172
+ }, {
173
+ e: void 0,
174
+ t: void 0,
175
+ a: void 0
176
+ }), r;
177
+ }
178
+ })
179
+ }), c), U(a, D(J, {
155
180
  get when() {
156
- return J(() => !!m())() && e.showAnnotation !== !1;
181
+ return W(() => !!m())() && e.showAnnotation !== !1;
157
182
  },
158
183
  get children() {
159
- return N(it, {
184
+ return D(G, {
160
185
  get each() {
161
- return j();
186
+ return $();
162
187
  },
163
- children: (t, d) => (() => {
164
- var h = ot();
165
- return q((a) => {
166
- var b = d(), k = t.x - 5 / w(), M = t.y - 5 / w(), C = 10 / w(), I = 10 / w(), A = 1 / w(), P = d() === 0 || d() === 3 ? "nwse-resize" : "nesw-resize";
167
- return b !== a.e && l(h, "data-corner", a.e = b), k !== a.t && l(h, "x", a.t = k), M !== a.a && l(h, "y", a.a = M), C !== a.o && l(h, "width", a.o = C), I !== a.i && l(h, "height", a.i = I), A !== a.n && l(h, "stroke-width", a.n = A), P !== a.s && S(h, "cursor", a.s = P), a;
188
+ children: (t, l) => (() => {
189
+ var r = ot();
190
+ return X((n) => {
191
+ var g = l(), x = t.x - 5 / w(), y = t.y - 5 / w(), C = 10 / w(), A = 10 / w(), S = 1 / w(), P = l() === 0 || l() === 3 ? "nwse-resize" : "nesw-resize";
192
+ return g !== n.e && h(r, "data-corner", n.e = g), x !== n.t && h(r, "x", n.t = x), y !== n.a && h(r, "y", n.a = y), C !== n.o && h(r, "width", n.o = C), A !== n.i && h(r, "height", n.i = A), S !== n.n && h(r, "stroke-width", n.n = S), P !== n.s && M(r, "cursor", n.s = P), n;
168
193
  }, {
169
194
  e: void 0,
170
195
  t: void 0,
@@ -173,13 +198,13 @@ function lt(e) {
173
198
  i: void 0,
174
199
  n: void 0,
175
200
  s: void 0
176
- }), h;
201
+ }), r;
177
202
  })()
178
203
  });
179
204
  }
180
- }), null), q((t) => {
181
- var d = e.class, h = `${Math.max(z().width, e.width * w())}px`, a = `${Math.max(z().height, e.height * w())}px`, b = e.width * w(), k = e.height * w(), M = `0 0 ${e.width} ${e.height}`, C = e.label, I = m() ? 0 : void 0, A = m() || e.panning ? "none" : "auto", P = e.panning ? "grab" : m() ? "crosshair" : "default", F = e.src, B = e.width, R = e.height, T = $();
182
- return d !== t.e && Q(i, t.e = d), h !== t.t && S(o, "width", t.t = h), a !== t.a && S(o, "height", t.a = a), b !== t.o && l(n, "width", t.o = b), k !== t.i && l(n, "height", t.i = k), M !== t.n && l(n, "viewBox", t.n = M), C !== t.s && l(n, "aria-label", t.s = C), I !== t.h && l(n, "tabindex", t.h = I), A !== t.r && S(n, "touch-action", t.r = A), P !== t.d && S(n, "cursor", t.d = P), F !== t.l && l(r, "href", t.l = F), B !== t.u && l(r, "width", t.u = B), R !== t.c && l(r, "height", t.c = R), T !== t.w && (c.innerHTML = t.w = T), t;
205
+ }), null), X((t) => {
206
+ var l = e.class, r = `${Math.max(L().width, e.width * w())}px`, n = `${Math.max(L().height, e.height * w())}px`, g = e.width * w(), x = e.height * w(), y = `0 0 ${e.width} ${e.height}`, C = e.label, A = m() ? 0 : void 0, S = m() || e.panning ? "none" : "auto", P = e.panning ? "grab" : m() ? "crosshair" : "default", H = e.src, R = e.width, q = e.height, K = Z();
207
+ return l !== t.e && _(i, t.e = l), r !== t.t && M(d, "width", t.t = r), n !== t.a && M(d, "height", t.a = n), g !== t.o && h(a, "width", t.o = g), x !== t.i && h(a, "height", t.i = x), y !== t.n && h(a, "viewBox", t.n = y), C !== t.s && h(a, "aria-label", t.s = C), A !== t.h && h(a, "tabindex", t.h = A), S !== t.r && M(a, "touch-action", t.r = S), P !== t.d && M(a, "cursor", t.d = P), H !== t.l && h(o, "href", t.l = H), R !== t.u && h(o, "width", t.u = R), q !== t.c && h(o, "height", t.c = q), K !== t.w && (c.innerHTML = t.w = K), t;
183
208
  }, {
184
209
  e: void 0,
185
210
  t: void 0,
@@ -198,7 +223,7 @@ function lt(e) {
198
223
  }), i;
199
224
  })();
200
225
  }
201
- V(["pointerdown", "pointermove", "pointerup", "keydown"]);
226
+ p(["pointerdown", "pointermove", "pointerup", "keydown"]);
202
227
  export {
203
- lt as ImageAnnotationSurface
228
+ ct as ImageAnnotationSurface
204
229
  };
@@ -27,5 +27,5 @@ export declare function imagePointFromClient(image: ImageDimensions, rect: Reado
27
27
  height: number;
28
28
  }>, client: ImagePoint, clamp?: boolean): ImagePoint | undefined;
29
29
  /** One deterministic overlay is used by the editor and exported/model-visible PNG. */
30
- export declare function imageAnnotationMarkup(image: ImageDimensions, annotation: ImageAnnotation): string;
31
- export declare function annotateImage(source: Blob, annotation: ImageAnnotation): Promise<Blob>;
30
+ export declare function imageAnnotationMarkup(image: ImageDimensions, annotation: ImageAnnotation, marker?: number): string;
31
+ export declare function annotateImage(source: Blob, annotation: ImageAnnotation | readonly ImageAnnotation[]): Promise<Blob>;
@@ -1,37 +1,40 @@
1
- function f(i, e) {
2
- return ![i.width, i.height].every((t) => Number.isSafeInteger(t) && t > 0 && t <= 16384) || !e || ![e.x, e.y].every(Number.isFinite) || e.x < 0 || e.y < 0 || e.x > i.width || e.y > i.height ? !1 : e.kind === "point" ? !0 : e.kind === "rectangle" && [e.width, e.height].every((t) => Number.isFinite(t) && t > 0) && e.x + e.width <= i.width && e.y + e.height <= i.height;
1
+ function g(i, e) {
2
+ return ![i.width, i.height].every((r) => Number.isSafeInteger(r) && r > 0 && r <= 16384) || !e || ![e.x, e.y].every(Number.isFinite) || e.x < 0 || e.y < 0 || e.x > i.width || e.y > i.height ? !1 : e.kind === "point" ? !0 : e.kind === "rectangle" && [e.width, e.height].every((r) => Number.isFinite(r) && r > 0) && e.x + e.width <= i.width && e.y + e.height <= i.height;
3
3
  }
4
- function $(i, e, t, s = !1) {
4
+ function x(i, e, r, t = !1) {
5
5
  if (e.width <= 0 || e.height <= 0) return;
6
- const h = (t.x - e.left) * i.width / e.width, r = (t.y - e.top) * i.height / e.height;
7
- if (!(![h, r].every(Number.isFinite) || !s && (h < 0 || r < 0 || h > i.width || r > i.height)))
8
- return { x: Math.max(0, Math.min(i.width, h)), y: Math.max(0, Math.min(i.height, r)) };
6
+ const h = (r.x - e.left) * i.width / e.width, n = (r.y - e.top) * i.height / e.height;
7
+ if (!(![h, n].every(Number.isFinite) || !t && (h < 0 || n < 0 || h > i.width || n > i.height)))
8
+ return { x: Math.max(0, Math.min(i.width, h)), y: Math.max(0, Math.min(i.height, n)) };
9
9
  }
10
- function g(i, e) {
11
- if (!f(i, e)) throw new Error("Invalid image annotation");
12
- const t = Math.max(1, Math.min(i.width, i.height) / 500), { x: s, y: h } = e, r = 9 * t, w = Math.max(r + t, Math.min(i.width - r - t, s + 17 * t)), n = Math.max(r + t, Math.min(i.height - r - t, h - 17 * t)), l = e.kind === "rectangle" ? `<rect x="${s}" y="${h}" width="${e.width}" height="${e.height}" fill="#f59e0b" fill-opacity=".08"/>` : `<path d="M${s - 6 * t},${h}h${12 * t}M${s},${h - 6 * t}v${12 * t}"/><circle cx="${s}" cy="${h}" r="${2 * t}" fill="#f59e0b"/>`;
13
- return `<g fill="none" stroke-linejoin="round"><g stroke="#111827" stroke-width="${4 * t}">${l}</g><g stroke="#fbbf24" stroke-width="${2 * t}">${l}<path d="M${s},${h}L${w},${n}"/></g><circle cx="${w}" cy="${n}" r="${r}" fill="#fbbf24" stroke="#111827" stroke-width="${t}"/><text x="${w}" y="${n}" dy=".35em" text-anchor="middle" fill="#111827" stroke="none" font-family="sans-serif" font-size="${12 * t}" font-weight="700">1</text></g>`;
10
+ function $(i, e, r = 1) {
11
+ if (!Number.isSafeInteger(r) || r < 1 || r > 99) throw new Error("Invalid annotation marker");
12
+ if (!g(i, e)) throw new Error("Invalid image annotation");
13
+ const t = Math.max(1, Math.min(i.width, i.height) / 500), { x: h, y: n } = e, s = 9 * t, w = Math.max(s + t, Math.min(i.width - s - t, h + 17 * t)), o = Math.max(s + t, Math.min(i.height - s - t, n - 17 * t)), l = e.kind === "rectangle" ? `<rect x="${h}" y="${n}" width="${e.width}" height="${e.height}" fill="#f59e0b" fill-opacity=".08"/>` : `<path d="M${h - 6 * t},${n}h${12 * t}M${h},${n - 6 * t}v${12 * t}"/><circle cx="${h}" cy="${n}" r="${2 * t}" fill="#f59e0b"/>`;
14
+ return `<g fill="none" stroke-linejoin="round"><g stroke="#111827" stroke-width="${4 * t}">${l}</g><g stroke="#fbbf24" stroke-width="${2 * t}">${l}<path d="M${h},${n}L${w},${o}"/></g><circle cx="${w}" cy="${o}" r="${s}" fill="#fbbf24" stroke="#111827" stroke-width="${t}"/><text x="${w}" y="${o}" dy=".35em" text-anchor="middle" fill="#111827" stroke="none" font-family="sans-serif" font-size="${12 * t}" font-weight="700">${r}</text></g>`;
14
15
  }
15
- async function x(i, e) {
16
- const t = await createImageBitmap(i);
17
- let s;
16
+ async function y(i, e) {
17
+ const r = await createImageBitmap(i);
18
+ let t;
18
19
  try {
19
- const { width: h, height: r } = t;
20
- if (h * r > 32e6) throw new Error("Image exceeds annotation pixel limit");
21
- const w = g({ width: h, height: r }, e), n = document.createElement("canvas");
22
- n.width = h, n.height = r;
23
- const l = n.getContext("2d");
20
+ const { width: h, height: n } = r;
21
+ if (h * n > 32e6) throw new Error("Image exceeds annotation pixel limit");
22
+ const s = Array.isArray(e) ? e : [e];
23
+ if (!s.length || s.length > 99) throw new Error("Invalid annotation count");
24
+ const w = s.map((c, d) => $({ width: h, height: n }, c, d + 1)).join(""), o = document.createElement("canvas");
25
+ o.width = h, o.height = n;
26
+ const l = o.getContext("2d");
24
27
  if (!l) throw new Error("Image annotation is unavailable");
25
- l.drawImage(t, 0, 0), s = URL.createObjectURL(new Blob([`<svg xmlns="http://www.w3.org/2000/svg" width="${h}" height="${r}" viewBox="0 0 ${h} ${r}">${w}</svg>`], { type: "image/svg+xml" }));
26
- const c = new Image();
27
- return c.src = s, await c.decode(), l.drawImage(c, 0, 0), await new Promise((o, a) => n.toBlob((d) => d ? o(d) : a(new Error("Image annotation is unavailable")), "image/png"));
28
+ l.drawImage(r, 0, 0), t = URL.createObjectURL(new Blob([`<svg xmlns="http://www.w3.org/2000/svg" width="${h}" height="${n}" viewBox="0 0 ${h} ${n}">${w}</svg>`], { type: "image/svg+xml" }));
29
+ const a = new Image();
30
+ return a.src = t, await a.decode(), l.drawImage(a, 0, 0), await new Promise((c, d) => o.toBlob((f) => f ? c(f) : d(new Error("Image annotation is unavailable")), "image/png"));
28
31
  } finally {
29
- t.close(), s && URL.revokeObjectURL(s);
32
+ r.close(), t && URL.revokeObjectURL(t);
30
33
  }
31
34
  }
32
35
  export {
33
- x as annotateImage,
34
- g as imageAnnotationMarkup,
35
- $ as imagePointFromClient,
36
- f as validateImageAnnotation
36
+ y as annotateImage,
37
+ $ as imageAnnotationMarkup,
38
+ x as imagePointFromClient,
39
+ g as validateImageAnnotation
37
40
  };
package/dist/graph.d.ts CHANGED
@@ -3,3 +3,4 @@ export * from './components/graph/geometry';
3
3
  export * from './components/graph/engine';
4
4
  export * from './components/graph/GraphCanvas';
5
5
  export * from './components/graph/GraphMinimap';
6
+ export * from './components/graph/viewport-motion';
package/dist/graph.js CHANGED
@@ -1,12 +1,14 @@
1
- import { fitGraphViewport as e, graphEdgeLabelPosition as o, graphRelatedEdges as p, graphSectionPath as t } from "./components/graph/geometry.js";
1
+ import { fitGraphViewport as a, graphEdgeLabelPosition as o, graphRelatedEdges as p, graphSectionPath as t } from "./components/graph/geometry.js";
2
2
  import { createGraphLayoutEngine as i } from "./components/graph/engine.js";
3
- import { GraphCanvas as n } from "./components/graph/GraphCanvas.js";
4
- import { GraphMinimap as m } from "./components/graph/GraphMinimap.js";
3
+ import { GraphCanvas as g } from "./components/graph/GraphCanvas.js";
4
+ import { GraphMinimap as n } from "./components/graph/GraphMinimap.js";
5
+ import { createGraphViewport as G } from "./components/graph/viewport-motion.js";
5
6
  export {
6
- n as GraphCanvas,
7
- m as GraphMinimap,
7
+ g as GraphCanvas,
8
+ n as GraphMinimap,
8
9
  i as createGraphLayoutEngine,
9
- e as fitGraphViewport,
10
+ G as createGraphViewport,
11
+ a as fitGraphViewport,
10
12
  o as graphEdgeLabelPosition,
11
13
  p as graphRelatedEdges,
12
14
  t as graphSectionPath
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.101.38",
3
+ "version": "0.101.41",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",