feat(photo-editor): Ajax Image Editor client (Photoshop-parity tools)

Photoshop-parity editor client: layers, selection/masking, brushes,
smart filters, LUT import, Quick Edit, mobile gestures, workspaces,
batch operations, and the service-worker versioning (v978->v1006).

Source: vendor/photocraft (ad1cff44) photo-editor client files, merged
onto upstream/dev (a8c147b2). Conflict resolution documented in
pr_work/A_conflicts.md; editor files taken from vendor/photocraft
(upstream's editor is an earlier snapshot of the same feature).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
pewdiepie-archdaemon
2026-10-15 11:57:35 +00:00
co-authored by Claude Opus 5.5
parent c74f475679
commit 5fac693c1c
290 changed files with 34358 additions and 766 deletions
@@ -0,0 +1,34 @@
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
EDITOR = ROOT / "static/js/galleryEditor.js"
def test_selection_bounds_helper_returns_document_scaled_bbox():
src = EDITOR.read_text(encoding="utf-8")
start = src.index("function _selectionBounds(mask, docW = 0, docH = 0) {")
block = src[start:src.index("function _activateSelectionCanvas", start)]
assert "data[(row + x) * 4 + 3] > 8" in block
assert "const sx = docW > 0 ? docW / mask.width : 1;" in block
assert "const sy = docH > 0 ? docH / mask.height : 1;" in block
assert "width: Math.max(1, Math.round((maxX - minX + 1) * sx))," in block
def test_crop_to_selection_is_a_deterministic_local_op():
src = EDITOR.read_text(encoding="utf-8")
assert "if (/\\bcrop\\b/.test(p) && /\\bselection\\b|\\bselected\\b/.test(p) && state.wandMask) {" in src
assert "const b = _selectionBounds(state.wandMask, state.imgWidth, state.imgHeight);" in src
assert "await _runQuickControlOp('document.crop', { x: b.x, y: b.y, width: b.width, height: b.height });" in src
def test_crop_to_selection_precedes_the_aspect_ratio_crop():
src = EDITOR.read_text(encoding="utf-8")
sel = src.index("if (/\\bcrop\\b/.test(p) && /\\bselection\\b|\\bselected\\b/.test(p) && state.wandMask) {")
ratio = src.index("const cropRect = (/\\bextend\\b|\\bexpand\\b/.test(p)) ? null : _formatCropRect(prompt, state.imgWidth, state.imgHeight);")
assert sel < ratio
def test_border_trim_fast_path_defers_to_the_selection_crop():
src = EDITOR.read_text(encoding="utf-8")
assert "if (tryLocal && /\\b(?:crop|trim)\\b/i.test(cropText) && !hasRatio && !/\\bselection\\b|\\bselected\\b/i.test(cropText)) {" in src