@oxygen-agent/cli 1.1026.33 → 1.1028.7

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/README.md CHANGED
@@ -34,4 +34,4 @@ oxygen update
34
34
 
35
35
  For product documentation, visit https://oxygen-agent.com/docs. For support, visit https://oxygen-agent.com.
36
36
 
37
- Version: 1.1026.33
37
+ Version: 1.1028.7
@@ -0,0 +1,54 @@
1
+ /**
2
+ * A newsletter's brand chrome (Tim, 2026-11-01: one-to-one with the emails OXYGEN
3
+ * sent from Resend): the brand kit's logo above the content, and below it the
4
+ * social icons, the company name and postal address, and the unsubscribe link.
5
+ *
6
+ * The email editor marks where the chrome goes in every email it composes
7
+ * (`markBrandSlots`: the first and last place inside the content column), and
8
+ * every renderer fills those marks from the workspace's current kit with
9
+ * `fillBrandSlots`: delivery, the test send and the in-app preview. So a kit
10
+ * edit reaches the next send, and an email whose HTML has no marks (written as
11
+ * raw HTML, or composed before the marks) keeps the plain footers delivery
12
+ * appends. Pure and browser-safe.
13
+ */
14
+ import type { EmailBrandKit } from "./email-brand-kit.js";
15
+ /** Where the footer's social icons are hosted (`apps/web/public/email/social/`): an origin every inbox can reach. */
16
+ export declare const BRAND_CHROME_ASSET_ORIGIN = "https://oxygen-agent.com";
17
+ export declare const BRAND_HEADER_SLOT = "<!--oxygen:brand-header-->";
18
+ export declare const BRAND_FOOTER_SLOT = "<!--oxygen:brand-footer-->";
19
+ /** The kit fields the chrome draws. */
20
+ export type EmailBrandChrome = Pick<EmailBrandKit, "logo_url" | "logo_width" | "company_name" | "postal_address" | "social_links" | "text_color" | "content_background_color">;
21
+ /** The chrome a kit draws; a kit without colours falls back to the default kit's (`DEFAULT_EMAIL_BRAND_COLORS`). */
22
+ export declare function brandChromeOf(kit: Partial<EmailBrandKit> | null | undefined): EmailBrandChrome;
23
+ /** `from` moved `amount` (0..1) of the way to `to`; `from` itself when either is not `#rrggbb`. */
24
+ export declare function mixHex(from: string, to: string, amount: number): string;
25
+ /** The footer's two greys, from the kit's text towards its background, as the Resend emails drew them. */
26
+ export declare function brandFooterColors(chrome: Pick<EmailBrandChrome, "text_color" | "content_background_color">): {
27
+ muted: string;
28
+ faint: string;
29
+ };
30
+ /** The logo above the content, or nothing when the kit has none. */
31
+ export declare function brandHeaderHtml(chrome: EmailBrandChrome): string;
32
+ /**
33
+ * Social icons, then the company name and address, then the unsubscribe link
34
+ * (`{{unsubscribe_url}}`, filled per recipient at send). `includeUnsubscribe:
35
+ * false` leaves the link out, for an email that places its own.
36
+ */
37
+ export declare function brandFooterHtml(chrome: EmailBrandChrome, options: {
38
+ assetOrigin: string;
39
+ includeUnsubscribe?: boolean;
40
+ }): string;
41
+ /**
42
+ * Mark the chrome's place in an email the editor composed: the header right
43
+ * inside the content column's cell, the footer at its end. HTML of any other
44
+ * shape comes back unchanged, so it keeps the footers delivery appends.
45
+ */
46
+ export declare function markBrandSlots(html: string): string;
47
+ export declare function hasBrandSlots(html: string): boolean;
48
+ /**
49
+ * Draw the kit's chrome into the marks. An email that already links its own
50
+ * unsubscribe keeps that link alone; one without marks comes back unchanged.
51
+ */
52
+ export declare function fillBrandSlots(html: string, chrome: EmailBrandChrome, options: {
53
+ assetOrigin: string;
54
+ }): string;
@@ -0,0 +1,134 @@
1
+ /** Where the footer's social icons are hosted (`apps/web/public/email/social/`): an origin every inbox can reach. */
2
+ export const BRAND_CHROME_ASSET_ORIGIN = "https://oxygen-agent.com";
3
+ export const BRAND_HEADER_SLOT = "<!--oxygen:brand-header-->";
4
+ export const BRAND_FOOTER_SLOT = "<!--oxygen:brand-footer-->";
5
+ /** The chrome a kit draws; a kit without colours falls back to the default kit's (`DEFAULT_EMAIL_BRAND_COLORS`). */
6
+ export function brandChromeOf(kit) {
7
+ return {
8
+ logo_url: kit?.logo_url ?? null,
9
+ logo_width: kit?.logo_width ?? null,
10
+ company_name: kit?.company_name ?? null,
11
+ postal_address: kit?.postal_address ?? null,
12
+ social_links: kit?.social_links ?? [],
13
+ text_color: kit?.text_color ?? "#18181b",
14
+ content_background_color: kit?.content_background_color ?? "#ffffff",
15
+ };
16
+ }
17
+ const SOCIAL_LABELS = {
18
+ website: "Website",
19
+ linkedin: "LinkedIn",
20
+ x: "X",
21
+ facebook: "Facebook",
22
+ instagram: "Instagram",
23
+ youtube: "YouTube",
24
+ tiktok: "TikTok",
25
+ github: "GitHub",
26
+ };
27
+ /** The networks with a hosted icon under `/email/social/`; the rest show as text links. */
28
+ const ICON_NETWORKS = new Set(["website", "linkedin", "x", "facebook", "instagram", "youtube"]);
29
+ const DEFAULT_LOGO_WIDTH = 28;
30
+ function escapeHtml(value) {
31
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
32
+ }
33
+ function channels(hex) {
34
+ const match = /^#([0-9a-f]{6})$/i.exec(hex.trim());
35
+ if (!match)
36
+ return null;
37
+ const value = Number.parseInt(match[1], 16);
38
+ return [(value >> 16) & 255, (value >> 8) & 255, value & 255];
39
+ }
40
+ /** `from` moved `amount` (0..1) of the way to `to`; `from` itself when either is not `#rrggbb`. */
41
+ export function mixHex(from, to, amount) {
42
+ const a = channels(from);
43
+ const b = channels(to);
44
+ if (!a || !b)
45
+ return from;
46
+ return `#${a.map((channel, index) => Math.round(channel + (b[index] - channel) * amount).toString(16).padStart(2, "0")).join("")}`;
47
+ }
48
+ /** The footer's two greys, from the kit's text towards its background, as the Resend emails drew them. */
49
+ export function brandFooterColors(chrome) {
50
+ return {
51
+ muted: mixHex(chrome.text_color, chrome.content_background_color, 0.27),
52
+ faint: mixHex(chrome.text_color, chrome.content_background_color, 0.39),
53
+ };
54
+ }
55
+ /** The logo above the content, or nothing when the kit has none. */
56
+ export function brandHeaderHtml(chrome) {
57
+ if (!chrome.logo_url)
58
+ return "";
59
+ const width = chrome.logo_width ?? DEFAULT_LOGO_WIDTH;
60
+ const alt = escapeHtml(chrome.company_name ?? "");
61
+ return `<table role="presentation" cellspacing="0" cellpadding="0" border="0" style="margin:0 0 44px"><tr><td>`
62
+ + `<img src="${escapeHtml(chrome.logo_url)}" width="${width}" alt="${alt}" style="display:block;width:${width}px;max-width:100%;height:auto;border:0" />`
63
+ + `</td></tr></table>`;
64
+ }
65
+ /**
66
+ * Social icons, then the company name and address, then the unsubscribe link
67
+ * (`{{unsubscribe_url}}`, filled per recipient at send). `includeUnsubscribe:
68
+ * false` leaves the link out, for an email that places its own.
69
+ */
70
+ export function brandFooterHtml(chrome, options) {
71
+ const { muted, faint } = brandFooterColors(chrome);
72
+ const origin = options.assetOrigin.replace(/\/+$/, "");
73
+ const links = chrome.social_links ?? [];
74
+ const icons = links.map((link, index) => {
75
+ const label = SOCIAL_LABELS[link.network];
76
+ const pad = index === links.length - 1 ? "0" : "0 16px 0 0";
77
+ const inner = ICON_NETWORKS.has(link.network)
78
+ ? `<img src="${origin}/email/social/${link.network}.png" width="20" height="20" alt="${label}" style="display:block;width:20px;height:20px;border:0" />`
79
+ : `<span style="font-size:12px;color:${muted}">${label}</span>`;
80
+ return `<td style="padding:${pad}"><a href="${escapeHtml(link.url)}" aria-label="${label}" style="text-decoration:none">${inner}</a></td>`;
81
+ }).join("");
82
+ const social = icons
83
+ ? `<table role="presentation" cellspacing="0" cellpadding="0" border="0" align="left" style="margin:0 0 14px"><tr>${icons}</tr></table>`
84
+ : "";
85
+ const company = chrome.company_name?.trim();
86
+ const address = (chrome.postal_address ?? "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
87
+ const postal = company || address.length > 0
88
+ ? `<p style="clear:both;margin:0;font-size:10px;line-height:1.55;color:${faint}">${[
89
+ ...(company ? [`<strong style="font-weight:600;color:${muted}">${escapeHtml(company)}</strong>`] : []),
90
+ ...address.map(escapeHtml),
91
+ ].join("<br />")}</p>`
92
+ : "";
93
+ const unsubscribe = options.includeUnsubscribe === false
94
+ ? ""
95
+ : `<a href="{{unsubscribe_url}}" ses:no-track style="display:inline-block;margin-top:12px;font-size:10px;color:${faint};text-decoration:underline;text-underline-offset:2px">Unsubscribe</a>`;
96
+ const body = `${social}${postal}${unsubscribe}`;
97
+ return body ? `<div style="padding-top:42px;text-align:left;color:${muted}">${body}</div>` : "";
98
+ }
99
+ const CONTAINER_TABLE = /<table\b[^>]*\bstyle="[^"]*max-width:[^"]*"[^>]*>/i;
100
+ const CONTAINER_CLOSE = "</td></tr></tbody></table></td></tr></tbody></table>";
101
+ /**
102
+ * Mark the chrome's place in an email the editor composed: the header right
103
+ * inside the content column's cell, the footer at its end. HTML of any other
104
+ * shape comes back unchanged, so it keeps the footers delivery appends.
105
+ */
106
+ export function markBrandSlots(html) {
107
+ if (html.includes(BRAND_HEADER_SLOT))
108
+ return html;
109
+ const container = CONTAINER_TABLE.exec(html);
110
+ if (!container)
111
+ return html;
112
+ const cellStart = html.indexOf("<td", container.index + container[0].length);
113
+ const cellOpenEnd = cellStart < 0 ? -1 : html.indexOf(">", cellStart);
114
+ const close = html.lastIndexOf(CONTAINER_CLOSE);
115
+ if (cellOpenEnd < 0 || close < cellOpenEnd)
116
+ return html;
117
+ return `${html.slice(0, cellOpenEnd + 1)}${BRAND_HEADER_SLOT}${html.slice(cellOpenEnd + 1, close)}${BRAND_FOOTER_SLOT}${html.slice(close)}`;
118
+ }
119
+ export function hasBrandSlots(html) {
120
+ return html.includes(BRAND_HEADER_SLOT) && html.includes(BRAND_FOOTER_SLOT);
121
+ }
122
+ const OWN_UNSUBSCRIBE_LINK = /href\s*=\s*(["'])\s*\{\{\s*(?:unsubscribe_url|preferences_url)\s*\}\}\s*\1/i;
123
+ /**
124
+ * Draw the kit's chrome into the marks. An email that already links its own
125
+ * unsubscribe keeps that link alone; one without marks comes back unchanged.
126
+ */
127
+ export function fillBrandSlots(html, chrome, options) {
128
+ if (!hasBrandSlots(html))
129
+ return html;
130
+ const includeUnsubscribe = !OWN_UNSUBSCRIBE_LINK.test(html);
131
+ return html
132
+ .replace(BRAND_HEADER_SLOT, () => brandHeaderHtml(chrome))
133
+ .replace(BRAND_FOOTER_SLOT, () => brandFooterHtml(chrome, { assetOrigin: options.assetOrigin, includeUnsubscribe }));
134
+ }
@@ -8,6 +8,7 @@
8
8
  * a patch names only the fields it changes, `null` clears one (a colour, width
9
9
  * or font falls back to its default). Pure and browser-safe.
10
10
  */
11
+ import { type EmailBrandChrome } from "./email-brand-chrome.js";
11
12
  export declare const EMAIL_BRAND_FONT_FAMILIES: readonly ["system", "georgia", "arial", "helvetica", "verdana"];
12
13
  export type EmailBrandFontFamily = typeof EMAIL_BRAND_FONT_FAMILIES[number];
13
14
  export declare const EMAIL_BRAND_FONT_LABELS: Record<EmailBrandFontFamily, string>;
@@ -96,6 +97,8 @@ export declare function parseEmailBrandKitPatch(body: Record<string, unknown>):
96
97
  export declare function brandKitHasPostalAddress(kit: Pick<EmailBrandKit, "postal_address"> | null | undefined): boolean;
97
98
  /** The email editor's global styles, as the composer and its preview consume them. */
98
99
  export type EmailBrandGlobalStyles = {
100
+ /** The logo, social links, company and address every email is framed with (`email-brand-chrome`). */
101
+ chrome: EmailBrandChrome;
99
102
  background: string;
100
103
  contentBackground: string;
101
104
  text: string;
@@ -8,6 +8,7 @@
8
8
  * a patch names only the fields it changes, `null` clears one (a colour, width
9
9
  * or font falls back to its default). Pure and browser-safe.
10
10
  */
11
+ import { brandChromeOf } from "./email-brand-chrome.js";
11
12
  export const EMAIL_BRAND_FONT_FAMILIES = ["system", "georgia", "arial", "helvetica", "verdana"];
12
13
  export const EMAIL_BRAND_FONT_LABELS = {
13
14
  system: "System sans",
@@ -199,6 +200,7 @@ export function brandKitHasPostalAddress(kit) {
199
200
  export function brandKitGlobalStyles(kit) {
200
201
  const merged = { ...DEFAULT_EMAIL_BRAND_KIT, ...stripNullish(kit ?? {}) };
201
202
  return {
203
+ chrome: brandChromeOf(merged),
202
204
  background: merged.background_color,
203
205
  contentBackground: merged.content_background_color,
204
206
  text: merged.text_color,
@@ -1 +1 @@
1
- export declare const OXYGEN_BUILD_VERSION = "1.1026.33";
1
+ export declare const OXYGEN_BUILD_VERSION = "1.1028.7";
@@ -1,2 +1,2 @@
1
1
  // GENERATED by scripts/ci/version-stamp.mjs from VERSION + git history. Do not edit; do not commit.
2
- export const OXYGEN_BUILD_VERSION = "1.1026.33";
2
+ export const OXYGEN_BUILD_VERSION = "1.1028.7";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxygen-agent/cli",
3
- "version": "1.1026.33",
3
+ "version": "1.1028.7",
4
4
  "private": false,
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",