@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.
- package/dist/{chunk-PTVY3Q7P.js → chunk-2QXJ2KGB.js} +1 -1
- package/dist/{chunk-DRCPDOW3.js → chunk-CZ3YXGK5.js} +59 -0
- package/dist/{chunk-NEDOJHHR.js → chunk-J75XGXYD.js} +2 -2
- package/dist/{chunk-6VOIZP2O.js → chunk-L2MAJKKC.js} +220 -207
- package/dist/{chunk-VY5V4HBV.js → chunk-MVX4ULYE.js} +6 -6
- package/dist/{chunk-EO7K45GV.js → chunk-NV4R6VHN.js} +1 -1
- package/dist/{chunk-XDG2K6UT.js → chunk-QFV5TSPO.js} +1 -1
- package/dist/{chunk-OEL57NYV.js → chunk-VK5KNH73.js} +25 -1
- package/dist/{chunk-XPUBUR64.js → chunk-WCBYXNAG.js} +27 -2
- package/dist/{chunk-WA3HFN54.js → chunk-Y24T75HT.js} +1 -1
- package/dist/components/brandguide/Colors.d.ts.map +1 -1
- package/dist/components/brandguide/ColorsEditable.d.ts +20 -0
- package/dist/components/brandguide/ColorsEditable.d.ts.map +1 -0
- package/dist/components/brandguide/ColorsView.d.ts +9 -0
- package/dist/components/brandguide/ColorsView.d.ts.map +1 -0
- package/dist/components/brandguide/colors-shared.d.ts +4 -0
- package/dist/components/brandguide/colors-shared.d.ts.map +1 -0
- package/dist/components/chat/ChatPanel.d.ts +20 -3
- package/dist/components/chat/ChatPanel.d.ts.map +1 -1
- package/dist/components/chat/ChatWidget.d.ts +7 -1
- package/dist/components/chat/ChatWidget.d.ts.map +1 -1
- package/dist/components/chat/chat-history.d.ts +24 -0
- package/dist/components/chat/chat-history.d.ts.map +1 -0
- package/dist/components/editor/index.js +4 -4
- package/dist/components/primitives/index.js +5 -5
- package/dist/components/sections/Colors/index.d.ts.map +1 -1
- package/dist/components/sections/SectionIsland.d.ts +8 -0
- package/dist/components/sections/SectionIsland.d.ts.map +1 -0
- package/dist/components/sections/brand-guide.js +5 -5
- package/dist/components/sections/register-schemas.js +8 -8
- package/dist/components/sections/register.js +8 -8
- package/dist/components/shared/Navigation.d.ts +6 -1
- package/dist/components/shared/Navigation.d.ts.map +1 -1
- package/dist/components/shell/EditorShell.d.ts.map +1 -1
- package/dist/components/shell/MediaLibraryContext.d.ts +3 -1
- package/dist/components/shell/MediaLibraryContext.d.ts.map +1 -1
- package/dist/components/shell/SiteSettingsChatbot.d.ts.map +1 -1
- package/dist/hooks/useCollabSession.d.ts.map +1 -1
- package/dist/hooks/useMediaPipeline.d.ts +5 -1
- package/dist/hooks/useMediaPipeline.d.ts.map +1 -1
- package/dist/index.js +14 -4
- package/dist/lib/chatbot.d.ts +10 -0
- package/dist/lib/chatbot.d.ts.map +1 -0
- package/dist/lib/contrast.d.ts +5 -0
- package/dist/lib/contrast.d.ts.map +1 -1
- package/dist/lib/index.d.ts +2 -1
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +10 -2
- package/dist/lib/registry.d.ts +7 -0
- package/dist/lib/registry.d.ts.map +1 -1
- package/dist/media/compose-preview.d.ts +23 -0
- package/dist/media/compose-preview.d.ts.map +1 -0
- package/dist/media/index.d.ts +1 -0
- package/dist/media/index.d.ts.map +1 -1
- package/dist/media/index.js +4 -2
- package/dist/media/preview-inputs.d.ts +31 -0
- package/dist/media/preview-inputs.d.ts.map +1 -0
- package/dist/schemas/index.js +2 -2
- package/dist/schemas/media.d.ts +2 -0
- package/dist/schemas/media.d.ts.map +1 -1
- package/dist/schemas/site-config.d.ts +12 -0
- package/dist/schemas/site-config.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/brandguide/Colors.tsx +2 -275
- package/src/components/brandguide/ColorsEditable.tsx +155 -0
- package/src/components/brandguide/ColorsView.tsx +100 -0
- package/src/components/brandguide/colors-shared.ts +17 -0
- package/src/components/chat/ChatPanel.tsx +437 -65
- package/src/components/chat/ChatWidget.tsx +90 -32
- package/src/components/chat/chat-history.ts +105 -0
- package/src/components/sections/Colors/index.tsx +1 -0
- package/src/components/sections/SectionIsland.tsx +21 -0
- package/src/components/shared/Navigation.tsx +18 -5
- package/src/components/shell/EditorShell.tsx +71 -1
- package/src/components/shell/MediaLibraryContext.tsx +1 -1
- package/src/components/shell/SiteSettingsChatbot.tsx +47 -0
- package/src/hooks/useCollabSession.ts +27 -0
- package/src/hooks/useMediaPipeline.ts +7 -3
- package/src/lib/chatbot.ts +30 -0
- package/src/lib/contrast.ts +12 -0
- package/src/lib/index.ts +2 -1
- package/src/lib/registry.ts +7 -0
- package/src/media/compose-preview.ts +90 -0
- package/src/media/index.ts +1 -0
- package/src/media/preview-inputs.ts +77 -0
- package/src/schemas/media.ts +3 -0
- package/src/schemas/site-config.ts +26 -1
|
@@ -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-
|
|
9
|
+
} from "./chunk-NV4R6VHN.js";
|
|
10
10
|
import {
|
|
11
11
|
rebindImageRef
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-CZ3YXGK5.js";
|
|
13
13
|
import {
|
|
14
14
|
cn
|
|
15
15
|
} from "./chunk-7EOSDFS3.js";
|