Commit Graph

71 Commits

Author SHA1 Message Date
Andrey Antukh
b86898eaf9 Revert "🐛 Fix "Cannot assign to read only property toString" error in plugins runtime"
This reverts commit f796f7ccb9.
2026-03-17 14:45:18 +01:00
Andrey Antukh
f796f7ccb9 🐛 Fix "Cannot assign to read only property toString" error in plugins runtime
The error "Cannot assign to read only property 'toString' of function"
occurs during React's commit phase after a plugin is loaded. The root
cause is an initialization ordering issue in the SES (Secure EcmaScript)
lockdown sequence.

When loadPlugin() is called, ses.harden(context) runs first, which
transitively freezes everything reachable from the context object —
including Function.prototype and Object.prototype — via prototype chain
traversal of getter functions. Later, createSandbox() calls
ses.hardenIntrinsics(), which attempts to run enablePropertyOverrides()
to convert frozen data properties (like Function.prototype.toString)
into accessor pairs that work around JavaScript's "override mistake".
However, enablePropertyOverrides checks "if (configurable)" before
converting, and since Function.prototype is already frozen (all
properties have configurable: false), the override taming is silently
skipped. This leaves Function.prototype.toString as a frozen
non-writable data property, causing any subsequent code that assigns
.toString to a function instance in strict mode to throw a TypeError.

The fix calls ses.hardenIntrinsics() before ses.harden(context) in
loadPlugin(), ensuring override taming installs the accessor pairs on
prototype properties before they get frozen. The existing
hardenIntrinsics() call in createSandbox() becomes a harmless no-op
thanks to the idempotency guard.

Signed-off-by: Andrey Antukh <niwi@niwi.nz>
2026-03-17 10:14:12 +01:00
Andrey Antukh
cf94b56154 Merge remote-tracking branch 'origin/staging' into develop 2026-03-13 11:41:56 +01:00
Andrey Antukh
33c5f82c43 🐛 Fix penpot.openPage() to navigate in same tab by default
- Change the default for the newWindow param from true to false, so
  openPage() navigates in the same tab instead of opening a new one
- Accept a UUID string as the page argument in addition to a Page object,
  avoiding the need to call penpot.getPage(uuid) first
- Add validation error when an invalid page argument is passed

Signed-off-by: Andrey Antukh <niwi@niwi.nz>
2026-03-13 09:19:50 +01:00
David Barragán Merino
3eabbffb0e 🔧 Change the assets dir to fix deployment with Wrangler 2026-03-12 19:50:46 +01:00
Andrey Antukh
dbe8304f0c Include plugins on the frontend bundle 2026-03-12 19:07:44 +01:00
Andrey Antukh
87488f4a98 Make the rename-layers-plugin work correctly on subpath 2026-03-12 19:07:44 +01:00
Andrey Antukh
f6259708ca Make the create-palette-plugin work correctly on subpath 2026-03-12 19:07:44 +01:00
Andrey Antukh
1229c2a5e5 Make the constrast-plugin work correctly on subpath 2026-03-12 19:07:44 +01:00
Andrey Antukh
4a6e6fce5b Make the lorem-ipsum-plugin work correctly on subpath 2026-03-12 19:07:44 +01:00
Andrey Antukh
b8c319aa61 Make the poc-tokens-plugin work correctly on subpath 2026-03-12 19:07:44 +01:00
Andrey Antukh
2d0058ef3b Make the poc-state-plugin work correctly on subpath 2026-03-12 19:07:44 +01:00
Andrey Antukh
d14e3a9914 Make the colors-to-tokens-plugin work correctly on subpath 2026-03-12 19:07:44 +01:00
Andrey Antukh
eebe90b2cd Make the table-plugin work correctly on subpath 2026-03-12 19:07:44 +01:00
Andrey Antukh
9fb6a3ab0e Make the icons-plugin work correctly on subpath 2026-03-12 19:07:44 +01:00
Andrey Antukh
207bc795c0 Add minor changes on plugins examples-style 2026-03-12 19:07:44 +01:00
Andrey Antukh
e841dc60b7 Make penpot depend on local plugins runtime
This removes the need to publish versions to pnpn
2026-03-12 19:07:44 +01:00
Andrey Antukh
85ffadf8d7 Add better approach for handling plugin iframe url
Ensure params are passed correctly to plugins declared to be version
2 and are prepared to run in a subpath.
2026-03-12 19:07:44 +01:00
Andrey Antukh
ec4f685aac 🐛 Fix penpot.openPage() to navigate in same tab by default
- Change the default for the newWindow param from true to false, so
  openPage() navigates in the same tab instead of opening a new one
- Accept a UUID string as the page argument in addition to a Page object,
  avoiding the need to call penpot.getPage(uuid) first
- Add validation error when an invalid page argument is passed

Signed-off-by: Andrey Antukh <niwi@niwi.nz>
2026-03-12 15:53:32 +01:00
Andrey Antukh
25df9f2f83 🐛 Fix DataCloneError in plugin postMessage communication
Fixes a crash where plugins sending messages via 'penpot.ui.sendMessage()'
could fail if their message payload contained non-serializable values like
functions or closures.

The fix adds validation using 'structuredClone()' to catch these messages
early with a helpful error message, and adds a defensive try/catch in the
modal's message handler as a safety net.

Fixes the error: 'Failed to execute postMessage on Window: ... could not
be cloned.'

Signed-off-by: Andrey Antukh <niwi@niwi.nz>
2026-03-12 15:26:00 +01:00
Andrey Antukh
98c1503bca Backport serveral plugin types documentation 2026-03-10 15:05:08 +01:00
Andrey Antukh
0de482da9d ⬆️ Update pnpm to 10.31.0 across all submodules (#8549) 2026-03-10 10:03:05 +01:00
Alonso Torres
40c9466718 🐛 Fix type in plugin attribute (#8543) 2026-03-09 12:06:56 +01:00
Alonso Torres
321b53e936 Add improvements on variants plugins (#8482) 2026-03-09 10:24:16 +01:00
Andrey Antukh
d680973c85 Merge remote-tracking branch 'origin/staging' into develop 2026-02-25 15:31:49 +01:00
Andrés Moya
c72e9ee1a0 🐛 Convert token values for the plugins 2026-02-25 14:04:20 +01:00
Andrés Moya
72a855d4ac 🐛 Fix activeSets in themes API 2026-02-25 14:04:20 +01:00
Andrey Antukh
20862c2da3 🐛 Fix incorrect plugin icon resolution 2026-02-24 00:07:30 +01:00
alonso.torres
426c8ea714 🐛 Fix type annotation for layoutCell property in plugins 2026-02-19 10:26:51 +01:00
alonso.torres
75e8d226d9 Add textBounds property in plugins 2026-02-19 10:26:51 +01:00
Andrey Antukh
916107ce04 📎 Update pnpm-lock.yaml file on plugins module 2026-02-17 17:42:39 +01:00
Andrey Antukh
dafad0c124 Merge remote-tracking branch 'origin/staging-render' into develop 2026-02-17 09:57:51 +01:00
Andrés Moya
643cd6f61f 🐛 Add resolved value to tokens in plugins API (#8372) 2026-02-17 09:20:04 +01:00
Alonso Torres
c32a336c50 🎉 Add MCP plugin embedded execution (#8368)
*  Add core changes for mcp server

*  Changes to plugins-runtime to add mcp extensions

*  Changes to MCP plugin

*  Changes post-review and ci fixes
2026-02-17 09:18:46 +01:00
Andrés Moya
619e2387dc 🐛 Fix applied tokens property names 2026-02-16 15:16:14 +01:00
David Barragán Merino
fe833c9e34 🔧 Disable observability for plugin docs and packages
This reverts commit a4f2641cc9.
2026-02-13 13:55:13 +01:00
Juanfran
449aa65f8d 🐛 Fix e2e tests for plugins 2026-02-13 13:17:08 +01:00
Andrey Antukh
bd7f4dca3a 🐛 Fix rpc methods on plugins e2e tests 2026-02-13 13:17:08 +01:00
Andrey Antukh
1e7bef081a Allow self-signed certs on plugins e2e browser setup 2026-02-13 13:17:08 +01:00
Andrey Antukh
12bc3ac9ed Update default cors headers 2026-02-13 13:17:08 +01:00
Andrés Moya
a23ca6a1cb 🐛 Fix applied tokens reading in shape proxy 2026-02-12 17:14:16 +01:00
Andrés Moya
11eedd0368 🐛 Patch alternative ways of applying tokens to shapes 2026-02-12 16:01:55 +01:00
Juanfran
394d597736 Add enhacements to plugins build mechanism (#8326)
* 🐛 Fix plugin code build

* 🔧 Update editor.defaultFormatter to new Prettier

* 🐛 Fix lint issues in create-palette-plugin

* 🐛 Add missing run in pnpm init script for plugins
2026-02-11 15:28:33 +01:00
Andrey Antukh
f4d07a3c36 ⬆️ Update pnpm on frontend and plugins modules 2026-02-10 19:02:32 +01:00
Andrés Moya
41f29767db 🐛 Fix configuration of poc-tokens-plugin (#8314)
* 🐛 Fix configuration of poc-tokens-plugin

* 📎 Add missing changes on poc-tokens-pligin tsconfig

---------

Co-authored-by: Andrey Antukh <niwi@niwi.nz>
2026-02-10 15:18:11 +01:00
Andrey Antukh
e3dfa69011 Make plugins devserver to be able run inside devenv 2026-02-10 08:29:24 +01:00
Juanfran
96b682aa12 ♻️ Remove Nx and rely on pnpm monorepo features 2026-02-10 08:29:24 +01:00
Juanfran
45d04942cc Add example ui storybook 2026-02-10 08:29:24 +01:00
Juanfran
07055b53d1 ⬆️ Update plugins dependencies 2026-02-10 08:29:24 +01:00
Andrés Moya
5b5f22a8c6 🎉 Add tokens to Penpot Plugins API (#7756)
* 🎉 Add tokens to plugins API documentation

And add poc plugin example

* 📚 Document better the tokens value in plugins API

* 🔧 Refactor token validation schemas

* 🔧 Use automatic validation in token proxies

* 🔧 Use schemas to validate token creation

* 🔧 Use multi schema for token value

* 🔧 Use schema in token api methods

* 🐛 Fix review comments

---------

Co-authored-by: Andrey Antukh <niwi@niwi.nz>
2026-02-09 14:18:31 +01:00