@travetto/email-inky 3.1.17 → 3.1.19
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/jsx-runtime.ts +71 -0
- package/package.json +2 -1
- package/src/render/html.ts +2 -2
- package/src/render/markdown.ts +2 -1
- package/src/render/subject.ts +1 -1
package/jsx-runtime.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ConcreteClass } from '@travetto/base';
|
|
2
|
+
|
|
3
|
+
export type JSXChild = JSXElement | number | bigint | boolean | object | string;
|
|
4
|
+
type JSXProps = { children?: JSXChild | JSXChild[] | null, class?: string, id?: string, name?: string, dir?: string };
|
|
5
|
+
|
|
6
|
+
export type JSXComponentFunction<P extends {} = {}> = (props: P & JSXProps, ...args: unknown[]) => (JSXElement | null);
|
|
7
|
+
|
|
8
|
+
export const JSXRuntimeTag = Symbol.for('@travetto/email-inky:jsx-runtime');
|
|
9
|
+
export class JSXFragmentType { }
|
|
10
|
+
|
|
11
|
+
let id = 0;
|
|
12
|
+
|
|
13
|
+
/** Simple JSX Element */
|
|
14
|
+
export interface JSXElement<
|
|
15
|
+
T extends string | ConcreteClass | JSXComponentFunction<P> = string | ConcreteClass | JSXComponentFunction,
|
|
16
|
+
P extends {} = {},
|
|
17
|
+
> {
|
|
18
|
+
[JSXRuntimeTag]?: { id: number };
|
|
19
|
+
key: string;
|
|
20
|
+
type: T;
|
|
21
|
+
props: P & JSXProps;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type ValidHtmlTags =
|
|
25
|
+
'strong' | 'em' | 'br' | 'hr' | 'a' |
|
|
26
|
+
'li' | 'ul' | 'ol' | 'img' | 'p' |
|
|
27
|
+
'h1' | 'h2' | 'h3' | 'h4' | 'small' |
|
|
28
|
+
'td' | 'tr' | 'th' | 'table' | 'thead' | 'tbody' |
|
|
29
|
+
'span' | 'div' | 'center' | 'title';
|
|
30
|
+
|
|
31
|
+
type BasicElements = { [K in ValidHtmlTags]: JSX.IntrinsicAttributes };
|
|
32
|
+
|
|
33
|
+
declare global {
|
|
34
|
+
namespace JSX {
|
|
35
|
+
interface Element extends JSXElement { }
|
|
36
|
+
interface IntrinsicAttributes {
|
|
37
|
+
class?: string;
|
|
38
|
+
id?: string;
|
|
39
|
+
dir?: string;
|
|
40
|
+
name?: string;
|
|
41
|
+
src?: string;
|
|
42
|
+
alt?: string;
|
|
43
|
+
href?: string;
|
|
44
|
+
title?: string;
|
|
45
|
+
height?: string;
|
|
46
|
+
target?: string;
|
|
47
|
+
width?: string;
|
|
48
|
+
style?: string;
|
|
49
|
+
align?: string;
|
|
50
|
+
valign?: string;
|
|
51
|
+
}
|
|
52
|
+
interface IntrinsicElements extends BasicElements { }
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function createElement<T extends string | ConcreteClass | JSXComponentFunction<P>, P extends {}>(
|
|
57
|
+
type: T, props: P & JSXProps
|
|
58
|
+
): JSXElement<T, P> {
|
|
59
|
+
return { [JSXRuntimeTag]: { id: (id += 1) }, key: '', type, props };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function createFragment<P extends {}>(props: P & JSXProps): JSXElement<typeof JSXFragmentType, P> {
|
|
63
|
+
return createElement(JSXFragmentType, props);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const jsx = createElement;
|
|
67
|
+
export const jsxs = createElement;
|
|
68
|
+
export const Fragment = createFragment;
|
|
69
|
+
export function isJSXElement(el: unknown): el is JSXElement {
|
|
70
|
+
return el !== undefined && el !== null && typeof el === 'object' && JSXRuntimeTag in el;
|
|
71
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/email-inky",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.19",
|
|
4
4
|
"description": "Email Inky templating module",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"email",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
19
19
|
"__index__.ts",
|
|
20
|
+
"jsx-runtime.ts",
|
|
20
21
|
"resources/email/inky.wrapper.html",
|
|
21
22
|
"src"
|
|
22
23
|
],
|
package/src/render/html.ts
CHANGED
|
@@ -92,12 +92,12 @@ export const Html: RenderProvider<RenderContext> = {
|
|
|
92
92
|
|
|
93
93
|
br: async () => '<br>\n',
|
|
94
94
|
hr: async (el) => `<table ${propsToStr(el.props)}><th></th></table>`,
|
|
95
|
-
strong: stdInline, em: stdInline,
|
|
95
|
+
strong: stdInline, em: stdInline, p: stdFull,
|
|
96
96
|
h1: stdFull, h2: stdFull, h3: stdFull, h4: stdFull,
|
|
97
97
|
li: std, ol: stdFull, ul: stdFull,
|
|
98
98
|
table: stdFull, thead: std, tr: std, td: std, th: std, tbody: std, center: std, img: stdInline,
|
|
99
99
|
title: std,
|
|
100
|
-
div: std, span: stdInline,
|
|
100
|
+
div: std, span: stdInline, small: stdInline,
|
|
101
101
|
a: async ({ recurse, props }) => `<a ${propsToStr(props)}>${await recurse()}</a>`,
|
|
102
102
|
|
|
103
103
|
Title: async ({ recurse, el }) => `<title>${await recurse()}</title>`,
|
package/src/render/markdown.ts
CHANGED
|
@@ -20,6 +20,7 @@ export const Markdown: RenderProvider<RenderContext> = {
|
|
|
20
20
|
hr: async () => '\n------------------\n',
|
|
21
21
|
HLine: async () => '\n------------------\n',
|
|
22
22
|
br: async () => '\n\n',
|
|
23
|
+
p: async ({ recurse }) => `${await recurse()}\n\n`,
|
|
23
24
|
em: async ({ recurse }) => `*${await recurse()}*`,
|
|
24
25
|
ul: async ({ recurse }) => `\n${await recurse()}`,
|
|
25
26
|
ol: async ({ recurse }) => `\n${await recurse()}`,
|
|
@@ -54,5 +55,5 @@ export const Markdown: RenderProvider<RenderContext> = {
|
|
|
54
55
|
|
|
55
56
|
Summary: ignore, Title: ignore,
|
|
56
57
|
img: ignore,
|
|
57
|
-
div: visit, title: visit, span: visit, center: visit, table: visit, tbody: visit,
|
|
58
|
+
div: visit, title: visit, span: visit, center: visit, table: visit, tbody: visit, small: visit
|
|
58
59
|
};
|
package/src/render/subject.ts
CHANGED
|
@@ -15,7 +15,7 @@ export const Subject: RenderProvider<RenderContext> = {
|
|
|
15
15
|
Value: async ({ props }) => `{{${props.attr}}}`,
|
|
16
16
|
Title: visit,
|
|
17
17
|
|
|
18
|
-
title: visit, span: visit, strong: visit, center: visit, em: visit,
|
|
18
|
+
title: visit, span: visit, strong: visit, center: visit, em: visit, p: visit, small: visit,
|
|
19
19
|
|
|
20
20
|
Summary: empty, Button: empty,
|
|
21
21
|
Callout: empty, Center: empty, HLine: empty,
|