@pictor-sdk/ui 0.2.2 → 0.3.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/index.d.mts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +1 -1
- package/src/panels/layoutMath.ts +23 -0
package/dist/index.d.mts
CHANGED
|
@@ -827,6 +827,22 @@ interface LayoutImageFit {
|
|
|
827
827
|
declare function fitImageToLayoutCell(cell: Rect, documentSize: Size, intrinsic: Size, options?: LayoutCropOptions): LayoutImageFit;
|
|
828
828
|
/** The transform patch that moves a layer into a cell, leaving its other fields alone. */
|
|
829
829
|
declare function cellToTransformPatch(cell: LayoutCell): Partial<Transform>;
|
|
830
|
+
/**
|
|
831
|
+
* The box a photo draws into when it fills one cell, in document pixels.
|
|
832
|
+
*
|
|
833
|
+
* The cell fixes the box: `fitImageToLayoutCell` picks a crop whose aspect
|
|
834
|
+
* matches the cell, so zooming and panning inside it move the source window
|
|
835
|
+
* and leave the box alone. That is what makes a live crop expressible as a
|
|
836
|
+
* source-space override at all, and it is why a cell's bounds cannot drift
|
|
837
|
+
* while a gesture is running.
|
|
838
|
+
*
|
|
839
|
+
* Paired with `imageSourceTransform` from `@pictor-sdk/skia`, this is
|
|
840
|
+
* everything a host needs to draw an uncommitted crop from a worklet, using
|
|
841
|
+
* the renderer's own arithmetic rather than a second copy of it.
|
|
842
|
+
*
|
|
843
|
+
* @experimental
|
|
844
|
+
*/
|
|
845
|
+
declare function layoutCellBox(cell: Rect, documentSize: Size): Size;
|
|
830
846
|
|
|
831
847
|
/** The active brush: kind, colour and width. Width is a fraction of document width. */
|
|
832
848
|
interface BrushConfig {
|
|
@@ -882,4 +898,4 @@ declare function UiStateProvider({ children }: {
|
|
|
882
898
|
/** Read and write one key of the ephemeral UI state. Throws outside an `<Editor>`. */
|
|
883
899
|
declare function useUiState<T>(key: string, fallback: T): [T, (value: T) => void];
|
|
884
900
|
|
|
885
|
-
export { type AddPhotoController, type AddPhotoControllerOptions, AddPhotoPanel, AdjustPanel, type BrushConfig, CanvasStage, type CanvasStageProps, CropGestureSurface, type CropGestureSurfaceProps, CropGrid, CropPanel, DEFAULT_BRUSH, type DrawController, DrawPanel, DrawingSurface, Editor, EditorGestures, type EditorGesturesProps, type EditorProps, type EditorSlots, type EditorTheme, FilterStrip, type GestureController, type GestureControllerOptions, type GestureMetrics, type GestureSnapEvent, type GestureSurfaceKind, type HostCallbacks, HostCallbacksProvider, InteractionGuides, type InteractionGuidesProps, InteractionProvider, InvalidImageResultError, LayerGestureSurface, type LayerGestureSurfaceProps, LayersPanel, type LayoutCell, type LayoutCropOptions, type LayoutImageFit, LayoutPanel, type LayoutPreset, MediaPanel, type PartialTheme, STRAIGHTEN_LIMIT, Slider, type SliderProps, type StickerAsset, StickerPanel, StoryMediaGestureSurface, type StoryMediaGestureSurfaceProps, StraightenRuler, type StraightenRulerProps, TextComposer, TextComposerHost, type TextComposerProps, TextPanel, type TextSessionController, ThemeContext, ToolPanelHost, ToolRail, TopBar, type TopBarProps, UiStateProvider, type UiStateStore, type UseTextSessionOptions, canvasSizeForAspect, cellToTransformPatch, centeredCropForAspect, createAddPhotoController, createDrawController, createGestureController, createUiStateStore, defaultTheme, fitImageToLayoutCell, layoutCellBounds, layoutCells, mergeSlots, mergeTheme, radiansToStraighten, resolveGestureSurface, resolvePanel, straightenToRadians, useBaseImageLayer, useBaseMediaLayer, useHostCallbacks, useInteractionState, useTargetImageLayer, useTextSession, useTheme, useUiState };
|
|
901
|
+
export { type AddPhotoController, type AddPhotoControllerOptions, AddPhotoPanel, AdjustPanel, type BrushConfig, CanvasStage, type CanvasStageProps, CropGestureSurface, type CropGestureSurfaceProps, CropGrid, CropPanel, DEFAULT_BRUSH, type DrawController, DrawPanel, DrawingSurface, Editor, EditorGestures, type EditorGesturesProps, type EditorProps, type EditorSlots, type EditorTheme, FilterStrip, type GestureController, type GestureControllerOptions, type GestureMetrics, type GestureSnapEvent, type GestureSurfaceKind, type HostCallbacks, HostCallbacksProvider, InteractionGuides, type InteractionGuidesProps, InteractionProvider, InvalidImageResultError, LayerGestureSurface, type LayerGestureSurfaceProps, LayersPanel, type LayoutCell, type LayoutCropOptions, type LayoutImageFit, LayoutPanel, type LayoutPreset, MediaPanel, type PartialTheme, STRAIGHTEN_LIMIT, Slider, type SliderProps, type StickerAsset, StickerPanel, StoryMediaGestureSurface, type StoryMediaGestureSurfaceProps, StraightenRuler, type StraightenRulerProps, TextComposer, TextComposerHost, type TextComposerProps, TextPanel, type TextSessionController, ThemeContext, ToolPanelHost, ToolRail, TopBar, type TopBarProps, UiStateProvider, type UiStateStore, type UseTextSessionOptions, canvasSizeForAspect, cellToTransformPatch, centeredCropForAspect, createAddPhotoController, createDrawController, createGestureController, createUiStateStore, defaultTheme, fitImageToLayoutCell, layoutCellBounds, layoutCellBox, layoutCells, mergeSlots, mergeTheme, radiansToStraighten, resolveGestureSurface, resolvePanel, straightenToRadians, useBaseImageLayer, useBaseMediaLayer, useHostCallbacks, useInteractionState, useTargetImageLayer, useTextSession, useTheme, useUiState };
|
package/dist/index.d.ts
CHANGED
|
@@ -827,6 +827,22 @@ interface LayoutImageFit {
|
|
|
827
827
|
declare function fitImageToLayoutCell(cell: Rect, documentSize: Size, intrinsic: Size, options?: LayoutCropOptions): LayoutImageFit;
|
|
828
828
|
/** The transform patch that moves a layer into a cell, leaving its other fields alone. */
|
|
829
829
|
declare function cellToTransformPatch(cell: LayoutCell): Partial<Transform>;
|
|
830
|
+
/**
|
|
831
|
+
* The box a photo draws into when it fills one cell, in document pixels.
|
|
832
|
+
*
|
|
833
|
+
* The cell fixes the box: `fitImageToLayoutCell` picks a crop whose aspect
|
|
834
|
+
* matches the cell, so zooming and panning inside it move the source window
|
|
835
|
+
* and leave the box alone. That is what makes a live crop expressible as a
|
|
836
|
+
* source-space override at all, and it is why a cell's bounds cannot drift
|
|
837
|
+
* while a gesture is running.
|
|
838
|
+
*
|
|
839
|
+
* Paired with `imageSourceTransform` from `@pictor-sdk/skia`, this is
|
|
840
|
+
* everything a host needs to draw an uncommitted crop from a worklet, using
|
|
841
|
+
* the renderer's own arithmetic rather than a second copy of it.
|
|
842
|
+
*
|
|
843
|
+
* @experimental
|
|
844
|
+
*/
|
|
845
|
+
declare function layoutCellBox(cell: Rect, documentSize: Size): Size;
|
|
830
846
|
|
|
831
847
|
/** The active brush: kind, colour and width. Width is a fraction of document width. */
|
|
832
848
|
interface BrushConfig {
|
|
@@ -882,4 +898,4 @@ declare function UiStateProvider({ children }: {
|
|
|
882
898
|
/** Read and write one key of the ephemeral UI state. Throws outside an `<Editor>`. */
|
|
883
899
|
declare function useUiState<T>(key: string, fallback: T): [T, (value: T) => void];
|
|
884
900
|
|
|
885
|
-
export { type AddPhotoController, type AddPhotoControllerOptions, AddPhotoPanel, AdjustPanel, type BrushConfig, CanvasStage, type CanvasStageProps, CropGestureSurface, type CropGestureSurfaceProps, CropGrid, CropPanel, DEFAULT_BRUSH, type DrawController, DrawPanel, DrawingSurface, Editor, EditorGestures, type EditorGesturesProps, type EditorProps, type EditorSlots, type EditorTheme, FilterStrip, type GestureController, type GestureControllerOptions, type GestureMetrics, type GestureSnapEvent, type GestureSurfaceKind, type HostCallbacks, HostCallbacksProvider, InteractionGuides, type InteractionGuidesProps, InteractionProvider, InvalidImageResultError, LayerGestureSurface, type LayerGestureSurfaceProps, LayersPanel, type LayoutCell, type LayoutCropOptions, type LayoutImageFit, LayoutPanel, type LayoutPreset, MediaPanel, type PartialTheme, STRAIGHTEN_LIMIT, Slider, type SliderProps, type StickerAsset, StickerPanel, StoryMediaGestureSurface, type StoryMediaGestureSurfaceProps, StraightenRuler, type StraightenRulerProps, TextComposer, TextComposerHost, type TextComposerProps, TextPanel, type TextSessionController, ThemeContext, ToolPanelHost, ToolRail, TopBar, type TopBarProps, UiStateProvider, type UiStateStore, type UseTextSessionOptions, canvasSizeForAspect, cellToTransformPatch, centeredCropForAspect, createAddPhotoController, createDrawController, createGestureController, createUiStateStore, defaultTheme, fitImageToLayoutCell, layoutCellBounds, layoutCells, mergeSlots, mergeTheme, radiansToStraighten, resolveGestureSurface, resolvePanel, straightenToRadians, useBaseImageLayer, useBaseMediaLayer, useHostCallbacks, useInteractionState, useTargetImageLayer, useTextSession, useTheme, useUiState };
|
|
901
|
+
export { type AddPhotoController, type AddPhotoControllerOptions, AddPhotoPanel, AdjustPanel, type BrushConfig, CanvasStage, type CanvasStageProps, CropGestureSurface, type CropGestureSurfaceProps, CropGrid, CropPanel, DEFAULT_BRUSH, type DrawController, DrawPanel, DrawingSurface, Editor, EditorGestures, type EditorGesturesProps, type EditorProps, type EditorSlots, type EditorTheme, FilterStrip, type GestureController, type GestureControllerOptions, type GestureMetrics, type GestureSnapEvent, type GestureSurfaceKind, type HostCallbacks, HostCallbacksProvider, InteractionGuides, type InteractionGuidesProps, InteractionProvider, InvalidImageResultError, LayerGestureSurface, type LayerGestureSurfaceProps, LayersPanel, type LayoutCell, type LayoutCropOptions, type LayoutImageFit, LayoutPanel, type LayoutPreset, MediaPanel, type PartialTheme, STRAIGHTEN_LIMIT, Slider, type SliderProps, type StickerAsset, StickerPanel, StoryMediaGestureSurface, type StoryMediaGestureSurfaceProps, StraightenRuler, type StraightenRulerProps, TextComposer, TextComposerHost, type TextComposerProps, TextPanel, type TextSessionController, ThemeContext, ToolPanelHost, ToolRail, TopBar, type TopBarProps, UiStateProvider, type UiStateStore, type UseTextSessionOptions, canvasSizeForAspect, cellToTransformPatch, centeredCropForAspect, createAddPhotoController, createDrawController, createGestureController, createUiStateStore, defaultTheme, fitImageToLayoutCell, layoutCellBounds, layoutCellBox, layoutCells, mergeSlots, mergeTheme, radiansToStraighten, resolveGestureSurface, resolvePanel, straightenToRadians, useBaseImageLayer, useBaseMediaLayer, useHostCallbacks, useInteractionState, useTargetImageLayer, useTextSession, useTheme, useUiState };
|
package/dist/index.js
CHANGED
|
@@ -75,6 +75,7 @@ __export(index_exports, {
|
|
|
75
75
|
defaultTheme: () => defaultTheme,
|
|
76
76
|
fitImageToLayoutCell: () => fitImageToLayoutCell,
|
|
77
77
|
layoutCellBounds: () => layoutCellBounds,
|
|
78
|
+
layoutCellBox: () => layoutCellBox,
|
|
78
79
|
layoutCells: () => layoutCells,
|
|
79
80
|
mergeSlots: () => mergeSlots,
|
|
80
81
|
mergeTheme: () => mergeTheme,
|
|
@@ -2924,6 +2925,13 @@ function fitImageToLayoutCell(cell, documentSize, intrinsic, options = {}) {
|
|
|
2924
2925
|
function cellToTransformPatch(cell) {
|
|
2925
2926
|
return { x: cell.x, y: cell.y, scale: cell.scale, rotation: 0 };
|
|
2926
2927
|
}
|
|
2928
|
+
function layoutCellBox(cell, documentSize) {
|
|
2929
|
+
"worklet";
|
|
2930
|
+
return {
|
|
2931
|
+
width: cell.width * documentSize.width,
|
|
2932
|
+
height: cell.height * documentSize.height
|
|
2933
|
+
};
|
|
2934
|
+
}
|
|
2927
2935
|
|
|
2928
2936
|
// src/panels/LayoutPanel.tsx
|
|
2929
2937
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
@@ -4720,6 +4728,7 @@ function TextPanel() {
|
|
|
4720
4728
|
defaultTheme,
|
|
4721
4729
|
fitImageToLayoutCell,
|
|
4722
4730
|
layoutCellBounds,
|
|
4731
|
+
layoutCellBox,
|
|
4723
4732
|
layoutCells,
|
|
4724
4733
|
mergeSlots,
|
|
4725
4734
|
mergeTheme,
|