@hussmartinez/image-sdk 0.8.0 → 0.9.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/assets/image/job.worker.js +1 -1
- package/dist/assets/image/render.worker.js +1 -1
- package/dist/element.js +2 -2
- package/dist/index.js +1 -1
- package/dist/lazy/{inline-job-worker-BSYw65Yh.js → inline-job-worker-BFybekkp.js} +2 -2
- package/dist/lazy/{inline-job-worker-BSYw65Yh.js.map → inline-job-worker-BFybekkp.js.map} +1 -1
- package/dist/lazy/{inline-worker-CNWqkatu.js → inline-worker-CMzixw3b.js} +2 -2
- package/dist/lazy/{inline-worker-CNWqkatu.js.map → inline-worker-CMzixw3b.js.map} +1 -1
- package/dist/react.js +1 -1
- package/dist/shared/{core-Dl1fQBA9.js → core-CCE45OTe.js} +4 -4
- package/dist/shared/{core-Dl1fQBA9.js.map → core-CCE45OTe.js.map} +1 -1
- package/dist/shared/{editor-B5NuHohd.js → editor-CJEZNOqH.js} +73 -14
- package/dist/shared/editor-CJEZNOqH.js.map +1 -0
- package/package.json +1 -1
- package/dist/shared/editor-B5NuHohd.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as dragHandle, At as createImageRenderer, B as outputSize, C as drawingBounds, Ct as MAX_SCENE_COORDINATE, D as aspectRatio, E as ASPECT_PRESETS, F as wholeCrop, Ft as createImageProcessor, I as compositionSize, It as createImageEngine, J as FORBIDDEN_IN_TEXT, Jt as isImageError, Kt as asImageError, L as compositionToSource, Lt as engineInternals, M as handleInSource, N as moveCrop, Nt as fittedView, O as compositionDeltaToSource, P as nudgeCropOnScreen, Pt as placement, R as cropRect, Rt as ANIMATION_LIMITS, T as simplifyStroke, Tt as MAX_STROKE_WIDTH, _ as layerToScene, _t as MAX_FRAME_DELAY, a as compositionRectToScene, at as MAX_METADATA_LENGTH, b as createImageKey, bt as MAX_LAYER_TEXT_LENGTH, ct as DEVELOP_ADJUSTMENTS, d as sceneRectToComposition, dt as LAYER_ALIGNMENTS, f as applyMatrix, ft as LAYER_FONTS, g as layerToOutput, i as newLayerBox, j as fitAspect, k as cropInComposition, kt as createPlan, lt as FILTER_PRESETS, m as invertMatrix, n as createImageSession, o as fitRedactionRegion, q as createImageReducer, r as keepsFields, st as longerThan, t as imageMessages, x as arrowBounds, y as sceneToOutput } from "./core-
|
|
1
|
+
import { A as dragHandle, At as createImageRenderer, B as outputSize, C as drawingBounds, Ct as MAX_SCENE_COORDINATE, D as aspectRatio, E as ASPECT_PRESETS, F as wholeCrop, Ft as createImageProcessor, I as compositionSize, It as createImageEngine, J as FORBIDDEN_IN_TEXT, Jt as isImageError, Kt as asImageError, L as compositionToSource, Lt as engineInternals, M as handleInSource, N as moveCrop, Nt as fittedView, O as compositionDeltaToSource, P as nudgeCropOnScreen, Pt as placement, R as cropRect, Rt as ANIMATION_LIMITS, T as simplifyStroke, Tt as MAX_STROKE_WIDTH, _ as layerToScene, _t as MAX_FRAME_DELAY, a as compositionRectToScene, at as MAX_METADATA_LENGTH, b as createImageKey, bt as MAX_LAYER_TEXT_LENGTH, ct as DEVELOP_ADJUSTMENTS, d as sceneRectToComposition, dt as LAYER_ALIGNMENTS, f as applyMatrix, ft as LAYER_FONTS, g as layerToOutput, i as newLayerBox, j as fitAspect, k as cropInComposition, kt as createPlan, lt as FILTER_PRESETS, m as invertMatrix, n as createImageSession, o as fitRedactionRegion, q as createImageReducer, r as keepsFields, st as longerThan, t as imageMessages, x as arrowBounds, y as sceneToOutput } from "./core-CCE45OTe.js";
|
|
2
2
|
import { applyCommands, createMessages, createShortcutRegistry, createStore, createToolRegistry, defineMessages, defineTool, plural } from "@hussmartinez/sdk-core";
|
|
3
3
|
import { AddIcon, AnnouncerProvider, ArrowIcon, Button, CloseIcon, ColorField, CropIcon, DeleteIcon, Dialog, DownloadIcon, DuplicateIcon, EllipseIcon, Field, FileDropZone, FitIcon, FlipHorizontalIcon, FlipVerticalIcon, HiddenIcon, IconButton, LayersIcon, MoveDownIcon, MoveUpIcon, NumberField, OpenIcon, PageGridIcon, PauseIcon, PenIcon, PlayIcon, ProgressBar, RectangleIcon, RedactIcon, RedoIcon, ReorderableList, ReorderableListItem, RotateLeftIcon, RotateRightIcon, SearchIcon, SegmentedControl, Slider, Spinner, TextArea, TextField, TextIcon, ToggleButton, Toolbar, ToolbarGroup, Tooltip, UiMessagesProvider, UndoIcon, VisibleIcon, ZoomInIcon, ZoomOutIcon, useAnnounce, usePlatform } from "@hussmartinez/ui/react";
|
|
4
4
|
import { createContext, forwardRef, useContext, useEffect, useId, useImperativeHandle, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
@@ -982,11 +982,7 @@ function useRedactActions() {
|
|
|
982
982
|
}]
|
|
983
983
|
}]);
|
|
984
984
|
},
|
|
985
|
-
commit(
|
|
986
|
-
if (soon) {
|
|
987
|
-
gesture.commitSoon();
|
|
988
|
-
return;
|
|
989
|
-
}
|
|
985
|
+
commit() {
|
|
990
986
|
const drew = gesture.active() && count();
|
|
991
987
|
gesture.commit();
|
|
992
988
|
if (drew !== false && count() > drew) announce(messages.t("redact.added", { count: count() }));
|
|
@@ -1157,9 +1153,8 @@ function useLayerActions() {
|
|
|
1157
1153
|
}]
|
|
1158
1154
|
}]);
|
|
1159
1155
|
},
|
|
1160
|
-
commit(
|
|
1161
|
-
|
|
1162
|
-
else gesture.commit();
|
|
1156
|
+
commit() {
|
|
1157
|
+
gesture.commit();
|
|
1163
1158
|
},
|
|
1164
1159
|
cancel() {
|
|
1165
1160
|
gesture.cancel();
|
|
@@ -1925,6 +1920,45 @@ function DrawOverlay(props) {
|
|
|
1925
1920
|
onPointerCancel: onPointerEnd
|
|
1926
1921
|
});
|
|
1927
1922
|
}
|
|
1923
|
+
// src/react/key-run.ts
|
|
1924
|
+
function createKeyRun() {
|
|
1925
|
+
const held = /* @__PURE__ */ new Set();
|
|
1926
|
+
let running = false;
|
|
1927
|
+
let cancelled = false;
|
|
1928
|
+
return {
|
|
1929
|
+
press(key) {
|
|
1930
|
+
held.add(key);
|
|
1931
|
+
if (cancelled) return false;
|
|
1932
|
+
running = true;
|
|
1933
|
+
return true;
|
|
1934
|
+
},
|
|
1935
|
+
release(key) {
|
|
1936
|
+
if (!held.delete(key) || held.size > 0) return false;
|
|
1937
|
+
const ended = running && !cancelled;
|
|
1938
|
+
running = false;
|
|
1939
|
+
cancelled = false;
|
|
1940
|
+
return ended;
|
|
1941
|
+
},
|
|
1942
|
+
cancel() {
|
|
1943
|
+
if (!running) return false;
|
|
1944
|
+
running = false;
|
|
1945
|
+
cancelled = held.size > 0;
|
|
1946
|
+
return true;
|
|
1947
|
+
},
|
|
1948
|
+
handOff() {
|
|
1949
|
+
const ended = running && !cancelled;
|
|
1950
|
+
running = false;
|
|
1951
|
+
return ended;
|
|
1952
|
+
},
|
|
1953
|
+
leave() {
|
|
1954
|
+
held.clear();
|
|
1955
|
+
const ended = running && !cancelled;
|
|
1956
|
+
running = false;
|
|
1957
|
+
cancelled = false;
|
|
1958
|
+
return ended;
|
|
1959
|
+
}
|
|
1960
|
+
};
|
|
1961
|
+
}
|
|
1928
1962
|
// src/react/layers/frame-geometry.ts
|
|
1929
1963
|
var isBoxedLayer = (layer) => layer.kind === "text" || layer.kind === "shape" || layer.kind === "image";
|
|
1930
1964
|
var LAYER_HANDLES = [
|
|
@@ -2043,6 +2077,7 @@ function LayersOverlay(props) {
|
|
|
2043
2077
|
const describedBy = useId();
|
|
2044
2078
|
const drag = useRef(void 0);
|
|
2045
2079
|
const focusNext = useRef(null);
|
|
2080
|
+
const keys = useRef(createKeyRun());
|
|
2046
2081
|
const frameOf = (key) => overlay.current?.querySelector(`[data-hm-layer="${CSS.escape(key)}"]`);
|
|
2047
2082
|
useEffect(() => {
|
|
2048
2083
|
const key = focusNext.current;
|
|
@@ -2100,6 +2135,7 @@ function LayersOverlay(props) {
|
|
|
2100
2135
|
};
|
|
2101
2136
|
const onFramePointerDown = (layer, part) => (event) => {
|
|
2102
2137
|
if (event.button !== 0) return;
|
|
2138
|
+
if (keys.current.handOff()) actions.commit();
|
|
2103
2139
|
event.preventDefault();
|
|
2104
2140
|
event.stopPropagation();
|
|
2105
2141
|
actions.select(layer.key);
|
|
@@ -2141,7 +2177,8 @@ function LayersOverlay(props) {
|
|
|
2141
2177
|
if (drag.current) {
|
|
2142
2178
|
drag.current = void 0;
|
|
2143
2179
|
actions.cancel();
|
|
2144
|
-
} else actions.
|
|
2180
|
+
} else if (keys.current.cancel()) actions.cancel();
|
|
2181
|
+
else actions.done();
|
|
2145
2182
|
return;
|
|
2146
2183
|
}
|
|
2147
2184
|
if (event.altKey || event.ctrlKey || event.metaKey) return;
|
|
@@ -2157,10 +2194,17 @@ function LayersOverlay(props) {
|
|
|
2157
2194
|
if (!arrow) return;
|
|
2158
2195
|
event.preventDefault();
|
|
2159
2196
|
event.stopPropagation();
|
|
2197
|
+
if (drag.current) return;
|
|
2198
|
+
if (!keys.current.press(event.key)) return;
|
|
2160
2199
|
const fields = nudgeOf(layer, arrow[0], arrow[1], event.shiftKey);
|
|
2161
2200
|
if (!fields) return;
|
|
2162
2201
|
actions.moving(layer.key, fields);
|
|
2163
|
-
|
|
2202
|
+
};
|
|
2203
|
+
const onKeyUp = (event) => {
|
|
2204
|
+
if (ARROWS$1[event.key] && keys.current.release(event.key)) actions.commit();
|
|
2205
|
+
};
|
|
2206
|
+
const onBlur = () => {
|
|
2207
|
+
if (keys.current.leave()) actions.commit();
|
|
2164
2208
|
};
|
|
2165
2209
|
const count = plan.layers.length;
|
|
2166
2210
|
const shown = plan.layers.filter((layer) => layer.visible || layer.key === selected);
|
|
@@ -2190,6 +2234,8 @@ function LayersOverlay(props) {
|
|
|
2190
2234
|
tabIndex: layer.key === tabStop ? 0 : -1,
|
|
2191
2235
|
onFocus: () => actions.select(layer.key),
|
|
2192
2236
|
onKeyDown: onKeyDown(layer),
|
|
2237
|
+
onKeyUp,
|
|
2238
|
+
onBlur,
|
|
2193
2239
|
onPointerDown: onFramePointerDown(layer, "move"),
|
|
2194
2240
|
...pointer
|
|
2195
2241
|
};
|
|
@@ -2325,6 +2371,7 @@ function RedactOverlay(props) {
|
|
|
2325
2371
|
const describedBy = useId();
|
|
2326
2372
|
const drag = useRef(void 0);
|
|
2327
2373
|
const focusNext = useRef(null);
|
|
2374
|
+
const keys = useRef(createKeyRun());
|
|
2328
2375
|
const selected = state.redact?.selected ?? null;
|
|
2329
2376
|
const exists = plan.redactions.some((redaction) => redaction.key === selected);
|
|
2330
2377
|
const previous = useRef(null);
|
|
@@ -2362,6 +2409,7 @@ function RedactOverlay(props) {
|
|
|
2362
2409
|
};
|
|
2363
2410
|
const onFramePointerDown = (redaction, handle) => (event) => {
|
|
2364
2411
|
if (event.button !== 0) return;
|
|
2412
|
+
if (keys.current.handOff()) actions.commit();
|
|
2365
2413
|
event.preventDefault();
|
|
2366
2414
|
event.stopPropagation();
|
|
2367
2415
|
actions.select(redaction.key);
|
|
@@ -2379,6 +2427,7 @@ function RedactOverlay(props) {
|
|
|
2379
2427
|
};
|
|
2380
2428
|
const onBackgroundPointerDown = (event) => {
|
|
2381
2429
|
if (event.button !== 0) return;
|
|
2430
|
+
if (keys.current.handOff()) actions.commit();
|
|
2382
2431
|
event.preventDefault();
|
|
2383
2432
|
capture(event);
|
|
2384
2433
|
const at = onComposition(event);
|
|
@@ -2452,7 +2501,8 @@ function RedactOverlay(props) {
|
|
|
2452
2501
|
if (drag.current) {
|
|
2453
2502
|
drag.current = void 0;
|
|
2454
2503
|
actions.cancel();
|
|
2455
|
-
} else actions.
|
|
2504
|
+
} else if (keys.current.cancel()) actions.cancel();
|
|
2505
|
+
else actions.done();
|
|
2456
2506
|
return;
|
|
2457
2507
|
}
|
|
2458
2508
|
if (event.key === "Delete" || event.key === "Backspace") {
|
|
@@ -2470,10 +2520,17 @@ function RedactOverlay(props) {
|
|
|
2470
2520
|
if (event.altKey || event.ctrlKey || event.metaKey) return;
|
|
2471
2521
|
event.preventDefault();
|
|
2472
2522
|
event.stopPropagation();
|
|
2523
|
+
if (drag.current) return;
|
|
2524
|
+
if (!keys.current.press(event.key)) return;
|
|
2473
2525
|
const [dx, dy] = arrow;
|
|
2474
2526
|
const moved = event.shiftKey ? dragged(shown(redaction), dx !== 0 ? "e" : "s", dx, dy) : dragged(shown(redaction), "move", dx, dy);
|
|
2475
2527
|
actions.moving(redaction.key, toScene(moved));
|
|
2476
|
-
|
|
2528
|
+
};
|
|
2529
|
+
const onKeyUp = (event) => {
|
|
2530
|
+
if (ARROWS[event.key] && keys.current.release(event.key)) actions.commit();
|
|
2531
|
+
};
|
|
2532
|
+
const onBlur = () => {
|
|
2533
|
+
if (keys.current.leave()) actions.commit();
|
|
2477
2534
|
};
|
|
2478
2535
|
const count = plan.redactions.length;
|
|
2479
2536
|
const tabStop = exists ? selected : plan.redactions[0]?.key;
|
|
@@ -2504,6 +2561,8 @@ function RedactOverlay(props) {
|
|
|
2504
2561
|
},
|
|
2505
2562
|
onFocus: () => actions.select(redaction.key),
|
|
2506
2563
|
onKeyDown: onKeyDown(redaction),
|
|
2564
|
+
onKeyUp,
|
|
2565
|
+
onBlur,
|
|
2507
2566
|
onPointerDown: onFramePointerDown(redaction, "move"),
|
|
2508
2567
|
...pointer,
|
|
2509
2568
|
children: [/* @__PURE__ */ jsx("span", {
|
|
@@ -5124,4 +5183,4 @@ var ImageEditor = forwardRef(function ImageEditor(props, ref) {
|
|
|
5124
5183
|
});
|
|
5125
5184
|
export { imageTools as S, useImageDocument as _, ImageFilterPanel as a, useImageSession as b, ImageLayersPanel as c, imageEditorMessages as d, ImageExportDialog as f, ImageCropPanel as g, ImageDrawPanel as h, ImageInfoPanel as i, ImageFramesPanel as l, ImageStage as m, imageIcons as n, ImageAdjustPanel as o, ExportListenerContext as p, ImageToolbar as r, ImageRedactPanel as s, ImageEditor as t, ImageEditorProvider as u, useImageEditorState as v, useImageView as x, useImageMessages as y };
|
|
5126
5185
|
|
|
5127
|
-
//# sourceMappingURL=editor-
|
|
5186
|
+
//# sourceMappingURL=editor-CJEZNOqH.js.map
|