diff --git a/lib/folk-shape.ts b/lib/folk-shape.ts index 493aaf6..81cf085 100644 --- a/lib/folk-shape.ts +++ b/lib/folk-shape.ts @@ -383,11 +383,19 @@ export class FolkShape extends FolkElement { this.#updateCursors(); - this.x = Number(this.getAttribute("x")) || 0; - this.y = Number(this.getAttribute("y")) || 0; - this.width = Number(this.getAttribute("width")) || "auto"; - this.height = Number(this.getAttribute("height")) || "auto"; - this.rotation = (Number(this.getAttribute("rotation")) || 0) * (Math.PI / 180); + // Only initialize from HTML attributes if they exist — when properties + // are set via JS before DOM insertion, attributes are absent and reading + // them would overwrite the already-set values with 0/"auto". + const attrX = this.getAttribute("x"); + const attrY = this.getAttribute("y"); + const attrW = this.getAttribute("width"); + const attrH = this.getAttribute("height"); + const attrR = this.getAttribute("rotation"); + if (attrX !== null) this.x = Number(attrX) || 0; + if (attrY !== null) this.y = Number(attrY) || 0; + if (attrW !== null) this.width = Number(attrW) || "auto"; + if (attrH !== null) this.height = Number(attrH) || "auto"; + if (attrR !== null) this.rotation = (Number(attrR) || 0) * (Math.PI / 180); this.#rect.transformOrigin = { x: 0, y: 0 }; this.#rect.rotateOrigin = { x: 0.5, y: 0.5 }; diff --git a/lib/folk-wrapper.ts b/lib/folk-wrapper.ts index 4cdc5bb..3edaa36 100644 --- a/lib/folk-wrapper.ts +++ b/lib/folk-wrapper.ts @@ -292,11 +292,12 @@ export class FolkWrapper extends FolkShape {
`; - // Replace existing content structure + // Replace existing content structure — save parent ref before clearing const existingSlot = root.querySelector("slot"); - if (existingSlot?.parentElement) { - existingSlot.parentElement.innerHTML = ""; - existingSlot.parentElement.appendChild(wrapper); + const slotParent = existingSlot?.parentElement; + if (slotParent) { + slotParent.innerHTML = ""; + slotParent.appendChild(wrapper); } // Get references diff --git a/server/index.ts b/server/index.ts index eb7bf3e..1178fa2 100644 --- a/server/index.ts +++ b/server/index.ts @@ -533,7 +533,7 @@ app.post("/api/image-gen", async (c) => { }; const styledPrompt = (stylePrompts[style] || "") + prompt; - const res = await fetch("https://queue.fal.run/fal-ai/flux-pro/v1.1", { + const res = await fetch("https://fal.run/fal-ai/flux-pro/v1.1", { method: "POST", headers: { Authorization: `Key ${FAL_KEY}`, @@ -567,7 +567,7 @@ app.post("/api/video-gen/t2v", async (c) => { const { prompt, duration } = await c.req.json(); if (!prompt) return c.json({ error: "prompt required" }, 400); - const res = await fetch("https://queue.fal.run/fal-ai/wan/v2.1", { + const res = await fetch("https://fal.run/fal-ai/wan/v2.1", { method: "POST", headers: { Authorization: `Key ${FAL_KEY}`, @@ -600,7 +600,7 @@ app.post("/api/video-gen/i2v", async (c) => { const { image, prompt, duration } = await c.req.json(); if (!image) return c.json({ error: "image required" }, 400); - const res = await fetch("https://queue.fal.run/fal-ai/kling-video/v1/standard/image-to-video", { + const res = await fetch("https://fal.run/fal-ai/kling-video/v1/standard/image-to-video", { method: "POST", headers: { Authorization: `Key ${FAL_KEY}`, diff --git a/shared/tab-cache.ts b/shared/tab-cache.ts index 24cb6f4..06d34cb 100644 --- a/shared/tab-cache.ts +++ b/shared/tab-cache.ts @@ -135,7 +135,7 @@ export class TabCache { this.panes.set(moduleId, pane); // Load module-specific assets - this.loadAssets(content.scripts, content.styles); + this.loadAssets(content.scripts, content.styles, content.inlineStyles, moduleId); // Update shell state this.currentModuleId = moduleId; @@ -159,6 +159,7 @@ export class TabCache { title: string; scripts: string[]; styles: string[]; + inlineStyles: string[]; } | null { const parser = new DOMParser(); const doc = parser.parseFromString(html, "text/html"); @@ -197,11 +198,20 @@ export class TabCache { styles.push(href); }); - return { body, title, scripts, styles }; + // Extract inline