@mjmx/core 1.0.0 → 1.2.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 +8 -1
- package/dist/{chunk-SUL5BGGO.js → chunk-JZZH5EZ3.js} +1 -1
- package/dist/{chunk-SUL5BGGO.js.map → chunk-JZZH5EZ3.js.map} +1 -1
- package/dist/index.cjs +7 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +131 -5
- package/dist/index.d.ts +131 -5
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/{jsx-dev-runtime-Dg-2Ex6t.d.cts → jsx-dev-runtime-CIghYpt3.d.cts} +76 -1
- package/dist/{jsx-dev-runtime-Dg-2Ex6t.d.ts → jsx-dev-runtime-CIghYpt3.d.ts} +76 -1
- package/dist/jsx-dev-runtime.cjs.map +1 -1
- package/dist/jsx-dev-runtime.d.cts +1 -1
- package/dist/jsx-dev-runtime.d.ts +1 -1
- package/dist/jsx-dev-runtime.js +1 -1
- package/dist/jsx-runtime.cjs.map +1 -1
- package/dist/jsx-runtime.d.cts +1 -1
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/jsx-runtime.js +1 -1
- package/package.json +12 -18
package/README.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="https://codecov.io/gh/skwee357/mjmx"><img src="https://codecov.io/gh/skwee357/mjmx/branch/main/graph/badge.svg" alt="codecov"></a>
|
|
3
|
+
<a href="https://www.npmjs.com/package/@mjmx/core"><img src="https://img.shields.io/npm/v/@mjmx/core" alt="npm version"></a>
|
|
4
|
+
<img src="https://img.shields.io/npm/l/@mjmx/core" alt="license">
|
|
5
|
+
<a href="https://github.com/skwee357/mjmx/actions/workflows/ci.yml"><img src="https://github.com/skwee357/mjmx/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
6
|
+
</div>
|
|
7
|
+
|
|
1
8
|
# mjmx
|
|
2
9
|
|
|
3
10
|
<p align="center">
|
|
@@ -25,7 +32,7 @@
|
|
|
25
32
|
## Installation
|
|
26
33
|
|
|
27
34
|
```bash
|
|
28
|
-
npm install @mjmx/core
|
|
35
|
+
npm install @mjmx/core mjml
|
|
29
36
|
```
|
|
30
37
|
|
|
31
38
|
## Usage
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ast.ts","../src/jsx-runtime.ts"],"sourcesContent":["export const MJML_NODE_TYPE = Symbol.for('mjmx.node');\n\nexport const Fragment = Symbol.for('mjmx.fragment');\n\nexport interface MjmlNode {\n readonly $$typeof: typeof MJML_NODE_TYPE;\n readonly tag: string | typeof Fragment;\n readonly attributes: Record<string, string | undefined>;\n readonly children: MjmlChild[];\n}\n\nexport type MjmlChild =\n | MjmlNode\n | string\n | number\n | boolean\n | null\n | undefined\n | MjmlChild[];\n\nexport function isMjmlNode(value: unknown): value is MjmlNode {\n return (\n typeof value === 'object' &&\n value !== null &&\n '$$typeof' in value &&\n value.$$typeof === MJML_NODE_TYPE\n );\n}\n\nexport function createNode(\n tag: string | typeof Fragment,\n attributes: Record<string, unknown>,\n children: MjmlChild[]\n): MjmlNode {\n const stringAttributes: Record<string, string | undefined> = {};\n\n for (const [key, value] of Object.entries(attributes)) {\n if (value === undefined || value === null) {\n continue;\n }\n if (value instanceof URL) {\n stringAttributes[key] = value.toString();\n } else {\n stringAttributes[key] = String(value);\n }\n }\n\n return {\n $$typeof: MJML_NODE_TYPE,\n tag,\n attributes: stringAttributes,\n children,\n };\n}\n","import { createNode, Fragment, type MjmlChild, type MjmlNode } from './ast';\nimport type {\n MjAccordionAttributes,\n MjAccordionElementAttributes,\n MjAccordionTextAttributes,\n MjAccordionTitleAttributes,\n MjAllAttributes,\n MjAttributesAttributes,\n MjBodyAttributes,\n MjBreakpointAttributes,\n MjButtonAttributes,\n MjCarouselAttributes,\n MjCarouselImageAttributes,\n MjClassAttributes,\n MjColumnAttributes,\n MjDividerAttributes,\n MjFontAttributes,\n MjGroupAttributes,\n MjHeadAttributes,\n MjHeroAttributes,\n MjHtmlAttributeAttributes,\n MjHtmlAttributesAttributes,\n MjImageAttributes,\n MjIncludeAttributes,\n MjmlAttributes,\n MjNavbarAttributes,\n MjNavbarLinkAttributes,\n MjPreviewAttributes,\n MjRawAttributes,\n MjSectionAttributes,\n MjSelectorAttributes,\n MjSocialAttributes,\n MjSocialElementAttributes,\n MjSpacerAttributes,\n MjStyleAttributes,\n MjTableAttributes,\n MjTextAttributes,\n MjTitleAttributes,\n MjWrapperAttributes,\n} from './types';\n\nexport { Fragment };\n\
|
|
1
|
+
{"version":3,"sources":["../src/ast.ts","../src/jsx-runtime.ts"],"sourcesContent":["export const MJML_NODE_TYPE = Symbol.for('mjmx.node');\n\nexport const Fragment = Symbol.for('mjmx.fragment');\n\nexport interface MjmlNode {\n readonly $$typeof: typeof MJML_NODE_TYPE;\n readonly tag: string | typeof Fragment;\n readonly attributes: Record<string, string | undefined>;\n readonly children: MjmlChild[];\n}\n\nexport type MjmlChild =\n | MjmlNode\n | string\n | number\n | boolean\n | null\n | undefined\n | MjmlChild[];\n\nexport function isMjmlNode(value: unknown): value is MjmlNode {\n return (\n typeof value === 'object' &&\n value !== null &&\n '$$typeof' in value &&\n value.$$typeof === MJML_NODE_TYPE\n );\n}\n\nexport function createNode(\n tag: string | typeof Fragment,\n attributes: Record<string, unknown>,\n children: MjmlChild[]\n): MjmlNode {\n const stringAttributes: Record<string, string | undefined> = {};\n\n for (const [key, value] of Object.entries(attributes)) {\n if (value === undefined || value === null) {\n continue;\n }\n if (value instanceof URL) {\n stringAttributes[key] = value.toString();\n } else {\n stringAttributes[key] = String(value);\n }\n }\n\n return {\n $$typeof: MJML_NODE_TYPE,\n tag,\n attributes: stringAttributes,\n children,\n };\n}\n","import { createNode, Fragment, type MjmlChild, type MjmlNode } from './ast';\nimport type {\n HtmlAnchorAttributes,\n HtmlGlobalAttributes,\n HtmlImgAttributes,\n HtmlListAttributes,\n HtmlMetaAttributes,\n HtmlTableCellAttributes,\n} from './html-types';\nimport type {\n MjAccordionAttributes,\n MjAccordionElementAttributes,\n MjAccordionTextAttributes,\n MjAccordionTitleAttributes,\n MjAllAttributes,\n MjAttributesAttributes,\n MjBodyAttributes,\n MjBreakpointAttributes,\n MjButtonAttributes,\n MjCarouselAttributes,\n MjCarouselImageAttributes,\n MjClassAttributes,\n MjColumnAttributes,\n MjDividerAttributes,\n MjFontAttributes,\n MjGroupAttributes,\n MjHeadAttributes,\n MjHeroAttributes,\n MjHtmlAttributeAttributes,\n MjHtmlAttributesAttributes,\n MjImageAttributes,\n MjIncludeAttributes,\n MjmlAttributes,\n MjNavbarAttributes,\n MjNavbarLinkAttributes,\n MjPreviewAttributes,\n MjRawAttributes,\n MjSectionAttributes,\n MjSelectorAttributes,\n MjSocialAttributes,\n MjSocialElementAttributes,\n MjSpacerAttributes,\n MjStyleAttributes,\n MjTableAttributes,\n MjTextAttributes,\n MjTitleAttributes,\n MjWrapperAttributes,\n} from './types';\n\nexport { Fragment };\n\nexport type PropsWithChildren<T = object> = T & { children?: MjmlChild };\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Component = (props: any) => MjmlNode;\n\nexport function jsx(\n tag: string | typeof Fragment | Component,\n props: Record<string, unknown>,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _key?: string\n): MjmlNode {\n if (typeof tag === 'function') {\n return tag(props);\n }\n\n const { children, ...attributes } = props;\n\n const childArray: MjmlChild[] =\n children === undefined\n ? []\n : Array.isArray(children)\n ? children\n : [children as MjmlChild];\n\n return createNode(tag, attributes, childArray);\n}\n\nexport const jsxs = jsx;\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace JSX {\n export type Element = MjmlNode;\n export type ElementType = string | typeof Fragment | Component;\n\n export interface ElementChildrenAttribute {\n children: MjmlChild;\n }\n\n export interface IntrinsicElements {\n mjml: PropsWithChildren<MjmlAttributes>;\n 'mj-head': PropsWithChildren<MjHeadAttributes>;\n 'mj-body': PropsWithChildren<MjBodyAttributes>;\n 'mj-attributes': PropsWithChildren<MjAttributesAttributes>;\n 'mj-breakpoint': MjBreakpointAttributes;\n 'mj-font': MjFontAttributes;\n 'mj-html-attributes': PropsWithChildren<MjHtmlAttributesAttributes>;\n 'mj-preview': PropsWithChildren<MjPreviewAttributes>;\n 'mj-style': PropsWithChildren<MjStyleAttributes>;\n 'mj-title': PropsWithChildren<MjTitleAttributes>;\n 'mj-all': MjAllAttributes;\n 'mj-class': MjClassAttributes;\n 'mj-section': PropsWithChildren<MjSectionAttributes>;\n 'mj-column': PropsWithChildren<MjColumnAttributes>;\n 'mj-group': PropsWithChildren<MjGroupAttributes>;\n 'mj-wrapper': PropsWithChildren<MjWrapperAttributes>;\n 'mj-text': PropsWithChildren<MjTextAttributes>;\n 'mj-button': PropsWithChildren<MjButtonAttributes>;\n 'mj-image': MjImageAttributes;\n 'mj-divider': MjDividerAttributes;\n 'mj-spacer': MjSpacerAttributes;\n 'mj-table': PropsWithChildren<MjTableAttributes>;\n 'mj-raw': PropsWithChildren<MjRawAttributes>;\n 'mj-hero': PropsWithChildren<MjHeroAttributes>;\n 'mj-accordion': PropsWithChildren<MjAccordionAttributes>;\n 'mj-accordion-element': PropsWithChildren<MjAccordionElementAttributes>;\n 'mj-accordion-title': PropsWithChildren<MjAccordionTitleAttributes>;\n 'mj-accordion-text': PropsWithChildren<MjAccordionTextAttributes>;\n 'mj-carousel': PropsWithChildren<MjCarouselAttributes>;\n 'mj-carousel-image': MjCarouselImageAttributes;\n 'mj-navbar': PropsWithChildren<MjNavbarAttributes>;\n 'mj-navbar-link': PropsWithChildren<MjNavbarLinkAttributes>;\n 'mj-social': PropsWithChildren<MjSocialAttributes>;\n 'mj-social-element': PropsWithChildren<MjSocialElementAttributes>;\n 'mj-include': MjIncludeAttributes;\n 'mj-selector': PropsWithChildren<MjSelectorAttributes>;\n 'mj-html-attribute': PropsWithChildren<MjHtmlAttributeAttributes>;\n\n // HTML inline text elements (for mj-text)\n a: PropsWithChildren<HtmlAnchorAttributes>;\n span: PropsWithChildren<HtmlGlobalAttributes>;\n strong: PropsWithChildren<HtmlGlobalAttributes>;\n b: PropsWithChildren<HtmlGlobalAttributes>;\n em: PropsWithChildren<HtmlGlobalAttributes>;\n i: PropsWithChildren<HtmlGlobalAttributes>;\n u: PropsWithChildren<HtmlGlobalAttributes>;\n s: PropsWithChildren<HtmlGlobalAttributes>;\n small: PropsWithChildren<HtmlGlobalAttributes>;\n code: PropsWithChildren<HtmlGlobalAttributes>;\n sub: PropsWithChildren<HtmlGlobalAttributes>;\n sup: PropsWithChildren<HtmlGlobalAttributes>;\n br: HtmlGlobalAttributes;\n\n // HTML block text elements (for mj-text)\n div: PropsWithChildren<HtmlGlobalAttributes>;\n p: PropsWithChildren<HtmlGlobalAttributes>;\n h1: PropsWithChildren<HtmlGlobalAttributes>;\n h2: PropsWithChildren<HtmlGlobalAttributes>;\n h3: PropsWithChildren<HtmlGlobalAttributes>;\n h4: PropsWithChildren<HtmlGlobalAttributes>;\n h5: PropsWithChildren<HtmlGlobalAttributes>;\n h6: PropsWithChildren<HtmlGlobalAttributes>;\n ul: PropsWithChildren<HtmlListAttributes>;\n ol: PropsWithChildren<HtmlListAttributes>;\n li: PropsWithChildren<HtmlGlobalAttributes>;\n blockquote: PropsWithChildren<HtmlGlobalAttributes>;\n pre: PropsWithChildren<HtmlGlobalAttributes>;\n hr: HtmlGlobalAttributes;\n\n // HTML table elements (for mj-table - use mj-table instead of <table>)\n tr: PropsWithChildren<HtmlGlobalAttributes>;\n td: PropsWithChildren<HtmlTableCellAttributes>;\n th: PropsWithChildren<HtmlTableCellAttributes>;\n thead: PropsWithChildren<HtmlGlobalAttributes>;\n tbody: PropsWithChildren<HtmlGlobalAttributes>;\n\n // HTML media elements (for mj-table - mj-image can't be used inside mj-table)\n img: HtmlImgAttributes;\n\n // HTML head elements (for mj-raw in mj-head - dark mode support)\n meta: HtmlMetaAttributes;\n }\n}\n"],"mappings":";AAAO,IAAM,iBAAiB,uBAAO,IAAI,WAAW;AAE7C,IAAM,WAAW,uBAAO,IAAI,eAAe;AAkB3C,SAAS,WAAW,OAAmC;AAC5D,SACE,OAAO,UAAU,YACjB,UAAU,QACV,cAAc,SACd,MAAM,aAAa;AAEvB;AAEO,SAAS,WACd,KACA,YACA,UACU;AACV,QAAM,mBAAuD,CAAC;AAE9D,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,UAAU,GAAG;AACrD,QAAI,UAAU,UAAa,UAAU,MAAM;AACzC;AAAA,IACF;AACA,QAAI,iBAAiB,KAAK;AACxB,uBAAiB,GAAG,IAAI,MAAM,SAAS;AAAA,IACzC,OAAO;AACL,uBAAiB,GAAG,IAAI,OAAO,KAAK;AAAA,IACtC;AAAA,EACF;AAEA,SAAO;AAAA,IACL,UAAU;AAAA,IACV;AAAA,IACA,YAAY;AAAA,IACZ;AAAA,EACF;AACF;;;ACGO,SAAS,IACd,KACA,OAEA,MACU;AACV,MAAI,OAAO,QAAQ,YAAY;AAC7B,WAAO,IAAI,KAAK;AAAA,EAClB;AAEA,QAAM,EAAE,UAAU,GAAG,WAAW,IAAI;AAEpC,QAAM,aACJ,aAAa,SACT,CAAC,IACD,MAAM,QAAQ,QAAQ,IACpB,WACA,CAAC,QAAqB;AAE9B,SAAO,WAAW,KAAK,YAAY,UAAU;AAC/C;AAEO,IAAM,OAAO;","names":[]}
|
package/dist/index.cjs
CHANGED
|
@@ -80,6 +80,7 @@ var import_mjml = __toESM(require("mjml"), 1);
|
|
|
80
80
|
|
|
81
81
|
// src/serialize.ts
|
|
82
82
|
var SELF_CLOSING_TAGS = /* @__PURE__ */ new Set([
|
|
83
|
+
// MJML
|
|
83
84
|
"mj-all",
|
|
84
85
|
"mj-breakpoint",
|
|
85
86
|
"mj-carousel-image",
|
|
@@ -88,7 +89,12 @@ var SELF_CLOSING_TAGS = /* @__PURE__ */ new Set([
|
|
|
88
89
|
"mj-font",
|
|
89
90
|
"mj-image",
|
|
90
91
|
"mj-include",
|
|
91
|
-
"mj-spacer"
|
|
92
|
+
"mj-spacer",
|
|
93
|
+
// HTML void elements
|
|
94
|
+
"br",
|
|
95
|
+
"hr",
|
|
96
|
+
"img",
|
|
97
|
+
"meta"
|
|
92
98
|
]);
|
|
93
99
|
function serializeAttributes(attributes) {
|
|
94
100
|
const parts = [];
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/ast.ts","../src/jsx-runtime.ts","../src/render.ts","../src/serialize.ts"],"sourcesContent":["export { Fragment, type MjmlChild, type MjmlNode } from './ast';\nexport { jsx, jsxs, type JSX } from './jsx-runtime';\nexport { render, type RenderOptions, type RenderResult } from './render';\nexport { serialize } from './serialize';\n\nexport type {\n Align,\n CSSPixel,\n CSSSpacing,\n CSSUnit,\n CSSWidth,\n Color,\n Direction,\n HexColor,\n MjAccordionAttributes,\n MjAccordionElementAttributes,\n MjAccordionTextAttributes,\n MjAccordionTitleAttributes,\n MjAllAttributes,\n MjAttributesAttributes,\n MjBodyAttributes,\n MjBreakpointAttributes,\n MjButtonAttributes,\n MjCarouselAttributes,\n MjCarouselImageAttributes,\n MjClassAttributes,\n MjColumnAttributes,\n MjDividerAttributes,\n MjFontAttributes,\n MjGroupAttributes,\n MjHeadAttributes,\n MjHeroAttributes,\n MjHtmlAttributeAttributes,\n MjHtmlAttributesAttributes,\n MjImageAttributes,\n MjIncludeAttributes,\n MjNavbarAttributes,\n MjNavbarLinkAttributes,\n MjPreviewAttributes,\n MjRawAttributes,\n MjSectionAttributes,\n MjSelectorAttributes,\n MjSocialAttributes,\n MjSocialElementAttributes,\n MjSpacerAttributes,\n MjStyleAttributes,\n MjTableAttributes,\n MjTextAttributes,\n MjTitleAttributes,\n MjWrapperAttributes,\n MjmlAttributes,\n URLString,\n VerticalAlign,\n} from './types';\n","export const MJML_NODE_TYPE = Symbol.for('mjmx.node');\n\nexport const Fragment = Symbol.for('mjmx.fragment');\n\nexport interface MjmlNode {\n readonly $$typeof: typeof MJML_NODE_TYPE;\n readonly tag: string | typeof Fragment;\n readonly attributes: Record<string, string | undefined>;\n readonly children: MjmlChild[];\n}\n\nexport type MjmlChild =\n | MjmlNode\n | string\n | number\n | boolean\n | null\n | undefined\n | MjmlChild[];\n\nexport function isMjmlNode(value: unknown): value is MjmlNode {\n return (\n typeof value === 'object' &&\n value !== null &&\n '$$typeof' in value &&\n value.$$typeof === MJML_NODE_TYPE\n );\n}\n\nexport function createNode(\n tag: string | typeof Fragment,\n attributes: Record<string, unknown>,\n children: MjmlChild[]\n): MjmlNode {\n const stringAttributes: Record<string, string | undefined> = {};\n\n for (const [key, value] of Object.entries(attributes)) {\n if (value === undefined || value === null) {\n continue;\n }\n if (value instanceof URL) {\n stringAttributes[key] = value.toString();\n } else {\n stringAttributes[key] = String(value);\n }\n }\n\n return {\n $$typeof: MJML_NODE_TYPE,\n tag,\n attributes: stringAttributes,\n children,\n };\n}\n","import { createNode, Fragment, type MjmlChild, type MjmlNode } from './ast';\nimport type {\n MjAccordionAttributes,\n MjAccordionElementAttributes,\n MjAccordionTextAttributes,\n MjAccordionTitleAttributes,\n MjAllAttributes,\n MjAttributesAttributes,\n MjBodyAttributes,\n MjBreakpointAttributes,\n MjButtonAttributes,\n MjCarouselAttributes,\n MjCarouselImageAttributes,\n MjClassAttributes,\n MjColumnAttributes,\n MjDividerAttributes,\n MjFontAttributes,\n MjGroupAttributes,\n MjHeadAttributes,\n MjHeroAttributes,\n MjHtmlAttributeAttributes,\n MjHtmlAttributesAttributes,\n MjImageAttributes,\n MjIncludeAttributes,\n MjmlAttributes,\n MjNavbarAttributes,\n MjNavbarLinkAttributes,\n MjPreviewAttributes,\n MjRawAttributes,\n MjSectionAttributes,\n MjSelectorAttributes,\n MjSocialAttributes,\n MjSocialElementAttributes,\n MjSpacerAttributes,\n MjStyleAttributes,\n MjTableAttributes,\n MjTextAttributes,\n MjTitleAttributes,\n MjWrapperAttributes,\n} from './types';\n\nexport { Fragment };\n\ntype PropsWithChildren<T = object> = T & { children?: MjmlChild };\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Component = (props: any) => MjmlNode;\n\nexport function jsx(\n tag: string | typeof Fragment | Component,\n props: Record<string, unknown>,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _key?: string\n): MjmlNode {\n if (typeof tag === 'function') {\n return tag(props);\n }\n\n const { children, ...attributes } = props;\n\n const childArray: MjmlChild[] =\n children === undefined\n ? []\n : Array.isArray(children)\n ? children\n : [children as MjmlChild];\n\n return createNode(tag, attributes, childArray);\n}\n\nexport const jsxs = jsx;\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace JSX {\n export type Element = MjmlNode;\n export type ElementType = string | typeof Fragment | Component;\n\n export interface ElementChildrenAttribute {\n children: MjmlChild;\n }\n\n export interface IntrinsicElements {\n mjml: PropsWithChildren<MjmlAttributes>;\n 'mj-head': PropsWithChildren<MjHeadAttributes>;\n 'mj-body': PropsWithChildren<MjBodyAttributes>;\n 'mj-attributes': PropsWithChildren<MjAttributesAttributes>;\n 'mj-breakpoint': MjBreakpointAttributes;\n 'mj-font': MjFontAttributes;\n 'mj-html-attributes': PropsWithChildren<MjHtmlAttributesAttributes>;\n 'mj-preview': PropsWithChildren<MjPreviewAttributes>;\n 'mj-style': PropsWithChildren<MjStyleAttributes>;\n 'mj-title': PropsWithChildren<MjTitleAttributes>;\n 'mj-all': MjAllAttributes;\n 'mj-class': MjClassAttributes;\n 'mj-section': PropsWithChildren<MjSectionAttributes>;\n 'mj-column': PropsWithChildren<MjColumnAttributes>;\n 'mj-group': PropsWithChildren<MjGroupAttributes>;\n 'mj-wrapper': PropsWithChildren<MjWrapperAttributes>;\n 'mj-text': PropsWithChildren<MjTextAttributes>;\n 'mj-button': PropsWithChildren<MjButtonAttributes>;\n 'mj-image': MjImageAttributes;\n 'mj-divider': MjDividerAttributes;\n 'mj-spacer': MjSpacerAttributes;\n 'mj-table': PropsWithChildren<MjTableAttributes>;\n 'mj-raw': PropsWithChildren<MjRawAttributes>;\n 'mj-hero': PropsWithChildren<MjHeroAttributes>;\n 'mj-accordion': PropsWithChildren<MjAccordionAttributes>;\n 'mj-accordion-element': PropsWithChildren<MjAccordionElementAttributes>;\n 'mj-accordion-title': PropsWithChildren<MjAccordionTitleAttributes>;\n 'mj-accordion-text': PropsWithChildren<MjAccordionTextAttributes>;\n 'mj-carousel': PropsWithChildren<MjCarouselAttributes>;\n 'mj-carousel-image': MjCarouselImageAttributes;\n 'mj-navbar': PropsWithChildren<MjNavbarAttributes>;\n 'mj-navbar-link': PropsWithChildren<MjNavbarLinkAttributes>;\n 'mj-social': PropsWithChildren<MjSocialAttributes>;\n 'mj-social-element': PropsWithChildren<MjSocialElementAttributes>;\n 'mj-include': MjIncludeAttributes;\n 'mj-selector': PropsWithChildren<MjSelectorAttributes>;\n 'mj-html-attribute': PropsWithChildren<MjHtmlAttributeAttributes>;\n }\n}\n","import mjml2html from 'mjml';\nimport type { MjmlNode } from './ast';\nimport { isMjmlNode } from './ast';\nimport { serialize } from './serialize';\n\nexport type RenderOptions = Parameters<typeof mjml2html>[1];\nexport type RenderResult = ReturnType<typeof mjml2html>;\n\nexport function render(\n mjml: MjmlNode | string,\n options?: RenderOptions\n): RenderResult {\n const str = isMjmlNode(mjml) ? serialize(mjml) : mjml;\n return mjml2html(str, options);\n}\n","import { Fragment, isMjmlNode, type MjmlChild, type MjmlNode } from './ast';\n\nconst SELF_CLOSING_TAGS = new Set([\n 'mj-all',\n 'mj-breakpoint',\n 'mj-carousel-image',\n 'mj-class',\n 'mj-divider',\n 'mj-font',\n 'mj-image',\n 'mj-include',\n 'mj-spacer',\n]);\n\nfunction serializeAttributes(\n attributes: Record<string, string | undefined>\n): string {\n const parts: string[] = [];\n\n for (const [key, value] of Object.entries(attributes)) {\n if (value !== undefined) {\n parts.push(`${key}=\"${value}\"`);\n }\n }\n\n return parts.length > 0 ? ' ' + parts.join(' ') : '';\n}\n\nfunction serializeChildren(children: MjmlChild[]): string {\n const parts: string[] = [];\n\n for (const child of children) {\n if (\n child === null ||\n child === undefined ||\n child === true ||\n child === false\n ) {\n continue;\n }\n\n if (Array.isArray(child)) {\n parts.push(serializeChildren(child));\n } else if (isMjmlNode(child)) {\n parts.push(serializeNode(child));\n } else {\n parts.push(String(child));\n }\n }\n\n return parts.join('');\n}\n\nfunction serializeNode(node: MjmlNode): string {\n if (node.tag === Fragment) {\n return serializeChildren(node.children);\n }\n\n const tag = node.tag as string;\n const attrs = serializeAttributes(node.attributes);\n\n if (SELF_CLOSING_TAGS.has(tag)) {\n return `<${tag}${attrs} />`;\n }\n\n const content = serializeChildren(node.children);\n return `<${tag}${attrs}>${content}</${tag}>`;\n}\n\nexport function serialize(node: MjmlNode): string {\n return serializeNode(node);\n}\n\nexport const toMjmlString = serialize;\n"],"mappings":"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","names":["mjml2html"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/ast.ts","../src/jsx-runtime.ts","../src/render.ts","../src/serialize.ts"],"sourcesContent":["export { Fragment, type MjmlChild, type MjmlNode } from './ast';\nexport type {\n HtmlAnchorAttributes,\n HtmlGlobalAttributes,\n HtmlImgAttributes,\n HtmlListAttributes,\n HtmlMetaAttributes,\n HtmlTableCellAttributes,\n} from './html-types';\nexport { jsx, jsxs, type JSX, type PropsWithChildren } from './jsx-runtime';\nexport { render, type RenderOptions, type RenderResult } from './render';\nexport { serialize } from './serialize';\n\nexport type {\n Align,\n CSSPixel,\n CSSSpacing,\n CSSUnit,\n CSSWidth,\n Color,\n Direction,\n HexColor,\n MjAccordionAttributes,\n MjAccordionElementAttributes,\n MjAccordionTextAttributes,\n MjAccordionTitleAttributes,\n MjAllAttributes,\n MjAttributesAttributes,\n MjBodyAttributes,\n MjBreakpointAttributes,\n MjButtonAttributes,\n MjCarouselAttributes,\n MjCarouselImageAttributes,\n MjClassAttributes,\n MjColumnAttributes,\n MjDividerAttributes,\n MjFontAttributes,\n MjGroupAttributes,\n MjHeadAttributes,\n MjHeroAttributes,\n MjHtmlAttributeAttributes,\n MjHtmlAttributesAttributes,\n MjImageAttributes,\n MjIncludeAttributes,\n MjNavbarAttributes,\n MjNavbarLinkAttributes,\n MjPreviewAttributes,\n MjRawAttributes,\n MjSectionAttributes,\n MjSelectorAttributes,\n MjSocialAttributes,\n MjSocialElementAttributes,\n MjSpacerAttributes,\n MjStyleAttributes,\n MjTableAttributes,\n MjTextAttributes,\n MjTitleAttributes,\n MjWrapperAttributes,\n MjmlAttributes,\n URLString,\n VerticalAlign,\n} from './types';\n","export const MJML_NODE_TYPE = Symbol.for('mjmx.node');\n\nexport const Fragment = Symbol.for('mjmx.fragment');\n\nexport interface MjmlNode {\n readonly $$typeof: typeof MJML_NODE_TYPE;\n readonly tag: string | typeof Fragment;\n readonly attributes: Record<string, string | undefined>;\n readonly children: MjmlChild[];\n}\n\nexport type MjmlChild =\n | MjmlNode\n | string\n | number\n | boolean\n | null\n | undefined\n | MjmlChild[];\n\nexport function isMjmlNode(value: unknown): value is MjmlNode {\n return (\n typeof value === 'object' &&\n value !== null &&\n '$$typeof' in value &&\n value.$$typeof === MJML_NODE_TYPE\n );\n}\n\nexport function createNode(\n tag: string | typeof Fragment,\n attributes: Record<string, unknown>,\n children: MjmlChild[]\n): MjmlNode {\n const stringAttributes: Record<string, string | undefined> = {};\n\n for (const [key, value] of Object.entries(attributes)) {\n if (value === undefined || value === null) {\n continue;\n }\n if (value instanceof URL) {\n stringAttributes[key] = value.toString();\n } else {\n stringAttributes[key] = String(value);\n }\n }\n\n return {\n $$typeof: MJML_NODE_TYPE,\n tag,\n attributes: stringAttributes,\n children,\n };\n}\n","import { createNode, Fragment, type MjmlChild, type MjmlNode } from './ast';\nimport type {\n HtmlAnchorAttributes,\n HtmlGlobalAttributes,\n HtmlImgAttributes,\n HtmlListAttributes,\n HtmlMetaAttributes,\n HtmlTableCellAttributes,\n} from './html-types';\nimport type {\n MjAccordionAttributes,\n MjAccordionElementAttributes,\n MjAccordionTextAttributes,\n MjAccordionTitleAttributes,\n MjAllAttributes,\n MjAttributesAttributes,\n MjBodyAttributes,\n MjBreakpointAttributes,\n MjButtonAttributes,\n MjCarouselAttributes,\n MjCarouselImageAttributes,\n MjClassAttributes,\n MjColumnAttributes,\n MjDividerAttributes,\n MjFontAttributes,\n MjGroupAttributes,\n MjHeadAttributes,\n MjHeroAttributes,\n MjHtmlAttributeAttributes,\n MjHtmlAttributesAttributes,\n MjImageAttributes,\n MjIncludeAttributes,\n MjmlAttributes,\n MjNavbarAttributes,\n MjNavbarLinkAttributes,\n MjPreviewAttributes,\n MjRawAttributes,\n MjSectionAttributes,\n MjSelectorAttributes,\n MjSocialAttributes,\n MjSocialElementAttributes,\n MjSpacerAttributes,\n MjStyleAttributes,\n MjTableAttributes,\n MjTextAttributes,\n MjTitleAttributes,\n MjWrapperAttributes,\n} from './types';\n\nexport { Fragment };\n\nexport type PropsWithChildren<T = object> = T & { children?: MjmlChild };\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Component = (props: any) => MjmlNode;\n\nexport function jsx(\n tag: string | typeof Fragment | Component,\n props: Record<string, unknown>,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _key?: string\n): MjmlNode {\n if (typeof tag === 'function') {\n return tag(props);\n }\n\n const { children, ...attributes } = props;\n\n const childArray: MjmlChild[] =\n children === undefined\n ? []\n : Array.isArray(children)\n ? children\n : [children as MjmlChild];\n\n return createNode(tag, attributes, childArray);\n}\n\nexport const jsxs = jsx;\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace JSX {\n export type Element = MjmlNode;\n export type ElementType = string | typeof Fragment | Component;\n\n export interface ElementChildrenAttribute {\n children: MjmlChild;\n }\n\n export interface IntrinsicElements {\n mjml: PropsWithChildren<MjmlAttributes>;\n 'mj-head': PropsWithChildren<MjHeadAttributes>;\n 'mj-body': PropsWithChildren<MjBodyAttributes>;\n 'mj-attributes': PropsWithChildren<MjAttributesAttributes>;\n 'mj-breakpoint': MjBreakpointAttributes;\n 'mj-font': MjFontAttributes;\n 'mj-html-attributes': PropsWithChildren<MjHtmlAttributesAttributes>;\n 'mj-preview': PropsWithChildren<MjPreviewAttributes>;\n 'mj-style': PropsWithChildren<MjStyleAttributes>;\n 'mj-title': PropsWithChildren<MjTitleAttributes>;\n 'mj-all': MjAllAttributes;\n 'mj-class': MjClassAttributes;\n 'mj-section': PropsWithChildren<MjSectionAttributes>;\n 'mj-column': PropsWithChildren<MjColumnAttributes>;\n 'mj-group': PropsWithChildren<MjGroupAttributes>;\n 'mj-wrapper': PropsWithChildren<MjWrapperAttributes>;\n 'mj-text': PropsWithChildren<MjTextAttributes>;\n 'mj-button': PropsWithChildren<MjButtonAttributes>;\n 'mj-image': MjImageAttributes;\n 'mj-divider': MjDividerAttributes;\n 'mj-spacer': MjSpacerAttributes;\n 'mj-table': PropsWithChildren<MjTableAttributes>;\n 'mj-raw': PropsWithChildren<MjRawAttributes>;\n 'mj-hero': PropsWithChildren<MjHeroAttributes>;\n 'mj-accordion': PropsWithChildren<MjAccordionAttributes>;\n 'mj-accordion-element': PropsWithChildren<MjAccordionElementAttributes>;\n 'mj-accordion-title': PropsWithChildren<MjAccordionTitleAttributes>;\n 'mj-accordion-text': PropsWithChildren<MjAccordionTextAttributes>;\n 'mj-carousel': PropsWithChildren<MjCarouselAttributes>;\n 'mj-carousel-image': MjCarouselImageAttributes;\n 'mj-navbar': PropsWithChildren<MjNavbarAttributes>;\n 'mj-navbar-link': PropsWithChildren<MjNavbarLinkAttributes>;\n 'mj-social': PropsWithChildren<MjSocialAttributes>;\n 'mj-social-element': PropsWithChildren<MjSocialElementAttributes>;\n 'mj-include': MjIncludeAttributes;\n 'mj-selector': PropsWithChildren<MjSelectorAttributes>;\n 'mj-html-attribute': PropsWithChildren<MjHtmlAttributeAttributes>;\n\n // HTML inline text elements (for mj-text)\n a: PropsWithChildren<HtmlAnchorAttributes>;\n span: PropsWithChildren<HtmlGlobalAttributes>;\n strong: PropsWithChildren<HtmlGlobalAttributes>;\n b: PropsWithChildren<HtmlGlobalAttributes>;\n em: PropsWithChildren<HtmlGlobalAttributes>;\n i: PropsWithChildren<HtmlGlobalAttributes>;\n u: PropsWithChildren<HtmlGlobalAttributes>;\n s: PropsWithChildren<HtmlGlobalAttributes>;\n small: PropsWithChildren<HtmlGlobalAttributes>;\n code: PropsWithChildren<HtmlGlobalAttributes>;\n sub: PropsWithChildren<HtmlGlobalAttributes>;\n sup: PropsWithChildren<HtmlGlobalAttributes>;\n br: HtmlGlobalAttributes;\n\n // HTML block text elements (for mj-text)\n div: PropsWithChildren<HtmlGlobalAttributes>;\n p: PropsWithChildren<HtmlGlobalAttributes>;\n h1: PropsWithChildren<HtmlGlobalAttributes>;\n h2: PropsWithChildren<HtmlGlobalAttributes>;\n h3: PropsWithChildren<HtmlGlobalAttributes>;\n h4: PropsWithChildren<HtmlGlobalAttributes>;\n h5: PropsWithChildren<HtmlGlobalAttributes>;\n h6: PropsWithChildren<HtmlGlobalAttributes>;\n ul: PropsWithChildren<HtmlListAttributes>;\n ol: PropsWithChildren<HtmlListAttributes>;\n li: PropsWithChildren<HtmlGlobalAttributes>;\n blockquote: PropsWithChildren<HtmlGlobalAttributes>;\n pre: PropsWithChildren<HtmlGlobalAttributes>;\n hr: HtmlGlobalAttributes;\n\n // HTML table elements (for mj-table - use mj-table instead of <table>)\n tr: PropsWithChildren<HtmlGlobalAttributes>;\n td: PropsWithChildren<HtmlTableCellAttributes>;\n th: PropsWithChildren<HtmlTableCellAttributes>;\n thead: PropsWithChildren<HtmlGlobalAttributes>;\n tbody: PropsWithChildren<HtmlGlobalAttributes>;\n\n // HTML media elements (for mj-table - mj-image can't be used inside mj-table)\n img: HtmlImgAttributes;\n\n // HTML head elements (for mj-raw in mj-head - dark mode support)\n meta: HtmlMetaAttributes;\n }\n}\n","import mjml2html from 'mjml';\nimport type { MjmlNode } from './ast';\nimport { isMjmlNode } from './ast';\nimport { serialize } from './serialize';\n\nexport interface RenderOptions {\n /**\n * Default fonts imported in the HTML rendered by HTML\n * ie. { 'Open Sans': 'https://fonts.googleapis.com/css?family=Open+Sans:300,400,500,700' }\n *\n * default: @see https://github.com/mjmlio/mjml/blob/master/packages/mjml-core/src/index.js\n */\n fonts?: { [key: string]: string } | undefined;\n\n /**\n * Option to keep comments in the HTML output\n * default: true\n */\n keepComments?: boolean | undefined;\n\n /**\n * @deprecated use js-beautify directly after processing the MJML\n *\n * Option to beautify the HTML output\n * default: false\n */\n beautify?: boolean | undefined;\n\n /**\n * @deprecated use html-minifier directly after processing the MJML\n *\n * Option to minify the HTML output\n *\n * default: false\n */\n minify?: boolean | undefined;\n /**\n * @deprecated @see minify\n *\n * Options for html minifier, see mjml-cli documentation for more info\n * Passed directly to html-minifier as options\n *\n * default: @see htmlMinify usage in mjml-core/src/index.js\n */\n minifyOptions?:\n | {\n collapseWhitespace?: boolean | undefined;\n minifyCSS?: boolean | undefined;\n removeEmptyAttributes?: boolean | undefined;\n }\n | undefined;\n\n /**\n * How to validate your MJML\n *\n * skip: your document is rendered without going through validation\n * soft: your document is going through validation and is rendered, even if it has errors\n * strict: your document is going through validation and is not rendered if it has any error\n *\n * default: soft\n */\n validationLevel?: 'strict' | 'soft' | 'skip' | undefined;\n\n /**\n * Full path of the specified file to use when resolving paths from mj-include components\n * default: '.'\n */\n filePath?: string | undefined;\n /**\n * The path or directory of the .mjmlconfig file\n * default: process.cwd()\n */\n mjmlConfigPath?: string | undefined;\n\n /**\n * Use the config attribute defined in the .mjmlconfig file.\n * The config passed into mjml2html overrides the .mjmlconfig.\n * default: false\n */\n useMjmlConfigOptions?: boolean | undefined;\n\n /**\n * optional setting when inlining css, see mjml-cli documentation for more info\n *\n */\n juicePreserveTags?:\n | { [index: string]: { start: string; end: string } }\n | undefined;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n juiceOptions?: any;\n\n /**\n * undocumented\n * a function returning html skeleton\n * default: see mjml-core/src/helpers/skeleton.js\n */\n skeleton?: string | (() => string) | undefined;\n\n actualPath?: string | undefined;\n /**\n * undocumented\n * ignore mj-include elements\n * default: false\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ignoreIncludes?: any;\n\n /**\n * see mjml-parser-xml\n */\n preprocessors?: Array<(xml: string) => string> | undefined;\n\n /**\n * Add media queries specific to printer when converting mjml into html. When enabling this option,\n * the html might not be compatible with all email clients anymore.\n */\n printerSupport?: boolean | undefined;\n}\n\ninterface MJMLJsonWithChildren {\n tagName: string;\n attributes: Record<string, unknown>;\n children: MJMLJsonObject[];\n}\n\ninterface MJMLJsonWithContent {\n tagName: string;\n attributes: Record<string, unknown>;\n content: string;\n}\n\ninterface MJMLJsonSelfClosingTag {\n tagName: string;\n attributes: Record<string, unknown>;\n}\n\ntype MJMLJsonObject =\n | MJMLJsonWithChildren\n | MJMLJsonWithContent\n | MJMLJsonSelfClosingTag;\n\ninterface MJMLParseError {\n line: number;\n message: string;\n tagName: string;\n formattedMessage: string;\n}\n\nexport interface RenderResult {\n html: string;\n json: MJMLJsonObject;\n errors: MJMLParseError[];\n}\n\nexport function render(\n mjml: MjmlNode | string,\n options?: RenderOptions\n): RenderResult {\n const str = isMjmlNode(mjml) ? serialize(mjml) : mjml;\n return mjml2html(str, options);\n}\n","import { Fragment, isMjmlNode, type MjmlChild, type MjmlNode } from './ast';\n\nconst SELF_CLOSING_TAGS = new Set([\n // MJML\n 'mj-all',\n 'mj-breakpoint',\n 'mj-carousel-image',\n 'mj-class',\n 'mj-divider',\n 'mj-font',\n 'mj-image',\n 'mj-include',\n 'mj-spacer',\n // HTML void elements\n 'br',\n 'hr',\n 'img',\n 'meta',\n]);\n\nfunction serializeAttributes(\n attributes: Record<string, string | undefined>\n): string {\n const parts: string[] = [];\n\n for (const [key, value] of Object.entries(attributes)) {\n if (value !== undefined) {\n parts.push(`${key}=\"${value}\"`);\n }\n }\n\n return parts.length > 0 ? ' ' + parts.join(' ') : '';\n}\n\nfunction serializeChildren(children: MjmlChild[]): string {\n const parts: string[] = [];\n\n for (const child of children) {\n if (\n child === null ||\n child === undefined ||\n child === true ||\n child === false\n ) {\n continue;\n }\n\n if (Array.isArray(child)) {\n parts.push(serializeChildren(child));\n } else if (isMjmlNode(child)) {\n parts.push(serializeNode(child));\n } else {\n parts.push(String(child));\n }\n }\n\n return parts.join('');\n}\n\nfunction serializeNode(node: MjmlNode): string {\n if (node.tag === Fragment) {\n return serializeChildren(node.children);\n }\n\n const tag = node.tag as string;\n const attrs = serializeAttributes(node.attributes);\n\n if (SELF_CLOSING_TAGS.has(tag)) {\n return `<${tag}${attrs} />`;\n }\n\n const content = serializeChildren(node.children);\n return `<${tag}${attrs}>${content}</${tag}>`;\n}\n\nexport function serialize(node: MjmlNode): string {\n return serializeNode(node);\n}\n\nexport const toMjmlString = serialize;\n"],"mappings":"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","names":["mjml2html"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,135 @@
|
|
|
1
|
-
import { M as MjmlNode } from './jsx-dev-runtime-
|
|
2
|
-
export { A as Align, C as CSSPixel, a as CSSSpacing, b as CSSUnit, c as CSSWidth, d as Color, D as Direction, F as Fragment, H as HexColor, J as JSX,
|
|
3
|
-
import mjml2html from 'mjml';
|
|
1
|
+
import { M as MjmlNode } from './jsx-dev-runtime-CIghYpt3.cjs';
|
|
2
|
+
export { A as Align, C as CSSPixel, a as CSSSpacing, b as CSSUnit, c as CSSWidth, d as Color, D as Direction, F as Fragment, H as HexColor, e as HtmlAnchorAttributes, f as HtmlGlobalAttributes, g as HtmlImgAttributes, h as HtmlListAttributes, i as HtmlMetaAttributes, j as HtmlTableCellAttributes, J as JSX, k as MjAccordionAttributes, l as MjAccordionElementAttributes, m as MjAccordionTextAttributes, n as MjAccordionTitleAttributes, o as MjAllAttributes, p as MjAttributesAttributes, q as MjBodyAttributes, r as MjBreakpointAttributes, s as MjButtonAttributes, t as MjCarouselAttributes, u as MjCarouselImageAttributes, v as MjClassAttributes, w as MjColumnAttributes, x as MjDividerAttributes, y as MjFontAttributes, z as MjGroupAttributes, B as MjHeadAttributes, E as MjHeroAttributes, G as MjHtmlAttributeAttributes, I as MjHtmlAttributesAttributes, K as MjImageAttributes, L as MjIncludeAttributes, N as MjNavbarAttributes, O as MjNavbarLinkAttributes, P as MjPreviewAttributes, Q as MjRawAttributes, R as MjSectionAttributes, S as MjSelectorAttributes, T as MjSocialAttributes, U as MjSocialElementAttributes, V as MjSpacerAttributes, W as MjStyleAttributes, X as MjTableAttributes, Y as MjTextAttributes, Z as MjTitleAttributes, _ as MjWrapperAttributes, $ as MjmlAttributes, a0 as MjmlChild, a1 as PropsWithChildren, a2 as URLString, a3 as VerticalAlign, a4 as jsx, a5 as jsxs } from './jsx-dev-runtime-CIghYpt3.cjs';
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
interface RenderOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Default fonts imported in the HTML rendered by HTML
|
|
7
|
+
* ie. { 'Open Sans': 'https://fonts.googleapis.com/css?family=Open+Sans:300,400,500,700' }
|
|
8
|
+
*
|
|
9
|
+
* default: @see https://github.com/mjmlio/mjml/blob/master/packages/mjml-core/src/index.js
|
|
10
|
+
*/
|
|
11
|
+
fonts?: {
|
|
12
|
+
[key: string]: string;
|
|
13
|
+
} | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Option to keep comments in the HTML output
|
|
16
|
+
* default: true
|
|
17
|
+
*/
|
|
18
|
+
keepComments?: boolean | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated use js-beautify directly after processing the MJML
|
|
21
|
+
*
|
|
22
|
+
* Option to beautify the HTML output
|
|
23
|
+
* default: false
|
|
24
|
+
*/
|
|
25
|
+
beautify?: boolean | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated use html-minifier directly after processing the MJML
|
|
28
|
+
*
|
|
29
|
+
* Option to minify the HTML output
|
|
30
|
+
*
|
|
31
|
+
* default: false
|
|
32
|
+
*/
|
|
33
|
+
minify?: boolean | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* @deprecated @see minify
|
|
36
|
+
*
|
|
37
|
+
* Options for html minifier, see mjml-cli documentation for more info
|
|
38
|
+
* Passed directly to html-minifier as options
|
|
39
|
+
*
|
|
40
|
+
* default: @see htmlMinify usage in mjml-core/src/index.js
|
|
41
|
+
*/
|
|
42
|
+
minifyOptions?: {
|
|
43
|
+
collapseWhitespace?: boolean | undefined;
|
|
44
|
+
minifyCSS?: boolean | undefined;
|
|
45
|
+
removeEmptyAttributes?: boolean | undefined;
|
|
46
|
+
} | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* How to validate your MJML
|
|
49
|
+
*
|
|
50
|
+
* skip: your document is rendered without going through validation
|
|
51
|
+
* soft: your document is going through validation and is rendered, even if it has errors
|
|
52
|
+
* strict: your document is going through validation and is not rendered if it has any error
|
|
53
|
+
*
|
|
54
|
+
* default: soft
|
|
55
|
+
*/
|
|
56
|
+
validationLevel?: 'strict' | 'soft' | 'skip' | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Full path of the specified file to use when resolving paths from mj-include components
|
|
59
|
+
* default: '.'
|
|
60
|
+
*/
|
|
61
|
+
filePath?: string | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* The path or directory of the .mjmlconfig file
|
|
64
|
+
* default: process.cwd()
|
|
65
|
+
*/
|
|
66
|
+
mjmlConfigPath?: string | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Use the config attribute defined in the .mjmlconfig file.
|
|
69
|
+
* The config passed into mjml2html overrides the .mjmlconfig.
|
|
70
|
+
* default: false
|
|
71
|
+
*/
|
|
72
|
+
useMjmlConfigOptions?: boolean | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* optional setting when inlining css, see mjml-cli documentation for more info
|
|
75
|
+
*
|
|
76
|
+
*/
|
|
77
|
+
juicePreserveTags?: {
|
|
78
|
+
[index: string]: {
|
|
79
|
+
start: string;
|
|
80
|
+
end: string;
|
|
81
|
+
};
|
|
82
|
+
} | undefined;
|
|
83
|
+
juiceOptions?: any;
|
|
84
|
+
/**
|
|
85
|
+
* undocumented
|
|
86
|
+
* a function returning html skeleton
|
|
87
|
+
* default: see mjml-core/src/helpers/skeleton.js
|
|
88
|
+
*/
|
|
89
|
+
skeleton?: string | (() => string) | undefined;
|
|
90
|
+
actualPath?: string | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* undocumented
|
|
93
|
+
* ignore mj-include elements
|
|
94
|
+
* default: false
|
|
95
|
+
*/
|
|
96
|
+
ignoreIncludes?: any;
|
|
97
|
+
/**
|
|
98
|
+
* see mjml-parser-xml
|
|
99
|
+
*/
|
|
100
|
+
preprocessors?: Array<(xml: string) => string> | undefined;
|
|
101
|
+
/**
|
|
102
|
+
* Add media queries specific to printer when converting mjml into html. When enabling this option,
|
|
103
|
+
* the html might not be compatible with all email clients anymore.
|
|
104
|
+
*/
|
|
105
|
+
printerSupport?: boolean | undefined;
|
|
106
|
+
}
|
|
107
|
+
interface MJMLJsonWithChildren {
|
|
108
|
+
tagName: string;
|
|
109
|
+
attributes: Record<string, unknown>;
|
|
110
|
+
children: MJMLJsonObject[];
|
|
111
|
+
}
|
|
112
|
+
interface MJMLJsonWithContent {
|
|
113
|
+
tagName: string;
|
|
114
|
+
attributes: Record<string, unknown>;
|
|
115
|
+
content: string;
|
|
116
|
+
}
|
|
117
|
+
interface MJMLJsonSelfClosingTag {
|
|
118
|
+
tagName: string;
|
|
119
|
+
attributes: Record<string, unknown>;
|
|
120
|
+
}
|
|
121
|
+
type MJMLJsonObject = MJMLJsonWithChildren | MJMLJsonWithContent | MJMLJsonSelfClosingTag;
|
|
122
|
+
interface MJMLParseError {
|
|
123
|
+
line: number;
|
|
124
|
+
message: string;
|
|
125
|
+
tagName: string;
|
|
126
|
+
formattedMessage: string;
|
|
127
|
+
}
|
|
128
|
+
interface RenderResult {
|
|
129
|
+
html: string;
|
|
130
|
+
json: MJMLJsonObject;
|
|
131
|
+
errors: MJMLParseError[];
|
|
132
|
+
}
|
|
7
133
|
declare function render(mjml: MjmlNode | string, options?: RenderOptions): RenderResult;
|
|
8
134
|
|
|
9
135
|
declare function serialize(node: MjmlNode): string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,135 @@
|
|
|
1
|
-
import { M as MjmlNode } from './jsx-dev-runtime-
|
|
2
|
-
export { A as Align, C as CSSPixel, a as CSSSpacing, b as CSSUnit, c as CSSWidth, d as Color, D as Direction, F as Fragment, H as HexColor, J as JSX,
|
|
3
|
-
import mjml2html from 'mjml';
|
|
1
|
+
import { M as MjmlNode } from './jsx-dev-runtime-CIghYpt3.js';
|
|
2
|
+
export { A as Align, C as CSSPixel, a as CSSSpacing, b as CSSUnit, c as CSSWidth, d as Color, D as Direction, F as Fragment, H as HexColor, e as HtmlAnchorAttributes, f as HtmlGlobalAttributes, g as HtmlImgAttributes, h as HtmlListAttributes, i as HtmlMetaAttributes, j as HtmlTableCellAttributes, J as JSX, k as MjAccordionAttributes, l as MjAccordionElementAttributes, m as MjAccordionTextAttributes, n as MjAccordionTitleAttributes, o as MjAllAttributes, p as MjAttributesAttributes, q as MjBodyAttributes, r as MjBreakpointAttributes, s as MjButtonAttributes, t as MjCarouselAttributes, u as MjCarouselImageAttributes, v as MjClassAttributes, w as MjColumnAttributes, x as MjDividerAttributes, y as MjFontAttributes, z as MjGroupAttributes, B as MjHeadAttributes, E as MjHeroAttributes, G as MjHtmlAttributeAttributes, I as MjHtmlAttributesAttributes, K as MjImageAttributes, L as MjIncludeAttributes, N as MjNavbarAttributes, O as MjNavbarLinkAttributes, P as MjPreviewAttributes, Q as MjRawAttributes, R as MjSectionAttributes, S as MjSelectorAttributes, T as MjSocialAttributes, U as MjSocialElementAttributes, V as MjSpacerAttributes, W as MjStyleAttributes, X as MjTableAttributes, Y as MjTextAttributes, Z as MjTitleAttributes, _ as MjWrapperAttributes, $ as MjmlAttributes, a0 as MjmlChild, a1 as PropsWithChildren, a2 as URLString, a3 as VerticalAlign, a4 as jsx, a5 as jsxs } from './jsx-dev-runtime-CIghYpt3.js';
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
interface RenderOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Default fonts imported in the HTML rendered by HTML
|
|
7
|
+
* ie. { 'Open Sans': 'https://fonts.googleapis.com/css?family=Open+Sans:300,400,500,700' }
|
|
8
|
+
*
|
|
9
|
+
* default: @see https://github.com/mjmlio/mjml/blob/master/packages/mjml-core/src/index.js
|
|
10
|
+
*/
|
|
11
|
+
fonts?: {
|
|
12
|
+
[key: string]: string;
|
|
13
|
+
} | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Option to keep comments in the HTML output
|
|
16
|
+
* default: true
|
|
17
|
+
*/
|
|
18
|
+
keepComments?: boolean | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated use js-beautify directly after processing the MJML
|
|
21
|
+
*
|
|
22
|
+
* Option to beautify the HTML output
|
|
23
|
+
* default: false
|
|
24
|
+
*/
|
|
25
|
+
beautify?: boolean | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated use html-minifier directly after processing the MJML
|
|
28
|
+
*
|
|
29
|
+
* Option to minify the HTML output
|
|
30
|
+
*
|
|
31
|
+
* default: false
|
|
32
|
+
*/
|
|
33
|
+
minify?: boolean | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* @deprecated @see minify
|
|
36
|
+
*
|
|
37
|
+
* Options for html minifier, see mjml-cli documentation for more info
|
|
38
|
+
* Passed directly to html-minifier as options
|
|
39
|
+
*
|
|
40
|
+
* default: @see htmlMinify usage in mjml-core/src/index.js
|
|
41
|
+
*/
|
|
42
|
+
minifyOptions?: {
|
|
43
|
+
collapseWhitespace?: boolean | undefined;
|
|
44
|
+
minifyCSS?: boolean | undefined;
|
|
45
|
+
removeEmptyAttributes?: boolean | undefined;
|
|
46
|
+
} | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* How to validate your MJML
|
|
49
|
+
*
|
|
50
|
+
* skip: your document is rendered without going through validation
|
|
51
|
+
* soft: your document is going through validation and is rendered, even if it has errors
|
|
52
|
+
* strict: your document is going through validation and is not rendered if it has any error
|
|
53
|
+
*
|
|
54
|
+
* default: soft
|
|
55
|
+
*/
|
|
56
|
+
validationLevel?: 'strict' | 'soft' | 'skip' | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Full path of the specified file to use when resolving paths from mj-include components
|
|
59
|
+
* default: '.'
|
|
60
|
+
*/
|
|
61
|
+
filePath?: string | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* The path or directory of the .mjmlconfig file
|
|
64
|
+
* default: process.cwd()
|
|
65
|
+
*/
|
|
66
|
+
mjmlConfigPath?: string | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Use the config attribute defined in the .mjmlconfig file.
|
|
69
|
+
* The config passed into mjml2html overrides the .mjmlconfig.
|
|
70
|
+
* default: false
|
|
71
|
+
*/
|
|
72
|
+
useMjmlConfigOptions?: boolean | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* optional setting when inlining css, see mjml-cli documentation for more info
|
|
75
|
+
*
|
|
76
|
+
*/
|
|
77
|
+
juicePreserveTags?: {
|
|
78
|
+
[index: string]: {
|
|
79
|
+
start: string;
|
|
80
|
+
end: string;
|
|
81
|
+
};
|
|
82
|
+
} | undefined;
|
|
83
|
+
juiceOptions?: any;
|
|
84
|
+
/**
|
|
85
|
+
* undocumented
|
|
86
|
+
* a function returning html skeleton
|
|
87
|
+
* default: see mjml-core/src/helpers/skeleton.js
|
|
88
|
+
*/
|
|
89
|
+
skeleton?: string | (() => string) | undefined;
|
|
90
|
+
actualPath?: string | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* undocumented
|
|
93
|
+
* ignore mj-include elements
|
|
94
|
+
* default: false
|
|
95
|
+
*/
|
|
96
|
+
ignoreIncludes?: any;
|
|
97
|
+
/**
|
|
98
|
+
* see mjml-parser-xml
|
|
99
|
+
*/
|
|
100
|
+
preprocessors?: Array<(xml: string) => string> | undefined;
|
|
101
|
+
/**
|
|
102
|
+
* Add media queries specific to printer when converting mjml into html. When enabling this option,
|
|
103
|
+
* the html might not be compatible with all email clients anymore.
|
|
104
|
+
*/
|
|
105
|
+
printerSupport?: boolean | undefined;
|
|
106
|
+
}
|
|
107
|
+
interface MJMLJsonWithChildren {
|
|
108
|
+
tagName: string;
|
|
109
|
+
attributes: Record<string, unknown>;
|
|
110
|
+
children: MJMLJsonObject[];
|
|
111
|
+
}
|
|
112
|
+
interface MJMLJsonWithContent {
|
|
113
|
+
tagName: string;
|
|
114
|
+
attributes: Record<string, unknown>;
|
|
115
|
+
content: string;
|
|
116
|
+
}
|
|
117
|
+
interface MJMLJsonSelfClosingTag {
|
|
118
|
+
tagName: string;
|
|
119
|
+
attributes: Record<string, unknown>;
|
|
120
|
+
}
|
|
121
|
+
type MJMLJsonObject = MJMLJsonWithChildren | MJMLJsonWithContent | MJMLJsonSelfClosingTag;
|
|
122
|
+
interface MJMLParseError {
|
|
123
|
+
line: number;
|
|
124
|
+
message: string;
|
|
125
|
+
tagName: string;
|
|
126
|
+
formattedMessage: string;
|
|
127
|
+
}
|
|
128
|
+
interface RenderResult {
|
|
129
|
+
html: string;
|
|
130
|
+
json: MJMLJsonObject;
|
|
131
|
+
errors: MJMLParseError[];
|
|
132
|
+
}
|
|
7
133
|
declare function render(mjml: MjmlNode | string, options?: RenderOptions): RenderResult;
|
|
8
134
|
|
|
9
135
|
declare function serialize(node: MjmlNode): string;
|
package/dist/index.js
CHANGED
|
@@ -3,13 +3,14 @@ import {
|
|
|
3
3
|
isMjmlNode,
|
|
4
4
|
jsx,
|
|
5
5
|
jsxs
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-JZZH5EZ3.js";
|
|
7
7
|
|
|
8
8
|
// src/render.ts
|
|
9
9
|
import mjml2html from "mjml";
|
|
10
10
|
|
|
11
11
|
// src/serialize.ts
|
|
12
12
|
var SELF_CLOSING_TAGS = /* @__PURE__ */ new Set([
|
|
13
|
+
// MJML
|
|
13
14
|
"mj-all",
|
|
14
15
|
"mj-breakpoint",
|
|
15
16
|
"mj-carousel-image",
|
|
@@ -18,7 +19,12 @@ var SELF_CLOSING_TAGS = /* @__PURE__ */ new Set([
|
|
|
18
19
|
"mj-font",
|
|
19
20
|
"mj-image",
|
|
20
21
|
"mj-include",
|
|
21
|
-
"mj-spacer"
|
|
22
|
+
"mj-spacer",
|
|
23
|
+
// HTML void elements
|
|
24
|
+
"br",
|
|
25
|
+
"hr",
|
|
26
|
+
"img",
|
|
27
|
+
"meta"
|
|
22
28
|
]);
|
|
23
29
|
function serializeAttributes(attributes) {
|
|
24
30
|
const parts = [];
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render.ts","../src/serialize.ts"],"sourcesContent":["import mjml2html from 'mjml';\nimport type { MjmlNode } from './ast';\nimport { isMjmlNode } from './ast';\nimport { serialize } from './serialize';\n\nexport
|
|
1
|
+
{"version":3,"sources":["../src/render.ts","../src/serialize.ts"],"sourcesContent":["import mjml2html from 'mjml';\nimport type { MjmlNode } from './ast';\nimport { isMjmlNode } from './ast';\nimport { serialize } from './serialize';\n\nexport interface RenderOptions {\n /**\n * Default fonts imported in the HTML rendered by HTML\n * ie. { 'Open Sans': 'https://fonts.googleapis.com/css?family=Open+Sans:300,400,500,700' }\n *\n * default: @see https://github.com/mjmlio/mjml/blob/master/packages/mjml-core/src/index.js\n */\n fonts?: { [key: string]: string } | undefined;\n\n /**\n * Option to keep comments in the HTML output\n * default: true\n */\n keepComments?: boolean | undefined;\n\n /**\n * @deprecated use js-beautify directly after processing the MJML\n *\n * Option to beautify the HTML output\n * default: false\n */\n beautify?: boolean | undefined;\n\n /**\n * @deprecated use html-minifier directly after processing the MJML\n *\n * Option to minify the HTML output\n *\n * default: false\n */\n minify?: boolean | undefined;\n /**\n * @deprecated @see minify\n *\n * Options for html minifier, see mjml-cli documentation for more info\n * Passed directly to html-minifier as options\n *\n * default: @see htmlMinify usage in mjml-core/src/index.js\n */\n minifyOptions?:\n | {\n collapseWhitespace?: boolean | undefined;\n minifyCSS?: boolean | undefined;\n removeEmptyAttributes?: boolean | undefined;\n }\n | undefined;\n\n /**\n * How to validate your MJML\n *\n * skip: your document is rendered without going through validation\n * soft: your document is going through validation and is rendered, even if it has errors\n * strict: your document is going through validation and is not rendered if it has any error\n *\n * default: soft\n */\n validationLevel?: 'strict' | 'soft' | 'skip' | undefined;\n\n /**\n * Full path of the specified file to use when resolving paths from mj-include components\n * default: '.'\n */\n filePath?: string | undefined;\n /**\n * The path or directory of the .mjmlconfig file\n * default: process.cwd()\n */\n mjmlConfigPath?: string | undefined;\n\n /**\n * Use the config attribute defined in the .mjmlconfig file.\n * The config passed into mjml2html overrides the .mjmlconfig.\n * default: false\n */\n useMjmlConfigOptions?: boolean | undefined;\n\n /**\n * optional setting when inlining css, see mjml-cli documentation for more info\n *\n */\n juicePreserveTags?:\n | { [index: string]: { start: string; end: string } }\n | undefined;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n juiceOptions?: any;\n\n /**\n * undocumented\n * a function returning html skeleton\n * default: see mjml-core/src/helpers/skeleton.js\n */\n skeleton?: string | (() => string) | undefined;\n\n actualPath?: string | undefined;\n /**\n * undocumented\n * ignore mj-include elements\n * default: false\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ignoreIncludes?: any;\n\n /**\n * see mjml-parser-xml\n */\n preprocessors?: Array<(xml: string) => string> | undefined;\n\n /**\n * Add media queries specific to printer when converting mjml into html. When enabling this option,\n * the html might not be compatible with all email clients anymore.\n */\n printerSupport?: boolean | undefined;\n}\n\ninterface MJMLJsonWithChildren {\n tagName: string;\n attributes: Record<string, unknown>;\n children: MJMLJsonObject[];\n}\n\ninterface MJMLJsonWithContent {\n tagName: string;\n attributes: Record<string, unknown>;\n content: string;\n}\n\ninterface MJMLJsonSelfClosingTag {\n tagName: string;\n attributes: Record<string, unknown>;\n}\n\ntype MJMLJsonObject =\n | MJMLJsonWithChildren\n | MJMLJsonWithContent\n | MJMLJsonSelfClosingTag;\n\ninterface MJMLParseError {\n line: number;\n message: string;\n tagName: string;\n formattedMessage: string;\n}\n\nexport interface RenderResult {\n html: string;\n json: MJMLJsonObject;\n errors: MJMLParseError[];\n}\n\nexport function render(\n mjml: MjmlNode | string,\n options?: RenderOptions\n): RenderResult {\n const str = isMjmlNode(mjml) ? serialize(mjml) : mjml;\n return mjml2html(str, options);\n}\n","import { Fragment, isMjmlNode, type MjmlChild, type MjmlNode } from './ast';\n\nconst SELF_CLOSING_TAGS = new Set([\n // MJML\n 'mj-all',\n 'mj-breakpoint',\n 'mj-carousel-image',\n 'mj-class',\n 'mj-divider',\n 'mj-font',\n 'mj-image',\n 'mj-include',\n 'mj-spacer',\n // HTML void elements\n 'br',\n 'hr',\n 'img',\n 'meta',\n]);\n\nfunction serializeAttributes(\n attributes: Record<string, string | undefined>\n): string {\n const parts: string[] = [];\n\n for (const [key, value] of Object.entries(attributes)) {\n if (value !== undefined) {\n parts.push(`${key}=\"${value}\"`);\n }\n }\n\n return parts.length > 0 ? ' ' + parts.join(' ') : '';\n}\n\nfunction serializeChildren(children: MjmlChild[]): string {\n const parts: string[] = [];\n\n for (const child of children) {\n if (\n child === null ||\n child === undefined ||\n child === true ||\n child === false\n ) {\n continue;\n }\n\n if (Array.isArray(child)) {\n parts.push(serializeChildren(child));\n } else if (isMjmlNode(child)) {\n parts.push(serializeNode(child));\n } else {\n parts.push(String(child));\n }\n }\n\n return parts.join('');\n}\n\nfunction serializeNode(node: MjmlNode): string {\n if (node.tag === Fragment) {\n return serializeChildren(node.children);\n }\n\n const tag = node.tag as string;\n const attrs = serializeAttributes(node.attributes);\n\n if (SELF_CLOSING_TAGS.has(tag)) {\n return `<${tag}${attrs} />`;\n }\n\n const content = serializeChildren(node.children);\n return `<${tag}${attrs}>${content}</${tag}>`;\n}\n\nexport function serialize(node: MjmlNode): string {\n return serializeNode(node);\n}\n\nexport const toMjmlString = serialize;\n"],"mappings":";;;;;;;;AAAA,OAAO,eAAe;;;ACEtB,IAAM,oBAAoB,oBAAI,IAAI;AAAA;AAAA,EAEhC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,SAAS,oBACP,YACQ;AACR,QAAM,QAAkB,CAAC;AAEzB,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,UAAU,GAAG;AACrD,QAAI,UAAU,QAAW;AACvB,YAAM,KAAK,GAAG,GAAG,KAAK,KAAK,GAAG;AAAA,IAChC;AAAA,EACF;AAEA,SAAO,MAAM,SAAS,IAAI,MAAM,MAAM,KAAK,GAAG,IAAI;AACpD;AAEA,SAAS,kBAAkB,UAA+B;AACxD,QAAM,QAAkB,CAAC;AAEzB,aAAW,SAAS,UAAU;AAC5B,QACE,UAAU,QACV,UAAU,UACV,UAAU,QACV,UAAU,OACV;AACA;AAAA,IACF;AAEA,QAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,YAAM,KAAK,kBAAkB,KAAK,CAAC;AAAA,IACrC,WAAW,WAAW,KAAK,GAAG;AAC5B,YAAM,KAAK,cAAc,KAAK,CAAC;AAAA,IACjC,OAAO;AACL,YAAM,KAAK,OAAO,KAAK,CAAC;AAAA,IAC1B;AAAA,EACF;AAEA,SAAO,MAAM,KAAK,EAAE;AACtB;AAEA,SAAS,cAAc,MAAwB;AAC7C,MAAI,KAAK,QAAQ,UAAU;AACzB,WAAO,kBAAkB,KAAK,QAAQ;AAAA,EACxC;AAEA,QAAM,MAAM,KAAK;AACjB,QAAM,QAAQ,oBAAoB,KAAK,UAAU;AAEjD,MAAI,kBAAkB,IAAI,GAAG,GAAG;AAC9B,WAAO,IAAI,GAAG,GAAG,KAAK;AAAA,EACxB;AAEA,QAAM,UAAU,kBAAkB,KAAK,QAAQ;AAC/C,SAAO,IAAI,GAAG,GAAG,KAAK,IAAI,OAAO,KAAK,GAAG;AAC3C;AAEO,SAAS,UAAU,MAAwB;AAChD,SAAO,cAAc,IAAI;AAC3B;;;AD8EO,SAAS,OACd,MACA,SACc;AACd,QAAM,MAAM,WAAW,IAAI,IAAI,UAAU,IAAI,IAAI;AACjD,SAAO,UAAU,KAAK,OAAO;AAC/B;","names":[]}
|
|
@@ -8,6 +8,47 @@ interface MjmlNode {
|
|
|
8
8
|
}
|
|
9
9
|
type MjmlChild = MjmlNode | string | number | boolean | null | undefined | MjmlChild[];
|
|
10
10
|
|
|
11
|
+
interface HtmlGlobalAttributes {
|
|
12
|
+
id?: string;
|
|
13
|
+
class?: string;
|
|
14
|
+
style?: string;
|
|
15
|
+
title?: string;
|
|
16
|
+
lang?: string;
|
|
17
|
+
dir?: 'ltr' | 'rtl' | 'auto';
|
|
18
|
+
hidden?: boolean | 'hidden' | '';
|
|
19
|
+
tabindex?: number | string;
|
|
20
|
+
[key: `data-${string}`]: string | undefined;
|
|
21
|
+
}
|
|
22
|
+
interface HtmlAnchorAttributes extends HtmlGlobalAttributes {
|
|
23
|
+
href?: string;
|
|
24
|
+
target?: '_blank' | '_self' | '_parent' | '_top' | string;
|
|
25
|
+
rel?: string;
|
|
26
|
+
download?: string | boolean;
|
|
27
|
+
}
|
|
28
|
+
interface HtmlImgAttributes extends HtmlGlobalAttributes {
|
|
29
|
+
src?: string;
|
|
30
|
+
alt?: string;
|
|
31
|
+
width?: string | number;
|
|
32
|
+
height?: string | number;
|
|
33
|
+
loading?: 'lazy' | 'eager';
|
|
34
|
+
}
|
|
35
|
+
interface HtmlTableCellAttributes extends HtmlGlobalAttributes {
|
|
36
|
+
colspan?: number | string;
|
|
37
|
+
rowspan?: number | string;
|
|
38
|
+
align?: 'left' | 'center' | 'right' | 'justify';
|
|
39
|
+
valign?: 'top' | 'middle' | 'bottom' | 'baseline';
|
|
40
|
+
}
|
|
41
|
+
interface HtmlListAttributes extends HtmlGlobalAttributes {
|
|
42
|
+
type?: string;
|
|
43
|
+
start?: number | string;
|
|
44
|
+
}
|
|
45
|
+
interface HtmlMetaAttributes {
|
|
46
|
+
name?: string;
|
|
47
|
+
content?: string;
|
|
48
|
+
charset?: string;
|
|
49
|
+
'http-equiv'?: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
11
52
|
type CSSPixel = `${number}px` | `${number}`;
|
|
12
53
|
type CSSUnit = CSSPixel;
|
|
13
54
|
type CSSSpacing = CSSUnit | `${CSSUnit} ${CSSUnit}` | `${CSSUnit} ${CSSUnit} ${CSSUnit}` | `${CSSUnit} ${CSSUnit} ${CSSUnit} ${CSSUnit}`;
|
|
@@ -429,7 +470,41 @@ declare namespace JSX {
|
|
|
429
470
|
'mj-include': MjIncludeAttributes;
|
|
430
471
|
'mj-selector': PropsWithChildren<MjSelectorAttributes>;
|
|
431
472
|
'mj-html-attribute': PropsWithChildren<MjHtmlAttributeAttributes>;
|
|
473
|
+
a: PropsWithChildren<HtmlAnchorAttributes>;
|
|
474
|
+
span: PropsWithChildren<HtmlGlobalAttributes>;
|
|
475
|
+
strong: PropsWithChildren<HtmlGlobalAttributes>;
|
|
476
|
+
b: PropsWithChildren<HtmlGlobalAttributes>;
|
|
477
|
+
em: PropsWithChildren<HtmlGlobalAttributes>;
|
|
478
|
+
i: PropsWithChildren<HtmlGlobalAttributes>;
|
|
479
|
+
u: PropsWithChildren<HtmlGlobalAttributes>;
|
|
480
|
+
s: PropsWithChildren<HtmlGlobalAttributes>;
|
|
481
|
+
small: PropsWithChildren<HtmlGlobalAttributes>;
|
|
482
|
+
code: PropsWithChildren<HtmlGlobalAttributes>;
|
|
483
|
+
sub: PropsWithChildren<HtmlGlobalAttributes>;
|
|
484
|
+
sup: PropsWithChildren<HtmlGlobalAttributes>;
|
|
485
|
+
br: HtmlGlobalAttributes;
|
|
486
|
+
div: PropsWithChildren<HtmlGlobalAttributes>;
|
|
487
|
+
p: PropsWithChildren<HtmlGlobalAttributes>;
|
|
488
|
+
h1: PropsWithChildren<HtmlGlobalAttributes>;
|
|
489
|
+
h2: PropsWithChildren<HtmlGlobalAttributes>;
|
|
490
|
+
h3: PropsWithChildren<HtmlGlobalAttributes>;
|
|
491
|
+
h4: PropsWithChildren<HtmlGlobalAttributes>;
|
|
492
|
+
h5: PropsWithChildren<HtmlGlobalAttributes>;
|
|
493
|
+
h6: PropsWithChildren<HtmlGlobalAttributes>;
|
|
494
|
+
ul: PropsWithChildren<HtmlListAttributes>;
|
|
495
|
+
ol: PropsWithChildren<HtmlListAttributes>;
|
|
496
|
+
li: PropsWithChildren<HtmlGlobalAttributes>;
|
|
497
|
+
blockquote: PropsWithChildren<HtmlGlobalAttributes>;
|
|
498
|
+
pre: PropsWithChildren<HtmlGlobalAttributes>;
|
|
499
|
+
hr: HtmlGlobalAttributes;
|
|
500
|
+
tr: PropsWithChildren<HtmlGlobalAttributes>;
|
|
501
|
+
td: PropsWithChildren<HtmlTableCellAttributes>;
|
|
502
|
+
th: PropsWithChildren<HtmlTableCellAttributes>;
|
|
503
|
+
thead: PropsWithChildren<HtmlGlobalAttributes>;
|
|
504
|
+
tbody: PropsWithChildren<HtmlGlobalAttributes>;
|
|
505
|
+
img: HtmlImgAttributes;
|
|
506
|
+
meta: HtmlMetaAttributes;
|
|
432
507
|
}
|
|
433
508
|
}
|
|
434
509
|
|
|
435
|
-
export { type Align as A, type
|
|
510
|
+
export { type MjmlAttributes as $, type Align as A, type MjHeadAttributes as B, type CSSPixel as C, type Direction as D, type MjHeroAttributes as E, Fragment as F, type MjHtmlAttributeAttributes as G, type HexColor as H, type MjHtmlAttributesAttributes as I, JSX as J, type MjImageAttributes as K, type MjIncludeAttributes as L, type MjmlNode as M, type MjNavbarAttributes as N, type MjNavbarLinkAttributes as O, type MjPreviewAttributes as P, type MjRawAttributes as Q, type MjSectionAttributes as R, type MjSelectorAttributes as S, type MjSocialAttributes as T, type MjSocialElementAttributes as U, type MjSpacerAttributes as V, type MjStyleAttributes as W, type MjTableAttributes as X, type MjTextAttributes as Y, type MjTitleAttributes as Z, type MjWrapperAttributes as _, type CSSSpacing as a, type MjmlChild as a0, type PropsWithChildren as a1, type URLString as a2, type VerticalAlign as a3, jsx as a4, jsxs as a5, type CSSUnit as b, type CSSWidth as c, type Color as d, type HtmlAnchorAttributes as e, type HtmlGlobalAttributes as f, type HtmlImgAttributes as g, type HtmlListAttributes as h, type HtmlMetaAttributes as i, type HtmlTableCellAttributes as j, type MjAccordionAttributes as k, type MjAccordionElementAttributes as l, type MjAccordionTextAttributes as m, type MjAccordionTitleAttributes as n, type MjAllAttributes as o, type MjAttributesAttributes as p, type MjBodyAttributes as q, type MjBreakpointAttributes as r, type MjButtonAttributes as s, type MjCarouselAttributes as t, type MjCarouselImageAttributes as u, type MjClassAttributes as v, type MjColumnAttributes as w, type MjDividerAttributes as x, type MjFontAttributes as y, type MjGroupAttributes as z };
|
|
@@ -8,6 +8,47 @@ interface MjmlNode {
|
|
|
8
8
|
}
|
|
9
9
|
type MjmlChild = MjmlNode | string | number | boolean | null | undefined | MjmlChild[];
|
|
10
10
|
|
|
11
|
+
interface HtmlGlobalAttributes {
|
|
12
|
+
id?: string;
|
|
13
|
+
class?: string;
|
|
14
|
+
style?: string;
|
|
15
|
+
title?: string;
|
|
16
|
+
lang?: string;
|
|
17
|
+
dir?: 'ltr' | 'rtl' | 'auto';
|
|
18
|
+
hidden?: boolean | 'hidden' | '';
|
|
19
|
+
tabindex?: number | string;
|
|
20
|
+
[key: `data-${string}`]: string | undefined;
|
|
21
|
+
}
|
|
22
|
+
interface HtmlAnchorAttributes extends HtmlGlobalAttributes {
|
|
23
|
+
href?: string;
|
|
24
|
+
target?: '_blank' | '_self' | '_parent' | '_top' | string;
|
|
25
|
+
rel?: string;
|
|
26
|
+
download?: string | boolean;
|
|
27
|
+
}
|
|
28
|
+
interface HtmlImgAttributes extends HtmlGlobalAttributes {
|
|
29
|
+
src?: string;
|
|
30
|
+
alt?: string;
|
|
31
|
+
width?: string | number;
|
|
32
|
+
height?: string | number;
|
|
33
|
+
loading?: 'lazy' | 'eager';
|
|
34
|
+
}
|
|
35
|
+
interface HtmlTableCellAttributes extends HtmlGlobalAttributes {
|
|
36
|
+
colspan?: number | string;
|
|
37
|
+
rowspan?: number | string;
|
|
38
|
+
align?: 'left' | 'center' | 'right' | 'justify';
|
|
39
|
+
valign?: 'top' | 'middle' | 'bottom' | 'baseline';
|
|
40
|
+
}
|
|
41
|
+
interface HtmlListAttributes extends HtmlGlobalAttributes {
|
|
42
|
+
type?: string;
|
|
43
|
+
start?: number | string;
|
|
44
|
+
}
|
|
45
|
+
interface HtmlMetaAttributes {
|
|
46
|
+
name?: string;
|
|
47
|
+
content?: string;
|
|
48
|
+
charset?: string;
|
|
49
|
+
'http-equiv'?: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
11
52
|
type CSSPixel = `${number}px` | `${number}`;
|
|
12
53
|
type CSSUnit = CSSPixel;
|
|
13
54
|
type CSSSpacing = CSSUnit | `${CSSUnit} ${CSSUnit}` | `${CSSUnit} ${CSSUnit} ${CSSUnit}` | `${CSSUnit} ${CSSUnit} ${CSSUnit} ${CSSUnit}`;
|
|
@@ -429,7 +470,41 @@ declare namespace JSX {
|
|
|
429
470
|
'mj-include': MjIncludeAttributes;
|
|
430
471
|
'mj-selector': PropsWithChildren<MjSelectorAttributes>;
|
|
431
472
|
'mj-html-attribute': PropsWithChildren<MjHtmlAttributeAttributes>;
|
|
473
|
+
a: PropsWithChildren<HtmlAnchorAttributes>;
|
|
474
|
+
span: PropsWithChildren<HtmlGlobalAttributes>;
|
|
475
|
+
strong: PropsWithChildren<HtmlGlobalAttributes>;
|
|
476
|
+
b: PropsWithChildren<HtmlGlobalAttributes>;
|
|
477
|
+
em: PropsWithChildren<HtmlGlobalAttributes>;
|
|
478
|
+
i: PropsWithChildren<HtmlGlobalAttributes>;
|
|
479
|
+
u: PropsWithChildren<HtmlGlobalAttributes>;
|
|
480
|
+
s: PropsWithChildren<HtmlGlobalAttributes>;
|
|
481
|
+
small: PropsWithChildren<HtmlGlobalAttributes>;
|
|
482
|
+
code: PropsWithChildren<HtmlGlobalAttributes>;
|
|
483
|
+
sub: PropsWithChildren<HtmlGlobalAttributes>;
|
|
484
|
+
sup: PropsWithChildren<HtmlGlobalAttributes>;
|
|
485
|
+
br: HtmlGlobalAttributes;
|
|
486
|
+
div: PropsWithChildren<HtmlGlobalAttributes>;
|
|
487
|
+
p: PropsWithChildren<HtmlGlobalAttributes>;
|
|
488
|
+
h1: PropsWithChildren<HtmlGlobalAttributes>;
|
|
489
|
+
h2: PropsWithChildren<HtmlGlobalAttributes>;
|
|
490
|
+
h3: PropsWithChildren<HtmlGlobalAttributes>;
|
|
491
|
+
h4: PropsWithChildren<HtmlGlobalAttributes>;
|
|
492
|
+
h5: PropsWithChildren<HtmlGlobalAttributes>;
|
|
493
|
+
h6: PropsWithChildren<HtmlGlobalAttributes>;
|
|
494
|
+
ul: PropsWithChildren<HtmlListAttributes>;
|
|
495
|
+
ol: PropsWithChildren<HtmlListAttributes>;
|
|
496
|
+
li: PropsWithChildren<HtmlGlobalAttributes>;
|
|
497
|
+
blockquote: PropsWithChildren<HtmlGlobalAttributes>;
|
|
498
|
+
pre: PropsWithChildren<HtmlGlobalAttributes>;
|
|
499
|
+
hr: HtmlGlobalAttributes;
|
|
500
|
+
tr: PropsWithChildren<HtmlGlobalAttributes>;
|
|
501
|
+
td: PropsWithChildren<HtmlTableCellAttributes>;
|
|
502
|
+
th: PropsWithChildren<HtmlTableCellAttributes>;
|
|
503
|
+
thead: PropsWithChildren<HtmlGlobalAttributes>;
|
|
504
|
+
tbody: PropsWithChildren<HtmlGlobalAttributes>;
|
|
505
|
+
img: HtmlImgAttributes;
|
|
506
|
+
meta: HtmlMetaAttributes;
|
|
432
507
|
}
|
|
433
508
|
}
|
|
434
509
|
|
|
435
|
-
export { type Align as A, type
|
|
510
|
+
export { type MjmlAttributes as $, type Align as A, type MjHeadAttributes as B, type CSSPixel as C, type Direction as D, type MjHeroAttributes as E, Fragment as F, type MjHtmlAttributeAttributes as G, type HexColor as H, type MjHtmlAttributesAttributes as I, JSX as J, type MjImageAttributes as K, type MjIncludeAttributes as L, type MjmlNode as M, type MjNavbarAttributes as N, type MjNavbarLinkAttributes as O, type MjPreviewAttributes as P, type MjRawAttributes as Q, type MjSectionAttributes as R, type MjSelectorAttributes as S, type MjSocialAttributes as T, type MjSocialElementAttributes as U, type MjSpacerAttributes as V, type MjStyleAttributes as W, type MjTableAttributes as X, type MjTextAttributes as Y, type MjTitleAttributes as Z, type MjWrapperAttributes as _, type CSSSpacing as a, type MjmlChild as a0, type PropsWithChildren as a1, type URLString as a2, type VerticalAlign as a3, jsx as a4, jsxs as a5, type CSSUnit as b, type CSSWidth as c, type Color as d, type HtmlAnchorAttributes as e, type HtmlGlobalAttributes as f, type HtmlImgAttributes as g, type HtmlListAttributes as h, type HtmlMetaAttributes as i, type HtmlTableCellAttributes as j, type MjAccordionAttributes as k, type MjAccordionElementAttributes as l, type MjAccordionTextAttributes as m, type MjAccordionTitleAttributes as n, type MjAllAttributes as o, type MjAttributesAttributes as p, type MjBodyAttributes as q, type MjBreakpointAttributes as r, type MjButtonAttributes as s, type MjCarouselAttributes as t, type MjCarouselImageAttributes as u, type MjClassAttributes as v, type MjColumnAttributes as w, type MjDividerAttributes as x, type MjFontAttributes as y, type MjGroupAttributes as z };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/jsx-dev-runtime.ts","../src/ast.ts","../src/jsx-runtime.ts"],"sourcesContent":["export { Fragment, jsx, jsx as jsxDEV, jsxs, type JSX } from './jsx-runtime';\n","export const MJML_NODE_TYPE = Symbol.for('mjmx.node');\n\nexport const Fragment = Symbol.for('mjmx.fragment');\n\nexport interface MjmlNode {\n readonly $$typeof: typeof MJML_NODE_TYPE;\n readonly tag: string | typeof Fragment;\n readonly attributes: Record<string, string | undefined>;\n readonly children: MjmlChild[];\n}\n\nexport type MjmlChild =\n | MjmlNode\n | string\n | number\n | boolean\n | null\n | undefined\n | MjmlChild[];\n\nexport function isMjmlNode(value: unknown): value is MjmlNode {\n return (\n typeof value === 'object' &&\n value !== null &&\n '$$typeof' in value &&\n value.$$typeof === MJML_NODE_TYPE\n );\n}\n\nexport function createNode(\n tag: string | typeof Fragment,\n attributes: Record<string, unknown>,\n children: MjmlChild[]\n): MjmlNode {\n const stringAttributes: Record<string, string | undefined> = {};\n\n for (const [key, value] of Object.entries(attributes)) {\n if (value === undefined || value === null) {\n continue;\n }\n if (value instanceof URL) {\n stringAttributes[key] = value.toString();\n } else {\n stringAttributes[key] = String(value);\n }\n }\n\n return {\n $$typeof: MJML_NODE_TYPE,\n tag,\n attributes: stringAttributes,\n children,\n };\n}\n","import { createNode, Fragment, type MjmlChild, type MjmlNode } from './ast';\nimport type {\n MjAccordionAttributes,\n MjAccordionElementAttributes,\n MjAccordionTextAttributes,\n MjAccordionTitleAttributes,\n MjAllAttributes,\n MjAttributesAttributes,\n MjBodyAttributes,\n MjBreakpointAttributes,\n MjButtonAttributes,\n MjCarouselAttributes,\n MjCarouselImageAttributes,\n MjClassAttributes,\n MjColumnAttributes,\n MjDividerAttributes,\n MjFontAttributes,\n MjGroupAttributes,\n MjHeadAttributes,\n MjHeroAttributes,\n MjHtmlAttributeAttributes,\n MjHtmlAttributesAttributes,\n MjImageAttributes,\n MjIncludeAttributes,\n MjmlAttributes,\n MjNavbarAttributes,\n MjNavbarLinkAttributes,\n MjPreviewAttributes,\n MjRawAttributes,\n MjSectionAttributes,\n MjSelectorAttributes,\n MjSocialAttributes,\n MjSocialElementAttributes,\n MjSpacerAttributes,\n MjStyleAttributes,\n MjTableAttributes,\n MjTextAttributes,\n MjTitleAttributes,\n MjWrapperAttributes,\n} from './types';\n\nexport { Fragment };\n\
|
|
1
|
+
{"version":3,"sources":["../src/jsx-dev-runtime.ts","../src/ast.ts","../src/jsx-runtime.ts"],"sourcesContent":["export { Fragment, jsx, jsx as jsxDEV, jsxs, type JSX } from './jsx-runtime';\n","export const MJML_NODE_TYPE = Symbol.for('mjmx.node');\n\nexport const Fragment = Symbol.for('mjmx.fragment');\n\nexport interface MjmlNode {\n readonly $$typeof: typeof MJML_NODE_TYPE;\n readonly tag: string | typeof Fragment;\n readonly attributes: Record<string, string | undefined>;\n readonly children: MjmlChild[];\n}\n\nexport type MjmlChild =\n | MjmlNode\n | string\n | number\n | boolean\n | null\n | undefined\n | MjmlChild[];\n\nexport function isMjmlNode(value: unknown): value is MjmlNode {\n return (\n typeof value === 'object' &&\n value !== null &&\n '$$typeof' in value &&\n value.$$typeof === MJML_NODE_TYPE\n );\n}\n\nexport function createNode(\n tag: string | typeof Fragment,\n attributes: Record<string, unknown>,\n children: MjmlChild[]\n): MjmlNode {\n const stringAttributes: Record<string, string | undefined> = {};\n\n for (const [key, value] of Object.entries(attributes)) {\n if (value === undefined || value === null) {\n continue;\n }\n if (value instanceof URL) {\n stringAttributes[key] = value.toString();\n } else {\n stringAttributes[key] = String(value);\n }\n }\n\n return {\n $$typeof: MJML_NODE_TYPE,\n tag,\n attributes: stringAttributes,\n children,\n };\n}\n","import { createNode, Fragment, type MjmlChild, type MjmlNode } from './ast';\nimport type {\n HtmlAnchorAttributes,\n HtmlGlobalAttributes,\n HtmlImgAttributes,\n HtmlListAttributes,\n HtmlMetaAttributes,\n HtmlTableCellAttributes,\n} from './html-types';\nimport type {\n MjAccordionAttributes,\n MjAccordionElementAttributes,\n MjAccordionTextAttributes,\n MjAccordionTitleAttributes,\n MjAllAttributes,\n MjAttributesAttributes,\n MjBodyAttributes,\n MjBreakpointAttributes,\n MjButtonAttributes,\n MjCarouselAttributes,\n MjCarouselImageAttributes,\n MjClassAttributes,\n MjColumnAttributes,\n MjDividerAttributes,\n MjFontAttributes,\n MjGroupAttributes,\n MjHeadAttributes,\n MjHeroAttributes,\n MjHtmlAttributeAttributes,\n MjHtmlAttributesAttributes,\n MjImageAttributes,\n MjIncludeAttributes,\n MjmlAttributes,\n MjNavbarAttributes,\n MjNavbarLinkAttributes,\n MjPreviewAttributes,\n MjRawAttributes,\n MjSectionAttributes,\n MjSelectorAttributes,\n MjSocialAttributes,\n MjSocialElementAttributes,\n MjSpacerAttributes,\n MjStyleAttributes,\n MjTableAttributes,\n MjTextAttributes,\n MjTitleAttributes,\n MjWrapperAttributes,\n} from './types';\n\nexport { Fragment };\n\nexport type PropsWithChildren<T = object> = T & { children?: MjmlChild };\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Component = (props: any) => MjmlNode;\n\nexport function jsx(\n tag: string | typeof Fragment | Component,\n props: Record<string, unknown>,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _key?: string\n): MjmlNode {\n if (typeof tag === 'function') {\n return tag(props);\n }\n\n const { children, ...attributes } = props;\n\n const childArray: MjmlChild[] =\n children === undefined\n ? []\n : Array.isArray(children)\n ? children\n : [children as MjmlChild];\n\n return createNode(tag, attributes, childArray);\n}\n\nexport const jsxs = jsx;\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace JSX {\n export type Element = MjmlNode;\n export type ElementType = string | typeof Fragment | Component;\n\n export interface ElementChildrenAttribute {\n children: MjmlChild;\n }\n\n export interface IntrinsicElements {\n mjml: PropsWithChildren<MjmlAttributes>;\n 'mj-head': PropsWithChildren<MjHeadAttributes>;\n 'mj-body': PropsWithChildren<MjBodyAttributes>;\n 'mj-attributes': PropsWithChildren<MjAttributesAttributes>;\n 'mj-breakpoint': MjBreakpointAttributes;\n 'mj-font': MjFontAttributes;\n 'mj-html-attributes': PropsWithChildren<MjHtmlAttributesAttributes>;\n 'mj-preview': PropsWithChildren<MjPreviewAttributes>;\n 'mj-style': PropsWithChildren<MjStyleAttributes>;\n 'mj-title': PropsWithChildren<MjTitleAttributes>;\n 'mj-all': MjAllAttributes;\n 'mj-class': MjClassAttributes;\n 'mj-section': PropsWithChildren<MjSectionAttributes>;\n 'mj-column': PropsWithChildren<MjColumnAttributes>;\n 'mj-group': PropsWithChildren<MjGroupAttributes>;\n 'mj-wrapper': PropsWithChildren<MjWrapperAttributes>;\n 'mj-text': PropsWithChildren<MjTextAttributes>;\n 'mj-button': PropsWithChildren<MjButtonAttributes>;\n 'mj-image': MjImageAttributes;\n 'mj-divider': MjDividerAttributes;\n 'mj-spacer': MjSpacerAttributes;\n 'mj-table': PropsWithChildren<MjTableAttributes>;\n 'mj-raw': PropsWithChildren<MjRawAttributes>;\n 'mj-hero': PropsWithChildren<MjHeroAttributes>;\n 'mj-accordion': PropsWithChildren<MjAccordionAttributes>;\n 'mj-accordion-element': PropsWithChildren<MjAccordionElementAttributes>;\n 'mj-accordion-title': PropsWithChildren<MjAccordionTitleAttributes>;\n 'mj-accordion-text': PropsWithChildren<MjAccordionTextAttributes>;\n 'mj-carousel': PropsWithChildren<MjCarouselAttributes>;\n 'mj-carousel-image': MjCarouselImageAttributes;\n 'mj-navbar': PropsWithChildren<MjNavbarAttributes>;\n 'mj-navbar-link': PropsWithChildren<MjNavbarLinkAttributes>;\n 'mj-social': PropsWithChildren<MjSocialAttributes>;\n 'mj-social-element': PropsWithChildren<MjSocialElementAttributes>;\n 'mj-include': MjIncludeAttributes;\n 'mj-selector': PropsWithChildren<MjSelectorAttributes>;\n 'mj-html-attribute': PropsWithChildren<MjHtmlAttributeAttributes>;\n\n // HTML inline text elements (for mj-text)\n a: PropsWithChildren<HtmlAnchorAttributes>;\n span: PropsWithChildren<HtmlGlobalAttributes>;\n strong: PropsWithChildren<HtmlGlobalAttributes>;\n b: PropsWithChildren<HtmlGlobalAttributes>;\n em: PropsWithChildren<HtmlGlobalAttributes>;\n i: PropsWithChildren<HtmlGlobalAttributes>;\n u: PropsWithChildren<HtmlGlobalAttributes>;\n s: PropsWithChildren<HtmlGlobalAttributes>;\n small: PropsWithChildren<HtmlGlobalAttributes>;\n code: PropsWithChildren<HtmlGlobalAttributes>;\n sub: PropsWithChildren<HtmlGlobalAttributes>;\n sup: PropsWithChildren<HtmlGlobalAttributes>;\n br: HtmlGlobalAttributes;\n\n // HTML block text elements (for mj-text)\n div: PropsWithChildren<HtmlGlobalAttributes>;\n p: PropsWithChildren<HtmlGlobalAttributes>;\n h1: PropsWithChildren<HtmlGlobalAttributes>;\n h2: PropsWithChildren<HtmlGlobalAttributes>;\n h3: PropsWithChildren<HtmlGlobalAttributes>;\n h4: PropsWithChildren<HtmlGlobalAttributes>;\n h5: PropsWithChildren<HtmlGlobalAttributes>;\n h6: PropsWithChildren<HtmlGlobalAttributes>;\n ul: PropsWithChildren<HtmlListAttributes>;\n ol: PropsWithChildren<HtmlListAttributes>;\n li: PropsWithChildren<HtmlGlobalAttributes>;\n blockquote: PropsWithChildren<HtmlGlobalAttributes>;\n pre: PropsWithChildren<HtmlGlobalAttributes>;\n hr: HtmlGlobalAttributes;\n\n // HTML table elements (for mj-table - use mj-table instead of <table>)\n tr: PropsWithChildren<HtmlGlobalAttributes>;\n td: PropsWithChildren<HtmlTableCellAttributes>;\n th: PropsWithChildren<HtmlTableCellAttributes>;\n thead: PropsWithChildren<HtmlGlobalAttributes>;\n tbody: PropsWithChildren<HtmlGlobalAttributes>;\n\n // HTML media elements (for mj-table - mj-image can't be used inside mj-table)\n img: HtmlImgAttributes;\n\n // HTML head elements (for mj-raw in mj-head - dark mode support)\n meta: HtmlMetaAttributes;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,iBAAiB,uBAAO,IAAI,WAAW;AAE7C,IAAM,WAAW,uBAAO,IAAI,eAAe;AA2B3C,SAAS,WACd,KACA,YACA,UACU;AACV,QAAM,mBAAuD,CAAC;AAE9D,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,UAAU,GAAG;AACrD,QAAI,UAAU,UAAa,UAAU,MAAM;AACzC;AAAA,IACF;AACA,QAAI,iBAAiB,KAAK;AACxB,uBAAiB,GAAG,IAAI,MAAM,SAAS;AAAA,IACzC,OAAO;AACL,uBAAiB,GAAG,IAAI,OAAO,KAAK;AAAA,IACtC;AAAA,EACF;AAEA,SAAO;AAAA,IACL,UAAU;AAAA,IACV;AAAA,IACA,YAAY;AAAA,IACZ;AAAA,EACF;AACF;;;ACGO,SAAS,IACd,KACA,OAEA,MACU;AACV,MAAI,OAAO,QAAQ,YAAY;AAC7B,WAAO,IAAI,KAAK;AAAA,EAClB;AAEA,QAAM,EAAE,UAAU,GAAG,WAAW,IAAI;AAEpC,QAAM,aACJ,aAAa,SACT,CAAC,IACD,MAAM,QAAQ,QAAQ,IACpB,WACA,CAAC,QAAqB;AAE9B,SAAO,WAAW,KAAK,YAAY,UAAU;AAC/C;AAEO,IAAM,OAAO;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { F as Fragment, J as JSX,
|
|
1
|
+
export { F as Fragment, J as JSX, a4 as jsx, a4 as jsxDEV, a5 as jsxs } from './jsx-dev-runtime-CIghYpt3.cjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { F as Fragment, J as JSX,
|
|
1
|
+
export { F as Fragment, J as JSX, a4 as jsx, a4 as jsxDEV, a5 as jsxs } from './jsx-dev-runtime-CIghYpt3.js';
|
package/dist/jsx-dev-runtime.js
CHANGED
package/dist/jsx-runtime.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/jsx-runtime.ts","../src/ast.ts"],"sourcesContent":["import { createNode, Fragment, type MjmlChild, type MjmlNode } from './ast';\nimport type {\n MjAccordionAttributes,\n MjAccordionElementAttributes,\n MjAccordionTextAttributes,\n MjAccordionTitleAttributes,\n MjAllAttributes,\n MjAttributesAttributes,\n MjBodyAttributes,\n MjBreakpointAttributes,\n MjButtonAttributes,\n MjCarouselAttributes,\n MjCarouselImageAttributes,\n MjClassAttributes,\n MjColumnAttributes,\n MjDividerAttributes,\n MjFontAttributes,\n MjGroupAttributes,\n MjHeadAttributes,\n MjHeroAttributes,\n MjHtmlAttributeAttributes,\n MjHtmlAttributesAttributes,\n MjImageAttributes,\n MjIncludeAttributes,\n MjmlAttributes,\n MjNavbarAttributes,\n MjNavbarLinkAttributes,\n MjPreviewAttributes,\n MjRawAttributes,\n MjSectionAttributes,\n MjSelectorAttributes,\n MjSocialAttributes,\n MjSocialElementAttributes,\n MjSpacerAttributes,\n MjStyleAttributes,\n MjTableAttributes,\n MjTextAttributes,\n MjTitleAttributes,\n MjWrapperAttributes,\n} from './types';\n\nexport { Fragment };\n\
|
|
1
|
+
{"version":3,"sources":["../src/jsx-runtime.ts","../src/ast.ts"],"sourcesContent":["import { createNode, Fragment, type MjmlChild, type MjmlNode } from './ast';\nimport type {\n HtmlAnchorAttributes,\n HtmlGlobalAttributes,\n HtmlImgAttributes,\n HtmlListAttributes,\n HtmlMetaAttributes,\n HtmlTableCellAttributes,\n} from './html-types';\nimport type {\n MjAccordionAttributes,\n MjAccordionElementAttributes,\n MjAccordionTextAttributes,\n MjAccordionTitleAttributes,\n MjAllAttributes,\n MjAttributesAttributes,\n MjBodyAttributes,\n MjBreakpointAttributes,\n MjButtonAttributes,\n MjCarouselAttributes,\n MjCarouselImageAttributes,\n MjClassAttributes,\n MjColumnAttributes,\n MjDividerAttributes,\n MjFontAttributes,\n MjGroupAttributes,\n MjHeadAttributes,\n MjHeroAttributes,\n MjHtmlAttributeAttributes,\n MjHtmlAttributesAttributes,\n MjImageAttributes,\n MjIncludeAttributes,\n MjmlAttributes,\n MjNavbarAttributes,\n MjNavbarLinkAttributes,\n MjPreviewAttributes,\n MjRawAttributes,\n MjSectionAttributes,\n MjSelectorAttributes,\n MjSocialAttributes,\n MjSocialElementAttributes,\n MjSpacerAttributes,\n MjStyleAttributes,\n MjTableAttributes,\n MjTextAttributes,\n MjTitleAttributes,\n MjWrapperAttributes,\n} from './types';\n\nexport { Fragment };\n\nexport type PropsWithChildren<T = object> = T & { children?: MjmlChild };\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Component = (props: any) => MjmlNode;\n\nexport function jsx(\n tag: string | typeof Fragment | Component,\n props: Record<string, unknown>,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _key?: string\n): MjmlNode {\n if (typeof tag === 'function') {\n return tag(props);\n }\n\n const { children, ...attributes } = props;\n\n const childArray: MjmlChild[] =\n children === undefined\n ? []\n : Array.isArray(children)\n ? children\n : [children as MjmlChild];\n\n return createNode(tag, attributes, childArray);\n}\n\nexport const jsxs = jsx;\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace JSX {\n export type Element = MjmlNode;\n export type ElementType = string | typeof Fragment | Component;\n\n export interface ElementChildrenAttribute {\n children: MjmlChild;\n }\n\n export interface IntrinsicElements {\n mjml: PropsWithChildren<MjmlAttributes>;\n 'mj-head': PropsWithChildren<MjHeadAttributes>;\n 'mj-body': PropsWithChildren<MjBodyAttributes>;\n 'mj-attributes': PropsWithChildren<MjAttributesAttributes>;\n 'mj-breakpoint': MjBreakpointAttributes;\n 'mj-font': MjFontAttributes;\n 'mj-html-attributes': PropsWithChildren<MjHtmlAttributesAttributes>;\n 'mj-preview': PropsWithChildren<MjPreviewAttributes>;\n 'mj-style': PropsWithChildren<MjStyleAttributes>;\n 'mj-title': PropsWithChildren<MjTitleAttributes>;\n 'mj-all': MjAllAttributes;\n 'mj-class': MjClassAttributes;\n 'mj-section': PropsWithChildren<MjSectionAttributes>;\n 'mj-column': PropsWithChildren<MjColumnAttributes>;\n 'mj-group': PropsWithChildren<MjGroupAttributes>;\n 'mj-wrapper': PropsWithChildren<MjWrapperAttributes>;\n 'mj-text': PropsWithChildren<MjTextAttributes>;\n 'mj-button': PropsWithChildren<MjButtonAttributes>;\n 'mj-image': MjImageAttributes;\n 'mj-divider': MjDividerAttributes;\n 'mj-spacer': MjSpacerAttributes;\n 'mj-table': PropsWithChildren<MjTableAttributes>;\n 'mj-raw': PropsWithChildren<MjRawAttributes>;\n 'mj-hero': PropsWithChildren<MjHeroAttributes>;\n 'mj-accordion': PropsWithChildren<MjAccordionAttributes>;\n 'mj-accordion-element': PropsWithChildren<MjAccordionElementAttributes>;\n 'mj-accordion-title': PropsWithChildren<MjAccordionTitleAttributes>;\n 'mj-accordion-text': PropsWithChildren<MjAccordionTextAttributes>;\n 'mj-carousel': PropsWithChildren<MjCarouselAttributes>;\n 'mj-carousel-image': MjCarouselImageAttributes;\n 'mj-navbar': PropsWithChildren<MjNavbarAttributes>;\n 'mj-navbar-link': PropsWithChildren<MjNavbarLinkAttributes>;\n 'mj-social': PropsWithChildren<MjSocialAttributes>;\n 'mj-social-element': PropsWithChildren<MjSocialElementAttributes>;\n 'mj-include': MjIncludeAttributes;\n 'mj-selector': PropsWithChildren<MjSelectorAttributes>;\n 'mj-html-attribute': PropsWithChildren<MjHtmlAttributeAttributes>;\n\n // HTML inline text elements (for mj-text)\n a: PropsWithChildren<HtmlAnchorAttributes>;\n span: PropsWithChildren<HtmlGlobalAttributes>;\n strong: PropsWithChildren<HtmlGlobalAttributes>;\n b: PropsWithChildren<HtmlGlobalAttributes>;\n em: PropsWithChildren<HtmlGlobalAttributes>;\n i: PropsWithChildren<HtmlGlobalAttributes>;\n u: PropsWithChildren<HtmlGlobalAttributes>;\n s: PropsWithChildren<HtmlGlobalAttributes>;\n small: PropsWithChildren<HtmlGlobalAttributes>;\n code: PropsWithChildren<HtmlGlobalAttributes>;\n sub: PropsWithChildren<HtmlGlobalAttributes>;\n sup: PropsWithChildren<HtmlGlobalAttributes>;\n br: HtmlGlobalAttributes;\n\n // HTML block text elements (for mj-text)\n div: PropsWithChildren<HtmlGlobalAttributes>;\n p: PropsWithChildren<HtmlGlobalAttributes>;\n h1: PropsWithChildren<HtmlGlobalAttributes>;\n h2: PropsWithChildren<HtmlGlobalAttributes>;\n h3: PropsWithChildren<HtmlGlobalAttributes>;\n h4: PropsWithChildren<HtmlGlobalAttributes>;\n h5: PropsWithChildren<HtmlGlobalAttributes>;\n h6: PropsWithChildren<HtmlGlobalAttributes>;\n ul: PropsWithChildren<HtmlListAttributes>;\n ol: PropsWithChildren<HtmlListAttributes>;\n li: PropsWithChildren<HtmlGlobalAttributes>;\n blockquote: PropsWithChildren<HtmlGlobalAttributes>;\n pre: PropsWithChildren<HtmlGlobalAttributes>;\n hr: HtmlGlobalAttributes;\n\n // HTML table elements (for mj-table - use mj-table instead of <table>)\n tr: PropsWithChildren<HtmlGlobalAttributes>;\n td: PropsWithChildren<HtmlTableCellAttributes>;\n th: PropsWithChildren<HtmlTableCellAttributes>;\n thead: PropsWithChildren<HtmlGlobalAttributes>;\n tbody: PropsWithChildren<HtmlGlobalAttributes>;\n\n // HTML media elements (for mj-table - mj-image can't be used inside mj-table)\n img: HtmlImgAttributes;\n\n // HTML head elements (for mj-raw in mj-head - dark mode support)\n meta: HtmlMetaAttributes;\n }\n}\n","export const MJML_NODE_TYPE = Symbol.for('mjmx.node');\n\nexport const Fragment = Symbol.for('mjmx.fragment');\n\nexport interface MjmlNode {\n readonly $$typeof: typeof MJML_NODE_TYPE;\n readonly tag: string | typeof Fragment;\n readonly attributes: Record<string, string | undefined>;\n readonly children: MjmlChild[];\n}\n\nexport type MjmlChild =\n | MjmlNode\n | string\n | number\n | boolean\n | null\n | undefined\n | MjmlChild[];\n\nexport function isMjmlNode(value: unknown): value is MjmlNode {\n return (\n typeof value === 'object' &&\n value !== null &&\n '$$typeof' in value &&\n value.$$typeof === MJML_NODE_TYPE\n );\n}\n\nexport function createNode(\n tag: string | typeof Fragment,\n attributes: Record<string, unknown>,\n children: MjmlChild[]\n): MjmlNode {\n const stringAttributes: Record<string, string | undefined> = {};\n\n for (const [key, value] of Object.entries(attributes)) {\n if (value === undefined || value === null) {\n continue;\n }\n if (value instanceof URL) {\n stringAttributes[key] = value.toString();\n } else {\n stringAttributes[key] = String(value);\n }\n }\n\n return {\n $$typeof: MJML_NODE_TYPE,\n tag,\n attributes: stringAttributes,\n children,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,iBAAiB,uBAAO,IAAI,WAAW;AAE7C,IAAM,WAAW,uBAAO,IAAI,eAAe;AA2B3C,SAAS,WACd,KACA,YACA,UACU;AACV,QAAM,mBAAuD,CAAC;AAE9D,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,UAAU,GAAG;AACrD,QAAI,UAAU,UAAa,UAAU,MAAM;AACzC;AAAA,IACF;AACA,QAAI,iBAAiB,KAAK;AACxB,uBAAiB,GAAG,IAAI,MAAM,SAAS;AAAA,IACzC,OAAO;AACL,uBAAiB,GAAG,IAAI,OAAO,KAAK;AAAA,IACtC;AAAA,EACF;AAEA,SAAO;AAAA,IACL,UAAU;AAAA,IACV;AAAA,IACA,YAAY;AAAA,IACZ;AAAA,EACF;AACF;;;ADGO,SAAS,IACd,KACA,OAEA,MACU;AACV,MAAI,OAAO,QAAQ,YAAY;AAC7B,WAAO,IAAI,KAAK;AAAA,EAClB;AAEA,QAAM,EAAE,UAAU,GAAG,WAAW,IAAI;AAEpC,QAAM,aACJ,aAAa,SACT,CAAC,IACD,MAAM,QAAQ,QAAQ,IACpB,WACA,CAAC,QAAqB;AAE9B,SAAO,WAAW,KAAK,YAAY,UAAU;AAC/C;AAEO,IAAM,OAAO;","names":[]}
|
package/dist/jsx-runtime.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { F as Fragment, J as JSX,
|
|
1
|
+
export { F as Fragment, J as JSX, a1 as PropsWithChildren, a4 as jsx, a5 as jsxs } from './jsx-dev-runtime-CIghYpt3.cjs';
|
package/dist/jsx-runtime.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { F as Fragment, J as JSX,
|
|
1
|
+
export { F as Fragment, J as JSX, a1 as PropsWithChildren, a4 as jsx, a5 as jsxs } from './jsx-dev-runtime-CIghYpt3.js';
|
package/dist/jsx-runtime.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mjmx/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Write mjml using JSX syntax",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mjml",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
|
-
"url": "
|
|
16
|
+
"url": "https://github.com/skwee357/mjmx"
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"author": "Dmitry Kudryavtsev <contact@kudmitry.com>",
|
|
@@ -59,15 +59,6 @@
|
|
|
59
59
|
"LICENSE",
|
|
60
60
|
"package.json"
|
|
61
61
|
],
|
|
62
|
-
"scripts": {
|
|
63
|
-
"build": "tsup",
|
|
64
|
-
"format": "prettier --write .",
|
|
65
|
-
"format:check": "prettier --check .",
|
|
66
|
-
"lint": "eslint src",
|
|
67
|
-
"lint:fix": "eslint src --fix",
|
|
68
|
-
"test": "vitest run",
|
|
69
|
-
"test:coverage": "vitest run --coverage"
|
|
70
|
-
},
|
|
71
62
|
"devDependencies": {
|
|
72
63
|
"@changesets/changelog-github": "^0.5.2",
|
|
73
64
|
"@changesets/cli": "^2.29.8",
|
|
@@ -87,13 +78,16 @@
|
|
|
87
78
|
"peerDependencies": {
|
|
88
79
|
"mjml": "^4.15.3"
|
|
89
80
|
},
|
|
90
|
-
"packageManager": "pnpm@10.28.2",
|
|
91
81
|
"engines": {
|
|
92
|
-
"node": ">=
|
|
82
|
+
"node": ">=20"
|
|
93
83
|
},
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
|
|
97
|
-
|
|
84
|
+
"scripts": {
|
|
85
|
+
"build": "tsup",
|
|
86
|
+
"format": "prettier --write .",
|
|
87
|
+
"format:check": "prettier --check .",
|
|
88
|
+
"lint": "eslint src",
|
|
89
|
+
"lint:fix": "eslint src --fix",
|
|
90
|
+
"test": "vitest run",
|
|
91
|
+
"test:coverage": "vitest run --coverage"
|
|
98
92
|
}
|
|
99
|
-
}
|
|
93
|
+
}
|