Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions types/mjml-browser/mjml-browser-tests.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import mjml2html = require("mjml-browser");

const simple_test = mjml2html("<mjml>");
const html = simple_test.html;
const errors = simple_test.errors;
let formattedMessage = errors[0].formattedMessage;
formattedMessage = "force string test";
async function tests() {
const simple_test = await mjml2html("<mjml>");
const html = simple_test.html;
const errors = simple_test.errors;
let formattedMessage = errors[0].formattedMessage;
formattedMessage = "force string test";

const minimalOptionsTest = mjml2html("<mjml>", { beautify: true });
const validationLevelTest = mjml2html("<mjml>", { validationLevel: "strict" });
const filePathTest = mjml2html("<mjml>", { filePath: "." });
const minimalOptionsTest = await mjml2html("<mjml>", { beautify: true });
const validationLevelTest = await mjml2html("<mjml>", { validationLevel: "strict" });
const filePathTest = await mjml2html("<mjml>", { filePath: "." });

const jsonObject = { tagName: "mjml", attributes: { width: "100px" }, content: "test content" };
const jsonObjectTest = mjml2html(jsonObject);
const jsonObject = { tagName: "mjml", attributes: { width: "100px" }, content: "test content" };
const jsonObjectTest = await mjml2html(jsonObject);

const minifyTest = mjml2html("<mjml", { minifyOptions: { minifyCSS: true } });
const minifyAllTest = mjml2html("<mjml", {
minifyOptions: { minifyCSS: true, collapseWhitespace: true, removeEmptyAttributes: true },
});
const minifyTest = await mjml2html("<mjml", { minifyOptions: { minifyCSS: true } });
const minifyAllTest = await mjml2html("<mjml", {
minifyOptions: { minifyCSS: true, collapseWhitespace: true, removeEmptyAttributes: true },
});
}
2 changes: 1 addition & 1 deletion types/mjml-browser/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@types/mjml-browser",
"version": "4.15.9999",
"version": "5.0.9999",
"projects": [
"https://github.com/mjmlio/mjml",
"https://mjml.io"
Expand Down
36 changes: 22 additions & 14 deletions types/mjml-core/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
* The main parser for MJML.
* This version doesn't contain any of the core components registered in the 'mjml' package.
*/
export default function mjml2html(input: string | MJMLJsonObject, options?: MJMLParsingOptions): MJMLParseResults;
export default function mjml2html(
input: string | MJMLJsonObject,
options?: MJMLParsingOptions,
): Promise<MJMLParseResults>;

/**
* Options passed as an object to the mjml2html function
Expand All @@ -25,28 +28,24 @@ export interface MJMLParsingOptions {
keepComments?: boolean | undefined;

/**
* @deprecated use js-beautify directly after processing the MJML
*
* Option to beautify the HTML output
* Beautify the HTML output using prettier (parser: 'html', printWidth: 240).
* Mutually exclusive with minify — if minify is true, beautify is skipped.
* Note: the CLI defaults this to true; the programmatic API defaults to false.
* default: false
*/
beautify?: boolean | undefined;

/**
* @deprecated use html-minifier directly after processing the MJML
*
* Option to minify the HTML output
*
* Minify the HTML output using htmlnano (with cssnano-preset-lite for CSS).
* Takes priority over beautify when both are true.
* default: false
*/
minify?: boolean | undefined;

/**
* @deprecated @see minify
*
* Options for html minifier, see mjml-cli documentation for more info
* Passed directly to html-minifier as options
*
* default: @see htmlMinify usage in mjml-core/src/index.js
* Options passed to htmlnano when minify is true.
* The minifyCss field accepts false, true, 'lite', or a cssnano options object.
* All htmlnano v3 options are accepted.
*/
minifyOptions?: MJMLMinifyOptions | undefined;

Expand Down Expand Up @@ -113,8 +112,17 @@ export interface MJMLParsingOptions {

export interface MJMLMinifyOptions {
collapseWhitespace?: boolean | undefined;
/**
* CSS minification options passed to cssnano-preset-lite.
* Accepts false (disable), true/'lite' (use lite preset), or a cssnano options object.
* @see https://cssnano.co/docs/presets
*/
minifyCss?: boolean | "lite" | { preset?: any; plugins?: any[]; configFile?: string } | undefined;
/** @deprecated use minifyCss instead */
minifyCSS?: boolean | undefined;
removeEmptyAttributes?: boolean | undefined;
minifyJs?: boolean | undefined;
removeComments?: false | "safe" | "all" | undefined;
}

export interface MJMLParseResults {
Expand Down
36 changes: 19 additions & 17 deletions types/mjml-core/mjml-core-tests.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
import mjml2html, { BodyComponent, Component, HeadComponent, MJMLJsonObject, registerComponent } from "mjml-core";

const simple_test = mjml2html("<mjml>");
const html = simple_test.html;
const errors = simple_test.errors;
let formattedMessage = errors[0].formattedMessage;
formattedMessage = "force string test";

const minimal_opts_test = mjml2html("<mjml>", { beautify: true });
const validation_level_test = mjml2html("<mjml>", { validationLevel: "strict" });
const filePath_test = mjml2html("<mjml>", { filePath: "." });

const jsonObject = { tagName: "mjml", attributes: { width: "100px" }, content: "test content" };
const jsonObject_test = mjml2html(jsonObject);

const minify_opts_test = mjml2html("<mjml", { minifyOptions: { minifyCSS: true } });
const minify_opts_all_test = mjml2html("<mjml", {
minifyOptions: { minifyCSS: true, collapseWhitespace: true, removeEmptyAttributes: true },
});
async function tests() {
const simple_test = await mjml2html("<mjml>");
const html = simple_test.html;
const errors = simple_test.errors;
let formattedMessage = errors[0].formattedMessage;
formattedMessage = "force string test";

const minimal_opts_test = await mjml2html("<mjml>", { beautify: true });
const validation_level_test = await mjml2html("<mjml>", { validationLevel: "strict" });
const filePath_test = await mjml2html("<mjml>", { filePath: "." });

const jsonObject = { tagName: "mjml", attributes: { width: "100px" }, content: "test content" };
const jsonObject_test = await mjml2html(jsonObject);

const minify_opts_test = await mjml2html("<mjml", { minifyOptions: { minifyCSS: true } });
const minify_opts_all_test = await mjml2html("<mjml", {
minifyOptions: { minifyCSS: true, collapseWhitespace: true, removeEmptyAttributes: true },
});
}

class NewBodyComponent extends BodyComponent {
render() {
Expand Down
2 changes: 1 addition & 1 deletion types/mjml-core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@types/mjml-core",
"version": "4.15.9999",
"version": "5.0.9999",
"projects": [
"https://mjml.io"
],
Expand Down
30 changes: 16 additions & 14 deletions types/mjml/mjml-tests.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import mjml2html = require("mjml");

const simple_test = mjml2html("<mjml>");
const html = simple_test.html;
const errors = simple_test.errors;
let formattedMessage = errors[0].formattedMessage;
formattedMessage = "force string test";
async function tests() {
const simple_test = await mjml2html("<mjml>");
const html = simple_test.html;
const errors = simple_test.errors;
let formattedMessage = errors[0].formattedMessage;
formattedMessage = "force string test";

const minimal_opts_test = mjml2html("<mjml>", { beautify: true });
const validation_level_test = mjml2html("<mjml>", { validationLevel: "strict" });
const filePath_test = mjml2html("<mjml>", { filePath: "." });
const minimal_opts_test = await mjml2html("<mjml>", { beautify: true });
const validation_level_test = await mjml2html("<mjml>", { validationLevel: "strict" });
const filePath_test = await mjml2html("<mjml>", { filePath: "." });

const jsonObject = { tagName: "mjml", attributes: { width: "100px" }, content: "test content" };
const jsonObject_test = mjml2html(jsonObject);
const jsonObject = { tagName: "mjml", attributes: { width: "100px" }, content: "test content" };
const jsonObject_test = await mjml2html(jsonObject);

const minify_opts_test = mjml2html("<mjml", { minifyOptions: { minifyCSS: true } });
const minify_opts_all_test = mjml2html("<mjml", {
minifyOptions: { minifyCSS: true, collapseWhitespace: true, removeEmptyAttributes: true },
});
const minify_opts_test = await mjml2html("<mjml", { minifyOptions: { minifyCSS: true } });
const minify_opts_all_test = await mjml2html("<mjml", {
minifyOptions: { minifyCSS: true, collapseWhitespace: true, removeEmptyAttributes: true },
});
}
2 changes: 1 addition & 1 deletion types/mjml/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@types/mjml",
"version": "4.7.9999",
"version": "5.0.9999",
"projects": [
"https://github.com/mjmlio/mjml",
"https://mjml.io"
Expand Down