d25d482dc2
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
63 lines
1.9 KiB
TypeScript
63 lines
1.9 KiB
TypeScript
/**
|
|
* Group node parser — handles grouped shapes (p:grpSp).
|
|
*/
|
|
|
|
import { emuToPx } from '../../parser/units'
|
|
import type { SafeXmlNode } from '../../parser/xml-parser'
|
|
import { type BaseNodeData, type Position, parseBaseProps, type Size } from './base-node'
|
|
|
|
export interface GroupNodeData extends BaseNodeData {
|
|
nodeType: 'group'
|
|
childOffset: Position
|
|
childExtent: Size
|
|
/** @internal Raw XML nodes — opaque to consumers. Use serializePresentation() for JSON-safe data. */
|
|
children: SafeXmlNode[]
|
|
}
|
|
|
|
/** Tag names of elements that can be children in a group's spTree. */
|
|
const GROUP_CHILD_TAGS = new Set(['sp', 'pic', 'grpSp', 'graphicFrame', 'cxnSp'])
|
|
|
|
/**
|
|
* Parse a group shape XML node (`p:grpSp`) into GroupNodeData.
|
|
*/
|
|
export function parseGroupNode(grpNode: SafeXmlNode): GroupNodeData {
|
|
const base = parseBaseProps(grpNode)
|
|
|
|
// --- Child coordinate space from grpSpPr > a:xfrm ---
|
|
// OOXML: when chOff/chExt omitted, child box equals group box (chOff=0,0, chExt=ext).
|
|
const grpSpPr = grpNode.child('grpSpPr')
|
|
const xfrm = grpSpPr.child('xfrm')
|
|
const chOff = xfrm.child('chOff')
|
|
const chExt = xfrm.child('chExt')
|
|
|
|
const childOffset: Position = chOff.exists()
|
|
? { x: emuToPx(chOff.numAttr('x') ?? 0), y: emuToPx(chOff.numAttr('y') ?? 0) }
|
|
: { x: 0, y: 0 }
|
|
|
|
const childExtent: Size = (() => {
|
|
if (!chExt.exists()) return { w: base.size.w, h: base.size.h }
|
|
const cx = chExt.numAttr('cx')
|
|
const cy = chExt.numAttr('cy')
|
|
return {
|
|
w: cx !== undefined && cx > 0 ? emuToPx(cx) : base.size.w,
|
|
h: cy !== undefined && cy > 0 ? emuToPx(cy) : base.size.h,
|
|
}
|
|
})()
|
|
|
|
// --- Collect direct child shape nodes ---
|
|
const children: SafeXmlNode[] = []
|
|
for (const child of grpNode.allChildren()) {
|
|
if (GROUP_CHILD_TAGS.has(child.localName)) {
|
|
children.push(child)
|
|
}
|
|
}
|
|
|
|
return {
|
|
...base,
|
|
nodeType: 'group',
|
|
childOffset,
|
|
childExtent,
|
|
children,
|
|
}
|
|
}
|