@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pictor-sdk/ui",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "Default slot-based editor UI for Pictor, built entirely on the public headless API.",
5
5
  "license": "MIT",
6
6
  "sideEffects": false,
@@ -33,8 +33,8 @@
33
33
  "react-native-gesture-handler": ">=2.20.0",
34
34
  "react-native-reanimated": ">=3.16.0",
35
35
  "react-native-worklets": ">=0.5.1",
36
- "@pictor-sdk/skia": "^0.2.1",
37
- "@pictor-sdk/core": "^0.2.0"
36
+ "@pictor-sdk/core": "^0.2.0",
37
+ "@pictor-sdk/skia": "^0.3.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@shopify/react-native-skia": "^2.0.0",
@@ -45,7 +45,7 @@
45
45
  "react-native-reanimated": "^4.1.0",
46
46
  "react-native-worklets": "0.5.1",
47
47
  "@pictor-sdk/core": "0.2.0",
48
- "@pictor-sdk/skia": "0.2.1"
48
+ "@pictor-sdk/skia": "0.3.0"
49
49
  },
50
50
  "publishConfig": {
51
51
  "access": "public",
package/src/index.ts CHANGED
@@ -67,7 +67,7 @@ export { StickerPanel, type StickerAsset } from './panels/StickerPanel'
67
67
  export { LayersPanel } from './panels/LayersPanel'
68
68
  export { LayoutPanel } from './panels/LayoutPanel'
69
69
  export { layoutCells, cellToTransformPatch, type LayoutCell, type LayoutPreset } from './panels/layoutMath'
70
- export { layoutCellBounds, fitImageToLayoutCell, type LayoutCropOptions, type LayoutImageFit } from './panels/layoutMath'
70
+ export { layoutCellBounds, layoutCellBox, fitImageToLayoutCell, type LayoutCropOptions, type LayoutImageFit } from './panels/layoutMath'
71
71
  export { DrawingSurface, DEFAULT_BRUSH } from './gestures/DrawingSurface'
72
72
  export { createDrawController, type BrushConfig, type DrawController } from './gestures/drawController'
73
73
  export { UiStateProvider, useUiState, createUiStateStore, type UiStateStore } from './uiState'
@@ -110,3 +110,26 @@ export function fitImageToLayoutCell(
110
110
  export function cellToTransformPatch(cell: LayoutCell): Partial<Transform> {
111
111
  return { x: cell.x, y: cell.y, scale: cell.scale, rotation: 0 }
112
112
  }
113
+
114
+ /**
115
+ * The box a photo draws into when it fills one cell, in document pixels.
116
+ *
117
+ * The cell fixes the box: `fitImageToLayoutCell` picks a crop whose aspect
118
+ * matches the cell, so zooming and panning inside it move the source window
119
+ * and leave the box alone. That is what makes a live crop expressible as a
120
+ * source-space override at all, and it is why a cell's bounds cannot drift
121
+ * while a gesture is running.
122
+ *
123
+ * Paired with `imageSourceTransform` from `@pictor-sdk/skia`, this is
124
+ * everything a host needs to draw an uncommitted crop from a worklet, using
125
+ * the renderer's own arithmetic rather than a second copy of it.
126
+ *
127
+ * @experimental
128
+ */
129
+ export function layoutCellBox(cell: Rect, documentSize: Size): Size {
130
+ 'worklet'
131
+ return {
132
+ width: cell.width * documentSize.width,
133
+ height: cell.height * documentSize.height,
134
+ }
135
+ }