@samva/vite 0.16.0 → 0.17.1
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/AGENTS.md +1 -1
- package/CHANGELOG.md +33 -0
- package/README.md +1 -1
- package/dist/build.d.ts +4 -4
- package/dist/build.js +3 -3
- package/dist/dev.js +1 -1
- package/dist/editor/assets/index-D7IQkVQz.css +2 -0
- package/dist/editor/assets/index-DUnuBcHY.js +39 -0
- package/dist/editor/index.html +2 -2
- package/dist/editor/licenses/better-result.md +21 -0
- package/dist/editor/licenses/class-variance-authority.md +190 -0
- package/dist/editor/licenses/tailwind-merge.md +21 -0
- package/dist/{editor-DN7IYCAG.js → editor-CXu5ksXm.js} +4 -4
- package/dist/index.js +1 -1
- package/dist/{project-DwbOoPDk.js → project-BDIqD8ho.js} +24 -34
- package/dist/project.d.ts +17 -10
- package/dist/project.js +1 -1
- package/dist/render.d.ts +2 -2
- package/dist/render.js +1 -1
- package/package.json +3 -3
- package/dist/editor/assets/index-BgBEaRaY.js +0 -38
- package/dist/editor/assets/index-CMqDuhRE.css +0 -2
package/dist/editor/index.html
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<title>Samva editor</title>
|
|
7
|
-
<script type="module" crossorigin src="./assets/index-
|
|
8
|
-
<link rel="stylesheet" crossorigin href="./assets/index-
|
|
7
|
+
<script type="module" crossorigin src="./assets/index-DUnuBcHY.js"></script>
|
|
8
|
+
<link rel="stylesheet" crossorigin href="./assets/index-D7IQkVQz.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
|
11
11
|
<div id="root"></div>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dillon Mulroy
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2022 Joe Bell
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Dany Castillo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { C as renderEmailFixtures, S as renderChannelFixture, c as restoreBase, f as isProjectFile, g as templateDirectories, i as loadProject, m as projectPath, o as compileBase, p as isWithin, y as emailCompatibility } from "./project-
|
|
1
|
+
import { C as renderEmailFixtures, S as renderChannelFixture, c as restoreBase, f as isProjectFile, g as templateDirectories, i as loadProject, m as projectPath, o as compileBase, p as isWithin, y as emailCompatibility } from "./project-BDIqD8ho.js";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import { open, readFile, realpath, rename, rm, stat } from "node:fs/promises";
|
|
4
4
|
import { isIP } from "node:net";
|
|
5
5
|
import { extname, isAbsolute, join, resolve } from "node:path";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { createHash, randomUUID } from "node:crypto";
|
|
8
|
-
import {
|
|
8
|
+
import { previewEmail } from "@samva/markup/edit";
|
|
9
9
|
//#region src/internal/guards.ts
|
|
10
10
|
/** A non-null, non-array object, narrowed for property access. */
|
|
11
11
|
const isObject = (input) => typeof input === "object" && input !== null && !Array.isArray(input);
|
|
@@ -42,7 +42,7 @@ const chooseFixture = (fixtures, wanted) => wanted !== void 0 && fixtures.includ
|
|
|
42
42
|
/** One preview render of the viewed fixture, or null when the renderer refuses it. */
|
|
43
43
|
const previewRender = (entry, fixture, revision, assetBase) => {
|
|
44
44
|
try {
|
|
45
|
-
const preview =
|
|
45
|
+
const preview = previewEmail(entry.compiled, entry.fixtures[fixture], entry.brandPlugin === void 0 ? {} : { brandPlugin: entry.brandPlugin });
|
|
46
46
|
return {
|
|
47
47
|
revision,
|
|
48
48
|
subject: preview.subject,
|
|
@@ -195,7 +195,7 @@ var EditorFileStore = class {
|
|
|
195
195
|
content,
|
|
196
196
|
authoredSource,
|
|
197
197
|
rev,
|
|
198
|
-
variables: variablesOf(entry.
|
|
198
|
+
variables: variablesOf(entry.compiled.schema),
|
|
199
199
|
compiled: entry
|
|
200
200
|
};
|
|
201
201
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as samvaEditor } from "./editor-
|
|
1
|
+
import { t as samvaEditor } from "./editor-CXu5ksXm.js";
|
|
2
2
|
export { samvaEditor };
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { watch } from "node:fs";
|
|
2
2
|
import { mkdir, readFile, readdir, stat, writeFile } from "node:fs/promises";
|
|
3
3
|
import { isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
4
|
-
import { TEMPLATE_NAME_PATTERN,
|
|
5
|
-
import {
|
|
4
|
+
import { TEMPLATE_NAME_PATTERN, compileTemplate, projectBrandSpecifier } from "@samva/markup/compiler";
|
|
5
|
+
import { checkCompatibility } from "@samva/markup/compatibility";
|
|
6
|
+
import { render } from "@samva/markup/render";
|
|
6
7
|
import { assetUrl, isAssetPath } from "@samva/markup/brand";
|
|
7
8
|
//#region src/brand.ts
|
|
8
9
|
/** Resolve only when a host supplies a resolver; brand imports otherwise fail loudly. */
|
|
9
10
|
const resolveBrand = async (files, themePath, resolver, plugin) => {
|
|
10
11
|
if (resolver !== void 0) return resolver.resolve(files, themePath);
|
|
11
|
-
const specifier = projectBrandSpecifier(files,
|
|
12
|
+
const specifier = projectBrandSpecifier(files, {
|
|
13
|
+
themePath: themePath ?? "",
|
|
14
|
+
brandPlugin: plugin
|
|
15
|
+
});
|
|
12
16
|
return specifier === void 0 ? {
|
|
13
17
|
ok: true,
|
|
14
18
|
brand: void 0,
|
|
@@ -39,7 +43,7 @@ const CHANNELS = [
|
|
|
39
43
|
"whatsapp"
|
|
40
44
|
];
|
|
41
45
|
/** The channels a compiled template declares, in a fixed order. */
|
|
42
|
-
const channelsOf = (
|
|
46
|
+
const channelsOf = (template) => CHANNELS.filter((channel) => template[channel] !== void 0);
|
|
43
47
|
const finding = (code, severity, message, extra = {}) => ({
|
|
44
48
|
code,
|
|
45
49
|
severity,
|
|
@@ -75,8 +79,8 @@ const compileEntry = async (input, entryPath) => {
|
|
|
75
79
|
}
|
|
76
80
|
};
|
|
77
81
|
const { compiled } = attempt;
|
|
78
|
-
const
|
|
79
|
-
if (
|
|
82
|
+
const template = compiled.template;
|
|
83
|
+
if (template === void 0) return isHelper(compiled.diagnostics) ? {
|
|
80
84
|
kind: "helper",
|
|
81
85
|
entryPath
|
|
82
86
|
} : {
|
|
@@ -89,13 +93,13 @@ const compileEntry = async (input, entryPath) => {
|
|
|
89
93
|
return {
|
|
90
94
|
kind: "template",
|
|
91
95
|
entry: {
|
|
92
|
-
id:
|
|
96
|
+
id: template.template,
|
|
93
97
|
entryPath,
|
|
94
|
-
|
|
98
|
+
compiled: template,
|
|
95
99
|
fixtures: compiled.fixtures,
|
|
96
100
|
assets: compiled.assets,
|
|
97
101
|
diagnostics: compiled.diagnostics,
|
|
98
|
-
channels: channelsOf(
|
|
102
|
+
channels: channelsOf(template),
|
|
99
103
|
brandPlugin: input.brandPlugin
|
|
100
104
|
}
|
|
101
105
|
};
|
|
@@ -157,8 +161,8 @@ const renderEmailFixtures = (entry, options = {}) => Object.entries(entry.fixtur
|
|
|
157
161
|
return {
|
|
158
162
|
templateId: entry.id,
|
|
159
163
|
fixture,
|
|
160
|
-
rendered:
|
|
161
|
-
|
|
164
|
+
rendered: render(entry.compiled, input, {
|
|
165
|
+
channel: "email",
|
|
162
166
|
...options,
|
|
163
167
|
...entry.brandPlugin === void 0 ? {} : { brandPlugin: entry.brandPlugin }
|
|
164
168
|
}),
|
|
@@ -174,27 +178,7 @@ const renderEmailFixtures = (entry, options = {}) => Object.entries(entry.fixtur
|
|
|
174
178
|
}
|
|
175
179
|
});
|
|
176
180
|
/** Client-matrix findings across the fixtures that rendered. */
|
|
177
|
-
const emailCompatibility = (entry, rendered) => {
|
|
178
|
-
return rendered.flatMap((result) => {
|
|
179
|
-
if (result.rendered === void 0) return [];
|
|
180
|
-
return checkEmailCompatibility({
|
|
181
|
-
html: result.rendered.html,
|
|
182
|
-
fixture: result.fixture,
|
|
183
|
-
positions: (result.rendered.positions ?? []).map((position, index) => ({
|
|
184
|
-
start: position.start,
|
|
185
|
-
end: position.end,
|
|
186
|
-
tag: position.tag,
|
|
187
|
-
instancePath: String(index),
|
|
188
|
-
authored: true,
|
|
189
|
-
origins: position.src === void 0 ? [] : [{
|
|
190
|
-
fileName: entry.ir.sources?.[position.src[2] ?? 0] ?? "",
|
|
191
|
-
lineNumber: position.src[0],
|
|
192
|
-
columnNumber: position.src[1]
|
|
193
|
-
}]
|
|
194
|
-
}))
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
};
|
|
181
|
+
const emailCompatibility = (entry, rendered) => checkCompatibility(entry.compiled, Object.fromEntries(rendered.filter((result) => result.rendered !== void 0).map((result) => [result.fixture, entry.fixtures[result.fixture]])), { brandPlugin: entry.brandPlugin });
|
|
198
182
|
/** Render the SMS or WhatsApp channel of one fixture. */
|
|
199
183
|
const renderChannelFixture = (entry, channel, fixture, options = {}) => {
|
|
200
184
|
if (!Object.hasOwn(entry.fixtures, fixture)) return {
|
|
@@ -206,11 +190,17 @@ const renderChannelFixture = (entry, channel, fixture, options = {}) => {
|
|
|
206
190
|
return channel === "sms" ? {
|
|
207
191
|
ok: true,
|
|
208
192
|
channel,
|
|
209
|
-
text:
|
|
193
|
+
text: render(entry.compiled, input, {
|
|
194
|
+
channel,
|
|
195
|
+
...options
|
|
196
|
+
}).text
|
|
210
197
|
} : {
|
|
211
198
|
ok: true,
|
|
212
199
|
channel,
|
|
213
|
-
message:
|
|
200
|
+
message: render(entry.compiled, input, {
|
|
201
|
+
channel,
|
|
202
|
+
...options
|
|
203
|
+
})
|
|
214
204
|
};
|
|
215
205
|
} catch (cause) {
|
|
216
206
|
return {
|
package/dist/project.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { a as DEFAULT_TEMPLATE_DIRS, c as discoverEntries, i as ResolvedBrand, l as readProjectFiles, n as BrandResolver, o as ProjectFiles, r as BrandWarning, s as SAMVA_DIR, t as BrandResolution, u as templateDirectories } from "./brand-BkXQMGgY.js";
|
|
2
|
-
import {
|
|
2
|
+
import { CompiledTemplate, RenderedEmail, RenderedWhatsApp } from "@samva/markup/render";
|
|
3
3
|
import { AssetEntry, BrandPlugin } from "@samva/markup/brand";
|
|
4
4
|
import { EmailDiagnostic } from "@samva/markup/diagnostics";
|
|
5
5
|
//#region src/compile.d.ts
|
|
6
6
|
type TemplateChannel = "email" | "sms" | "whatsapp";
|
|
7
7
|
/** The channels a compiled template declares, in a fixed order. */
|
|
8
|
-
declare const channelsOf: (
|
|
8
|
+
declare const channelsOf: (template: CompiledTemplate) => readonly TemplateChannel[];
|
|
9
9
|
declare const finding: (code: string, severity: EmailDiagnostic["severity"], message: string, extra?: Partial<EmailDiagnostic>) => EmailDiagnostic;
|
|
10
10
|
/** One entry that declares a template and compiled. */
|
|
11
11
|
interface CompiledEntry {
|
|
12
|
-
/** The identity the definition declares for itself (`
|
|
12
|
+
/** The identity the definition declares for itself (`compiled.template`). */
|
|
13
13
|
readonly id: string;
|
|
14
14
|
/** Project-relative path of the authored entry. */
|
|
15
15
|
readonly entryPath: string;
|
|
16
|
-
readonly
|
|
16
|
+
readonly compiled: CompiledTemplate;
|
|
17
17
|
readonly fixtures: Readonly<Record<string, unknown>>;
|
|
18
18
|
readonly assets: readonly AssetEntry[];
|
|
19
19
|
/** Compile warnings. Errors leave no IR, so they are on a `FailedEntry` instead. */
|
|
@@ -60,11 +60,18 @@ interface CompileProjectInput {
|
|
|
60
60
|
* from a template without evaluating either. One failure stays with its entry.
|
|
61
61
|
*/
|
|
62
62
|
declare const compileProject: (input: CompileProjectInput) => Promise<CompiledProject>;
|
|
63
|
+
/** What a fixture render reads besides the template and its input. */
|
|
64
|
+
interface FixtureRenderOptions {
|
|
65
|
+
/** Overrides the template's locale for formatters. */
|
|
66
|
+
readonly locale?: string | undefined;
|
|
67
|
+
/** IANA time zone for date and time formatters; defaults to UTC. */
|
|
68
|
+
readonly timeZone?: string | undefined;
|
|
69
|
+
}
|
|
63
70
|
/** One fixture rendered through the email channel of the template it belongs to. */
|
|
64
71
|
interface RenderedFixture {
|
|
65
72
|
readonly templateId: string;
|
|
66
73
|
readonly fixture: string;
|
|
67
|
-
readonly rendered:
|
|
74
|
+
readonly rendered: RenderedEmail | undefined;
|
|
68
75
|
readonly diagnostics: readonly EmailDiagnostic[];
|
|
69
76
|
}
|
|
70
77
|
/**
|
|
@@ -72,9 +79,9 @@ interface RenderedFixture {
|
|
|
72
79
|
* the renderer refuses is a finding on that fixture, never a thrown error, so
|
|
73
80
|
* one bad input does not take the rest of the catalog with it.
|
|
74
81
|
*/
|
|
75
|
-
declare const renderEmailFixtures: (entry: Pick<CompiledEntry, "id" | "
|
|
82
|
+
declare const renderEmailFixtures: (entry: Pick<CompiledEntry, "id" | "compiled" | "fixtures" | "brandPlugin">, options?: FixtureRenderOptions) => readonly RenderedFixture[];
|
|
76
83
|
/** Client-matrix findings across the fixtures that rendered. */
|
|
77
|
-
declare const emailCompatibility: (entry: Pick<CompiledEntry, "
|
|
84
|
+
declare const emailCompatibility: (entry: Pick<CompiledEntry, "compiled" | "fixtures" | "brandPlugin">, rendered: readonly RenderedFixture[]) => readonly EmailDiagnostic[];
|
|
78
85
|
/** A channel's rendered output for one fixture, or the findings that stopped it. */
|
|
79
86
|
type RenderedChannel = {
|
|
80
87
|
readonly ok: true;
|
|
@@ -83,13 +90,13 @@ type RenderedChannel = {
|
|
|
83
90
|
} | {
|
|
84
91
|
readonly ok: true;
|
|
85
92
|
readonly channel: "whatsapp";
|
|
86
|
-
readonly message:
|
|
93
|
+
readonly message: RenderedWhatsApp;
|
|
87
94
|
} | {
|
|
88
95
|
readonly ok: false;
|
|
89
96
|
readonly diagnostics: readonly EmailDiagnostic[];
|
|
90
97
|
};
|
|
91
98
|
/** Render the SMS or WhatsApp channel of one fixture. */
|
|
92
|
-
declare const renderChannelFixture: (entry: Pick<CompiledEntry, "id" | "
|
|
99
|
+
declare const renderChannelFixture: (entry: Pick<CompiledEntry, "id" | "compiled" | "fixtures" | "brandPlugin">, channel: "sms" | "whatsapp", fixture: string, options?: FixtureRenderOptions) => RenderedChannel;
|
|
93
100
|
declare const hasErrors: (diagnostics: readonly EmailDiagnostic[]) => boolean;
|
|
94
101
|
//#endregion
|
|
95
102
|
//#region src/project.d.ts
|
|
@@ -188,4 +195,4 @@ declare const exportProject: (input: ProjectOptions & {
|
|
|
188
195
|
readonly out: string;
|
|
189
196
|
}) => Promise<ProjectExportReceipt>;
|
|
190
197
|
//#endregion
|
|
191
|
-
export { type BrandResolution, type BrandResolver, type BrandWarning, CompileProjectInput, CompiledEntry, CompiledProject, DEFAULT_EXPORT_ASSET_BASE, DEFAULT_TEMPLATE_DIRS, ExportedFixture, FailedEntry, LoadedProject, ProjectExportReceipt, type ProjectFiles, ProjectOptions, ProjectSession, RenderedChannel, RenderedFixture, type ResolvedBrand, SAMVA_DIR, TemplateChannel, channelsOf, compileProject, createProjectSession, discoverEntries, emailCompatibility, exportProject, finding, hasErrors, loadProject, projectRoot, readProjectFiles, renderChannelFixture, renderEmailFixtures, templateDirectories };
|
|
198
|
+
export { type BrandResolution, type BrandResolver, type BrandWarning, CompileProjectInput, CompiledEntry, CompiledProject, DEFAULT_EXPORT_ASSET_BASE, DEFAULT_TEMPLATE_DIRS, ExportedFixture, FailedEntry, FixtureRenderOptions, LoadedProject, ProjectExportReceipt, type ProjectFiles, ProjectOptions, ProjectSession, RenderedChannel, RenderedFixture, type ResolvedBrand, SAMVA_DIR, TemplateChannel, channelsOf, compileProject, createProjectSession, discoverEntries, emailCompatibility, exportProject, finding, hasErrors, loadProject, projectRoot, readProjectFiles, renderChannelFixture, renderEmailFixtures, templateDirectories };
|
package/dist/project.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as renderEmailFixtures, S as renderChannelFixture, _ as channelsOf, a as projectRoot, b as finding, d as discoverEntries, g as templateDirectories, h as readProjectFiles, i as loadProject, l as DEFAULT_TEMPLATE_DIRS, n as createProjectSession, r as exportProject, t as DEFAULT_EXPORT_ASSET_BASE, u as SAMVA_DIR, v as compileProject, x as hasErrors, y as emailCompatibility } from "./project-
|
|
1
|
+
import { C as renderEmailFixtures, S as renderChannelFixture, _ as channelsOf, a as projectRoot, b as finding, d as discoverEntries, g as templateDirectories, h as readProjectFiles, i as loadProject, l as DEFAULT_TEMPLATE_DIRS, n as createProjectSession, r as exportProject, t as DEFAULT_EXPORT_ASSET_BASE, u as SAMVA_DIR, v as compileProject, x as hasErrors, y as emailCompatibility } from "./project-BDIqD8ho.js";
|
|
2
2
|
export { DEFAULT_EXPORT_ASSET_BASE, DEFAULT_TEMPLATE_DIRS, SAMVA_DIR, channelsOf, compileProject, createProjectSession, discoverEntries, emailCompatibility, exportProject, finding, hasErrors, loadProject, projectRoot, readProjectFiles, renderChannelFixture, renderEmailFixtures, templateDirectories };
|
package/dist/render.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ProjectOptions } from "./project.js";
|
|
2
|
-
import {
|
|
2
|
+
import { RenderedWhatsApp } from "@samva/markup/render";
|
|
3
3
|
import { EmailDiagnostic } from "@samva/markup/diagnostics";
|
|
4
4
|
//#region src/render.d.ts
|
|
5
5
|
interface RenderTemplateInput extends ProjectOptions {
|
|
@@ -39,7 +39,7 @@ type RenderChannelResult = {
|
|
|
39
39
|
readonly channel: "whatsapp";
|
|
40
40
|
readonly template: string;
|
|
41
41
|
readonly fixture: string;
|
|
42
|
-
readonly message:
|
|
42
|
+
readonly message: RenderedWhatsApp;
|
|
43
43
|
readonly diagnostics: readonly EmailDiagnostic[];
|
|
44
44
|
} | {
|
|
45
45
|
readonly ok: false;
|
package/dist/render.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as renderEmailFixtures, S as renderChannelFixture, b as finding, i as loadProject, w as brandDiagnostics, x as hasErrors } from "./project-
|
|
1
|
+
import { C as renderEmailFixtures, S as renderChannelFixture, b as finding, i as loadProject, w as brandDiagnostics, x as hasErrors } from "./project-BDIqD8ho.js";
|
|
2
2
|
//#region src/render.ts
|
|
3
3
|
/** Compile just enough of the project to find and build the named template. */
|
|
4
4
|
const locate = async (input) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@samva/vite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.1",
|
|
4
4
|
"description": "Local editor, dev server and build for Samva email, SMS and WhatsApp templates",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"email",
|
|
@@ -70,12 +70,12 @@
|
|
|
70
70
|
"test:browser:cross": "bun run build:dependencies && bun run build && playwright test --config playwright.config.ts"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@samva/markup": "^0.
|
|
73
|
+
"@samva/markup": "^0.17.1"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@effect/vitest": "4.0.0",
|
|
77
77
|
"@playwright/test": "1.63.0",
|
|
78
|
-
"@samva/editor": "^0.
|
|
78
|
+
"@samva/editor": "^0.17.1",
|
|
79
79
|
"@types/node": "^26.6.2",
|
|
80
80
|
"tsdown": "^0.22.13",
|
|
81
81
|
"typescript": "^7.0.2",
|