@buoy-gg/image-overlay 2.1.11
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/lib/commonjs/imageOverlay/components/ImageOverlayModal.js +847 -0
- package/lib/commonjs/imageOverlay/components/ImageOverlayStandalone.js +455 -0
- package/lib/commonjs/imageOverlay/components/OverlayControls.js +253 -0
- package/lib/commonjs/imageOverlay/components/TargetList.js +183 -0
- package/lib/commonjs/imageOverlay/index.js +33 -0
- package/lib/commonjs/imageOverlay/types/index.js +1 -0
- package/lib/commonjs/imageOverlay/utils/ImageOverlayController.js +392 -0
- package/lib/commonjs/imageOverlay/utils/componentMeasurement.js +106 -0
- package/lib/commonjs/imageOverlay/utils/fiberScanner.js +101 -0
- package/lib/commonjs/index.js +46 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/preset.js +59 -0
- package/lib/module/imageOverlay/components/ImageOverlayModal.js +843 -0
- package/lib/module/imageOverlay/components/ImageOverlayStandalone.js +451 -0
- package/lib/module/imageOverlay/components/OverlayControls.js +249 -0
- package/lib/module/imageOverlay/components/TargetList.js +179 -0
- package/lib/module/imageOverlay/index.js +6 -0
- package/lib/module/imageOverlay/types/index.js +1 -0
- package/lib/module/imageOverlay/utils/ImageOverlayController.js +388 -0
- package/lib/module/imageOverlay/utils/componentMeasurement.js +102 -0
- package/lib/module/imageOverlay/utils/fiberScanner.js +97 -0
- package/lib/module/index.js +34 -0
- package/lib/module/preset.js +53 -0
- package/lib/typescript/imageOverlay/components/ImageOverlayModal.d.ts +3 -0
- package/lib/typescript/imageOverlay/components/ImageOverlayModal.d.ts.map +1 -0
- package/lib/typescript/imageOverlay/components/ImageOverlayStandalone.d.ts +12 -0
- package/lib/typescript/imageOverlay/components/ImageOverlayStandalone.d.ts.map +1 -0
- package/lib/typescript/imageOverlay/components/OverlayControls.d.ts +18 -0
- package/lib/typescript/imageOverlay/components/OverlayControls.d.ts.map +1 -0
- package/lib/typescript/imageOverlay/components/TargetList.d.ts +12 -0
- package/lib/typescript/imageOverlay/components/TargetList.d.ts.map +1 -0
- package/lib/typescript/imageOverlay/index.d.ts +6 -0
- package/lib/typescript/imageOverlay/index.d.ts.map +1 -0
- package/lib/typescript/imageOverlay/types/index.d.ts +53 -0
- package/lib/typescript/imageOverlay/types/index.d.ts.map +1 -0
- package/lib/typescript/imageOverlay/utils/ImageOverlayController.d.ts +34 -0
- package/lib/typescript/imageOverlay/utils/ImageOverlayController.d.ts.map +1 -0
- package/lib/typescript/imageOverlay/utils/componentMeasurement.d.ts +13 -0
- package/lib/typescript/imageOverlay/utils/componentMeasurement.d.ts.map +1 -0
- package/lib/typescript/imageOverlay/utils/fiberScanner.d.ts +13 -0
- package/lib/typescript/imageOverlay/utils/fiberScanner.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +14 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/preset.d.ts +46 -0
- package/lib/typescript/preset.d.ts.map +1 -0
- package/package.json +79 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Fiber tree scanner for discovering image-overlay targets.
|
|
5
|
+
* Finds components tagged with testID="image-target:LabelName".
|
|
6
|
+
*
|
|
7
|
+
* Core traversal adapted from debug-borders/utils/fiberTreeTraversal.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const IMAGE_TARGET_PREFIX = "image-target:";
|
|
11
|
+
|
|
12
|
+
// Fiber tag constants (from React internals)
|
|
13
|
+
const HostComponent = 5;
|
|
14
|
+
const OffscreenComponent = 22;
|
|
15
|
+
function getReactDevToolsHook() {
|
|
16
|
+
if (typeof global === "undefined") return null;
|
|
17
|
+
return global.__REACT_DEVTOOLS_GLOBAL_HOOK__ ?? null;
|
|
18
|
+
}
|
|
19
|
+
function getFiberRoots() {
|
|
20
|
+
const hook = getReactDevToolsHook();
|
|
21
|
+
if (!hook?.getFiberRoots) return [];
|
|
22
|
+
try {
|
|
23
|
+
const rootsSet = hook.getFiberRoots(1);
|
|
24
|
+
return rootsSet ? Array.from(rootsSet) : [];
|
|
25
|
+
} catch {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function isHiddenOffscreen(fiber) {
|
|
30
|
+
return fiber.tag === OffscreenComponent && fiber.memoizedState !== null;
|
|
31
|
+
}
|
|
32
|
+
function isInactiveScreen(fiber) {
|
|
33
|
+
return fiber.memoizedProps?.activityState === 0;
|
|
34
|
+
}
|
|
35
|
+
function traverseFiberTree(fiber, callback, depth = 0, visited = new Set()) {
|
|
36
|
+
if (!fiber || visited.has(fiber) || depth > 500) return;
|
|
37
|
+
visited.add(fiber);
|
|
38
|
+
if (isHiddenOffscreen(fiber)) {
|
|
39
|
+
if (fiber.sibling) traverseFiberTree(fiber.sibling, callback, depth, visited);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (isInactiveScreen(fiber)) {
|
|
43
|
+
if (fiber.sibling) traverseFiberTree(fiber.sibling, callback, depth, visited);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
callback(fiber, depth);
|
|
47
|
+
if (fiber.child) traverseFiberTree(fiber.child, callback, depth + 1, visited);
|
|
48
|
+
if (fiber.sibling) traverseFiberTree(fiber.sibling, callback, depth, visited);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Walk the fiber tree upward to find the owning user-defined React component name.
|
|
53
|
+
*/
|
|
54
|
+
function getOwningComponentName(fiber) {
|
|
55
|
+
const internalNames = new Set(["View", "RCTView", "Text", "RCTText", "Image", "RCTImageView", "ScrollView", "RCTScrollView", "TextInput", "RCTTextInput", "TouchableOpacity", "TouchableHighlight", "TouchableWithoutFeedback", "Pressable", "FlatList", "SectionList", "SafeAreaView"]);
|
|
56
|
+
let current = fiber._debugOwner || fiber.return;
|
|
57
|
+
let depth = 0;
|
|
58
|
+
while (current && depth < 30) {
|
|
59
|
+
depth++;
|
|
60
|
+
const type = current.type;
|
|
61
|
+
if (type) {
|
|
62
|
+
const name = typeof type === "string" ? type : type.displayName || type.name;
|
|
63
|
+
if (name && !internalNames.has(name)) {
|
|
64
|
+
return name;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
current = current.return;
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Scan the React fiber tree for components with testID="image-target:*".
|
|
74
|
+
* Returns an array of discovered targets with their fiber references for measurement.
|
|
75
|
+
*/
|
|
76
|
+
export function scanForImageTargets() {
|
|
77
|
+
const roots = getFiberRoots();
|
|
78
|
+
if (roots.length === 0) return [];
|
|
79
|
+
const targets = [];
|
|
80
|
+
for (const root of roots) {
|
|
81
|
+
traverseFiberTree(root.current, fiber => {
|
|
82
|
+
if (fiber.tag !== HostComponent) return;
|
|
83
|
+
const testID = fiber.memoizedProps?.testID ?? fiber.pendingProps?.testID;
|
|
84
|
+
if (!testID || !testID.startsWith(IMAGE_TARGET_PREFIX)) return;
|
|
85
|
+
const label = testID.slice(IMAGE_TARGET_PREFIX.length);
|
|
86
|
+
if (!label) return;
|
|
87
|
+
targets.push({
|
|
88
|
+
label,
|
|
89
|
+
testID,
|
|
90
|
+
fiber,
|
|
91
|
+
instance: fiber.stateNode,
|
|
92
|
+
componentName: getOwningComponentName(fiber)
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return targets;
|
|
97
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @buoy-gg/image-overlay
|
|
5
|
+
*
|
|
6
|
+
* Image overlay tool for comparing design mockups against your running app.
|
|
7
|
+
*
|
|
8
|
+
* PUBLIC API - Only these exports are supported for external use.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// =============================================================================
|
|
12
|
+
// PRESET (Primary entry point for users)
|
|
13
|
+
// =============================================================================
|
|
14
|
+
export { imageOverlayToolPreset, createImageOverlayTool } from "./preset";
|
|
15
|
+
|
|
16
|
+
// =============================================================================
|
|
17
|
+
// COMPONENTS (For custom UI implementations)
|
|
18
|
+
// =============================================================================
|
|
19
|
+
export { ImageOverlayModal } from "./imageOverlay/components/ImageOverlayModal";
|
|
20
|
+
export { ImageOverlayStandalone } from "./imageOverlay/components/ImageOverlayStandalone";
|
|
21
|
+
|
|
22
|
+
// =============================================================================
|
|
23
|
+
// CONTROLLER (For programmatic control)
|
|
24
|
+
// =============================================================================
|
|
25
|
+
export { ImageOverlayController } from "./imageOverlay/utils/ImageOverlayController";
|
|
26
|
+
|
|
27
|
+
// =============================================================================
|
|
28
|
+
// UTILITIES (For custom integrations)
|
|
29
|
+
// =============================================================================
|
|
30
|
+
export { scanForImageTargets } from "./imageOverlay/utils/fiberScanner";
|
|
31
|
+
|
|
32
|
+
// =============================================================================
|
|
33
|
+
// TYPES (For TypeScript users)
|
|
34
|
+
// =============================================================================
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Pre-configured image overlay tool for FloatingDevTools
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* import { imageOverlayToolPreset } from '@buoy-gg/image-overlay';
|
|
9
|
+
*
|
|
10
|
+
* const installedApps = [
|
|
11
|
+
* imageOverlayToolPreset,
|
|
12
|
+
* ];
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { ImageOverlayIcon } from "@buoy-gg/shared-ui";
|
|
17
|
+
import { ImageOverlayModal } from "./imageOverlay/components/ImageOverlayModal";
|
|
18
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
|
+
export const IMAGE_OVERLAY_ICON_COLOR = "#A855F7";
|
|
20
|
+
export const imageOverlayToolPreset = {
|
|
21
|
+
id: "image-overlay",
|
|
22
|
+
name: "IMG",
|
|
23
|
+
description: "Design mockup overlay",
|
|
24
|
+
slot: "both",
|
|
25
|
+
icon: ({
|
|
26
|
+
size
|
|
27
|
+
}) => /*#__PURE__*/_jsx(ImageOverlayIcon, {
|
|
28
|
+
size: size,
|
|
29
|
+
color: IMAGE_OVERLAY_ICON_COLOR
|
|
30
|
+
}),
|
|
31
|
+
component: ImageOverlayModal,
|
|
32
|
+
props: {
|
|
33
|
+
enableSharedModalDimensions: false
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
export function createImageOverlayTool(options) {
|
|
37
|
+
return {
|
|
38
|
+
id: options?.id || "image-overlay",
|
|
39
|
+
name: options?.name || "IMG",
|
|
40
|
+
description: options?.description || "Design mockup overlay",
|
|
41
|
+
slot: "both",
|
|
42
|
+
icon: ({
|
|
43
|
+
size
|
|
44
|
+
}) => /*#__PURE__*/_jsx(ImageOverlayIcon, {
|
|
45
|
+
size: size,
|
|
46
|
+
color: IMAGE_OVERLAY_ICON_COLOR
|
|
47
|
+
}),
|
|
48
|
+
component: ImageOverlayModal,
|
|
49
|
+
props: {
|
|
50
|
+
enableSharedModalDimensions: options?.enableSharedModalDimensions !== undefined ? options.enableSharedModalDimensions : false
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ImageOverlayModalProps } from "../types";
|
|
2
|
+
export declare function ImageOverlayModal({ visible, onClose, onBack, onMinimize, enableSharedModalDimensions, initialModalState, minimizeTargetPosition, }: ImageOverlayModalProps): import("react").JSX.Element;
|
|
3
|
+
//# sourceMappingURL=ImageOverlayModal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImageOverlayModal.d.ts","sourceRoot":"","sources":["../../../../src/imageOverlay/components/ImageOverlayModal.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,sBAAsB,EAAkC,MAAM,UAAU,CAAC;AAWvF,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,OAAO,EACP,MAAM,EACN,UAAU,EACV,2BAAmC,EACnC,iBAAiB,EACjB,sBAAsB,GACvB,EAAE,sBAAsB,+BAshBxB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standalone overlay that renders:
|
|
3
|
+
* - Component mode: highlight border + image overlay on a tagged component
|
|
4
|
+
* - Free mode: draggable, resizable image anywhere on screen (aspect-ratio locked)
|
|
5
|
+
*
|
|
6
|
+
* Supports Normal, Difference, and Multiply blend modes.
|
|
7
|
+
* Supports image inversion (flip X/Y) and position locking.
|
|
8
|
+
* Auto-mounted by FloatingDevTools alongside other standalone overlays.
|
|
9
|
+
*/
|
|
10
|
+
import React from "react";
|
|
11
|
+
export declare function ImageOverlayStandalone(): React.ReactElement | null;
|
|
12
|
+
//# sourceMappingURL=ImageOverlayStandalone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImageOverlayStandalone.d.ts","sourceRoot":"","sources":["../../../../src/imageOverlay/components/ImageOverlayStandalone.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAA4D,MAAM,OAAO,CAAC;AAuNjF,wBAAgB,sBAAsB,IAAI,KAAK,CAAC,YAAY,GAAG,IAAI,CAuFlE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Controls for adjusting the overlay: opacity, scale, offset.
|
|
3
|
+
* Each control has a slider track plus -/+ stepper buttons.
|
|
4
|
+
*/
|
|
5
|
+
interface OverlayControlsProps {
|
|
6
|
+
opacity: number;
|
|
7
|
+
scale: number;
|
|
8
|
+
offsetX: number;
|
|
9
|
+
offsetY: number;
|
|
10
|
+
onOpacityChange: (value: number) => void;
|
|
11
|
+
onScaleChange: (value: number) => void;
|
|
12
|
+
onOffsetChange: (x: number, y: number) => void;
|
|
13
|
+
/** Only show opacity control */
|
|
14
|
+
opacityOnly?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function OverlayControls({ opacity, scale, offsetX, offsetY, onOpacityChange, onScaleChange, onOffsetChange, opacityOnly, }: OverlayControlsProps): import("react").JSX.Element;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=OverlayControls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OverlayControls.d.ts","sourceRoot":"","sources":["../../../../src/imageOverlay/components/OverlayControls.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAmIH,UAAU,oBAAoB;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,cAAc,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,gCAAgC;IAChC,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,wBAAgB,eAAe,CAAC,EAC9B,OAAO,EACP,KAAK,EACL,OAAO,EACP,OAAO,EACP,eAAe,EACf,aAAa,EACb,cAAc,EACd,WAAW,GACZ,EAAE,oBAAoB,+BAuDtB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* List of discovered image-overlay target components.
|
|
3
|
+
* Styled to match RenderListItem from highlight-updates.
|
|
4
|
+
*/
|
|
5
|
+
import type { DiscoveredTarget } from "../types";
|
|
6
|
+
interface TargetListProps {
|
|
7
|
+
targets: DiscoveredTarget[];
|
|
8
|
+
onSelect: (target: DiscoveredTarget) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function TargetList({ targets, onSelect }: TargetListProps): import("react").JSX.Element;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=TargetList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TargetList.d.ts","sourceRoot":"","sources":["../../../../src/imageOverlay/components/TargetList.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAwCjD,UAAU,eAAe;IACvB,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,QAAQ,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAC;CAC9C;AAED,wBAAgB,UAAU,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,eAAe,+BAuBhE"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { ImageOverlayModal } from "./components/ImageOverlayModal";
|
|
2
|
+
export { ImageOverlayStandalone } from "./components/ImageOverlayStandalone";
|
|
3
|
+
export { ImageOverlayController } from "./utils/ImageOverlayController";
|
|
4
|
+
export { scanForImageTargets } from "./utils/fiberScanner";
|
|
5
|
+
export type { ImageOverlayModalProps, OverlayState, OverlayMode, MeasuredRect, DiscoveredTarget, } from "./types";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/imageOverlay/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,YAAY,EACV,sBAAsB,EACtB,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,gBAAgB,GACjB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Image Overlay DevTools types
|
|
3
|
+
*/
|
|
4
|
+
export interface MeasuredRect {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
}
|
|
10
|
+
export type OverlayMode = "component" | "free" | null;
|
|
11
|
+
export interface OverlayState {
|
|
12
|
+
mode: OverlayMode;
|
|
13
|
+
enabled: boolean;
|
|
14
|
+
imageUri: string | null;
|
|
15
|
+
imageWidth: number | null;
|
|
16
|
+
imageHeight: number | null;
|
|
17
|
+
targetTag: number | null;
|
|
18
|
+
targetLabel: string | null;
|
|
19
|
+
targetRect: MeasuredRect | null;
|
|
20
|
+
showOutline: boolean;
|
|
21
|
+
opacity: number;
|
|
22
|
+
scale: number;
|
|
23
|
+
offsetX: number;
|
|
24
|
+
offsetY: number;
|
|
25
|
+
invertX: boolean;
|
|
26
|
+
invertY: boolean;
|
|
27
|
+
locked: boolean;
|
|
28
|
+
freeX: number;
|
|
29
|
+
freeY: number;
|
|
30
|
+
freeWidth: number;
|
|
31
|
+
freeHeight: number;
|
|
32
|
+
}
|
|
33
|
+
export interface DiscoveredTarget {
|
|
34
|
+
label: string;
|
|
35
|
+
testID: string;
|
|
36
|
+
fiber: any;
|
|
37
|
+
instance: any;
|
|
38
|
+
componentName: string | null;
|
|
39
|
+
}
|
|
40
|
+
export interface ImageOverlayModalProps {
|
|
41
|
+
visible: boolean;
|
|
42
|
+
onClose: () => void;
|
|
43
|
+
onBack?: () => void;
|
|
44
|
+
onMinimize?: (modalState: unknown) => void;
|
|
45
|
+
enableSharedModalDimensions?: boolean;
|
|
46
|
+
initialModalState?: any;
|
|
47
|
+
minimizeTargetPosition?: {
|
|
48
|
+
x: number;
|
|
49
|
+
y: number;
|
|
50
|
+
};
|
|
51
|
+
[key: string]: any;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/imageOverlay/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,YAAY;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,MAAM,GAAG,IAAI,CAAC;AACtD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAE3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,YAAY,GAAG,IAAI,CAAC;IAChC,WAAW,EAAE,OAAO,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAEhB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,GAAG,CAAC;IACX,QAAQ,EAAE,GAAG,CAAC;IACd,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,UAAU,CAAC,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,iBAAiB,CAAC,EAAE,GAAG,CAAC;IACxB,sBAAsB,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAClD,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Singleton state manager for the image overlay tool.
|
|
3
|
+
* Bridges the modal (controls) and standalone overlay (rendering).
|
|
4
|
+
* Supports two modes: "component" (match to tagged element) and "free" (drag anywhere).
|
|
5
|
+
*/
|
|
6
|
+
import type { OverlayState } from "../types";
|
|
7
|
+
type Listener = (state: OverlayState) => void;
|
|
8
|
+
export declare const ImageOverlayController: {
|
|
9
|
+
subscribe(listener: Listener): () => void;
|
|
10
|
+
getState(): OverlayState;
|
|
11
|
+
setTarget(instance: any, label: string, fiber?: any): Promise<void>;
|
|
12
|
+
setImageUri(uri: string): Promise<void>;
|
|
13
|
+
setOpacity(value: number): void;
|
|
14
|
+
setScale(value: number): void;
|
|
15
|
+
setOffset(x: number, y: number): void;
|
|
16
|
+
toggleInvertX(): void;
|
|
17
|
+
toggleInvertY(): void;
|
|
18
|
+
setLocked(locked: boolean): void;
|
|
19
|
+
setAutoTrack(enabled: boolean): void;
|
|
20
|
+
isAutoTracking(): boolean;
|
|
21
|
+
setShowOutline(show: boolean): void;
|
|
22
|
+
setEnabled(enabled: boolean): void;
|
|
23
|
+
toggle(): void;
|
|
24
|
+
fitWidth(): void;
|
|
25
|
+
fitHeight(): void;
|
|
26
|
+
resetSettings(): void;
|
|
27
|
+
remeasure(): Promise<void>;
|
|
28
|
+
startFreeMode(uri: string): Promise<void>;
|
|
29
|
+
setFreePosition(x: number, y: number): void;
|
|
30
|
+
setFreeDimensions(width: number, height: number, x: number, y: number): void;
|
|
31
|
+
reset(): void;
|
|
32
|
+
};
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=ImageOverlayController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImageOverlayController.d.ts","sourceRoot":"","sources":["../../../../src/imageOverlay/utils/ImageOverlayController.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAgB,YAAY,EAAE,MAAM,UAAU,CAAC;AAI3D,KAAK,QAAQ,GAAG,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;AAqI9C,eAAO,MAAM,sBAAsB;wBACb,QAAQ,GAAG,MAAM,IAAI;gBAM7B,YAAY;wBAME,GAAG,SAAS,MAAM,UAAU,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;qBAmBlD,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;sBAmB3B,MAAM;oBAKR,MAAM;iBAKT,MAAM,KAAK,MAAM;;;sBAeZ,OAAO;0BAKH,OAAO;sBASX,OAAO;yBAIJ,OAAO;wBAKR,OAAO;;;;;iBA+CR,OAAO,CAAC,IAAI,CAAC;uBAYP,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;uBAkC5B,MAAM,KAAK,MAAM;6BAKX,MAAM,UAAU,MAAM,KAAK,MAAM,KAAK,MAAM;;CAgBtE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component measurement utilities for image overlay positioning.
|
|
3
|
+
* Adapted from debug-borders/utils/componentMeasurement.js
|
|
4
|
+
*
|
|
5
|
+
* Supports both Fabric (new arch) and Paper (legacy) measurement APIs.
|
|
6
|
+
*/
|
|
7
|
+
import type { MeasuredRect } from "../types";
|
|
8
|
+
/**
|
|
9
|
+
* Measures a component instance and returns its screen-space bounding rect.
|
|
10
|
+
* Tries multiple strategies to handle Fabric, Paper, and edge cases.
|
|
11
|
+
*/
|
|
12
|
+
export declare function measureInstance(instance: any): Promise<MeasuredRect | null>;
|
|
13
|
+
//# sourceMappingURL=componentMeasurement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"componentMeasurement.d.ts","sourceRoot":"","sources":["../../../../src/imageOverlay/utils/componentMeasurement.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C;;;GAGG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAoG3E"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fiber tree scanner for discovering image-overlay targets.
|
|
3
|
+
* Finds components tagged with testID="image-target:LabelName".
|
|
4
|
+
*
|
|
5
|
+
* Core traversal adapted from debug-borders/utils/fiberTreeTraversal.js
|
|
6
|
+
*/
|
|
7
|
+
import type { DiscoveredTarget } from "../types";
|
|
8
|
+
/**
|
|
9
|
+
* Scan the React fiber tree for components with testID="image-target:*".
|
|
10
|
+
* Returns an array of discovered targets with their fiber references for measurement.
|
|
11
|
+
*/
|
|
12
|
+
export declare function scanForImageTargets(): DiscoveredTarget[];
|
|
13
|
+
//# sourceMappingURL=fiberScanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fiberScanner.d.ts","sourceRoot":"","sources":["../../../../src/imageOverlay/utils/fiberScanner.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAoFjD;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,gBAAgB,EAAE,CA6BxD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @buoy-gg/image-overlay
|
|
3
|
+
*
|
|
4
|
+
* Image overlay tool for comparing design mockups against your running app.
|
|
5
|
+
*
|
|
6
|
+
* PUBLIC API - Only these exports are supported for external use.
|
|
7
|
+
*/
|
|
8
|
+
export { imageOverlayToolPreset, createImageOverlayTool } from "./preset";
|
|
9
|
+
export { ImageOverlayModal } from "./imageOverlay/components/ImageOverlayModal";
|
|
10
|
+
export { ImageOverlayStandalone } from "./imageOverlay/components/ImageOverlayStandalone";
|
|
11
|
+
export { ImageOverlayController } from "./imageOverlay/utils/ImageOverlayController";
|
|
12
|
+
export { scanForImageTargets } from "./imageOverlay/utils/fiberScanner";
|
|
13
|
+
export type { ImageOverlayModalProps, OverlayState, OverlayMode, MeasuredRect, DiscoveredTarget, } from "./imageOverlay/types";
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAK1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AAChF,OAAO,EAAE,sBAAsB,EAAE,MAAM,kDAAkD,CAAC;AAK1F,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AAKrF,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAKxE,YAAY,EACV,sBAAsB,EACtB,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,gBAAgB,GACjB,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pre-configured image overlay tool for FloatingDevTools
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```tsx
|
|
6
|
+
* import { imageOverlayToolPreset } from '@buoy-gg/image-overlay';
|
|
7
|
+
*
|
|
8
|
+
* const installedApps = [
|
|
9
|
+
* imageOverlayToolPreset,
|
|
10
|
+
* ];
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
import { ImageOverlayModal } from "./imageOverlay/components/ImageOverlayModal";
|
|
14
|
+
export declare const IMAGE_OVERLAY_ICON_COLOR = "#A855F7";
|
|
15
|
+
export declare const imageOverlayToolPreset: {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
slot: "both";
|
|
20
|
+
icon: ({ size }: {
|
|
21
|
+
size: number;
|
|
22
|
+
}) => import("react").JSX.Element;
|
|
23
|
+
component: typeof ImageOverlayModal;
|
|
24
|
+
props: {
|
|
25
|
+
enableSharedModalDimensions: boolean;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export declare function createImageOverlayTool(options?: {
|
|
29
|
+
name?: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
id?: string;
|
|
32
|
+
enableSharedModalDimensions?: boolean;
|
|
33
|
+
}): {
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
description: string;
|
|
37
|
+
slot: "both";
|
|
38
|
+
icon: ({ size }: {
|
|
39
|
+
size: number;
|
|
40
|
+
}) => import("react").JSX.Element;
|
|
41
|
+
component: typeof ImageOverlayModal;
|
|
42
|
+
props: {
|
|
43
|
+
enableSharedModalDimensions: boolean;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=preset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preset.d.ts","sourceRoot":"","sources":["../../src/preset.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AAEhF,eAAO,MAAM,wBAAwB,YAAY,CAAC;AAElD,eAAO,MAAM,sBAAsB;;;;;qBAKhB;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;;;;;CAOlC,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,OAAO,CAAC,EAAE;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACvC;;;;;qBAMoB;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;;;;;EAWpC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@buoy-gg/image-overlay",
|
|
3
|
+
"version": "2.1.11",
|
|
4
|
+
"description": "Image overlay tool for matching design mockups",
|
|
5
|
+
"main": "lib/commonjs/index.js",
|
|
6
|
+
"module": "lib/module/index.js",
|
|
7
|
+
"types": "lib/typescript/index.d.ts",
|
|
8
|
+
"react-native": "lib/module/index.js",
|
|
9
|
+
"source": "src/index.tsx",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"react-native": "./lib/module/index.js",
|
|
13
|
+
"import": {
|
|
14
|
+
"default": "./lib/module/index.js",
|
|
15
|
+
"types": "./lib/typescript/index.d.ts"
|
|
16
|
+
},
|
|
17
|
+
"require": {
|
|
18
|
+
"default": "./lib/commonjs/index.js",
|
|
19
|
+
"types": "./lib/typescript/index.d.ts"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"./package.json": "./package.json"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"lib"
|
|
26
|
+
],
|
|
27
|
+
"sideEffects": false,
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "bob build",
|
|
30
|
+
"typecheck": "tsc --noEmit",
|
|
31
|
+
"prepublishOnly": "bob build",
|
|
32
|
+
"clean": "rimraf lib",
|
|
33
|
+
"test": "pnpm run typecheck"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@buoy-gg/shared-ui": "workspace:*"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"react": "*",
|
|
40
|
+
"react-native": "*"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/react": "^19.1.0",
|
|
44
|
+
"@types/react-native": "^0.73.0",
|
|
45
|
+
"typescript": "~5.8.3"
|
|
46
|
+
},
|
|
47
|
+
"react-native-builder-bob": {
|
|
48
|
+
"source": "src",
|
|
49
|
+
"output": "lib",
|
|
50
|
+
"targets": [
|
|
51
|
+
[
|
|
52
|
+
"commonjs",
|
|
53
|
+
{
|
|
54
|
+
"sourceMaps": false
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
[
|
|
58
|
+
"module",
|
|
59
|
+
{
|
|
60
|
+
"sourceMaps": false
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
"typescript"
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
"repository": {
|
|
67
|
+
"type": "git",
|
|
68
|
+
"url": "https://github.com/LovesWorking/react-native-buoy.git",
|
|
69
|
+
"directory": "packages/image-overlay"
|
|
70
|
+
},
|
|
71
|
+
"bugs": {
|
|
72
|
+
"url": "https://github.com/LovesWorking/react-native-buoy/issues"
|
|
73
|
+
},
|
|
74
|
+
"homepage": "https://github.com/LovesWorking/react-native-buoy/tree/main/packages/image-overlay#readme",
|
|
75
|
+
"publishConfig": {
|
|
76
|
+
"access": "public",
|
|
77
|
+
"tag": "latest"
|
|
78
|
+
}
|
|
79
|
+
}
|