mirror of
https://github.com/penpot/penpot.git
synced 2026-02-13 08:01:39 -05:00
Compare commits
1 Commits
develop
...
palba-nitr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72485a39ea |
2
.github/workflows/plugins-deploy-package.yml
vendored
2
.github/workflows/plugins-deploy-package.yml
vendored
@@ -80,7 +80,7 @@ jobs:
|
||||
- name: "Build package for ${{ inputs.plugin_name }}-plugin"
|
||||
working-directory: plugins
|
||||
shell: bash
|
||||
run: pnpm --filter ${{ inputs.plugin_name }}-plugin build
|
||||
run: npx nx build ${{ inputs.plugin_name }}-plugin
|
||||
|
||||
- name: Select Worker name
|
||||
run: |
|
||||
|
||||
@@ -213,14 +213,14 @@
|
||||
(assoc "access-control-allow-origin" origin)
|
||||
(assoc "access-control-allow-methods" "GET,POST,DELETE,OPTIONS,PUT,HEAD,PATCH")
|
||||
(assoc "access-control-allow-credentials" "true")
|
||||
(assoc "access-control-expose-headers" "content-type, set-cookie")
|
||||
(assoc "access-control-allow-headers" "x-frontend-version, x-client, x-requested-width, content-type, accept, cookie")))
|
||||
(assoc "access-control-expose-headers" "x-requested-with, content-type, cookie")
|
||||
(assoc "access-control-allow-headers" "x-frontend-version, content-type, accept, x-requested-width")))
|
||||
|
||||
(defn wrap-cors
|
||||
[handler]
|
||||
(fn [request]
|
||||
(let [response (if (= (yreq/method request) :options)
|
||||
{::yres/status 204}
|
||||
{::yres/status 200}
|
||||
(handler request))
|
||||
origin (yreq/get-header request "origin")]
|
||||
(update response ::yres/headers with-cors-headers origin))))
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
java.util.Optional
|
||||
java.util.concurrent.atomic.AtomicLong
|
||||
org.reactivestreams.Subscriber
|
||||
software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider
|
||||
software.amazon.awssdk.core.ResponseBytes
|
||||
software.amazon.awssdk.core.async.AsyncRequestBody
|
||||
software.amazon.awssdk.core.async.AsyncResponseTransformer
|
||||
@@ -200,8 +199,7 @@
|
||||
|
||||
(defn- build-s3-client
|
||||
[{:keys [::region ::endpoint ::wrk/netty-io-executor]}]
|
||||
(let [creds-provider (DefaultCredentialsProvider/create)
|
||||
aconfig (-> (ClientAsyncConfiguration/builder)
|
||||
(let [aconfig (-> (ClientAsyncConfiguration/builder)
|
||||
(.build))
|
||||
|
||||
sconfig (-> (S3Configuration/builder)
|
||||
@@ -223,7 +221,6 @@
|
||||
builder (.asyncConfiguration ^S3AsyncClientBuilder builder ^ClientAsyncConfiguration aconfig)
|
||||
builder (.httpClient ^S3AsyncClientBuilder builder ^NettyNioAsyncHttpClient hclient)
|
||||
builder (.region ^S3AsyncClientBuilder builder (lookup-region region))
|
||||
builder (.credentialsProvider ^S3AsyncClientBuilder builder creds-provider)
|
||||
builder (cond-> ^S3AsyncClientBuilder builder
|
||||
(some? endpoint)
|
||||
(.endpointOverride (URI. (str endpoint))))]
|
||||
@@ -240,8 +237,7 @@
|
||||
|
||||
(defn- build-s3-presigner
|
||||
[{:keys [::region ::endpoint]}]
|
||||
(let [creds-provider (DefaultCredentialsProvider/create)
|
||||
config (-> (S3Configuration/builder)
|
||||
(let [config (-> (S3Configuration/builder)
|
||||
(cond-> (some? endpoint) (.pathStyleAccessEnabled true))
|
||||
(.build))]
|
||||
|
||||
@@ -249,7 +245,6 @@
|
||||
(cond-> (some? endpoint) (.endpointOverride (URI. (str endpoint))))
|
||||
(.region (lookup-region region))
|
||||
(.serviceConfiguration ^S3Configuration config)
|
||||
(.credentialsProvider creds-provider)
|
||||
(.build))))
|
||||
|
||||
(defn- write-input-stream
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
[::sm/text {:error/fn token-value-empty-fn}])
|
||||
|
||||
(def schema:token-value-font-family
|
||||
[:vector ::sm/text])
|
||||
[:vector :string])
|
||||
|
||||
(def schema:token-value-typography-map
|
||||
[:map
|
||||
|
||||
@@ -43,13 +43,9 @@
|
||||
(> dy dx)
|
||||
(assoc :x (- (:x point) (* sx (- dy dx)))))))
|
||||
|
||||
(defn resize-shape [{:keys [x y width height] :as shape} initial point lock? mod? snap-pixel?]
|
||||
(defn resize-shape [{:keys [x y width height] :as shape} initial point lock? mod?]
|
||||
(if (and (some? x) (some? y) (some? width) (some? height))
|
||||
(let [draw-rect (cond-> (grc/make-rect initial (cond-> point lock? (adjust-ratio initial)))
|
||||
snap-pixel?
|
||||
(-> (update :width max 1)
|
||||
(update :height max 1)))
|
||||
|
||||
(let [draw-rect (grc/make-rect initial (cond-> point lock? (adjust-ratio initial)))
|
||||
shape-rect (grc/make-rect x y width height)
|
||||
|
||||
scalev (gpt/point (/ (:width draw-rect)
|
||||
@@ -68,8 +64,8 @@
|
||||
(ctm/move movev)))))
|
||||
shape))
|
||||
|
||||
(defn- update-drawing [state initial point lock? mod? snap-pixel?]
|
||||
(update-in state [:workspace-drawing :object] resize-shape initial point lock? mod? snap-pixel?))
|
||||
(defn update-drawing [state initial point lock? mod?]
|
||||
(update-in state [:workspace-drawing :object] resize-shape initial point lock? mod?))
|
||||
|
||||
(defn move-drawing
|
||||
[{:keys [x y]}]
|
||||
@@ -124,7 +120,7 @@
|
||||
(rx/map move-drawing))
|
||||
|
||||
(->> ms/mouse-position
|
||||
(rx/filter #(> (* (gpt/distance % initial) zoom) 10))
|
||||
(rx/filter #(> (gpt/distance % initial) (/ 2 zoom)))
|
||||
;; Take until before the snap calculation otherwise we could cancel the snap in the worker
|
||||
;; and its a problem for fast moving drawing
|
||||
(rx/take-until stopper)
|
||||
@@ -135,7 +131,7 @@
|
||||
(rx/map (partial array/conj current)))))
|
||||
(rx/map
|
||||
(fn [[_ shift? mod? point]]
|
||||
#(update-drawing % initial (cond-> point snap-pixel? (gpt/round-step 1)) shift? mod? snap-pixel?))))))
|
||||
#(update-drawing % initial (cond-> point snap-pixel? (gpt/round-step 1)) shift? mod?))))))
|
||||
|
||||
(->> (rx/of (common/handle-finish-drawing))
|
||||
(rx/delay 100)))))))
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
[app.main.ui.dashboard.subscription :refer [dashboard-cta*
|
||||
get-subscription-type
|
||||
menu-team-icon*
|
||||
nitrate-sidebar*
|
||||
show-subscription-dashboard-banner?
|
||||
subscription-sidebar*]]
|
||||
[app.main.ui.dashboard.team-form]
|
||||
@@ -1007,6 +1008,9 @@
|
||||
show-comments* (mf/use-state false)
|
||||
show-comments? @show-comments*
|
||||
|
||||
show-nitrate? (and (contains? cf/flags :nitrate)
|
||||
(:nitrate-licence profile))
|
||||
|
||||
handle-hide-comments
|
||||
(mf/use-fn
|
||||
(fn []
|
||||
@@ -1056,10 +1060,12 @@
|
||||
(dom/open-new-window "https://penpot.app/pricing")))]
|
||||
|
||||
[:*
|
||||
(when (contains? cf/flags :subscriptions)
|
||||
(if (show-subscription-dashboard-banner? profile)
|
||||
[:> dashboard-cta* {:profile profile}]
|
||||
[:> subscription-sidebar* {:profile profile}]))
|
||||
(if show-nitrate?
|
||||
[:> nitrate-sidebar* {:profile profile}]
|
||||
(when (contains? cf/flags :subscriptions)
|
||||
(if (show-subscription-dashboard-banner? profile)
|
||||
[:> dashboard-cta* {:profile profile}]
|
||||
[:> subscription-sidebar* {:profile profile}])))
|
||||
|
||||
;; TODO remove this block when subscriptions is full implemented
|
||||
(when (contains? cf/flags :subscriptions-old)
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
[app.common.data.macros :as dm]
|
||||
[app.config :as cf]
|
||||
[app.main.data.event :as ev]
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.router :as rt]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.components.dropdown-menu :refer [dropdown-menu-item*]]
|
||||
@@ -115,6 +116,26 @@
|
||||
:has-dropdown false
|
||||
:is-highlighted false}]))))
|
||||
|
||||
(mf/defc nitrate-sidebar*
|
||||
[]
|
||||
(let [handle-click
|
||||
(mf/use-fn
|
||||
(fn []
|
||||
(st/emit! (modal/show :nitrate-form {}))))]
|
||||
|
||||
;; TODO add translations for this texts when we have the definitive ones
|
||||
[:div {:class (stl/css :nitrate-banner :highlighted)}
|
||||
|
||||
[:div {:class (stl/css :nitrate-content)}
|
||||
[:span {:class (stl/css :nitrate-title)} "Unlock Nitrate features"]]
|
||||
[:div {:class (stl/css :nitrate-content)}
|
||||
|
||||
[:span {:class (stl/css :nitrate-info)} "Some further information and explanation."]
|
||||
[:> button* {:variant "primary"
|
||||
:type "button"
|
||||
:class (stl/css :cta-bottom-button)
|
||||
:on-click handle-click} "UPGRADE TO NITRATE"]]]))
|
||||
|
||||
(mf/defc team*
|
||||
[{:keys [is-owner team]}]
|
||||
(let [subscription (:subscription team)
|
||||
|
||||
@@ -205,3 +205,28 @@
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
}
|
||||
|
||||
.nitrate-banner {
|
||||
display: flex;
|
||||
border-radius: var(--sp-s);
|
||||
flex-direction: column;
|
||||
margin: var(--sp-m);
|
||||
background: var(--color-background-quaternary);
|
||||
border: $b-1 solid var(--color-accent-primary-muted);
|
||||
padding: var(--sp-l);
|
||||
}
|
||||
|
||||
.nitrate-title {
|
||||
@include t.use-typography("body-large");
|
||||
color: var(--color-foreground-primary);
|
||||
}
|
||||
|
||||
.nitrate-info {
|
||||
@include t.use-typography("body-medium");
|
||||
color: var(--color-foreground-secondary);
|
||||
}
|
||||
|
||||
.nitrate-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
@@ -126,6 +126,6 @@
|
||||
|
||||
(defn check-permission
|
||||
[plugin-id permission]
|
||||
(or (= plugin-id "00000000-0000-0000-0000-000000000000")
|
||||
(or (= plugin-id "TEST")
|
||||
(let [{:keys [permissions]} (dm/get-in @registry [:data plugin-id])]
|
||||
(contains? permissions permission))))
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
[app.common.files.helpers :as cfh]
|
||||
[app.common.geom.rect :as grc]
|
||||
[app.common.geom.shapes :as gsh]
|
||||
[app.common.json :as json]
|
||||
[app.common.path-names :as cpn]
|
||||
[app.common.record :as crc]
|
||||
[app.common.schema :as sm]
|
||||
@@ -1296,7 +1295,7 @@
|
||||
(get :applied-tokens))]
|
||||
(reduce
|
||||
(fn [acc [prop name]]
|
||||
(obj/set! acc (json/write-camel-key prop) name))
|
||||
(obj/set! acc (d/name prop) name))
|
||||
#js {}
|
||||
tokens)))}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
[app.main.data.workspace.tokens.application :as dwta]
|
||||
[app.main.data.workspace.tokens.library-edit :as dwtl]
|
||||
[app.main.store :as st]
|
||||
;; [app.plugins.shape :as shape]
|
||||
[app.plugins.shape :as shape]
|
||||
[app.plugins.utils :as u]
|
||||
[app.util.object :as obj]
|
||||
[beicon.v2.core :as rx]
|
||||
@@ -113,17 +113,13 @@
|
||||
|
||||
:applyToShapes
|
||||
{:schema [:tuple
|
||||
;; FIXME: the schema decoder is interpreting the array of shape-proxys and converting
|
||||
;; them to plain maps. For now we adapt the schema to accept it, but the decoder
|
||||
;; should be fixed to keep the original proxy objects coming from the plugin.
|
||||
;; [:vector [:fn shape/shape-proxy?]]
|
||||
[:vector [:map [:id ::sm/uuid]]]
|
||||
[:maybe [:set [:set [:and ::sm/keyword [:fn cto/token-attr?]]]]]]
|
||||
[:vector [:fn shape/shape-proxy?]]
|
||||
[:maybe [:set ::sm/keyword]]]
|
||||
:fn (fn [shapes attrs]
|
||||
(apply-token-to-shapes file-id set-id id (map :id shapes) attrs))}
|
||||
|
||||
:applyToSelected
|
||||
{:schema [:tuple [:maybe [:set [:and ::sm/keyword [:fn cto/token-attr?]]]]]
|
||||
{:schema [:tuple [:maybe [:set ::sm/keyword]]]
|
||||
:fn (fn [attrs]
|
||||
(let [selected (get-in @st/state [:workspace-local :selected])]
|
||||
(apply-token-to-shapes file-id set-id id selected attrs)))}))
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
(let [;; ==== Setup
|
||||
store (ths/setup-store (cthf/sample-file :file1 :page-label :page1))
|
||||
|
||||
^js context (api/create-context "00000000-0000-0000-0000-000000000000")
|
||||
^js context (api/create-context "TEST")
|
||||
|
||||
_ (set! st/state store)
|
||||
|
||||
|
||||
@@ -3,6 +3,21 @@ compatibility_date = "2025-01-01"
|
||||
|
||||
assets = { directory = "../../dist/apps/colors-to-tokens-plugin/browser" }
|
||||
|
||||
[observability]
|
||||
enabled = true
|
||||
head_sampling_rate = 1
|
||||
|
||||
[observability.logs]
|
||||
enabled = true
|
||||
head_sampling_rate = 1
|
||||
persist = true
|
||||
invocation_logs = true
|
||||
|
||||
[observability.traces]
|
||||
enabled = false
|
||||
persist = true
|
||||
head_sampling_rate = 1
|
||||
|
||||
[[routes]]
|
||||
pattern = "WORKER_URI"
|
||||
custom_domain = true
|
||||
|
||||
@@ -3,6 +3,21 @@ compatibility_date = "2025-01-01"
|
||||
|
||||
assets = { directory = "../../dist/apps/contrast-plugin/browser" }
|
||||
|
||||
[observability]
|
||||
enabled = true
|
||||
head_sampling_rate = 1
|
||||
|
||||
[observability.logs]
|
||||
enabled = true
|
||||
head_sampling_rate = 1
|
||||
persist = true
|
||||
invocation_logs = true
|
||||
|
||||
[observability.traces]
|
||||
enabled = false
|
||||
persist = true
|
||||
head_sampling_rate = 1
|
||||
|
||||
[[routes]]
|
||||
pattern = "WORKER_URI"
|
||||
custom_domain = true
|
||||
|
||||
@@ -3,6 +3,21 @@ compatibility_date = "2025-01-01"
|
||||
|
||||
assets = { directory = "../../dist/apps/create-palette-plugin" }
|
||||
|
||||
[observability]
|
||||
enabled = true
|
||||
head_sampling_rate = 1
|
||||
|
||||
[observability.logs]
|
||||
enabled = true
|
||||
head_sampling_rate = 1
|
||||
persist = true
|
||||
invocation_logs = true
|
||||
|
||||
[observability.traces]
|
||||
enabled = false
|
||||
persist = true
|
||||
head_sampling_rate = 1
|
||||
|
||||
[[routes]]
|
||||
pattern = "WORKER_URI"
|
||||
custom_domain = true
|
||||
|
||||
@@ -28,5 +28,5 @@ export default [
|
||||
files: ['**/*.js', '**/*.jsx'],
|
||||
rules: {},
|
||||
},
|
||||
{ ignores: ['vite.config.ts', 'vitest.setup.ts'] },
|
||||
{ ignores: ['vite.config.ts'] },
|
||||
];
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -29,7 +29,6 @@ describe('Plugins', () => {
|
||||
|
||||
it('create grid layout', async () => {
|
||||
const agent = await Agent();
|
||||
|
||||
const result = await agent.runCode(grid.toString(), {
|
||||
screenshot: 'create-gridlayout',
|
||||
});
|
||||
@@ -84,9 +83,9 @@ describe('Plugins', () => {
|
||||
|
||||
it('comments', async () => {
|
||||
const agent = await Agent();
|
||||
console.log(comments.toString());
|
||||
const result = await agent.runCode(comments.toString(), {
|
||||
screenshot: 'create-comments',
|
||||
avoidSavedStatus: true,
|
||||
});
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import puppeteer, { ConsoleMessage } from 'puppeteer';
|
||||
import puppeteer from 'puppeteer';
|
||||
import { PenpotApi } from './api';
|
||||
import { getFileUrl } from './get-file-url';
|
||||
import { idObjectToArray } from './clean-id';
|
||||
@@ -56,16 +56,10 @@ export async function Agent() {
|
||||
console.log('File URL:', fileUrl);
|
||||
|
||||
console.log('Launching browser...');
|
||||
const browser = await puppeteer.launch({
|
||||
headless: process.env['E2E_HEADLESS'] !== 'false',
|
||||
args: ['--ignore-certificate-errors'],
|
||||
});
|
||||
const browser = await puppeteer.launch({});
|
||||
const page = await browser.newPage();
|
||||
|
||||
await page.setViewport({ width: 1920, height: 1080 });
|
||||
await page.setExtraHTTPHeaders({
|
||||
'X-Client': 'plugins/e2e:puppeter',
|
||||
});
|
||||
|
||||
console.log('Setting authentication cookie...');
|
||||
page.setCookie({
|
||||
@@ -91,11 +85,8 @@ export async function Agent() {
|
||||
|
||||
const finish = async () => {
|
||||
console.log('Deleting file and closing browser...');
|
||||
// TODO
|
||||
// await penpotApi.deleteFile(file['~:id']);
|
||||
if (process.env['E2E_CLOSE_BROWSER'] !== 'false') {
|
||||
await browser.close();
|
||||
}
|
||||
await penpotApi.deleteFile(file['~:id']);
|
||||
await browser.close();
|
||||
console.log('Clean up done.');
|
||||
};
|
||||
|
||||
@@ -105,9 +96,11 @@ export async function Agent() {
|
||||
options: {
|
||||
screenshot?: string;
|
||||
autoFinish?: boolean;
|
||||
avoidSavedStatus?: boolean;
|
||||
} = {
|
||||
screenshot: '',
|
||||
autoFinish: true,
|
||||
avoidSavedStatus: false,
|
||||
},
|
||||
) {
|
||||
const autoFinish = options.autoFinish ?? true;
|
||||
@@ -116,27 +109,28 @@ export async function Agent() {
|
||||
await page.evaluate((testingPlugin) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(globalThis as any).ɵloadPlugin({
|
||||
pluginId: '00000000-0000-0000-0000-000000000000',
|
||||
pluginId: 'TEST',
|
||||
name: 'Test',
|
||||
code: `
|
||||
(${testingPlugin})();
|
||||
`,
|
||||
icon: '',
|
||||
description: '',
|
||||
permissions: [
|
||||
'content:read',
|
||||
'content:write',
|
||||
'library:read',
|
||||
'library:write',
|
||||
'user:read',
|
||||
'comment:read',
|
||||
'comment:write',
|
||||
'allow:downloads',
|
||||
'allow:localstorage',
|
||||
],
|
||||
permissions: ['content:read', 'content:write'],
|
||||
});
|
||||
}, code);
|
||||
|
||||
if (!options.avoidSavedStatus) {
|
||||
console.log('Waiting for save status...');
|
||||
await page.waitForSelector(
|
||||
'.main_ui_workspace_right_header__saved-status',
|
||||
{
|
||||
timeout: 10000,
|
||||
},
|
||||
);
|
||||
console.log('Save status found.');
|
||||
}
|
||||
|
||||
if (options.screenshot && screenshotsEnable) {
|
||||
console.log('Taking screenshot:', options.screenshot);
|
||||
await page.screenshot({
|
||||
@@ -144,55 +138,30 @@ export async function Agent() {
|
||||
});
|
||||
}
|
||||
|
||||
const result = await new Promise((resolve) => {
|
||||
const handleConsole = async (msg: ConsoleMessage) => {
|
||||
return new Promise((resolve) => {
|
||||
page.once('console', async (msg) => {
|
||||
const args = (await Promise.all(
|
||||
msg.args().map((arg) => arg.jsonValue()),
|
||||
)) as unknown[];
|
||||
)) as Record<string, unknown>[];
|
||||
|
||||
const type = args[0];
|
||||
const data = args[1];
|
||||
|
||||
if (type !== 'objects' || !data || typeof data !== 'object') {
|
||||
console.log('Invalid console message, waiting for valid one...');
|
||||
page.once('console', handleConsole);
|
||||
return;
|
||||
}
|
||||
|
||||
const result = Object.values(data) as Shape[];
|
||||
const result = Object.values(args[1]) as Shape[];
|
||||
|
||||
replaceIds(result);
|
||||
console.log('IDs replaced in result.');
|
||||
|
||||
resolve(result);
|
||||
};
|
||||
|
||||
page.once('console', handleConsole);
|
||||
if (autoFinish) {
|
||||
console.log('Auto finish enabled. Cleaning up...');
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
console.log('Evaluating debug.dump_objects...');
|
||||
page.evaluate(`
|
||||
debug.dump_objects();
|
||||
`);
|
||||
});
|
||||
|
||||
await page.waitForNetworkIdle({ idleTime: 2000 });
|
||||
|
||||
// Wait for the update-file API call to complete
|
||||
if (process.env['E2E_WAIT_API_RESPONSE'] === 'true') {
|
||||
await page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('api/main/methods/update-file') &&
|
||||
response.status() === 200,
|
||||
{ timeout: 10000 },
|
||||
);
|
||||
}
|
||||
|
||||
if (autoFinish) {
|
||||
console.log('Auto finish enabled. Cleaning up...');
|
||||
await finish();
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
finish,
|
||||
};
|
||||
|
||||
@@ -1,34 +1,31 @@
|
||||
import { FileRpc } from '../models/file-rpc.model';
|
||||
const apiUrl = 'https://localhost:3449';
|
||||
|
||||
const apiUrl = 'http://localhost:3449';
|
||||
|
||||
export async function PenpotApi() {
|
||||
if (!process.env['E2E_LOGIN_EMAIL']) {
|
||||
throw new Error('E2E_LOGIN_EMAIL not set');
|
||||
}
|
||||
|
||||
const body = JSON.stringify({
|
||||
email: process.env['E2E_LOGIN_EMAIL'],
|
||||
password: process.env['E2E_LOGIN_PASSWORD'],
|
||||
});
|
||||
|
||||
const resultLoginRequest = await fetch(
|
||||
`${apiUrl}/api/main/methods/login-with-password`,
|
||||
`${apiUrl}/api/rpc/command/login-with-password`,
|
||||
{
|
||||
credentials: 'include',
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Content-Type': 'application/transit+json',
|
||||
},
|
||||
body: body,
|
||||
body: JSON.stringify({
|
||||
'~:email': process.env['E2E_LOGIN_EMAIL'],
|
||||
'~:password': process.env['E2E_LOGIN_PASSWORD'],
|
||||
}),
|
||||
},
|
||||
);
|
||||
|
||||
const loginData = await resultLoginRequest.json();
|
||||
|
||||
const authToken = resultLoginRequest.headers
|
||||
.getSetCookie()
|
||||
.find((cookie: string) => cookie.startsWith('auth-token='))
|
||||
?.split(';')[0];
|
||||
.get('set-cookie')
|
||||
?.split(';')
|
||||
.at(0);
|
||||
|
||||
if (!authToken) {
|
||||
throw new Error('Login failed');
|
||||
@@ -38,7 +35,7 @@ export async function PenpotApi() {
|
||||
getAuth: () => authToken,
|
||||
createFile: async () => {
|
||||
const createFileRequest = await fetch(
|
||||
`${apiUrl}/api/main/methods/create-file`,
|
||||
`${apiUrl}/api/rpc/command/create-file`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@@ -54,9 +51,6 @@ export async function PenpotApi() {
|
||||
'fdata/objects-map',
|
||||
'fdata/pointer-map',
|
||||
'fdata/shape-data-type',
|
||||
'fdata/path-data',
|
||||
'design-tokens/v1',
|
||||
'variants/v1',
|
||||
'components/v2',
|
||||
'styles/v2',
|
||||
'layout/grid',
|
||||
@@ -67,13 +61,11 @@ export async function PenpotApi() {
|
||||
},
|
||||
);
|
||||
|
||||
const fileData = (await createFileRequest.json()) as FileRpc;
|
||||
console.log('File data received:', fileData);
|
||||
return fileData;
|
||||
return (await createFileRequest.json()) as FileRpc;
|
||||
},
|
||||
deleteFile: async (fileId: string) => {
|
||||
const deleteFileRequest = await fetch(
|
||||
`${apiUrl}/api/main/methods/delete-file`,
|
||||
`${apiUrl}/api/rpc/command/delete-file`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
||||
@@ -6,5 +6,5 @@ export function getFileUrl(file: FileRpc) {
|
||||
const fileId = cleanId(file['~:id']);
|
||||
const pageId = cleanId(file['~:data']['~:pages'][0]);
|
||||
|
||||
return `https://localhost:3449/#/workspace/${projectId}/${fileId}?page-id=${pageId}`;
|
||||
return `http://localhost:3449/#/workspace/${projectId}/${fileId}?page-id=${pageId}`;
|
||||
}
|
||||
|
||||
@@ -7,27 +7,13 @@ export default defineConfig({
|
||||
testTimeout: 20000,
|
||||
watch: false,
|
||||
globals: true,
|
||||
environment: 'node',
|
||||
environmentOptions: {
|
||||
happyDOM: {
|
||||
settings: {
|
||||
disableCSSFileLoading: true,
|
||||
disableJavaScriptFileLoading: true,
|
||||
disableJavaScriptEvaluation: true,
|
||||
enableFileSystemHttpRequests: false,
|
||||
navigator: {
|
||||
userAgent:
|
||||
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
environment: 'happy-dom',
|
||||
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
||||
reporters: ['default'],
|
||||
coverage: {
|
||||
reportsDirectory: '../coverage/e2e',
|
||||
provider: 'v8',
|
||||
},
|
||||
setupFiles: ['dotenv/config', 'vitest.setup.ts'],
|
||||
setupFiles: ['dotenv/config'],
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0';
|
||||
@@ -3,6 +3,21 @@ compatibility_date = "2025-01-01"
|
||||
|
||||
assets = { directory = "../../dist/apps/icons-plugin/browser" }
|
||||
|
||||
[observability]
|
||||
enabled = true
|
||||
head_sampling_rate = 1
|
||||
|
||||
[observability.logs]
|
||||
enabled = true
|
||||
head_sampling_rate = 1
|
||||
persist = true
|
||||
invocation_logs = true
|
||||
|
||||
[observability.traces]
|
||||
enabled = false
|
||||
persist = true
|
||||
head_sampling_rate = 1
|
||||
|
||||
[[routes]]
|
||||
pattern = "WORKER_URI"
|
||||
custom_domain = true
|
||||
|
||||
@@ -3,6 +3,21 @@ compatibility_date = "2025-01-01"
|
||||
|
||||
assets = { directory = "../../dist/apps/lorem-ipsum-plugin/browser" }
|
||||
|
||||
[observability]
|
||||
enabled = true
|
||||
head_sampling_rate = 1
|
||||
|
||||
[observability.logs]
|
||||
enabled = true
|
||||
head_sampling_rate = 1
|
||||
persist = true
|
||||
invocation_logs = true
|
||||
|
||||
[observability.traces]
|
||||
enabled = false
|
||||
persist = true
|
||||
head_sampling_rate = 1
|
||||
|
||||
[[routes]]
|
||||
pattern = "WORKER_URI"
|
||||
custom_domain = true
|
||||
|
||||
@@ -251,14 +251,7 @@ function applyToken(
|
||||
token.applyToSelected(properties);
|
||||
}
|
||||
|
||||
// Alternative way
|
||||
//
|
||||
// const selection = penpot.selection;
|
||||
// if (token && selection) {
|
||||
// token.applyToShapes(selection, properties);
|
||||
// }
|
||||
|
||||
// Other alternative way
|
||||
// Alternatve way
|
||||
//
|
||||
// const selection = penpot.selection;
|
||||
// if (token && selection) {
|
||||
|
||||
@@ -3,6 +3,21 @@ compatibility_date = "2025-01-01"
|
||||
|
||||
assets = { directory = "../../dist/apps/rename-layers-plugin/browser" }
|
||||
|
||||
[observability]
|
||||
enabled = true
|
||||
head_sampling_rate = 1
|
||||
|
||||
[observability.logs]
|
||||
enabled = true
|
||||
head_sampling_rate = 1
|
||||
persist = true
|
||||
invocation_logs = true
|
||||
|
||||
[observability.traces]
|
||||
enabled = false
|
||||
persist = true
|
||||
head_sampling_rate = 1
|
||||
|
||||
[[routes]]
|
||||
pattern = "WORKER_URI"
|
||||
custom_domain = true
|
||||
|
||||
@@ -3,6 +3,21 @@ compatibility_date = "2025-01-01"
|
||||
|
||||
assets = { directory = "../../dist/apps/table-plugin/browser" }
|
||||
|
||||
[observability]
|
||||
enabled = true
|
||||
head_sampling_rate = 1
|
||||
|
||||
[observability.logs]
|
||||
enabled = true
|
||||
head_sampling_rate = 1
|
||||
persist = true
|
||||
invocation_logs = true
|
||||
|
||||
[observability.traces]
|
||||
enabled = false
|
||||
persist = true
|
||||
head_sampling_rate = 1
|
||||
|
||||
[[routes]]
|
||||
pattern = "WORKER_URI"
|
||||
custom_domain = true
|
||||
|
||||
@@ -4,15 +4,12 @@
|
||||
|
||||
1. **Configure Environment Variables**
|
||||
|
||||
Create and populate the `apps/e2e/.env` file with a valid user mail & password:
|
||||
Create and populate the `.env` file with a valid user mail & password:
|
||||
|
||||
```env
|
||||
E2E_LOGIN_EMAIL="test@penpot.app"
|
||||
E2E_LOGIN_PASSWORD="123123123"
|
||||
E2E_SCREENSHOTS="true" # Enable/disable screenshots (default: false)
|
||||
E2E_HEADLESS="false" # Run browser in headless mode (default: true)
|
||||
E2E_CLOSE_BROWSER="true" # Close browser after tests (default: true)
|
||||
E2E_WAIT_API_RESPONSE="false" # Wait for update-file API response (default: false)
|
||||
E2E_SCREENSHOTS= "true"
|
||||
```
|
||||
|
||||
2. **Run E2E Tests**
|
||||
@@ -27,7 +24,7 @@
|
||||
|
||||
1. **Adding Tests**
|
||||
|
||||
Place your test files in the `apps/e2e/src/**/*.spec.ts` directory. Below is an example of a test file:
|
||||
Place your test files in the `/apps/e2e/src/**/*.spec.ts` directory. Below is an example of a test file:
|
||||
|
||||
```ts
|
||||
import testingPlugin from './plugins/create-board-text-rect';
|
||||
@@ -80,5 +77,5 @@
|
||||
If you need to refresh all the snapshopts run the test with the update option:
|
||||
|
||||
```bash
|
||||
pnpm run test:e2e --update
|
||||
pnpm run test:e2e -- --update
|
||||
```
|
||||
|
||||
4
plugins/libs/plugin-types/index.d.ts
vendored
4
plugins/libs/plugin-types/index.d.ts
vendored
@@ -3744,7 +3744,7 @@ export interface ShapeBase extends PluginData {
|
||||
* and the value set to the attributes will depend on which sets are active
|
||||
* (and will change if different sets or themes are activated later).
|
||||
*/
|
||||
readonly tokens: { [property in TokenProperty]: string };
|
||||
readonly tokens: { [property: string]: string };
|
||||
|
||||
/**
|
||||
* @return Returns true if the current shape is inside a component instance
|
||||
@@ -5221,7 +5221,7 @@ type TokenDimensionProps =
|
||||
| 'y'
|
||||
|
||||
// Stroke width
|
||||
| 'strokeWidth';
|
||||
| 'stroke-width';
|
||||
|
||||
/**
|
||||
* The properties that a FontFamilies token can be applied to.
|
||||
|
||||
@@ -28,9 +28,7 @@ export const initPluginsRuntime = (contextBuilder: (id: string) => Context) => {
|
||||
try {
|
||||
console.log('%c[PLUGINS] Initialize runtime', 'color: #008d7c');
|
||||
setContextBuilder(contextBuilder);
|
||||
globalThisAny$.ɵcontext = contextBuilder(
|
||||
'00000000-0000-0000-0000-000000000000',
|
||||
);
|
||||
globalThisAny$.ɵcontext = contextBuilder('TEST');
|
||||
globalThis.ɵloadPlugin = ɵloadPlugin;
|
||||
globalThis.ɵloadPluginByUrl = ɵloadPluginByUrl;
|
||||
globalThis.ɵunloadPlugin = ɵunloadPlugin;
|
||||
|
||||
@@ -3,6 +3,21 @@ compatibility_date = "2025-01-01"
|
||||
|
||||
assets = { directory = "dist/doc" }
|
||||
|
||||
[observability]
|
||||
enabled = true
|
||||
head_sampling_rate = 1
|
||||
|
||||
[observability.logs]
|
||||
enabled = true
|
||||
head_sampling_rate = 1
|
||||
persist = true
|
||||
invocation_logs = true
|
||||
|
||||
[observability.traces]
|
||||
enabled = false
|
||||
persist = true
|
||||
head_sampling_rate = 1
|
||||
|
||||
[[routes]]
|
||||
pattern = "WORKER_URI"
|
||||
custom_domain = true
|
||||
|
||||
@@ -3,6 +3,21 @@ compatibility_date = "2025-01-01"
|
||||
|
||||
assets = { directory = "dist/apps/example-styles" }
|
||||
|
||||
[observability]
|
||||
enabled = true
|
||||
head_sampling_rate = 1
|
||||
|
||||
[observability.logs]
|
||||
enabled = true
|
||||
head_sampling_rate = 1
|
||||
persist = true
|
||||
invocation_logs = true
|
||||
|
||||
[observability.traces]
|
||||
enabled = false
|
||||
persist = true
|
||||
head_sampling_rate = 1
|
||||
|
||||
[[routes]]
|
||||
pattern = "WORKER_URI"
|
||||
custom_domain = true
|
||||
|
||||
Reference in New Issue
Block a user