mirror of
https://github.com/penpot/penpot.git
synced 2026-11-18 16:12:24 +00:00
* ✨ Delay building schemas in check-fn check-fn eagerly builds its schemas which contributes to the startup time. But we can delay this to when the check function is actually called, which seems to be when an edit is made. On the Travel A2B - Locofy Sample project file this reduced the time to the first viewport render by ~15%. * ✨ Make schema resolution lazy only on production builds Add a lazy-delay macro that defers the expression only on builds that set the app.common.data.macros/lazy-delay? closure define, and use it in check-fn to resolve the schema. The previous change made the schema resolution unconditionally lazy, which hid wrong schema definitions until the first check call. With this change development builds, tests and storybook resolve the schema when the namespace loads, so a bad definition fails early, and production builds keep the deferred resolution and the startup win. The define is enabled in the release builds of frontend (main and worker), exporter and library. On the JVM the expression is always evaluated immediately. AI-assisted-by: deepseek-v4.1-flash --------- Co-authored-by: Andrey Antukh <niwi@niwi.nz>
Penpot Library
A library that exposes a limited set of Penpot's features for programmatic use. Currently, it provides methods to build Penpot files in memory and export them as .penpot files (ZIP archives containing all the necessary data to import them into a Penpot application).
User Guide
How to install
pnpm add @penpot/library
Example of use
import * as penpot from "@penpot/library";
import { createWriteStream } from 'fs';
import { Writable } from "stream";
const context = penpot.createBuildContext();
context.addFile({name: "Test File 1"});
context.addPage({name: "Foo Page"});
context.addBoard({
name: "Foo Board",
x: 0,
y: 0,
width: 500,
height: 300,
});
context.closeBoard();
context.closeFile();
// Create a file stream to write the zip to
const output = createWriteStream('sample-stream.zip');
// Wrap Node's stream in a WHATWG WritableStream
const writable = Writable.toWeb(output);
await penpot.exportStream(context, writable);
Developer Guide
How to publish
Build the library:
./scripts/build
Login on npm:
npm login
Publish on npm:
npm publish --access public
License
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
Copyright (c) KALEIDOS SUBSIDIARY SL