render-tag 0.1.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/README.md +159 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +69 -0
- package/lib/index.js.map +1 -0
- package/lib/layout.d.ts +16 -0
- package/lib/layout.d.ts.map +1 -0
- package/lib/layout.js +1323 -0
- package/lib/layout.js.map +1 -0
- package/lib/parse.d.ts +9 -0
- package/lib/parse.d.ts.map +1 -0
- package/lib/parse.js +25 -0
- package/lib/parse.js.map +1 -0
- package/lib/render.d.ts +6 -0
- package/lib/render.d.ts.map +1 -0
- package/lib/render.js +351 -0
- package/lib/render.js.map +1 -0
- package/lib/style-resolver.d.ts +10 -0
- package/lib/style-resolver.d.ts.map +1 -0
- package/lib/style-resolver.js +257 -0
- package/lib/style-resolver.js.map +1 -0
- package/lib/types.d.ts +143 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +2 -0
- package/lib/types.js.map +1 -0
- package/package.json +39 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
let containerId = 0;
|
|
2
|
+
function parsePixels(value) {
|
|
3
|
+
if (!value || value === 'normal' || value === 'auto' || value === 'none')
|
|
4
|
+
return 0;
|
|
5
|
+
const num = parseFloat(value);
|
|
6
|
+
return isNaN(num) ? 0 : num;
|
|
7
|
+
}
|
|
8
|
+
function parseFontWeight(value) {
|
|
9
|
+
const num = parseInt(value, 10);
|
|
10
|
+
if (!isNaN(num))
|
|
11
|
+
return num;
|
|
12
|
+
if (value === 'bold')
|
|
13
|
+
return 700;
|
|
14
|
+
if (value === 'normal')
|
|
15
|
+
return 400;
|
|
16
|
+
return 400;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Resolve line-height to a pixel value.
|
|
20
|
+
* "normal" is resolved using font metrics via a canvas context.
|
|
21
|
+
*/
|
|
22
|
+
function resolveLineHeight(cs, fontSize) {
|
|
23
|
+
const raw = cs.lineHeight;
|
|
24
|
+
if (raw && raw !== 'normal') {
|
|
25
|
+
const px = parseFloat(raw);
|
|
26
|
+
if (!isNaN(px))
|
|
27
|
+
return px;
|
|
28
|
+
}
|
|
29
|
+
// "normal" — approximate as fontSize * 1.2 (will be refined in layout with actual font metrics)
|
|
30
|
+
return 0; // 0 signals "normal" — layout will compute from font metrics
|
|
31
|
+
}
|
|
32
|
+
function extractStyle(cs, el = null) {
|
|
33
|
+
const fontSize = parsePixels(cs.fontSize);
|
|
34
|
+
return {
|
|
35
|
+
fontFamily: cs.fontFamily,
|
|
36
|
+
fontSize,
|
|
37
|
+
fontWeight: parseFontWeight(cs.fontWeight),
|
|
38
|
+
fontStyle: cs.fontStyle || 'normal',
|
|
39
|
+
color: cs.color,
|
|
40
|
+
textAlign: cs.textAlign || 'left',
|
|
41
|
+
textTransform: cs.textTransform || 'none',
|
|
42
|
+
textDecorationLine: cs.textDecorationLine || 'none',
|
|
43
|
+
textDecorationStyle: cs.textDecorationStyle || 'solid',
|
|
44
|
+
textDecorationColor: cs.textDecorationColor || cs.color,
|
|
45
|
+
textShadow: cs.textShadow || 'none',
|
|
46
|
+
webkitTextStrokeWidth: parsePixels(cs.webkitTextStrokeWidth),
|
|
47
|
+
webkitTextStrokeColor: cs.webkitTextStrokeColor || '',
|
|
48
|
+
webkitTextFillColor: cs.webkitTextFillColor || '',
|
|
49
|
+
webkitBackgroundClip: cs.webkitBackgroundClip || cs.backgroundClip || '',
|
|
50
|
+
backgroundImage: cs.backgroundImage || 'none',
|
|
51
|
+
letterSpacing: cs.letterSpacing === 'normal' ? 0 : parsePixels(cs.letterSpacing),
|
|
52
|
+
fontKerning: cs.fontKerning || 'auto',
|
|
53
|
+
lineHeight: resolveLineHeight(cs, fontSize),
|
|
54
|
+
verticalAlign: cs.verticalAlign || 'baseline',
|
|
55
|
+
whiteSpace: cs.whiteSpace || 'normal',
|
|
56
|
+
wordBreak: cs.wordBreak || 'normal',
|
|
57
|
+
overflowWrap: cs.overflowWrap || 'normal',
|
|
58
|
+
direction: cs.direction || 'ltr',
|
|
59
|
+
display: cs.display || 'block',
|
|
60
|
+
// Only use width if explicitly set (inline style or stylesheet).
|
|
61
|
+
// getComputedStyle resolves 'auto' to a pixel value for block elements,
|
|
62
|
+
// which we must NOT treat as an explicit width constraint.
|
|
63
|
+
width: el && el instanceof HTMLElement && el.style.width ? parsePixels(cs.width) : 0,
|
|
64
|
+
minHeight: parsePixels(cs.minHeight),
|
|
65
|
+
paddingTop: parsePixels(cs.paddingTop),
|
|
66
|
+
paddingRight: parsePixels(cs.paddingRight),
|
|
67
|
+
paddingBottom: parsePixels(cs.paddingBottom),
|
|
68
|
+
paddingLeft: parsePixels(cs.paddingLeft),
|
|
69
|
+
marginTop: parsePixels(cs.marginTop),
|
|
70
|
+
marginRight: parsePixels(cs.marginRight),
|
|
71
|
+
marginBottom: parsePixels(cs.marginBottom),
|
|
72
|
+
marginLeft: parsePixels(cs.marginLeft),
|
|
73
|
+
backgroundColor: cs.backgroundColor,
|
|
74
|
+
borderTopWidth: parsePixels(cs.borderTopWidth),
|
|
75
|
+
borderTopColor: cs.borderTopColor,
|
|
76
|
+
borderTopStyle: cs.borderTopStyle || 'none',
|
|
77
|
+
borderRightWidth: parsePixels(cs.borderRightWidth),
|
|
78
|
+
borderRightColor: cs.borderRightColor,
|
|
79
|
+
borderRightStyle: cs.borderRightStyle || 'none',
|
|
80
|
+
borderBottomWidth: parsePixels(cs.borderBottomWidth),
|
|
81
|
+
borderBottomColor: cs.borderBottomColor,
|
|
82
|
+
borderBottomStyle: cs.borderBottomStyle || 'none',
|
|
83
|
+
borderLeftWidth: parsePixels(cs.borderLeftWidth),
|
|
84
|
+
borderLeftColor: cs.borderLeftColor,
|
|
85
|
+
borderLeftStyle: cs.borderLeftStyle || 'none',
|
|
86
|
+
flexDirection: cs.flexDirection || 'row',
|
|
87
|
+
gap: parsePixels(cs.gap),
|
|
88
|
+
flexGrow: parseFloat(cs.flexGrow) || 0,
|
|
89
|
+
flexShrink: parseFloat(cs.flexShrink) || 1,
|
|
90
|
+
listStyleType: cs.listStyleType || 'disc',
|
|
91
|
+
listStylePosition: cs.listStylePosition || 'outside',
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Detect list marker text for a <li> element.
|
|
96
|
+
*/
|
|
97
|
+
function getListMarker(el, cs) {
|
|
98
|
+
const tag = el.tagName.toLowerCase();
|
|
99
|
+
if (tag !== 'li')
|
|
100
|
+
return undefined;
|
|
101
|
+
const beforeStyle = window.getComputedStyle(el, '::before');
|
|
102
|
+
const content = beforeStyle.content;
|
|
103
|
+
if (content && content !== 'none' && content !== 'normal') {
|
|
104
|
+
if (!content.includes('counter(')) {
|
|
105
|
+
const cleaned = content.replace(/^["']|["']$/g, '');
|
|
106
|
+
if (cleaned)
|
|
107
|
+
return cleaned;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const parent = el.parentElement;
|
|
111
|
+
if (!parent)
|
|
112
|
+
return '•';
|
|
113
|
+
const parentTag = parent.tagName.toLowerCase();
|
|
114
|
+
if (parentTag === 'ol') {
|
|
115
|
+
let index = 0;
|
|
116
|
+
for (const child of parent.children) {
|
|
117
|
+
if (child.tagName.toLowerCase() === 'li') {
|
|
118
|
+
index++;
|
|
119
|
+
if (child === el)
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return `${index}.`;
|
|
124
|
+
}
|
|
125
|
+
if (parentTag === 'ul') {
|
|
126
|
+
// Use computed list-style-type for correct nesting level markers
|
|
127
|
+
const listStyle = cs.listStyleType;
|
|
128
|
+
if (listStyle === 'circle')
|
|
129
|
+
return '○';
|
|
130
|
+
if (listStyle === 'square')
|
|
131
|
+
return '■';
|
|
132
|
+
if (listStyle === 'none')
|
|
133
|
+
return undefined;
|
|
134
|
+
return '•';
|
|
135
|
+
}
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Rewrite CSS so that `body` and `html` selectors target our container instead.
|
|
140
|
+
*/
|
|
141
|
+
function scopeCSS(css, containerId) {
|
|
142
|
+
const selector = `#${containerId}`;
|
|
143
|
+
return css.replace(/(^|[},;\s])(\s*)(html|body)\b/gm, (match, before, space, _tag) => `${before}${space}${selector}`);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Insert HTML into a hidden offscreen container, walk the DOM tree,
|
|
147
|
+
* and extract computed styles for every element. No measurements — only CSS values.
|
|
148
|
+
*/
|
|
149
|
+
export function resolveStyles(fragment, css, width, height) {
|
|
150
|
+
const id = `__html_canvas_${containerId++}__`;
|
|
151
|
+
const container = document.createElement('div');
|
|
152
|
+
container.id = id;
|
|
153
|
+
container.style.position = 'absolute';
|
|
154
|
+
container.style.left = '-99999px';
|
|
155
|
+
container.style.top = '-99999px';
|
|
156
|
+
container.style.visibility = 'hidden';
|
|
157
|
+
container.style.width = `${width}px`;
|
|
158
|
+
container.style.margin = '0';
|
|
159
|
+
container.style.padding = '0';
|
|
160
|
+
if (css) {
|
|
161
|
+
const styleEl = document.createElement('style');
|
|
162
|
+
styleEl.textContent = scopeCSS(css, id);
|
|
163
|
+
container.appendChild(styleEl);
|
|
164
|
+
}
|
|
165
|
+
container.appendChild(fragment);
|
|
166
|
+
document.body.appendChild(container);
|
|
167
|
+
// Force reflow so getComputedStyle returns resolved values
|
|
168
|
+
container.getBoundingClientRect();
|
|
169
|
+
function walkNode(node) {
|
|
170
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
171
|
+
const text = node.textContent;
|
|
172
|
+
if (!text)
|
|
173
|
+
return null;
|
|
174
|
+
if (text.trim() === '' && !text.includes('\u00A0')) {
|
|
175
|
+
// Whitespace-only text node. Decide whether to keep or drop.
|
|
176
|
+
const parentEl = node.parentElement;
|
|
177
|
+
const ws = parentEl ? window.getComputedStyle(parentEl).whiteSpace : '';
|
|
178
|
+
const prev = node.previousSibling;
|
|
179
|
+
const next = node.nextSibling;
|
|
180
|
+
const isInlineSibling = (n) => {
|
|
181
|
+
if (!n || n.nodeType !== Node.ELEMENT_NODE)
|
|
182
|
+
return n?.nodeType === Node.TEXT_NODE;
|
|
183
|
+
const d = window.getComputedStyle(n).display;
|
|
184
|
+
return d === 'inline' || d === 'inline-block';
|
|
185
|
+
};
|
|
186
|
+
// Between block elements: drop in normal mode (HTML formatting).
|
|
187
|
+
// But in pre-wrap, the \n IS content — creates a visible line break.
|
|
188
|
+
if (prev && next && !isInlineSibling(prev) && !isInlineSibling(next)) {
|
|
189
|
+
if (ws === 'pre' || ws === 'pre-wrap' || ws === 'pre-line') {
|
|
190
|
+
// Keep — pre-wrap makes this whitespace visible
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (ws !== 'pre' && ws !== 'pre-wrap' && ws !== 'pre-line') {
|
|
197
|
+
// Skip whitespace that contains newlines (HTML source indentation)
|
|
198
|
+
if (text.includes('\n'))
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
const parent = node.parentElement;
|
|
203
|
+
if (!parent)
|
|
204
|
+
return null;
|
|
205
|
+
const parentCS = window.getComputedStyle(parent);
|
|
206
|
+
return {
|
|
207
|
+
element: null,
|
|
208
|
+
tagName: '#text',
|
|
209
|
+
style: extractStyle(parentCS),
|
|
210
|
+
children: [],
|
|
211
|
+
textContent: text,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
if (node.nodeType !== Node.ELEMENT_NODE)
|
|
215
|
+
return null;
|
|
216
|
+
const el = node;
|
|
217
|
+
const tag = el.tagName.toLowerCase();
|
|
218
|
+
if (tag === 'style' || tag === 'script')
|
|
219
|
+
return null;
|
|
220
|
+
// <br> → emit as a text node with newline content
|
|
221
|
+
if (tag === 'br') {
|
|
222
|
+
const parent = el.parentElement;
|
|
223
|
+
const cs = parent ? window.getComputedStyle(parent) : window.getComputedStyle(el);
|
|
224
|
+
return {
|
|
225
|
+
element: null,
|
|
226
|
+
tagName: '#text',
|
|
227
|
+
style: extractStyle(cs),
|
|
228
|
+
children: [],
|
|
229
|
+
textContent: '\n',
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
const cs = window.getComputedStyle(el);
|
|
233
|
+
const style = extractStyle(cs, el);
|
|
234
|
+
const marker = getListMarker(el, cs);
|
|
235
|
+
const children = [];
|
|
236
|
+
for (const child of el.childNodes) {
|
|
237
|
+
const childNode = walkNode(child);
|
|
238
|
+
if (childNode) {
|
|
239
|
+
children.push(childNode);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return {
|
|
243
|
+
element: el,
|
|
244
|
+
tagName: tag,
|
|
245
|
+
style,
|
|
246
|
+
children,
|
|
247
|
+
textContent: null,
|
|
248
|
+
listMarker: marker,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
const tree = walkNode(container);
|
|
252
|
+
const cleanup = () => {
|
|
253
|
+
container.remove();
|
|
254
|
+
};
|
|
255
|
+
return { tree, cleanup };
|
|
256
|
+
}
|
|
257
|
+
//# sourceMappingURL=style-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-resolver.js","sourceRoot":"","sources":["../src/style-resolver.ts"],"names":[],"mappings":"AAEA,IAAI,WAAW,GAAG,CAAC,CAAC;AAEpB,SAAS,WAAW,CAAC,KAAa;IAChC,IAAI,CAAC,KAAK,IAAI,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,MAAM;QAAE,OAAO,CAAC,CAAC;IACnF,MAAM,GAAG,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IAC9B,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AAC9B,CAAC;AAED,SAAS,eAAe,CAAC,KAAa;IACpC,MAAM,GAAG,GAAG,QAAQ,CAAC,KA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O,EAAE,CAAC;AAC3B,CAAC"}
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
export interface RenderOptions {
|
|
2
|
+
/** Target canvas element (created if not provided) */
|
|
3
|
+
canvas?: HTMLCanvasElement;
|
|
4
|
+
/** Width of the rendering area in CSS pixels */
|
|
5
|
+
width: number;
|
|
6
|
+
/** Height of the rendering area in CSS pixels (auto-sized if not set) */
|
|
7
|
+
height?: number;
|
|
8
|
+
/** Additional CSS to apply */
|
|
9
|
+
css?: string;
|
|
10
|
+
/** Device pixel ratio (default: 1) */
|
|
11
|
+
pixelRatio?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Use DOM measurements for improved cross-browser consistency (default: true).
|
|
14
|
+
* When enabled, uses hidden DOM elements to measure line heights and verify
|
|
15
|
+
* text wrapping at font boundaries. When disabled, uses pure canvas API
|
|
16
|
+
* measurements only — faster and DOM-free, but may have slight differences
|
|
17
|
+
* across browsers (e.g. Firefox list item heights).
|
|
18
|
+
*/
|
|
19
|
+
useDomMeasurements?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Debug callback for layout diagnostics. Receives structured log entries
|
|
22
|
+
* during text measurement, wrapping decisions, and positioning.
|
|
23
|
+
*/
|
|
24
|
+
debug?: (entry: DebugEntry) => void;
|
|
25
|
+
}
|
|
26
|
+
export interface DebugEntry {
|
|
27
|
+
type: 'measure-word' | 'line-wrap' | 'line-commit' | 'position-text';
|
|
28
|
+
/** Human-readable description */
|
|
29
|
+
message: string;
|
|
30
|
+
/** Relevant data */
|
|
31
|
+
data: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
/** A text line extracted from the layout tree */
|
|
34
|
+
export interface LayoutLine {
|
|
35
|
+
/** Y coordinate of the text baseline */
|
|
36
|
+
y: number;
|
|
37
|
+
/** Concatenated text content on this line */
|
|
38
|
+
text: string;
|
|
39
|
+
}
|
|
40
|
+
export interface RenderResult {
|
|
41
|
+
canvas: HTMLCanvasElement;
|
|
42
|
+
/** Actual content height after layout */
|
|
43
|
+
height: number;
|
|
44
|
+
/** The layout tree root (for debugging/comparison) */
|
|
45
|
+
layoutRoot: LayoutBox;
|
|
46
|
+
/** Text lines extracted from the layout tree, grouped by Y coordinate */
|
|
47
|
+
lines: LayoutLine[];
|
|
48
|
+
}
|
|
49
|
+
/** Resolved style for a single element — all values in px / concrete strings */
|
|
50
|
+
export interface ResolvedStyle {
|
|
51
|
+
fontFamily: string;
|
|
52
|
+
fontSize: number;
|
|
53
|
+
fontWeight: number;
|
|
54
|
+
fontStyle: string;
|
|
55
|
+
color: string;
|
|
56
|
+
textAlign: string;
|
|
57
|
+
textTransform: string;
|
|
58
|
+
textDecorationLine: string;
|
|
59
|
+
textDecorationStyle: string;
|
|
60
|
+
textDecorationColor: string;
|
|
61
|
+
textShadow: string;
|
|
62
|
+
webkitTextStrokeWidth: number;
|
|
63
|
+
webkitTextStrokeColor: string;
|
|
64
|
+
webkitTextFillColor: string;
|
|
65
|
+
webkitBackgroundClip: string;
|
|
66
|
+
backgroundImage: string;
|
|
67
|
+
letterSpacing: number;
|
|
68
|
+
fontKerning: string;
|
|
69
|
+
lineHeight: number;
|
|
70
|
+
verticalAlign: string;
|
|
71
|
+
whiteSpace: string;
|
|
72
|
+
wordBreak: string;
|
|
73
|
+
overflowWrap: string;
|
|
74
|
+
direction: string;
|
|
75
|
+
display: string;
|
|
76
|
+
width: number;
|
|
77
|
+
minHeight: number;
|
|
78
|
+
paddingTop: number;
|
|
79
|
+
paddingRight: number;
|
|
80
|
+
paddingBottom: number;
|
|
81
|
+
paddingLeft: number;
|
|
82
|
+
marginTop: number;
|
|
83
|
+
marginRight: number;
|
|
84
|
+
marginBottom: number;
|
|
85
|
+
marginLeft: number;
|
|
86
|
+
backgroundColor: string;
|
|
87
|
+
borderTopWidth: number;
|
|
88
|
+
borderTopColor: string;
|
|
89
|
+
borderTopStyle: string;
|
|
90
|
+
borderRightWidth: number;
|
|
91
|
+
borderRightColor: string;
|
|
92
|
+
borderRightStyle: string;
|
|
93
|
+
borderBottomWidth: number;
|
|
94
|
+
borderBottomColor: string;
|
|
95
|
+
borderBottomStyle: string;
|
|
96
|
+
borderLeftWidth: number;
|
|
97
|
+
borderLeftColor: string;
|
|
98
|
+
borderLeftStyle: string;
|
|
99
|
+
flexDirection: string;
|
|
100
|
+
gap: number;
|
|
101
|
+
flexGrow: number;
|
|
102
|
+
flexShrink: number;
|
|
103
|
+
listStyleType: string;
|
|
104
|
+
listStylePosition: string;
|
|
105
|
+
}
|
|
106
|
+
/** A node in our styled tree (no positions — layout computes those) */
|
|
107
|
+
export interface StyledNode {
|
|
108
|
+
/** Original DOM element (null for text nodes) */
|
|
109
|
+
element: Element | null;
|
|
110
|
+
/** Tag name in lowercase, '#text' for text nodes */
|
|
111
|
+
tagName: string;
|
|
112
|
+
/** Resolved CSS style */
|
|
113
|
+
style: ResolvedStyle;
|
|
114
|
+
/** Child nodes */
|
|
115
|
+
children: StyledNode[];
|
|
116
|
+
/** Text content (only for text nodes) */
|
|
117
|
+
textContent: string | null;
|
|
118
|
+
/** For list items: the marker text (e.g. "•", "1.") */
|
|
119
|
+
listMarker?: string;
|
|
120
|
+
}
|
|
121
|
+
/** A positioned text run ready for canvas rendering */
|
|
122
|
+
export interface LayoutText {
|
|
123
|
+
type: 'text';
|
|
124
|
+
text: string;
|
|
125
|
+
x: number;
|
|
126
|
+
y: number;
|
|
127
|
+
width: number;
|
|
128
|
+
style: ResolvedStyle;
|
|
129
|
+
}
|
|
130
|
+
/** A positioned box (element) */
|
|
131
|
+
export interface LayoutBox {
|
|
132
|
+
type: 'box';
|
|
133
|
+
style: ResolvedStyle;
|
|
134
|
+
x: number;
|
|
135
|
+
y: number;
|
|
136
|
+
width: number;
|
|
137
|
+
height: number;
|
|
138
|
+
tagName: string;
|
|
139
|
+
children: LayoutNode[];
|
|
140
|
+
listMarker?: string;
|
|
141
|
+
}
|
|
142
|
+
export type LayoutNode = LayoutText | LayoutBox;
|
|
143
|
+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AAED,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC"}
|
package/lib/types.js
ADDED
package/lib/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "render-tag",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Render HTML rich text onto canvas using pure 2D API",
|
|
6
|
+
"main": "./lib/index.js",
|
|
7
|
+
"types": "./lib/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./lib/index.js",
|
|
11
|
+
"types": "./lib/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://polotno.com/render-tag/",
|
|
15
|
+
"author": "Anton Lavrenov",
|
|
16
|
+
"files": [
|
|
17
|
+
"lib",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"dev": "vite",
|
|
22
|
+
"test": "vitest run tests/render.test.ts",
|
|
23
|
+
"test:stress": "vitest run tests/stress.test.ts",
|
|
24
|
+
"test:firefox": "vitest run tests/render.test.ts -c vitest.firefox.config.ts",
|
|
25
|
+
"build": "tsc",
|
|
26
|
+
"docs": "vite --config docs/vite.config.ts",
|
|
27
|
+
"docs:build": "vite build --config docs/vite.config.ts"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@vitest/browser": "^4",
|
|
31
|
+
"@vitest/browser-playwright": "^4.1.2",
|
|
32
|
+
"pixelmatch": "^7",
|
|
33
|
+
"playwright": "^1",
|
|
34
|
+
"rasterizehtml": "^1.4.1",
|
|
35
|
+
"typescript": "^6",
|
|
36
|
+
"vite": "^8",
|
|
37
|
+
"vitest": "^4"
|
|
38
|
+
}
|
|
39
|
+
}
|