From 27d27241530790b5812b9753243df102932efe9b Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 3 Jun 2025 17:55:07 +0200 Subject: [PATCH] :bug: Fix incorrect shape filtering on bool creation on library --- common/src/app/common/files/builder.cljc | 4 +- library/CHANGES.md | 5 + library/package.json | 2 +- .../playground/sample-bool-with-components.js | 132 ++++++++++++++++++ 4 files changed, 139 insertions(+), 4 deletions(-) create mode 100644 library/playground/sample-bool-with-components.js diff --git a/common/src/app/common/files/builder.cljc b/common/src/app/common/files/builder.cljc index d23a25c860..1ad590dbbb 100644 --- a/common/src/app/common/files/builder.cljc +++ b/common/src/app/common/files/builder.cljc @@ -21,7 +21,6 @@ [app.common.time :as dt] [app.common.types.color :as types.color] [app.common.types.component :as types.comp] - [app.common.types.container :as types.cont] [app.common.types.file :as types.file] [app.common.types.page :as types.page] [app.common.types.path :as types.path] @@ -341,8 +340,7 @@ (comp (map (d/getf objects)) (remove cph/frame-shape?) - (remove types.comp/is-variant?) - (remove (partial types.cont/has-any-copy-parent? objects))) + (remove types.comp/is-variant?)) children (->> (get bool-shape :shapes) diff --git a/library/CHANGES.md b/library/CHANGES.md index bfd544e169..c62be46685 100644 --- a/library/CHANGES.md +++ b/library/CHANGES.md @@ -1,5 +1,10 @@ # CHANGELOG +## 1.0.4 + +- Fix incorrect shapes filtering on creating boolean shapes within components + + ## 1.0.3 - Add missing isLocal field on file media for fix compatibility of the diff --git a/library/package.json b/library/package.json index 9810904f40..c1e9898a26 100644 --- a/library/package.json +++ b/library/package.json @@ -1,6 +1,6 @@ { "name": "@penpot/library", - "version": "1.0.3", + "version": "1.0.4", "license": "MPL-2.0", "author": "Kaleidos INC", "packageManager": "yarn@4.9.1+sha512.f95ce356460e05be48d66401c1ae64ef84d163dd689964962c6888a9810865e39097a5e9de748876c2e0bf89b232d583c33982773e9903ae7a76257270986538", diff --git a/library/playground/sample-bool-with-components.js b/library/playground/sample-bool-with-components.js new file mode 100644 index 0000000000..97620c1f93 --- /dev/null +++ b/library/playground/sample-bool-with-components.js @@ -0,0 +1,132 @@ +import * as penpot from "#self"; +import { writeFile } from "fs/promises"; + +(async function () { + const context = penpot.createBuildContext(); + + { + context.addFile({ name: "Test File 1" }); + context.addPage({ name: "Foo Page" }); + + const componentId = context.genId(); + + const mainInstanceId = context.addBoard({ + name: "Artboard 1", + componentFile: context.currentFileId, + componentId, + componentRoot: true, + mainInstance: true, + x: 20, + y: 20, + width: 100, + height: 200 + }); + + const groupId = context.addGroup({ + name: "Group 1", + x: 20, + y: 20, + width: 100, + height: 200 + }); + + const rectId = context.addRect({ + name: "Rect 1", + x: 20, + y: 20, + width: 100, + height: 200 + }); + + const circleId = context.addCircle({ + name: "Circle 1", + x: 20, + y: 20, + width: 100, + height: 100 + }); + + context.closeGroup(); + + context.addBool({ + groupId, + type: "intersection" + }); + + context.closeBoard(); + + context.addBoard({ + name: "Artboard 1", + componentFile: context.currentFileId, + componentId, + componentRoot: true, + shapeRef: mainInstanceId, + x: 20, + y: 20, + width: 100, + height: 200 + }); + + const groupId2 = context.addGroup({ + name: "Group 1", + shapeRef: groupId, + x: 20, + y: 20, + width: 100, + height: 200 + }); + + context.addRect({ + name: "Rect 1", + shapeRef: rectId, + x: 20, + y: 20, + width: 100, + height: 200 + }); + + context.addCircle({ + name: "Circle 1", + shapeRef: circleId, + x: 20, + y: 20, + width: 100, + height: 100 + }); + + context.closeGroup(); + + context.addBool({ + groupId: groupId2, + type: "intersection" + }); + + context.closeBoard(); + + context.addComponent({ + componentId: componentId, + fileId: context.currentFileId, + name: "Artboard 1", + frameId: mainInstanceId, + }); + + context.closeFile(); + } + + { + let result = await penpot.exportAsBytes(context); + await writeFile("sample-bool-and-comp.zip", result); + } +})() + .catch(cause => { + console.error(cause); + + const innerCause = cause.cause; + if (innerCause) { + console.error("Inner cause:", innerCause); + } + process.exit(-1); + }) + .finally(() => { + process.exit(0); + });