mirror of
https://github.com/penpot/penpot.git
synced 2026-09-30 15:56:17 +00:00
Merge remote-tracking branch 'origin/staging' into develop
This commit is contained in:
commit
cdb0b3950d
@ -305,8 +305,9 @@
|
|||||||
(defn write-export!
|
(defn write-export!
|
||||||
[{:keys [::bfc/include-libraries ::bfc/embed-assets] :as cfg}]
|
[{:keys [::bfc/include-libraries ::bfc/embed-assets] :as cfg}]
|
||||||
(when (and include-libraries embed-assets)
|
(when (and include-libraries embed-assets)
|
||||||
(throw (IllegalArgumentException.
|
(ex/raise :type :validation
|
||||||
"the `include-libraries` and `embed-assets` are mutally excluding options")))
|
:code :incompatible-options
|
||||||
|
:hint "the `include-libraries` and `embed-assets` are mutually exclusive options"))
|
||||||
|
|
||||||
(write-export cfg))
|
(write-export cfg))
|
||||||
|
|
||||||
|
|||||||
@ -10,12 +10,19 @@ export class TextContent implements TextItem {
|
|||||||
constructor(public text: string) {}
|
constructor(public text: string) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param data - Text data as string or as object (from JSON representation where indices are mapped to character codes)
|
* @param data - Text data as string or as object (wrapped base64 data or JSON representation of array where
|
||||||
|
* indices are mapped to character codes)
|
||||||
*/
|
*/
|
||||||
public static textData(data: string | object): string {
|
public static textData(data: string | object): string {
|
||||||
if (typeof data === "object") {
|
if (typeof data === "object") {
|
||||||
// convert object containing character codes (as obtained from JSON conversion of string) back to string
|
// check for wrapped base64 data
|
||||||
return String.fromCharCode(...(Object.values(data) as number[]));
|
if ("__type" in data && data["__type"] === "base64" && "data" in data && typeof data["data"] === "string") {
|
||||||
|
return Buffer.from(data["data"], "base64").toString("utf-8");
|
||||||
|
}
|
||||||
|
// legacy fallback: assume object containing character codes (as obtained from direct JSON conversion)
|
||||||
|
else {
|
||||||
|
return String.fromCharCode(...(Object.values(data) as number[]));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@ -84,8 +91,8 @@ export class TextResponse extends ToolResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a TextResponse from text data given as string or as object (from JSON representation where indices are mapped to
|
* Creates a TextResponse from text data given as string or as object (wrapped base64 data or JSON representation
|
||||||
* character codes).
|
* of array where indices are mapped to character codes).
|
||||||
*
|
*
|
||||||
* @param data - Text data as string or as object (from JSON representation where indices are mapped to character codes)
|
* @param data - Text data as string or as object (from JSON representation where indices are mapped to character codes)
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user