@lit-pigeon/ssr 0.1.3 → 0.1.5
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 +49 -0
- package/package.json +21 -5
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# @lit-pigeon/ssr
|
|
2
|
+
|
|
3
|
+
Server-side rendering API for [Lit Pigeon](https://github.com/snxstudio/lit-pigeon).
|
|
4
|
+
Render, parse, validate, and merge-tag-substitute `PigeonDocument`s from Node
|
|
5
|
+
with **zero DOM dependencies** — built for transactional email pipelines and
|
|
6
|
+
edge/worker runtimes.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @lit-pigeon/ssr
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import {
|
|
18
|
+
renderDocument,
|
|
19
|
+
parseMjml,
|
|
20
|
+
validateDocumentSafe,
|
|
21
|
+
applyMergeTags,
|
|
22
|
+
} from '@lit-pigeon/ssr';
|
|
23
|
+
|
|
24
|
+
// Validate, then render to email-safe HTML — with merge tags substituted.
|
|
25
|
+
const check = validateDocumentSafe(doc);
|
|
26
|
+
if (!check.valid) throw new Error(JSON.stringify(check.errors));
|
|
27
|
+
|
|
28
|
+
const { html, mjml, errors } = await renderDocument(doc, {
|
|
29
|
+
mergeTags: { firstName: 'Ada', 'user.plan': 'Pro' },
|
|
30
|
+
outlookWorkarounds: true,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Import an existing MJML template into a document.
|
|
34
|
+
const { document, warnings } = parseMjml(existingMjml);
|
|
35
|
+
|
|
36
|
+
// Or substitute {{key}} placeholders into already-rendered HTML.
|
|
37
|
+
const personalised = applyMergeTags(html, { firstName: 'Grace' });
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Also exported: `renderDocumentToMjml`, `renderTemplate` (render a stored
|
|
41
|
+
`Template` from `@lit-pigeon/core`), and `extractMergeTags`. Every function is
|
|
42
|
+
stateless — no globals, no editor instance. To serve these over HTTP, use
|
|
43
|
+
[`@lit-pigeon/rest`](../rest).
|
|
44
|
+
|
|
45
|
+
Part of [Lit Pigeon](https://github.com/snxstudio/lit-pigeon) — open-source drag-and-drop email editor.
|
|
46
|
+
|
|
47
|
+
## License
|
|
48
|
+
|
|
49
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lit-pigeon/ssr",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
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",
|
|
@@ -13,12 +13,14 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
|
-
"dist"
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE"
|
|
17
19
|
],
|
|
18
20
|
"dependencies": {
|
|
19
|
-
"@lit-pigeon/core": "^0.
|
|
20
|
-
"@lit-pigeon/parser-mjml": "^0.1.
|
|
21
|
-
"@lit-pigeon/renderer-mjml": "^0.2.
|
|
21
|
+
"@lit-pigeon/core": "^0.3.1",
|
|
22
|
+
"@lit-pigeon/parser-mjml": "^0.1.5",
|
|
23
|
+
"@lit-pigeon/renderer-mjml": "^0.2.2"
|
|
22
24
|
},
|
|
23
25
|
"devDependencies": {
|
|
24
26
|
"typescript": "^5.5.0",
|
|
@@ -33,6 +35,20 @@
|
|
|
33
35
|
"directory": "packages/ssr"
|
|
34
36
|
},
|
|
35
37
|
"license": "MIT",
|
|
38
|
+
"homepage": "https://github.com/snxstudio/lit-pigeon/tree/main/packages/ssr#readme",
|
|
39
|
+
"bugs": "https://github.com/snxstudio/lit-pigeon/issues",
|
|
40
|
+
"author": "Lit Pigeon Contributors",
|
|
41
|
+
"keywords": [
|
|
42
|
+
"email",
|
|
43
|
+
"email-template",
|
|
44
|
+
"email-editor",
|
|
45
|
+
"mjml",
|
|
46
|
+
"html-email",
|
|
47
|
+
"lit",
|
|
48
|
+
"web-components",
|
|
49
|
+
"ssr",
|
|
50
|
+
"server-side-rendering"
|
|
51
|
+
],
|
|
36
52
|
"scripts": {
|
|
37
53
|
"build": "tsc",
|
|
38
54
|
"dev": "tsc -w",
|