New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

emeio

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

emeio - npm Package Compare versions

Comparing version 0.0.1-alpha.4 to 0.0.1-alpha.5

dist/infer-helpers.d.ts

23

dist/emeio.d.ts

@@ -1,10 +0,23 @@

import { Template, TemplateProps, TemplateNames } from "./template";
export declare function createEmeio<T extends Template[]>(templates: T): {
templates: T;
compileEmail: <Name extends TemplateNames<T>>(name: Name, props: TemplateProps<T, Name>) => {
errors: import("mjml-core").MJMLParseError[];
import React from "react";
import { GenericTemplate, TemplateOf, TemplateProps, TemplateNames } from "./template";
declare type Compiler = (element: React.ReactElement<any, string | React.JSXElementConstructor<any>>) => {
html: string;
errors?: any[];
};
declare type EmeioConfig<Templates extends GenericTemplate[]> = {
templates: Templates;
compiler?: Compiler;
};
export declare function createEmeio<Templates extends GenericTemplate[]>(config: EmeioConfig<Templates>): {
getTemplate: <Name extends TemplateNames<Templates>>(name: Name) => Extract<Templates[number], {
name: Name;
}>;
compile: <Name_1 extends TemplateNames<Templates>>(name: Name_1, props: TemplateProps<Templates, Name_1>) => {
errors: any[];
html: string;
subject: string;
};
previewProps: <Name_2 extends TemplateNames<Templates>>(name: Name_2) => TemplateProps<Templates, Name_2>;
};
export {};
//# sourceMappingURL=emeio.d.ts.map

@@ -10,5 +10,13 @@ "use strict";

var server_1 = require("react-dom/server");
function createEmeio(templates) {
var defaultCompiler = function (element) {
var compiled = (0, mjml_1["default"])((0, server_1.renderToStaticMarkup)(element));
return {
errors: compiled.errors,
html: compiled.html
};
};
function createEmeio(config) {
var templates = config.templates, _a = config.compiler, compiler = _a === void 0 ? defaultCompiler : _a;
checkDuplicatedNames(templates);
function compileEmail(name, props) {
function getTemplate(name) {
var template = templates.find(function (t) { return t.name === name; });

@@ -18,5 +26,9 @@ if (!template) {

}
return template;
}
function compile(name, props) {
var template = getTemplate(name);
var Component = template.render;
var subject = template.subject(props);
var compiled = (0, mjml_1["default"])((0, server_1.renderToStaticMarkup)(react_1["default"].createElement(Component, props)));
var compiled = compiler(react_1["default"].createElement(Component, props));
return {

@@ -28,3 +40,7 @@ errors: compiled.errors,

}
return { templates: templates, compileEmail: compileEmail };
function previewProps(name) {
var template = getTemplate(name);
return template.previewProps;
}
return { getTemplate: getTemplate, compile: compile, previewProps: previewProps };
}

@@ -31,0 +47,0 @@ exports.createEmeio = createEmeio;

@@ -1,2 +0,2 @@

export * from "./helpers";
export * from "./infer-helpers";
export * from "./template";

@@ -3,0 +3,0 @@ export * from "./emeio";

@@ -13,3 +13,3 @@ "use strict";

exports.__esModule = true;
__exportStar(require("./helpers"), exports);
__exportStar(require("./infer-helpers"), exports);
__exportStar(require("./template"), exports);

@@ -16,0 +16,0 @@ __exportStar(require("./emeio"), exports);

@@ -23,10 +23,11 @@ /// <reference types="react" />

}
export declare type Template = ReturnType<Wrapper<any>["wrapped"]>;
export declare type TemplateNames<Templates extends Template[]> = Templates extends {
export declare type GenericTemplate = ReturnType<Wrapper<any>["wrapped"]>;
export declare type TemplateNames<Templates extends GenericTemplate[]> = Templates extends {
name: infer Name;
}[] ? Name : never;
export declare type TemplateProps<Templates extends Template[], Name> = Extract<Templates[number], {
export declare type TemplateOf<Templates extends GenericTemplate[], Name> = Extract<Templates[number], {
name: Name;
}>["previewProps"];
}>;
export declare type TemplateProps<Templates extends GenericTemplate[], Name> = TemplateOf<Templates, Name>["previewProps"];
export {};
//# sourceMappingURL=template.d.ts.map
{
"name": "emeio",
"version": "0.0.1-alpha.4",
"version": "0.0.1-alpha.5",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "types": "dist/index.d.ts",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc