@drawnagency/primitives 0.1.87 → 0.1.89

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.
Files changed (87) hide show
  1. package/dist/{chunk-PTVY3Q7P.js → chunk-2QXJ2KGB.js} +1 -1
  2. package/dist/{chunk-DRCPDOW3.js → chunk-CZ3YXGK5.js} +59 -0
  3. package/dist/{chunk-NEDOJHHR.js → chunk-J75XGXYD.js} +2 -2
  4. package/dist/{chunk-6VOIZP2O.js → chunk-L2MAJKKC.js} +220 -207
  5. package/dist/{chunk-VY5V4HBV.js → chunk-MVX4ULYE.js} +6 -6
  6. package/dist/{chunk-EO7K45GV.js → chunk-NV4R6VHN.js} +1 -1
  7. package/dist/{chunk-XDG2K6UT.js → chunk-QFV5TSPO.js} +1 -1
  8. package/dist/{chunk-OEL57NYV.js → chunk-VK5KNH73.js} +25 -1
  9. package/dist/{chunk-XPUBUR64.js → chunk-WCBYXNAG.js} +27 -2
  10. package/dist/{chunk-WA3HFN54.js → chunk-Y24T75HT.js} +1 -1
  11. package/dist/components/brandguide/Colors.d.ts.map +1 -1
  12. package/dist/components/brandguide/ColorsEditable.d.ts +20 -0
  13. package/dist/components/brandguide/ColorsEditable.d.ts.map +1 -0
  14. package/dist/components/brandguide/ColorsView.d.ts +9 -0
  15. package/dist/components/brandguide/ColorsView.d.ts.map +1 -0
  16. package/dist/components/brandguide/colors-shared.d.ts +4 -0
  17. package/dist/components/brandguide/colors-shared.d.ts.map +1 -0
  18. package/dist/components/chat/ChatPanel.d.ts +20 -3
  19. package/dist/components/chat/ChatPanel.d.ts.map +1 -1
  20. package/dist/components/chat/ChatWidget.d.ts +7 -1
  21. package/dist/components/chat/ChatWidget.d.ts.map +1 -1
  22. package/dist/components/chat/chat-history.d.ts +24 -0
  23. package/dist/components/chat/chat-history.d.ts.map +1 -0
  24. package/dist/components/editor/index.js +4 -4
  25. package/dist/components/primitives/index.js +5 -5
  26. package/dist/components/sections/Colors/index.d.ts.map +1 -1
  27. package/dist/components/sections/SectionIsland.d.ts +8 -0
  28. package/dist/components/sections/SectionIsland.d.ts.map +1 -0
  29. package/dist/components/sections/brand-guide.js +5 -5
  30. package/dist/components/sections/register-schemas.js +8 -8
  31. package/dist/components/sections/register.js +8 -8
  32. package/dist/components/shared/Navigation.d.ts +6 -1
  33. package/dist/components/shared/Navigation.d.ts.map +1 -1
  34. package/dist/components/shell/EditorShell.d.ts.map +1 -1
  35. package/dist/components/shell/MediaLibraryContext.d.ts +3 -1
  36. package/dist/components/shell/MediaLibraryContext.d.ts.map +1 -1
  37. package/dist/components/shell/SiteSettingsChatbot.d.ts.map +1 -1
  38. package/dist/hooks/useCollabSession.d.ts.map +1 -1
  39. package/dist/hooks/useMediaPipeline.d.ts +5 -1
  40. package/dist/hooks/useMediaPipeline.d.ts.map +1 -1
  41. package/dist/index.js +14 -4
  42. package/dist/lib/chatbot.d.ts +10 -0
  43. package/dist/lib/chatbot.d.ts.map +1 -0
  44. package/dist/lib/contrast.d.ts +5 -0
  45. package/dist/lib/contrast.d.ts.map +1 -1
  46. package/dist/lib/index.d.ts +2 -1
  47. package/dist/lib/index.d.ts.map +1 -1
  48. package/dist/lib/index.js +10 -2
  49. package/dist/lib/registry.d.ts +7 -0
  50. package/dist/lib/registry.d.ts.map +1 -1
  51. package/dist/media/compose-preview.d.ts +23 -0
  52. package/dist/media/compose-preview.d.ts.map +1 -0
  53. package/dist/media/index.d.ts +1 -0
  54. package/dist/media/index.d.ts.map +1 -1
  55. package/dist/media/index.js +4 -2
  56. package/dist/media/preview-inputs.d.ts +31 -0
  57. package/dist/media/preview-inputs.d.ts.map +1 -0
  58. package/dist/schemas/index.js +2 -2
  59. package/dist/schemas/media.d.ts +2 -0
  60. package/dist/schemas/media.d.ts.map +1 -1
  61. package/dist/schemas/site-config.d.ts +12 -0
  62. package/dist/schemas/site-config.d.ts.map +1 -1
  63. package/package.json +1 -1
  64. package/src/components/brandguide/Colors.tsx +2 -275
  65. package/src/components/brandguide/ColorsEditable.tsx +155 -0
  66. package/src/components/brandguide/ColorsView.tsx +100 -0
  67. package/src/components/brandguide/colors-shared.ts +17 -0
  68. package/src/components/chat/ChatPanel.tsx +437 -65
  69. package/src/components/chat/ChatWidget.tsx +90 -32
  70. package/src/components/chat/chat-history.ts +105 -0
  71. package/src/components/sections/Colors/index.tsx +1 -0
  72. package/src/components/sections/SectionIsland.tsx +21 -0
  73. package/src/components/shared/Navigation.tsx +18 -5
  74. package/src/components/shell/EditorShell.tsx +71 -1
  75. package/src/components/shell/MediaLibraryContext.tsx +1 -1
  76. package/src/components/shell/SiteSettingsChatbot.tsx +47 -0
  77. package/src/hooks/useCollabSession.ts +27 -0
  78. package/src/hooks/useMediaPipeline.ts +7 -3
  79. package/src/lib/chatbot.ts +30 -0
  80. package/src/lib/contrast.ts +12 -0
  81. package/src/lib/index.ts +2 -1
  82. package/src/lib/registry.ts +7 -0
  83. package/src/media/compose-preview.ts +90 -0
  84. package/src/media/index.ts +1 -0
  85. package/src/media/preview-inputs.ts +77 -0
  86. package/src/schemas/media.ts +3 -0
  87. package/src/schemas/site-config.ts +26 -1
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  EditablePlainText
3
- } from "./chunk-NEDOJHHR.js";
3
+ } from "./chunk-J75XGXYD.js";
4
4
  import {
5
5
  Button,
6
6
  usePages
@@ -308,6 +308,64 @@ function generateVideoPoster(blob, quality) {
308
308
  });
309
309
  }
310
310
 
311
+ // src/media/compose-preview.ts
312
+ var WIDTH = 1200;
313
+ var HEIGHT = 630;
314
+ async function composePreviewImage(inputs) {
315
+ const canvas = document.createElement("canvas");
316
+ canvas.width = WIDTH;
317
+ canvas.height = HEIGHT;
318
+ const ctx = canvas.getContext("2d");
319
+ if (!ctx) throw new Error("2D canvas context unavailable");
320
+ ctx.fillStyle = inputs.background;
321
+ ctx.fillRect(0, 0, WIDTH, HEIGHT);
322
+ let drewLogo = false;
323
+ if (inputs.mode === "logo" && inputs.logoUrl) {
324
+ try {
325
+ const img = await loadImage(inputs.logoUrl);
326
+ if (!(img.width > 0 && img.height > 0)) {
327
+ throw new Error("Logo image has no intrinsic size");
328
+ }
329
+ const maxW = WIDTH * 0.6;
330
+ const maxH = HEIGHT * 0.5;
331
+ const scale = Math.min(maxW / img.width, maxH / img.height);
332
+ const w = img.width * scale;
333
+ const h = img.height * scale;
334
+ ctx.filter = inputs.invertLogo ? "invert(1)" : "none";
335
+ ctx.drawImage(img, (WIDTH - w) / 2, (HEIGHT - h) / 2, w, h);
336
+ ctx.filter = "none";
337
+ drewLogo = true;
338
+ } catch {
339
+ }
340
+ }
341
+ if (!drewLogo) {
342
+ if (document.fonts?.ready) await document.fonts.ready;
343
+ await document.fonts.load(`600 84px ${inputs.headingFont}`).catch(() => {
344
+ });
345
+ ctx.fillStyle = inputs.textColor;
346
+ ctx.textAlign = "center";
347
+ ctx.textBaseline = "middle";
348
+ ctx.font = `600 84px ${inputs.headingFont}, system-ui, sans-serif`;
349
+ ctx.fillText(inputs.siteName, WIDTH / 2, HEIGHT / 2, WIDTH * 0.86);
350
+ }
351
+ return await new Promise((resolve, reject) => {
352
+ canvas.toBlob(
353
+ (blob) => blob ? resolve(blob) : reject(new Error("toBlob returned null")),
354
+ "image/webp",
355
+ 0.9
356
+ );
357
+ });
358
+ }
359
+ function loadImage(url) {
360
+ return new Promise((resolve, reject) => {
361
+ const img = new Image();
362
+ img.crossOrigin = "anonymous";
363
+ img.onload = () => resolve(img);
364
+ img.onerror = () => reject(new Error(`failed to load ${url}`));
365
+ img.src = url;
366
+ });
367
+ }
368
+
311
369
  // src/media/index.ts
312
370
  var MEDIA_KEY = /* @__PURE__ */ Symbol.for("@drawnagency/primitives/media");
313
371
  var _g = globalThis;
@@ -339,6 +397,7 @@ export {
339
397
  rebindImageRef,
340
398
  resolveLogo,
341
399
  generateVideoPoster,
400
+ composePreviewImage,
342
401
  setMediaProvider,
343
402
  getMediaProvider
344
403
  };
@@ -6,10 +6,10 @@ import {
6
6
  SettingsIcon,
7
7
  useMediaLibrary,
8
8
  useResolvedMedia
9
- } from "./chunk-EO7K45GV.js";
9
+ } from "./chunk-NV4R6VHN.js";
10
10
  import {
11
11
  rebindImageRef
12
- } from "./chunk-DRCPDOW3.js";
12
+ } from "./chunk-CZ3YXGK5.js";
13
13
  import {
14
14
  cn
15
15
  } from "./chunk-7EOSDFS3.js";