Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
fix: Preserve transitions and animation preview behavior (#6602)
Oleg Isonen659e953869c8
diff --git a/apps/builder/app/services/github-issue-report.server.test.ts b/apps/builder/app/services/github-issue-report.server.test.tsindex bef40cea79..98b5375334 100644--- a/apps/builder/app/services/github-issue-report.server.test.ts+++ b/apps/builder/app/services/github-issue-report.server.test.ts@@ -147,11 +147,19 @@ describe("GitHub issue reports", () => {exitSignal: "SIGABRT",attempts: [{ browser: "chromium", source: "path" }],};+ responseReport.runtime.recentFailure.previewInstall = {+ processErrorCode: "ETIMEDOUT",+ terminated: true,+ };const body = formatIssueReport(responseReport);expect(body).toContain("Response: json; envelope=result; batch size=1");expect(body).toContain("Browser exit: SIGABRT");expect(body).toContain("Browser attempts: chromium (path)");+ expect(body).toContain("Preview install: ETIMEDOUT; process terminated");++ responseReport.runtime.recentFailure.previewInstall = {};+ expect(formatIssueReport(responseReport)).not.toContain("Preview install:");});test("discovers the repository installation before creating its token", async () => {diff --git a/apps/builder/app/services/github-issue-report.server.ts b/apps/builder/app/services/github-issue-report.server.tsindex 63856e1ce8..104c11ca34 100644--- a/apps/builder/app/services/github-issue-report.server.ts+++ b/apps/builder/app/services/github-issue-report.server.ts@@ -67,6 +67,16 @@ const formatFailureDiagnostics = (runtime: IssueReportInput["runtime"]) => {return "";}const issues = failure.issues ?? [];+ const previewInstall = failure.previewInstall;+ const previewInstallDetails = [+ previewInstall?.processErrorCode,+ previewInstall?.exitCode === undefined+ ? undefined+ : `exit code ${previewInstall.exitCode}`,+ previewInstall?.terminated ? "process terminated" : undefined,+ ]+ .filter(Boolean)+ .join("; ");return ["## Captured failure diagnostics","",@@ -106,6 +116,9 @@ const formatFailureDiagnostics = (runtime: IssueReportInput["runtime"]) => {`- Browser attempts: ${failure.browser.attempts.map((attempt) => `${attempt.browser} (${attempt.source})`).join(", ")}`,]),]),+ ...(previewInstallDetails === ""+ ? []+ : [`- Preview install: ${previewInstallDetails}`]),...(issues.length === 0? []: [diff --git a/docs/university/core-components/stagger-animation.md b/docs/university/core-components/stagger-animation.mdindex b736ace017..4b16b7fa10 100644--- a/docs/university/core-components/stagger-animation.md+++ b/docs/university/core-components/stagger-animation.md@@ -27,6 +27,8 @@ Controls how many child elements animate concurrently during the stagger effect.Controls the easing within the sliding window. The default is `linear`. Supported values are `linear`, `easeIn`, `easeInCubic`, `easeInQuart`, `easeOut`, `easeOutCubic`, `easeOutQuart`, `ease`, `easeInOutCubic`, and `easeInOutQuart`.+Easing follows each item from hidden to visible. If the parent animation runs backward, the timing runs backward too.+## StructureThe Stagger Animation component must be the direct child of Animation Group. Put the repeated cards, list items, or rows directly inside Stagger Animation. Start with the default `slidingWindow` and `easing`; add overrides only when you intentionally want a different rhythm.diff --git a/docs/university/core-components/text-animation.md b/docs/university/core-components/text-animation.mdindex 57ba8d2bbe..4aea78f0bd 100644--- a/docs/university/core-components/text-animation.md+++ b/docs/university/core-components/text-animation.md@@ -50,6 +50,8 @@ Controls how many text parts animate concurrently. The default is `5`.Controls the easing within the sliding window. The default is `linear`. Supported values are `linear`, `easeIn`, `easeInCubic`, `easeInQuart`, `easeOut`, `easeOutCubic`, `easeOutQuart`, `ease`, `easeInOutCubic`, and `easeInOutQuart`.+Easing follows each item from hidden to visible. If the parent animation runs backward, the timing runs backward too.+## StructureThe Text Animation component must be the direct child of Animation Group. The text-containing element goes inside Text Animation. Configure word or character splitting on Text Animation, then define the actual opacity, translate, scale, or other animated styles on the parent Animation Group.diff --git a/packages/cli/src/commands/preview.test.ts b/packages/cli/src/commands/preview.test.tsindex de3f556603..bfc9a73f6f 100644--- a/packages/cli/src/commands/preview.test.ts+++ b/packages/cli/src/commands/preview.test.ts@@ -789,13 +789,14 @@ test("installs generated dependencies through the available windows pnpm launche);});-test("reports an actionable error when generated dependencies cannot install", async () => {+test("reports an actionable, stable error when generated dependencies cannot install", async () => {const access = vi.fn(async () => {throw Object.assign(new Error("missing"), { code: "ENOENT" });});- await expect(- ensurePreviewDependencies("/tmp/project/.webstudio/preview", {+ const failedInstall = ensurePreviewDependencies(+ "/tmp/project/.webstudio/preview",+ {access,execFile: vi.fn(async () => {throw new Error("npm failed");@@ -806,10 +807,14 @@ test("reports an actionable error when generated dependencies cannot install", areadFile: vi.fn(async () => '{"dependencies":{"vite":"1.0.0"}}'),symlink: vi.fn(async () => undefined),platform: "linux",- })- ).rejects.toThrow(+ }+ );+ await expect(failedInstall).rejects.toThrow("PREVIEW_DEPENDENCY_INSTALL_FAILED: Could not install the generated preview dependencies");+ await expect(failedInstall).rejects.toMatchObject({+ code: "PREVIEW_DEPENDENCY_INSTALL_FAILED",+ });});test("reports sanitized package-manager diagnostics for preview install failures", async () => {diff --git a/packages/cli/src/commands/preview.ts b/packages/cli/src/commands/preview.tsindex 108124f711..06b64bde85 100644--- a/packages/cli/src/commands/preview.ts+++ b/packages/cli/src/commands/preview.ts@@ -218,6 +218,10 @@ const getPreviewInstallFailureDiagnostics = (error: unknown) => {return `${codeDiagnostics}${diagnostics}`;};+class PreviewDependencyInstallError extends Error {+ readonly code = "PREVIEW_DEPENDENCY_INSTALL_FAILED";+}+export const getPreviewProjectDir = (projectDir = cwd()) =>join(projectDir, ".webstudio", "preview");@@ -410,7 +414,7 @@ export const ensurePreviewDependencies = async (timeout: previewDependencyInstallTimeout,});} catch (error) {- throw new Error(+ throw new PreviewDependencyInstallError(`PREVIEW_DEPENDENCY_INSTALL_FAILED: Could not install the generated preview dependencies with ${packageManager.name} at ${packageManagerPath}. For npm cache permission errors, unset npm_config_cache to use the preview-local cache, then retry. Check the package-manager/network configuration, then reinstall or update webstudio if the problem persists.\n\nPackage-manager diagnostics:\n${getPreviewInstallFailureDiagnostics(error)}`,{ cause: error });diff --git a/packages/cli/src/project-session.test.ts b/packages/cli/src/project-session.test.tsindex 31d777c1e9..94240ed7be 100644--- a/packages/cli/src/project-session.test.ts+++ b/packages/cli/src/project-session.test.ts@@ -56,6 +56,36 @@ test("adds anonymous local runtime metadata only to issue reports", () => {expect(addIssueReportRuntime("audit", report, () => runtime)).toBe(report);});+test("captures safe preview install failure details without npm output", () => {+ const error = Object.assign(new Error("private npm output"), {+ code: "PREVIEW_DEPENDENCY_INSTALL_FAILED",+ cause: Object.assign(new Error("private local path"), {+ code: "ETIMEDOUT",+ killed: true,+ stderr: "private registry token",+ }),+ });++ expect(createIssueReportFailure("preview.start", error)).toEqual({+ tool: "preview.start",+ code: "PREVIEW_DEPENDENCY_INSTALL_FAILED",+ previewInstall: { processErrorCode: "ETIMEDOUT", terminated: true },+ });++ const npmExit = Object.assign(new Error("private npm output"), {+ code: "PREVIEW_DEPENDENCY_INSTALL_FAILED",+ cause: Object.assign(new Error("private registry token"), {+ code: 1,+ stderr: "private registry token",+ }),+ });+ expect(createIssueReportFailure("preview.start", npmExit)).toEqual({+ tool: "preview.start",+ code: "PREVIEW_DEPENDENCY_INSTALL_FAILED",+ previewInstall: { exitCode: 1 },+ });+});+test("keeps only anonymous structured fields from the latest tool failure", () => {const error = Object.assign(new Error("Asset customer-logo.png is invalid"), {code: "PROJECT_BUNDLE_INVALID",diff --git a/packages/cli/src/project-session.ts b/packages/cli/src/project-session.tsindex 2454898ad5..5acb62afb7 100644--- a/packages/cli/src/project-session.ts+++ b/packages/cli/src/project-session.ts@@ -578,6 +578,24 @@ export const createIssueReportFailure = (constraint: issue.constraint,}));const entityIds = getIssueReportEntityIds(input);+ const previewProcess =+ errorCode === "PREVIEW_DEPENDENCY_INSTALL_FAILED"+ ? records+ .slice(1)+ .find(+ (candidate) =>+ candidate.code !== undefined || candidate.killed === true+ )+ : undefined;+ const processErrorCode = getStableErrorCode(previewProcess);+ const previewExitCode =+ typeof previewProcess?.code === "number" &&+ Number.isInteger(previewProcess.code) &&+ previewProcess.code >= 0 &&+ previewProcess.code <= 255+ ? previewProcess.code+ : undefined;+ const previewTerminated = previewProcess?.killed === true;return {tool: canonicalTool,code: isResponseTransformFailure@@ -594,6 +612,19 @@ export const createIssueReportFailure = (...(elapsedMs === undefined ? {} : { elapsedMs }),...(entityIds.length === 0 ? {} : { entityIds }),...(issues === undefined || issues.length === 0 ? {} : { issues }),+ ...(processErrorCode === undefined &&+ previewExitCode === undefined &&+ previewTerminated === false+ ? {}+ : {+ previewInstall: {+ ...(processErrorCode === undefined ? {} : { processErrorCode }),+ ...(previewExitCode === undefined+ ? {}+ : { exitCode: previewExitCode }),+ ...(previewTerminated ? { terminated: true } : {}),+ },+ }),...(response === undefined? {}: {diff --git a/packages/css-data/src/parse-css.test.ts b/packages/css-data/src/parse-css.test.tsindex 35287f3f1e..c5b0458cdb 100644--- a/packages/css-data/src/parse-css.test.ts+++ b/packages/css-data/src/parse-css.test.ts@@ -2003,6 +2003,23 @@ test("shorthand: var() in transition is substituted and expanded", () => {);});+test("transition with unresolved vars keeps the authored shorthand", () => {+ const result = parseCss(+ ".box { transition: opacity 300ms var(--ease), transform var(--duration) ease; }",+ new Map()+ );++ expect(result.styles).toEqual([+ expect.objectContaining({+ property: "transition",+ value: {+ type: "unparsed",+ value: "opacity 300ms var(--ease),transform var(--duration) ease",+ },+ }),+ ]);+});+// ─── Comprehensive var() substitution in shorthands ───────────────────────────const u = (value: number, unit: string) =>diff --git a/packages/css-data/src/parse-css.ts b/packages/css-data/src/parse-css.tsindex c358531555..e59ad04973 100644--- a/packages/css-data/src/parse-css.ts+++ b/packages/css-data/src/parse-css.ts@@ -619,6 +619,17 @@ const substituteVarsInShorthand = (const { resolved, dropped } = resolution;const { usedCssVarsSubstitution } = resolution;+ // An unresolved var() can represent any transition part (or several parts).+ // Keep the shorthand for the browser instead of guessing its longhands.+ if (property === "transition" && dropped.length > 0) {+ return {+ result: new Map<CssProperty, StyleValue>([+ [normalizeProperty(property), { type: "unparsed", value }],+ ]),+ droppedVars: [],+ };+ }+if (resolved === value) {// No substitution happened.if (dropped.length === 0) {diff --git a/packages/project-build/src/runtime/components.test.ts b/packages/project-build/src/runtime/components.test.tsindex 702af74e3c..61e6fd987a 100644--- a/packages/project-build/src/runtime/components.test.ts+++ b/packages/project-build/src/runtime/components.test.ts@@ -1711,6 +1711,28 @@ test("inserts font shorthand with separate line-height and variable family", asy);});+test("inserts transition lists with unresolved variables without corrupting them", async () => {+ const parent = createParent();+ const fragment = await parseWebstudioJsxFragment(+ '<ws.element ws:tag="div" ws:style={css`transition: opacity 300ms var(--ease), transform var(--duration) ease;`} />'+ );+ const mutation = insertFragment(+ createState(parent),+ { parentInstanceId: parent.id, fragment },+ { createId: createIdFactory(), projectId: "project-id" }+ );++ expect(getAddedValues<StyleDecl>(mutation, "styles")).toEqual([+ expect.objectContaining({+ property: "transition",+ value: {+ type: "unparsed",+ value: "opacity 300ms var(--ease),transform var(--duration) ease",+ },+ }),+ ]);+});+test("inserts bare template-backed components from webstudio jsx fragments", async () => {const parent = createParent();const fragment = await parseWebstudioJsxFragment(`<Switch />`);diff --git a/packages/project-build/src/runtime/styles.test.ts b/packages/project-build/src/runtime/styles.test.tsindex 8c30df3467..bd6f16f34b 100644--- a/packages/project-build/src/runtime/styles.test.ts+++ b/packages/project-build/src/runtime/styles.test.ts@@ -2341,6 +2341,42 @@ describe("style declaration helpers", () => {);});+ test("keeps unresolved transition variables together for browser parsing", () => {+ const declarations = createStyleDeclsFromInput({+ styleSourceId: "token",+ property: "transition",+ value: {+ type: "unparsed",+ value: "opacity 300ms var(--ease), transform var(--duration) ease",+ },+ });+ expect(declarations).toEqual([+ expect.objectContaining({+ styleSourceId: "token",+ breakpointId: "base",+ property: "transition",+ value: {+ type: "unparsed",+ value: "opacity 300ms var(--ease),transform var(--duration) ease",+ },+ }),+ ]);++ const sheet = createRegularStyleSheet();+ const rule = sheet.addNestingRule(".box");+ for (const declaration of declarations) {+ rule.setDeclaration({+ breakpoint: declaration.breakpointId,+ selector: "",+ property: declaration.property,+ value: declaration.value,+ });+ }+ expect(rule.toString({ breakpoint: "base" })).toContain(+ "transition: opacity 300ms var(--ease),transform var(--duration) ease"+ );+ });+test("creates style declaration keys from user input with base breakpoint default", () => {expect(getStyleDeclKeyFromInput({diff --git a/packages/protocol/src/builder-api/__generated__/server-only-router-operation-metadata.ts b/packages/protocol/src/builder-api/__generated__/server-only-router-operation-metadata.tsindex 35374f0fbf..7cdeab3c5e 100644--- a/packages/protocol/src/builder-api/__generated__/server-only-router-operation-metadata.ts+++ b/packages/protocol/src/builder-api/__generated__/server-only-router-operation-metadata.ts@@ -444,6 +444,25 @@ export const serverOnlyRouterOperationMetadata = {additionalProperties: false,required: [],},+ previewInstall: {+ type: "object",+ properties: {+ processErrorCode: {+ type: "string",+ pattern: "^[A-Z][A-Z0-9_]{0,159}$",+ },+ exitCode: {+ type: "integer",+ minimum: 0,+ maximum: 255,+ },+ terminated: {+ type: "boolean",+ },+ },+ additionalProperties: false,+ required: [],+ },},required: ["tool", "code"],additionalProperties: false,diff --git a/packages/protocol/src/issue-report.test.ts b/packages/protocol/src/issue-report.test.tsindex fbc74c8166..f81f2ee1f9 100644--- a/packages/protocol/src/issue-report.test.ts+++ b/packages/protocol/src/issue-report.test.ts@@ -164,7 +164,7 @@ describe("issue report contract", () => {).toThrow();});- test("accepts bounded response and browser diagnostics but no raw payloads", () => {+ test("accepts bounded response, browser, and preview diagnostics but no raw payloads", () => {const failure = {...report.runtime.recentFailure,errorType: "AssetRevisionConflictError",@@ -174,6 +174,7 @@ describe("issue report contract", () => {exitSignal: "SIGABRT",attempts: [{ browser: "chromium", source: "path" }],},+ previewInstall: { processErrorCode: "ETIMEDOUT", terminated: true },};expect(issueReportInput.parse({@@ -219,5 +220,17 @@ describe("issue report contract", () => {},})).toThrow();+ expect(() =>+ issueReportInput.parse({+ ...report,+ runtime: {+ ...report.runtime,+ recentFailure: {+ ...failure,+ previewInstall: { stderr: "private registry token" },+ },+ },+ })+ ).toThrow();});});diff --git a/packages/protocol/src/issue-report.ts b/packages/protocol/src/issue-report.tsindex 2dc1f2ca56..81322fad0e 100644--- a/packages/protocol/src/issue-report.ts+++ b/packages/protocol/src/issue-report.ts@@ -133,6 +133,17 @@ export const issueReportRecentFailureSchema = z}).strict().optional(),+ previewInstall: z+ .object({+ processErrorCode: z+ .string()+ .regex(/^[A-Z][A-Z0-9_]{0,159}$/)+ .optional(),+ exitCode: z.number().int().min(0).max(255).optional(),+ terminated: z.boolean().optional(),+ })+ .strict()+ .optional(),}).strict();diff --git a/packages/sdk-components-animation/private-src b/packages/sdk-components-animation/private-srcindex 008dd3e92a..e8662ce700 160000--- a/packages/sdk-components-animation/private-src+++ b/packages/sdk-components-animation/private-src@@ -1 +1 @@-Subproject commit 008dd3e92a4d28605151d5111fd611653830e874+Subproject commit e8662ce7008f140e180f8f97d34065cf0eeb5d78diff --git a/packages/sdk-components-animation/src/__generated__/animate-text.props.ts b/packages/sdk-components-animation/src/__generated__/animate-text.props.tsindex c4024d6776..82cf241746 100644--- a/packages/sdk-components-animation/src/__generated__/animate-text.props.ts+++ b/packages/sdk-components-animation/src/__generated__/animate-text.props.ts@@ -2,13 +2,14 @@ import type { PropMeta } from "@webstudio-is/sdk";export const props: Record<string, PropMeta> = {className: {+ description: "Classes to which the element belongs",required: false,control: "text",type: "string",- description: "Classes to which the element belongs",},easing: {- description: "Easing function applied within the sliding window.",+ description:+ "Easing follows each item's progress from hidden to visible; reversing the animation reverses the timing.",required: false,control: "select",type: "string",diff --git a/packages/sdk-components-animation/src/__generated__/stagger-animation.props.ts b/packages/sdk-components-animation/src/__generated__/stagger-animation.props.tsindex 4e2a36b860..b10ebe97f1 100644--- a/packages/sdk-components-animation/src/__generated__/stagger-animation.props.ts+++ b/packages/sdk-components-animation/src/__generated__/stagger-animation.props.ts@@ -2,13 +2,14 @@ import type { PropMeta } from "@webstudio-is/sdk";export const props: Record<string, PropMeta> = {className: {+ description: "Classes to which the element belongs",required: false,control: "text",type: "string",- description: "Classes to which the element belongs",},easing: {- description: "Easing function applied within the sliding window.",+ description:+ "Easing follows each item's progress from hidden to visible; reversing the animation reverses the timing.",required: false,control: "select",type: "string",diff --git a/packages/sdk-components-animation/src/animate-text.tsx b/packages/sdk-components-animation/src/animate-text.tsxindex e8547345b4..7b772cbdf2 100644--- a/packages/sdk-components-animation/src/animate-text.tsx+++ b/packages/sdk-components-animation/src/animate-text.tsx@@ -29,7 +29,7 @@ type AnimateChildrenProps = {*/slidingWindow?: number;/**- * Easing function applied within the sliding window.+ * Easing follows each item's progress from hidden to visible; reversing the animation reverses the timing.*/easing?: keyof typeof easings;/**@@ -41,6 +41,7 @@ type AnimateChildrenProps = {*/splitBy?: keyof typeof split;} & {+ /** Classes to which the element belongs */className?: string;};diff --git a/packages/sdk-components-animation/src/stagger-animation.tsx b/packages/sdk-components-animation/src/stagger-animation.tsxindex 41c2a47c49..b447554a56 100644--- a/packages/sdk-components-animation/src/stagger-animation.tsx+++ b/packages/sdk-components-animation/src/stagger-animation.tsx@@ -22,7 +22,7 @@ type StaggerAnimationProps = {*/slidingWindow?: number;/**- * Easing function applied within the sliding window.+ * Easing follows each item's progress from hidden to visible; reversing the animation reverses the timing.*/easing?: keyof typeof easings;/**@@ -30,6 +30,7 @@ type StaggerAnimationProps = {*/children: React.ReactNode;} & {+ /** Classes to which the element belongs */className?: string;};