@travetto/email-inky 6.0.0-rc.1 → 6.0.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 +1 -0
- package/__index__.ts +8 -2
- package/jsx-runtime.ts +25 -28
- package/package.json +6 -6
- package/src/render/context.ts +1 -1
- package/src/render/html.ts +7 -7
- package/src/render/markdown.ts +5 -5
- package/src/render/renderer.ts +3 -3
- package/src/render/subject.ts +3 -3
- package/src/types.ts +2 -2
- package/src/wrapper.ts +4 -4
package/README.md
CHANGED
|
@@ -50,4 +50,5 @@ The template extension points are defined at:
|
|
|
50
50
|
1. `email/main.scss` - The entry point for adding, and overriding any [sass](https://github.com/sass/dart-sass)
|
|
51
51
|
1. `email/inky.variables.scss` - Allows for specifying any variables that should be defined before [inky](https://github.com/zurb/inky)'s styles are loaded.
|
|
52
52
|
1. `email/inky.wrapper.html` - Provides direct access to override the entire base HTML document for all HTML emails.
|
|
53
|
+
|
|
53
54
|
In addition to the overrides, you can find the list of available settings at [Github](https://github.com/foundation/foundation-emails/blob/develop/scss/settings/_settings.scss)
|
package/__index__.ts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
export * from './src/components';
|
|
2
|
-
export * from './src/wrapper';
|
|
1
|
+
export * from './src/components.ts';
|
|
2
|
+
export * from './src/wrapper.ts';
|
|
3
|
+
export * from './src/render/renderer.ts';
|
|
4
|
+
export * from './src/render/html.ts';
|
|
5
|
+
export * from './src/render/markdown.ts';
|
|
6
|
+
export * from './src/render/subject.ts';
|
|
7
|
+
export * from './src/render/context.ts';
|
|
8
|
+
export * from './src/render/common.ts';
|
package/jsx-runtime.ts
CHANGED
|
@@ -29,32 +29,6 @@ export type ValidHtmlTags =
|
|
|
29
29
|
'td' | 'tr' | 'th' | 'table' | 'thead' | 'tbody' |
|
|
30
30
|
'span' | 'div' | 'center' | 'title';
|
|
31
31
|
|
|
32
|
-
type BasicElements = { [K in ValidHtmlTags]: JSX.IntrinsicAttributes };
|
|
33
|
-
|
|
34
|
-
declare global {
|
|
35
|
-
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
36
|
-
namespace JSX {
|
|
37
|
-
interface Element extends JSXElement { }
|
|
38
|
-
interface IntrinsicAttributes {
|
|
39
|
-
className?: string;
|
|
40
|
-
id?: string;
|
|
41
|
-
dir?: string;
|
|
42
|
-
name?: string;
|
|
43
|
-
src?: string | Function;
|
|
44
|
-
alt?: string;
|
|
45
|
-
href?: string;
|
|
46
|
-
title?: string;
|
|
47
|
-
height?: string;
|
|
48
|
-
target?: string;
|
|
49
|
-
width?: string;
|
|
50
|
-
style?: string;
|
|
51
|
-
align?: string;
|
|
52
|
-
valign?: string;
|
|
53
|
-
}
|
|
54
|
-
interface IntrinsicElements extends BasicElements { }
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
32
|
let createFrag: Function | undefined = undefined;
|
|
59
33
|
|
|
60
34
|
export function createElement<T extends string | Class | JSXComponentFunction<P>, P extends {}>(
|
|
@@ -71,7 +45,7 @@ export function createRootElement<T extends string | Class | JSXComponentFunctio
|
|
|
71
45
|
|
|
72
46
|
Object.assign(res, {
|
|
73
47
|
prepare(loc: EmailTemplateLocation): Promise<EmailTemplateModule> {
|
|
74
|
-
return import('@travetto/email-inky
|
|
48
|
+
return import('@travetto/email-inky').then(v => v.prepare(castTo(res), loc));
|
|
75
49
|
}
|
|
76
50
|
});
|
|
77
51
|
|
|
@@ -89,4 +63,27 @@ export function isJSXElement(el: unknown): el is JSXElement {
|
|
|
89
63
|
return el !== undefined && el !== null && typeof el === 'object' && JSXRuntimeTag in el;
|
|
90
64
|
}
|
|
91
65
|
|
|
92
|
-
createFrag = Fragment;
|
|
66
|
+
createFrag = Fragment;
|
|
67
|
+
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
69
|
+
export namespace JSX {
|
|
70
|
+
export interface Element extends JSXElement { }
|
|
71
|
+
export interface IntrinsicAttributes extends JSXProps {
|
|
72
|
+
className?: string;
|
|
73
|
+
id?: string;
|
|
74
|
+
dir?: string;
|
|
75
|
+
name?: string;
|
|
76
|
+
src?: string | Function;
|
|
77
|
+
alt?: string;
|
|
78
|
+
href?: string;
|
|
79
|
+
title?: string;
|
|
80
|
+
height?: string;
|
|
81
|
+
target?: string;
|
|
82
|
+
width?: string;
|
|
83
|
+
style?: string;
|
|
84
|
+
align?: string;
|
|
85
|
+
valign?: string;
|
|
86
|
+
}
|
|
87
|
+
type BasicElements = { [K in ValidHtmlTags]: IntrinsicAttributes };
|
|
88
|
+
export interface IntrinsicElements extends BasicElements { }
|
|
89
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/email-inky",
|
|
3
|
-
"version": "6.0.0
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Email Inky templating module",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"email",
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
"directory": "module/email-inky"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@travetto/config": "^6.0.0
|
|
31
|
-
"@travetto/di": "^6.0.0
|
|
32
|
-
"@travetto/email": "^6.0.0
|
|
33
|
-
"@travetto/runtime": "^6.0.0
|
|
30
|
+
"@travetto/config": "^6.0.0",
|
|
31
|
+
"@travetto/di": "^6.0.0",
|
|
32
|
+
"@travetto/email": "^6.0.0",
|
|
33
|
+
"@travetto/runtime": "^6.0.0",
|
|
34
34
|
"foundation-emails": "^2.4.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@travetto/email-compiler": "^6.0.0
|
|
37
|
+
"@travetto/email-compiler": "^6.0.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependenciesMeta": {
|
|
40
40
|
"@travetto/cli": {
|
package/src/render/context.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { createElement } from '@travetto/email-inky/jsx-runtime';
|
|
|
2
2
|
import { castTo, FileLoader } from '@travetto/runtime';
|
|
3
3
|
import { EmailTemplateLocation, EmailResourceLoader } from '@travetto/email';
|
|
4
4
|
|
|
5
|
-
import { JSXElementByFn, c } from '../components';
|
|
5
|
+
import { JSXElementByFn, c } from '../components.ts';
|
|
6
6
|
|
|
7
7
|
export type RenderContextInit = EmailTemplateLocation & { loader?: FileLoader, columnCount?: number };
|
|
8
8
|
|
package/src/render/html.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { JSXElement } from '@travetto/email-inky/jsx-runtime';
|
|
2
2
|
|
|
3
|
-
import { RenderProvider, RenderState } from '../types';
|
|
4
|
-
import { RenderContext } from './context';
|
|
5
|
-
import { classStr, combinePropsToStr, getKids, isOfType, visit } from './common';
|
|
3
|
+
import { RenderProvider, RenderState } from '../types.ts';
|
|
4
|
+
import { RenderContext } from './context.ts';
|
|
5
|
+
import { classStr, combinePropsToStr, getKids, isOfType, visit } from './common.ts';
|
|
6
6
|
|
|
7
7
|
export const SUMMARY_STYLE = Object.entries({
|
|
8
8
|
display: 'none',
|
|
@@ -75,8 +75,8 @@ export const Html: RenderProvider<RenderContext> = {
|
|
|
75
75
|
a: async ({ recurse, props }) => `<a ${propsToStr(props)}>${await recurse()}</a>`,
|
|
76
76
|
|
|
77
77
|
InkyTemplate: c => c.recurse(),
|
|
78
|
-
Title: async ({ recurse
|
|
79
|
-
Summary: async ({ recurse
|
|
78
|
+
Title: async ({ recurse }) => `<title>${await recurse()}</title>`,
|
|
79
|
+
Summary: async ({ recurse }) => `<span id="summary" style="${SUMMARY_STYLE}">${await recurse()}</span>`,
|
|
80
80
|
|
|
81
81
|
Column: async ({ props, recurse, stack, el, context }): Promise<string> => {
|
|
82
82
|
|
|
@@ -159,7 +159,7 @@ export const Html: RenderProvider<RenderContext> = {
|
|
|
159
159
|
</tbody>
|
|
160
160
|
</table>`,
|
|
161
161
|
|
|
162
|
-
Button: async ({ recurse,
|
|
162
|
+
Button: async ({ recurse, props, createState }): Promise<string> => {
|
|
163
163
|
const { href, target, ...rest } = props;
|
|
164
164
|
let inner = await recurse();
|
|
165
165
|
let expander = '';
|
|
@@ -280,7 +280,7 @@ export const Html: RenderProvider<RenderContext> = {
|
|
|
280
280
|
`;
|
|
281
281
|
},
|
|
282
282
|
|
|
283
|
-
Callout: async ({ recurse,
|
|
283
|
+
Callout: async ({ recurse, props }): Promise<string> => {
|
|
284
284
|
|
|
285
285
|
const innerProps: JSXElement['props'] = { className: props.className };
|
|
286
286
|
delete props.className;
|
package/src/render/markdown.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { JSXElement } from '@travetto/email-inky/jsx-runtime';
|
|
2
2
|
import { castTo } from '@travetto/runtime';
|
|
3
3
|
|
|
4
|
-
import { RenderProvider, RenderState } from '../types';
|
|
5
|
-
import { RenderContext } from './context';
|
|
4
|
+
import { RenderProvider, RenderState } from '../types.ts';
|
|
5
|
+
import { RenderContext } from './context.ts';
|
|
6
6
|
|
|
7
7
|
const visit = ({ recurse }: RenderState<JSXElement, RenderContext>): Promise<string> => recurse();
|
|
8
|
-
const ignore = async (
|
|
8
|
+
const ignore = async (_: RenderState<JSXElement, RenderContext>): Promise<string> => '';
|
|
9
9
|
|
|
10
10
|
export const Markdown: RenderProvider<RenderContext> = {
|
|
11
11
|
finalize: (text) => {
|
|
12
12
|
text = text
|
|
13
|
-
.replace(/(\[[^\]]
|
|
13
|
+
.replace(/(\[[^\]]{1,100}\]\([^)]{1,1000}\))([A-Za-z0-9$]{1,100})/g, (all, link, v) => v === 's' ? all : `${link} ${v}`)
|
|
14
14
|
.replace(/(\S)\n(#)/g, (_, l, r) => `${l}\n\n${r}`);
|
|
15
15
|
return text;
|
|
16
16
|
},
|
|
@@ -29,7 +29,7 @@ export const Markdown: RenderProvider<RenderContext> = {
|
|
|
29
29
|
ul: async ({ recurse }) => `\n${await recurse()}`,
|
|
30
30
|
ol: async ({ recurse }) => `\n${await recurse()}`,
|
|
31
31
|
li: async ({ recurse, stack }) => {
|
|
32
|
-
const parent = stack.
|
|
32
|
+
const parent = stack.toReversed().find(x => x.type === 'ol' || x.type === 'ul');
|
|
33
33
|
const depth = stack.filter(x => x.type === 'ol' || x.type === 'ul').length;
|
|
34
34
|
return `${' '.repeat(depth)}${(parent && parent.type === 'ol') ? '1.' : '* '} ${await recurse()}\n`;
|
|
35
35
|
},
|
package/src/render/renderer.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { isJSXElement, JSXElement, createFragment, JSXFragmentType, JSXChild } from '@travetto/email-inky/jsx-runtime';
|
|
2
2
|
import { castTo } from '@travetto/runtime';
|
|
3
3
|
|
|
4
|
-
import { EMPTY_ELEMENT, getComponentName, JSXElementByFn, c } from '../components';
|
|
5
|
-
import { RenderProvider, RenderState } from '../types';
|
|
6
|
-
import { RenderContext, RenderContextInit } from './context';
|
|
4
|
+
import { EMPTY_ELEMENT, getComponentName, JSXElementByFn, c } from '../components.ts';
|
|
5
|
+
import { RenderProvider, RenderState } from '../types.ts';
|
|
6
|
+
import { RenderContext, RenderContextInit } from './context.ts';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Inky Renderer
|
package/src/render/subject.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { JSXElement } from '@travetto/email-inky/jsx-runtime';
|
|
2
2
|
|
|
3
|
-
import { RenderProvider, RenderState } from '../types';
|
|
4
|
-
import { RenderContext } from './context';
|
|
3
|
+
import { RenderProvider, RenderState } from '../types.ts';
|
|
4
|
+
import { RenderContext } from './context.ts';
|
|
5
5
|
|
|
6
6
|
const empty = async (): Promise<string> => '';
|
|
7
7
|
const visit = ({ recurse }: RenderState<JSXElement, RenderContext>): Promise<string> => recurse();
|
|
8
8
|
|
|
9
9
|
export const Subject: RenderProvider<RenderContext> = {
|
|
10
|
-
finalize: (text
|
|
10
|
+
finalize: (text) => text,
|
|
11
11
|
|
|
12
12
|
For: async ({ recurse, props }) => `{{#${props.attr}}}${await recurse()}{{/${props.attr}}}`,
|
|
13
13
|
If: async ({ recurse, props }) => `{{#${props.attr}}}${await recurse()}{{/${props.attr}}}`,
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { JSXElement, ValidHtmlTags } from '../jsx-runtime';
|
|
2
|
-
import { JSXElementByFn, c } from './components';
|
|
1
|
+
import { JSXElement, ValidHtmlTags } from '../jsx-runtime.ts';
|
|
2
|
+
import { JSXElementByFn, c } from './components.ts';
|
|
3
3
|
|
|
4
4
|
export type Wrapper = Record<string, (cnt: string) => string>;
|
|
5
5
|
|
package/src/wrapper.ts
CHANGED
|
@@ -4,10 +4,10 @@ import { EmailTemplateModule, EmailTemplateLocation, EmailResourceLoader } from
|
|
|
4
4
|
import { PackageUtil } from '@travetto/manifest';
|
|
5
5
|
import { JSXElement } from '@travetto/email-inky/jsx-runtime';
|
|
6
6
|
|
|
7
|
-
import { InkyRenderer } from './render/renderer';
|
|
8
|
-
import { Html } from './render/html';
|
|
9
|
-
import { Markdown } from './render/markdown';
|
|
10
|
-
import { Subject } from './render/subject';
|
|
7
|
+
import { InkyRenderer } from './render/renderer.ts';
|
|
8
|
+
import { Html } from './render/html.ts';
|
|
9
|
+
import { Markdown } from './render/markdown.ts';
|
|
10
|
+
import { Subject } from './render/subject.ts';
|
|
11
11
|
|
|
12
12
|
export async function prepare(node: JSXElement, loc: EmailTemplateLocation): Promise<EmailTemplateModule> {
|
|
13
13
|
const ctx = {
|