@orangecatai/adgen-canvas 0.0.13 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dev/index.js CHANGED
@@ -67,10 +67,10 @@ import {
67
67
  serializeAsJSON,
68
68
  serializeLibraryAsJSON,
69
69
  strokeRectWithRotation_simple
70
- } from "./chunk-SL25BHFI.js";
70
+ } from "./chunk-W3WRQE6Q.js";
71
71
  import {
72
72
  define_import_meta_env_default
73
- } from "./chunk-SNMJI5ML.js";
73
+ } from "./chunk-3OPVOEOA.js";
74
74
  import {
75
75
  en_default
76
76
  } from "./chunk-IFMURN5W.js";
@@ -84,7 +84,7 @@ import {
84
84
  } from "./chunk-XDFCUUT6.js";
85
85
 
86
86
  // index.tsx
87
- import React64, { useEffect as useEffect62 } from "react";
87
+ import React64, { useEffect as useEffect62, useMemo as useMemo15 } from "react";
88
88
  import { DEFAULT_UI_OPTIONS, isShallowEqual as isShallowEqual10 } from "@orangecatai/common";
89
89
 
90
90
  // components/App.tsx
@@ -5250,7 +5250,8 @@ import React10, {
5250
5250
  useState as useState6,
5251
5251
  useRef as useRef9,
5252
5252
  useEffect as useEffect10,
5253
- useCallback as useCallback3
5253
+ useCallback as useCallback3,
5254
+ useSyncExternalStore
5254
5255
  } from "react";
5255
5256
  import {
5256
5257
  arrayToList,
@@ -5526,6 +5527,10 @@ var FontPickerList = React10.memo(
5526
5527
  const stylesPanelMode = useStylesPanelMode();
5527
5528
  const [searchTerm, setSearchTerm] = useState6("");
5528
5529
  const inputRef = useRef9(null);
5530
+ const customFontVersion = useSyncExternalStore(
5531
+ Fonts.subscribeToCustomFonts,
5532
+ Fonts.getCustomFontVersion
5533
+ );
5529
5534
  const allFonts = useMemo(
5530
5535
  () => Array.from(Fonts.registered.entries()).filter(
5531
5536
  ([_, { metadata }]) => !metadata.private && !metadata.fallback
@@ -5548,7 +5553,7 @@ var FontPickerList = React10.memo(
5548
5553
  }).sort(
5549
5554
  (a, b) => a.text.toLowerCase() > b.text.toLowerCase() ? 1 : -1
5550
5555
  ),
5551
- []
5556
+ [customFontVersion]
5552
5557
  );
5553
5558
  const sceneFamilies = useMemo(
5554
5559
  () => new Set(fonts.getSceneFamilies()),
@@ -9765,7 +9770,7 @@ var exportCanvas = async (type, elements, appState, files, {
9765
9770
  let blob = canvasToBlob(tempCanvas);
9766
9771
  if (appState.exportEmbedScene) {
9767
9772
  blob = blob.then(
9768
- (blob2) => import("./data/image-AVAYTNBV.js").then(
9773
+ (blob2) => import("./data/image-NKXZX2BO.js").then(
9769
9774
  ({ encodePngMetadata: encodePngMetadata2 }) => encodePngMetadata2({
9770
9775
  blob: blob2,
9771
9776
  metadata: serializeAsJSON(elements, appState, files, "local")
@@ -27486,15 +27491,15 @@ var ImageEditToolbar = ({
27486
27491
  },
27487
27492
  tool.id
27488
27493
  )),
27489
- !!element.customData?.brandAssetId && /* @__PURE__ */ jsxs52(
27494
+ !!callbacks?.onSwapAsset && /* @__PURE__ */ jsxs52(
27490
27495
  "button",
27491
27496
  {
27492
27497
  type: "button",
27493
27498
  className: "iet__tool-btn",
27494
27499
  onClick: () => {
27495
- void callbacks?.onSwapAsset?.(element.id);
27500
+ void callbacks.onSwapAsset(element.id);
27496
27501
  },
27497
- title: "Swap brand asset",
27502
+ title: "Swap image from asset bank",
27498
27503
  disabled: isToolbarBusy,
27499
27504
  children: [
27500
27505
  /* @__PURE__ */ jsx94(SwapAssetIcon, {}),
@@ -51373,7 +51378,8 @@ function execAddRectangle(args, ctx) {
51373
51378
  fillStyle: args.fillStyle || "solid",
51374
51379
  strokeColor: args.strokeColor || "transparent",
51375
51380
  strokeWidth: args.strokeWidth ?? 0,
51376
- opacity: args.opacity ?? 100
51381
+ opacity: args.opacity ?? 100,
51382
+ roughness: 0
51377
51383
  });
51378
51384
  const elements = ctx.excalidrawAPI.getSceneElements();
51379
51385
  const frameIndex = elements.findIndex((el) => el.id === frameId);
@@ -51434,7 +51440,8 @@ function execAddText(args, ctx) {
51434
51440
  fontFamily: args.fontFamily || 2,
51435
51441
  strokeColor: args.strokeColor || "#000000",
51436
51442
  textAlign: args.textAlign || "left",
51437
- width: args.width
51443
+ width: args.width,
51444
+ roughness: 0
51438
51445
  });
51439
51446
  const elements = ctx.excalidrawAPI.getSceneElements();
51440
51447
  const frameIndex = elements.findIndex((el) => el.id === frameId);
@@ -51477,7 +51484,8 @@ async function execGenerateImage(args, ctx) {
51477
51484
  const height = args.height;
51478
51485
  const referenceImageIndex = args.referenceImageIndex;
51479
51486
  const referenceImageDataUrl = referenceImageIndex !== void 0 ? ctx.fileAttachments?.[referenceImageIndex]?.dataUrl : void 0;
51480
- const safePrompt = `${prompt} \u2014 NO text, NO typography, NO words, NO captions, NO watermarks, NO overlaid copy. Pure clean visual image only.`;
51487
+ const fontHint = ctx.brandHeadlineFontName ? ` Brand typography: ${ctx.brandHeadlineFontName}.` : ctx.brandBodyFontName ? ` Brand typography: ${ctx.brandBodyFontName}.` : "";
51488
+ const safePrompt = `${prompt}${fontHint} \u2014 NO text, NO typography, NO words, NO captions, NO watermarks, NO overlaid copy. Pure clean visual image only.`;
51481
51489
  if (!frameId || !prompt) {
51482
51490
  return {
51483
51491
  success: false,
@@ -52707,15 +52715,17 @@ function buildBrandContextMessage(ctx) {
52707
52715
  if (headline?.family) {
52708
52716
  const sizeHint = headline.sizeScale ? ` (suggested size: ${SIZE_SCALE_MAP[headline.sizeScale] ?? headline.sizeScale})` : "";
52709
52717
  const idNote = headline.fontFamilyId ? ` \u2014 custom font registered in canvas; use \`font-family: "${headline.family}", Arial, sans-serif\` in your HTML CSS` : ` \u2014 no custom font file loaded; use \`font-family: "${headline.family}", Arial, sans-serif\` in your HTML CSS (will render as Arial on canvas)`;
52718
+ const fileNote = headline.fontName ? ` [file: ${headline.fontName}]` : "";
52710
52719
  lines.push(
52711
- `**Headline font**: ${headline.family}${headline.weight ? ` weight ${headline.weight}` : ""}${sizeHint}${idNote}`
52720
+ `**Headline font**: ${headline.family}${headline.weight ? ` weight ${headline.weight}` : ""}${sizeHint}${idNote}${fileNote}`
52712
52721
  );
52713
52722
  }
52714
52723
  if (body?.family) {
52715
52724
  const sizeHint = body.sizeScale ? ` (suggested size: ${SIZE_SCALE_MAP[body.sizeScale] ?? body.sizeScale})` : "";
52716
52725
  const idNote = body.fontFamilyId ? ` \u2014 custom font registered in canvas; use \`font-family: "${body.family}", Arial, sans-serif\` in your HTML CSS` : ` \u2014 no custom font file loaded; use \`font-family: "${body.family}", Arial, sans-serif\` in your HTML CSS (will render as Arial on canvas)`;
52726
+ const fileNote = body.fontName ? ` [file: ${body.fontName}]` : "";
52717
52727
  lines.push(
52718
- `**Body font**: ${body.family}${body.weight ? ` weight ${body.weight}` : ""}${sizeHint}${idNote}`
52728
+ `**Body font**: ${body.family}${body.weight ? ` weight ${body.weight}` : ""}${sizeHint}${idNote}${fileNote}`
52719
52729
  );
52720
52730
  }
52721
52731
  }
@@ -52814,7 +52824,9 @@ async function runAgentLoop(opts) {
52814
52824
  const augmentedToolCtx = {
52815
52825
  ...toolCtx,
52816
52826
  ...Object.keys(customFontMap).length ? { customFontMap } : {},
52817
- ...allImageAttachments.length ? { fileAttachments: allImageAttachments } : {}
52827
+ ...allImageAttachments.length ? { fileAttachments: allImageAttachments } : {},
52828
+ ...brandContext?.typography?.headline?.fontName ? { brandHeadlineFontName: brandContext.typography.headline.fontName } : {},
52829
+ ...brandContext?.typography?.body?.fontName ? { brandBodyFontName: brandContext.typography.body.fontName } : {}
52818
52830
  };
52819
52831
  const messages = [{ role: "system", content: SYSTEM_PROMPT }];
52820
52832
  if (brandContext) {
@@ -55026,11 +55038,8 @@ var ExcalidrawBase = (props) => {
55026
55038
  document.removeEventListener("touchmove", handleTouchMove);
55027
55039
  };
55028
55040
  }, []);
55029
- useEffect62(() => {
55030
- if (!customFonts?.length) {
55031
- return;
55032
- }
55033
- for (const spec of customFonts) {
55041
+ useMemo15(() => {
55042
+ for (const spec of customFonts ?? []) {
55034
55043
  Fonts.registerCustomFont(spec);
55035
55044
  }
55036
55045
  }, [customFonts]);