How to change Paragraph Text box dimensions (bounds) in UXP?

Hi everyone,

I’m developing a UXP script to automate text insertion for comic speech bubbles, and I’m currently testing it inside the UXP Developer Tool Playground.

My script successfully creates a text layer and converts it to Paragraph Text, but I cannot find a way to natively define the width and height (dimensions/bounds) of the paragraph text box without distorting the font characters (which means layer.scale() is out of the question).

I noticed in the documentation that Layer.bounds and TextItem.bounds are Read-Only.

Here is my current code:

const app = require('photoshop').app;
const core = require('photoshop').core;

const fontSize = 18;
const posX = 16 + fontSize;
const posY = 18 + fontSize;
const width = 358;
const height = 122;

async function setText() {
    const doc = app.activeDocument;

    if (!doc) return;

    const options = {
        name: 'Name',
        contents: 'Contents',
        fontName: 'ComicSansMS-Bold',
        fontSize: fontSize,
        position: { x: posX, y: posY}
    };

    await core.executeAsModal(async () => {
        const layer = await doc.createTextLayer(options);
        const textItem = layer.textItem;
        await textItem.convertToParagraphText();
        textItem.paragraphStyle.justification = 'center';
    })
}

setText();