Implement the analyze overlaps CLI command, RPC endpoint, and ToolDef to enable heuristic detection of visual overlaps, parent overflows, and overlay patterns. Geometry computation now uses world-matrix visual bounds to handle nested ancestor rotations and clipping frames correctly. Update file-backed CLI commands to use Node fs/promises instead of Bun runtime file APIs. This is required for the published CLI to function when installed and executed in a standard Node environment. Add the package.json subpath export to the core package for metadata consumers.
58 lines
873 B
TypeScript
58 lines
873 B
TypeScript
import type { SceneGraph } from '@open-pencil/core'
|
|
|
|
export function pageId(graph: SceneGraph) {
|
|
return graph.getPages()[0].id
|
|
}
|
|
|
|
export function rect(
|
|
graph: SceneGraph,
|
|
name: string,
|
|
parentId: string,
|
|
x = 0,
|
|
y = 0,
|
|
w = 50,
|
|
h = 50
|
|
) {
|
|
return graph.createNode('RECTANGLE', parentId, { name, x, y, width: w, height: h })
|
|
}
|
|
|
|
export function frame(
|
|
graph: SceneGraph,
|
|
name: string,
|
|
parentId: string,
|
|
x = 0,
|
|
y = 0,
|
|
w = 100,
|
|
h = 100,
|
|
clipsContent = false
|
|
) {
|
|
return graph.createNode('FRAME', parentId, {
|
|
name,
|
|
x,
|
|
y,
|
|
width: w,
|
|
height: h,
|
|
clipsContent
|
|
})
|
|
}
|
|
|
|
export function text(
|
|
graph: SceneGraph,
|
|
name: string,
|
|
parentId: string,
|
|
x = 0,
|
|
y = 0,
|
|
w = 100,
|
|
h = 20
|
|
) {
|
|
return graph.createNode('TEXT', parentId, {
|
|
name,
|
|
x,
|
|
y,
|
|
width: w,
|
|
height: h,
|
|
text: name,
|
|
fontSize: 14
|
|
})
|
|
}
|