@lit-pigeon/ssr 0.1.5 → 0.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 +10 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/render.d.ts +5 -0
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +11 -1
- package/dist/render.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -26,7 +26,8 @@ const check = validateDocumentSafe(doc);
|
|
|
26
26
|
if (!check.valid) throw new Error(JSON.stringify(check.errors));
|
|
27
27
|
|
|
28
28
|
const { html, mjml, errors } = await renderDocument(doc, {
|
|
29
|
-
|
|
29
|
+
// {{firstName}} and {{user.plan}}; dotted paths read nested objects.
|
|
30
|
+
mergeTags: { firstName: 'Ada', user: { plan: 'Pro' } },
|
|
30
31
|
outlookWorkarounds: true,
|
|
31
32
|
});
|
|
32
33
|
|
|
@@ -42,6 +43,14 @@ Also exported: `renderDocumentToMjml`, `renderTemplate` (render a stored
|
|
|
42
43
|
stateless — no globals, no editor instance. To serve these over HTTP, use
|
|
43
44
|
[`@lit-pigeon/rest`](../rest).
|
|
44
45
|
|
|
46
|
+
Merge-tag values are HTML-escaped by default (`applyMergeTags(html, values,
|
|
47
|
+
{ escape: false })` turns that off), and placeholders without a value are left
|
|
48
|
+
in place unless you set `mergeTagFallback`. `{{#if …}}` blocks from row
|
|
49
|
+
conditions are not evaluated. `validateDocumentSafe` accepts only the built-in
|
|
50
|
+
block types. The `mjml` returned by `renderDocument` does not include
|
|
51
|
+
`<mj-font>` tags even when `fonts` is passed (the `html` does). See
|
|
52
|
+
[Server-side](../../docs/guide/server-side.md) for a render-and-send example.
|
|
53
|
+
|
|
45
54
|
Part of [Lit Pigeon](https://github.com/snxstudio/lit-pigeon) — open-source drag-and-drop email editor.
|
|
46
55
|
|
|
47
56
|
## License
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { renderDocument, renderDocumentToMjml } from './render.js';
|
|
1
|
+
export { renderDocument, renderDocumentToMjml, renderDocumentToText } from './render.js';
|
|
2
2
|
export type { RenderDocumentOptions, RenderDocumentResult } from './render.js';
|
|
3
3
|
export { renderTemplate } from './template.js';
|
|
4
4
|
export type { RenderTemplateOptions } from './template.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACzF,YAAY,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAE/E,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnE,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { renderDocument, renderDocumentToMjml } from './render.js';
|
|
1
|
+
export { renderDocument, renderDocumentToMjml, renderDocumentToText } from './render.js';
|
|
2
2
|
export { renderTemplate } from './template.js';
|
|
3
3
|
export { parseMjml } from './parse.js';
|
|
4
4
|
export { validateDocumentSafe } from './validate.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGzF,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG/C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAGrD,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/render.d.ts
CHANGED
|
@@ -29,4 +29,9 @@ export interface RenderDocumentResult {
|
|
|
29
29
|
export declare function renderDocument(doc: PigeonDocument, options?: RenderDocumentOptions): Promise<RenderDocumentResult>;
|
|
30
30
|
/** Render a document straight to MJML markup (no `mjml2html` pass). */
|
|
31
31
|
export declare function renderDocumentToMjml(doc: PigeonDocument, options?: Pick<RenderOptions, 'outlookWorkarounds'>): string;
|
|
32
|
+
/**
|
|
33
|
+
* Render a document to the `text/plain` alternative part. Merge-tag values
|
|
34
|
+
* are substituted verbatim (no HTML escaping) when supplied.
|
|
35
|
+
*/
|
|
36
|
+
export declare function renderDocumentToText(doc: PigeonDocument, options?: Pick<RenderDocumentOptions, 'mergeTags' | 'mergeTagFallback'>): string;
|
|
32
37
|
//# sourceMappingURL=render.d.ts.map
|
package/dist/render.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEnF,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtE,MAAM,WAAW,qBAAsB,SAAQ,aAAa;IAC1D;;;;OAIG;IACH,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,oBAAoB;IACnC,qFAAqF;IACrF,IAAI,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,IAAI,EAAE,MAAM,CAAC;IACb,gDAAgD;IAChD,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB;AAID;;;GAGG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,cAAc,EACnB,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,oBAAoB,CAAC,CAQ/B;AAED,uEAAuE;AACvE,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,cAAc,EACnB,OAAO,GAAE,IAAI,CAAC,aAAa,EAAE,oBAAoB,CAAM,GACtD,MAAM,CAER"}
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEnF,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtE,MAAM,WAAW,qBAAsB,SAAQ,aAAa;IAC1D;;;;OAIG;IACH,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,oBAAoB;IACnC,qFAAqF;IACrF,IAAI,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,IAAI,EAAE,MAAM,CAAC;IACb,gDAAgD;IAChD,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB;AAID;;;GAGG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,cAAc,EACnB,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,oBAAoB,CAAC,CAQ/B;AAED,uEAAuE;AACvE,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,cAAc,EACnB,OAAO,GAAE,IAAI,CAAC,aAAa,EAAE,oBAAoB,CAAM,GACtD,MAAM,CAER;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,cAAc,EACnB,OAAO,GAAE,IAAI,CAAC,qBAAqB,EAAE,WAAW,GAAG,kBAAkB,CAAM,GAC1E,MAAM,CAKR"}
|
package/dist/render.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { documentToMjml, MjmlRenderer } from '@lit-pigeon/renderer-mjml';
|
|
1
|
+
import { documentToMjml, documentToPlainText, MjmlRenderer } from '@lit-pigeon/renderer-mjml';
|
|
2
2
|
import { applyMergeTags } from './merge-tags.js';
|
|
3
3
|
const renderer = new MjmlRenderer();
|
|
4
4
|
/**
|
|
@@ -17,4 +17,14 @@ export async function renderDocument(doc, options = {}) {
|
|
|
17
17
|
export function renderDocumentToMjml(doc, options = {}) {
|
|
18
18
|
return documentToMjml(doc, { outlookWorkarounds: options.outlookWorkarounds });
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Render a document to the `text/plain` alternative part. Merge-tag values
|
|
22
|
+
* are substituted verbatim (no HTML escaping) when supplied.
|
|
23
|
+
*/
|
|
24
|
+
export function renderDocumentToText(doc, options = {}) {
|
|
25
|
+
const text = documentToPlainText(doc);
|
|
26
|
+
return options.mergeTags && Object.keys(options.mergeTags).length > 0
|
|
27
|
+
? applyMergeTags(text, options.mergeTags, { fallback: options.mergeTagFallback, escape: false })
|
|
28
|
+
: text;
|
|
29
|
+
}
|
|
20
30
|
//# sourceMappingURL=render.js.map
|
package/dist/render.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9F,OAAO,EAAE,cAAc,EAAuB,MAAM,iBAAiB,CAAC;AA0BtE,MAAM,QAAQ,GAAG,IAAI,YAAY,EAAE,CAAC;AAEpC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,GAAmB,EACnB,UAAiC,EAAE;IAEnC,MAAM,IAAI,GAAG,cAAc,CAAC,GAAG,EAAE,EAAE,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACrF,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACnD,MAAM,IAAI,GACR,OAAO,CAAC,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC;QAC5D,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,gBAAgB,EAAE,CAAC;QACxF,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;IAClB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;AAC/C,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,oBAAoB,CAClC,GAAmB,EACnB,UAAqD,EAAE;IAEvD,OAAO,cAAc,CAAC,GAAG,EAAE,EAAE,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;AACjF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAClC,GAAmB,EACnB,UAAyE,EAAE;IAE3E,MAAM,IAAI,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,OAAO,CAAC,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC;QACnE,CAAC,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,gBAAgB,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QAChG,CAAC,CAAC,IAAI,CAAC;AACX,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lit-pigeon/ssr",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Server-side rendering API for Lit Pigeon — render, parse, validate, and merge-tag-substitute documents from Node with zero DOM dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
"LICENSE"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@lit-pigeon/core": "^0.
|
|
22
|
-
"@lit-pigeon/parser-mjml": "^0.
|
|
23
|
-
"@lit-pigeon/renderer-mjml": "^0.
|
|
21
|
+
"@lit-pigeon/core": "^0.4.0",
|
|
22
|
+
"@lit-pigeon/parser-mjml": "^0.2.0",
|
|
23
|
+
"@lit-pigeon/renderer-mjml": "^0.3.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"typescript": "^5.5.0",
|
|
27
|
-
"vitest": "^
|
|
27
|
+
"vitest": "^4.1.12"
|
|
28
28
|
},
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|