@templatical/renderer 0.30.0 → 0.32.0

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/index.d.ts CHANGED
@@ -18,11 +18,11 @@ type BlockRenderer = (block: Block, context: RenderContext) => string;
18
18
  * construction instead of by review.
19
19
  */
20
20
  type BlockRendererMap = Partial<Record<BlockType, BlockRenderer>>;
21
- declare const DEFAULT_SOCIAL_ICONS_BASE_URL: string;
21
+ export declare const DEFAULT_SOCIAL_ICONS_BASE_URL: string;
22
22
  /**
23
23
  * Immutable context passed through the block rendering chain.
24
24
  */
25
- declare class RenderContext {
25
+ export declare class RenderContext {
26
26
  readonly containerWidth: number;
27
27
  readonly customFonts: CustomFont[];
28
28
  readonly defaultFallbackFont: string;
@@ -84,12 +84,12 @@ declare class RenderContext {
84
84
  * Escape HTML special characters (& < > " ').
85
85
  * Equivalent to PHP htmlspecialchars with ENT_QUOTES | ENT_HTML5.
86
86
  */
87
- declare function escapeHtml(text: string): string;
87
+ export declare function escapeHtml(text: string): string;
88
88
  /**
89
89
  * Escape a string for use in an HTML attribute value.
90
90
  * Same implementation as escapeHtml for consistency with PHP.
91
91
  */
92
- declare function escapeAttr(text: string): string;
92
+ export declare function escapeAttr(text: string): string;
93
93
  /**
94
94
  * Replace merge tag span elements with their data attribute values.
95
95
  * Converts `<span data-merge-tag="{{name}}">Label</span>` to `{{name}}`.
@@ -101,13 +101,13 @@ declare function escapeAttr(text: string): string;
101
101
  * position. The scan below resolves each `<span>` open tag with a bounded,
102
102
  * quote-aware `findOpenTagEnd`, keeping the work strictly O(n).
103
103
  */
104
- declare function convertMergeTagsToValues(html: string): string;
104
+ export declare function convertMergeTagsToValues(html: string): string;
105
105
  //#endregion
106
106
  //#region src/visibility.d.ts
107
107
  /**
108
108
  * Check if a block is hidden on all viewports.
109
109
  */
110
- declare function isHiddenOnAll(block: Block): boolean;
110
+ export declare function isHiddenOnAll(block: Block): boolean;
111
111
  /**
112
112
  * Get the MJML css-class attribute string for a block.
113
113
  * Returns a string like ` css-class="tpl-hide-desktop"` or empty string.
@@ -116,11 +116,11 @@ declare function isHiddenOnAll(block: Block): boolean;
116
116
  * attribute. MJML keeps only one `css-class` per element, so a caller needing
117
117
  * both must merge here rather than emitting a second attribute.
118
118
  */
119
- declare function getCssClassAttr(block: Block, extraClasses?: string[]): string;
119
+ export declare function getCssClassAttr(block: Block, extraClasses?: string[]): string;
120
120
  /**
121
121
  * Get the CSS classes for visibility hiding.
122
122
  */
123
- declare function getCssClasses(block: Block): string;
123
+ export declare function getCssClasses(block: Block): string;
124
124
  //#endregion
125
125
  //#region src/rich-text.d.ts
126
126
  /**
@@ -134,7 +134,7 @@ declare function getCssClasses(block: Block): string;
134
134
  * would trade this mismatch for another one, and an inlined declaration would
135
135
  * beat the consumer's own stylesheet.
136
136
  */
137
- declare const RICH_TEXT_CSS_CLASS = "tpl-rich-text";
137
+ export declare const RICH_TEXT_CSS_CLASS = "tpl-rich-text";
138
138
  /**
139
139
  * The class carrying one specific paragraph gap, e.g. `tpl-rich-text-8`.
140
140
  *
@@ -144,7 +144,7 @@ declare const RICH_TEXT_CSS_CLASS = "tpl-rich-text";
144
144
  * surviving base rule would win on source order and flatten every per-block gap
145
145
  * back to the default.
146
146
  */
147
- declare function richTextGapClass(gap: number): string;
147
+ export declare function richTextGapClass(gap: number): string;
148
148
  /**
149
149
  * The paragraph gap a block asks for, or the built-in default.
150
150
  *
@@ -156,23 +156,23 @@ declare function richTextGapClass(gap: number): string;
156
156
  * Mirrored on the canvas side by `getBlockWrapperStyle` in
157
157
  * `@templatical/editor`.
158
158
  */
159
- declare function resolveParagraphGap(spacing: number | undefined): number;
159
+ export declare function resolveParagraphGap(spacing: number | undefined): number;
160
160
  //#endregion
161
161
  //#region src/columns.d.ts
162
162
  /**
163
163
  * Get width percentages for each column in a layout.
164
164
  */
165
- declare function getWidthPercentages(layout: ColumnLayout): string[];
165
+ export declare function getWidthPercentages(layout: ColumnLayout): string[];
166
166
  /**
167
167
  * Get width in pixels for each column in a layout.
168
168
  */
169
- declare function getWidthPixels(layout: ColumnLayout, containerWidth: number): number[];
169
+ export declare function getWidthPixels(layout: ColumnLayout, containerWidth: number): number[];
170
170
  //#endregion
171
171
  //#region src/padding.d.ts
172
172
  /**
173
173
  * Convert a SpacingValue to a CSS padding string like "10px 10px 10px 10px".
174
174
  */
175
- declare function toPaddingString(padding: SpacingValue): string;
175
+ export declare function toPaddingString(padding: SpacingValue): string;
176
176
  //#endregion
177
177
  //#region src/renderers/index.d.ts
178
178
  /**
@@ -183,7 +183,7 @@ declare function toPaddingString(padding: SpacingValue): string;
183
183
  * renderer — see {@link RenderContext.blockRenderers}. A type with neither gets a
184
184
  * placeholder marker plus a warning rather than disappearing.
185
185
  */
186
- declare function renderBlock(block: Block, context: RenderContext): string;
186
+ export declare function renderBlock(block: Block, context: RenderContext): string;
187
187
  //#endregion
188
188
  //#region src/unrenderable.d.ts
189
189
  /**
@@ -191,7 +191,7 @@ declare function renderBlock(block: Block, context: RenderContext): string;
191
191
  * purpose: it is what a consumer searches for after noticing a gap in a rendered
192
192
  * email, and what a send pipeline can scan for before shipping.
193
193
  */
194
- declare const UNRENDERABLE_MARKER_PREFIX = "templatical:unrenderable-block";
194
+ export declare const UNRENDERABLE_MARKER_PREFIX = "templatical:unrenderable-block";
195
195
  /**
196
196
  * Emit the placeholder for a block no renderer can handle — no built-in renderer
197
197
  * and no `blockRenderers` override for its type.
@@ -208,10 +208,10 @@ declare const UNRENDERABLE_MARKER_PREFIX = "templatical:unrenderable-block";
208
208
  * verbatim and is valid everywhere a block renders — inside `mj-column`, which is
209
209
  * where every non-section block ends up.
210
210
  */
211
- declare function renderUnrenderableBlock(block: Block): string;
211
+ export declare function renderUnrenderableBlock(block: Block): string;
212
212
  //#endregion
213
213
  //#region src/index.d.ts
214
- interface RenderOptions {
214
+ export interface RenderOptions {
215
215
  customFonts?: CustomFont[];
216
216
  defaultFallbackFont?: string;
217
217
  allowHtmlBlocks?: boolean;
@@ -291,7 +291,7 @@ interface RenderOptions {
291
291
  * is omitted, no async work is performed but the function still resolves
292
292
  * synchronously — i.e., it always returns a Promise.
293
293
  */
294
- declare function renderToMjml(content: TemplateContent, options?: RenderOptions): Promise<string>;
294
+ export declare function renderToMjml(content: TemplateContent, options?: RenderOptions): Promise<string>;
295
295
  //#endregion
296
- export { type BlockRenderer, type BlockRendererMap, DEFAULT_SOCIAL_ICONS_BASE_URL, RICH_TEXT_CSS_CLASS, RenderContext, RenderOptions, UNRENDERABLE_MARKER_PREFIX, convertMergeTagsToValues, escapeAttr, escapeHtml, getCssClassAttr, getCssClasses, getWidthPercentages, getWidthPixels, isHiddenOnAll, renderBlock, renderToMjml, renderUnrenderableBlock, resolveParagraphGap, richTextGapClass, toPaddingString };
296
+ export type { BlockRenderer, BlockRendererMap };
297
297
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { HEADING_LEVEL_FONT_SIZE, RICH_TEXT_SPACING, findOpenTagEnd, getTagAttrValue, isButton, isCustomBlock, isDivider, isHtml, isImage, isMenu, isParagraph, isSection, isSocialIcons, isSpacer, isTable, isTitle, isVideo } from "@templatical/types";
2
2
  //#endregion
3
3
  //#region src/render-context.ts
4
- const DEFAULT_SOCIAL_ICONS_BASE_URL = `https://cdn.jsdelivr.net/npm/@templatical/renderer@0.30.0/assets/social`;
4
+ const DEFAULT_SOCIAL_ICONS_BASE_URL = `https://cdn.jsdelivr.net/npm/@templatical/renderer@0.32.0/assets/social`;
5
5
  const BUILT_IN_FONT_FALLBACKS = {
6
6
  arial: "Arial, sans-serif",
7
7
  helvetica: "Helvetica, sans-serif",
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@templatical/renderer",
3
3
  "description": "Render Templatical email templates to MJML",
4
- "version": "0.30.0",
4
+ "version": "0.32.0",
5
5
  "bugs": "https://github.com/templatical/sdk/issues",
6
6
  "dependencies": {
7
- "@templatical/types": "0.30.0"
7
+ "@templatical/types": "0.32.0"
8
8
  },
9
9
  "devDependencies": {
10
10
  "@resvg/resvg-js": "^2.6.2",
11
11
  "mjml": "^5.4.0",
12
12
  "typescript": "^6.0.3",
13
- "vitest": "^4.1.11"
13
+ "vitest": "^5.0.0"
14
14
  },
15
15
  "exports": {
16
16
  ".": {