fix(studio): the book tools state every field once, and the server typechecks within its memory again

- The element, spread, document, page operation and card unions carry a
  name of their own, so the declarations of every schema that holds them
  refer to them instead of spelling them out again. The shared declarations
  shrink from 9 to 5.5 MB and the server's typecheck from 4.4 to 2.9 GB, so
  the build fits the image's 4 GB again.
- edit_book_page and revise_book_design take add by what the element is,
  with an id of its own; its look follows with style by that id in the same
  call, every look field described once. A change an assistant card kept
  with its look on add still reads and runs.
- restore_book_page states what every element has once, then each kind's
  own fields and the type the five travel kinds share, without defaults; the
  page is read as a spread again before it goes back.
- The theme links are explained once in the page edit's description, and
  style points a text's face, a shape's paint and outline and a photo's crop
  look at their one full description.
- The lockup roles live in a module of their own, so the operation schemas
  no longer import the lockup engine, whose cycle left the operations unset
  in the shared tests.
- The theme switches no longer fall through a comment, the newer document
  test follows the current revision, the line inspector names its stroke
  keys, a text's anchor reads no physical side, two shapes record the
  proportions they are drawn at, and the photo look and line tests follow
  the slider and the folded ornaments.
This commit is contained in:
Maurice
2026-10-23 22:03:51 +00:00
parent a32465ad32
commit cbf9325e7e
27 changed files with 447 additions and 142 deletions
@@ -146,13 +146,11 @@ export function LineInspector({
<Line label={t('journey.studio.strokeStyle')} wide>
<Choice
value={el.dash}
options={(
[
['solid', 'strokeSolid'],
['dashed', 'strokeDashed'],
['dotted', 'strokeDotted'],
] as const
).map(([value, key]) => ({ value, label: t(`journey.studio.${key}`) }))}
options={[
{ value: 'solid' as const, label: t('journey.studio.strokeSolid') },
{ value: 'dashed' as const, label: t('journey.studio.strokeDashed') },
{ value: 'dotted' as const, label: t('journey.studio.strokeDotted') },
]}
onPick={(dash) => set({ dash })}
/>
</Line>
@@ -1,7 +1,7 @@
import { PHOTO_DUOTONES, PHOTO_LOOK_STARTS, bookPhotoElementSchema, type BookPhotoElement } from '@trek/shared';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { fireEvent, render, screen } from '../../../../tests/helpers/render';
import { cleanup, fireEvent, render, screen } from '../../../../tests/helpers/render';
import { PhotoCropExtras, PhotoLookSections } from './StudioPhotoLook';
/**
@@ -40,9 +40,13 @@ describe('beside the crop', () => {
expect(set).not.toHaveBeenCalled();
fireEvent.pointerUp(slider);
expect(set).toHaveBeenCalledWith({ zoom: 1.5 });
fireEvent.change(slider, { target: { value: '1' } });
fireEvent.blur(slider);
expect(set).toHaveBeenLastCalledWith({ zoom: undefined });
// A zoomed picture taken back to 100 % leaves the zoom out of the document.
cleanup();
const zoomed = mount('crop', photo({ zoom: 1.5 }));
const back = screen.getByRole('slider');
fireEvent.change(back, { target: { value: '1' } });
fireEvent.blur(back);
expect(zoomed.set).toHaveBeenLastCalledWith({ zoom: undefined });
});
it('FE-STUDIO-LOOKUI-002: mirrors the picture and takes the mirror away again', () => {
@@ -71,7 +75,9 @@ describe('beside the crop', () => {
mount('crop', photo({ zoom: 2 }));
expect(screen.getByText('journey.studio.photo.dpi 127')).toBeTruthy();
expect(screen.getByText('journey.studio.photo.dpiLow 200')).toBeTruthy();
expect(screen.getByRole('status').className).toContain('is-low');
// The slider's own readout is an output, a status too; the warning is the one marked low.
const warning = screen.getAllByRole('status').find((el) => el.classList.contains('st-photo-dpi'));
expect(warning?.className).toContain('is-low');
});
it('FE-STUDIO-LOOKUI-006: shows nothing for an empty frame', () => {
+5 -3
View File
@@ -65,7 +65,9 @@ export function caseStyle(el: BookTextElement): {
return {};
}
const ANCHOR = { left: 'start', center: 'middle', right: 'end', justify: 'start' } as const;
/** The SVG anchor of a text's alignment, in the page's own left to right coordinates; justified sets from the start. */
const anchorOf = (align: BookTextElement['align']): 'start' | 'middle' | 'end' =>
align === 'center' ? 'middle' : align === 'right' ? 'end' : 'start';
/** How far across the frame, and along a curve, each anchor sits. */
const ACROSS = { start: 0, middle: 0.5, end: 1 } as const;
/** How far down the frame's spare room the block of lines sits. */
@@ -76,13 +78,13 @@ export function lineAnchor(
align: BookTextElement['align'],
w: number
): { x: number; anchor: 'start' | 'middle' | 'end' } {
const anchor = ANCHOR[align];
const anchor = anchorOf(align);
return { x: w * ACROSS[anchor], anchor };
}
/** The same anchor along a curve: where on the path the words are pinned. */
export function curveAnchor(align: BookTextElement['align']): { offset: string; anchor: 'start' | 'middle' | 'end' } {
const anchor = ANCHOR[align];
const anchor = anchorOf(align);
return { offset: `${ACROSS[anchor] * 100}%`, anchor };
}