@tonycodes-ui/mortar 0.14.0 → 0.16.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/CHANGELOG.md +5 -2
- package/catalog.json +119 -119
- package/cli/audit.mjs +98 -6
- package/cli/data.mjs +5 -0
- package/cli/mcp.mjs +1 -1
- package/cli/packet.mjs +17 -0
- package/dist/agent-data.json +1 -1
- package/dist/email-components.d.ts +115 -0
- package/dist/email-components.js +221 -0
- package/dist/email-templates.d.ts +108 -0
- package/dist/email-templates.js +57 -0
- package/dist/email.d.ts +4 -98
- package/dist/email.js +4 -151
- package/docs/agents.md +4 -2
- package/docs/auth-flows.md +1 -1
- package/docs/email.md +44 -19
- package/package.json +1 -1
- package/skills/mortar/SKILL.md +3 -2
- package/src/{email.tsx → email-components.tsx} +208 -93
- package/src/email-templates.tsx +355 -0
- package/src/email.ts +47 -0
package/cli/audit.mjs
CHANGED
|
@@ -604,6 +604,22 @@ function exportsFromDts(root) {
|
|
|
604
604
|
const IMPORT =
|
|
605
605
|
/\b(import|export)\s+(type\s+)?((?:(?!\bfrom\b)[^;])*?)\s*\bfrom\s*(["'])(@tonycodes-ui\/mortar(?:\/[^"']*)?)\4/g;
|
|
606
606
|
const SIDE_EFFECT = /\bimport\s*(["'])(@tonycodes-ui\/mortar\/[^"']*)\1/g;
|
|
607
|
+
// A file that builds an email: it imports Mortar's email entry or React Email.
|
|
608
|
+
const EMAIL_FILE =
|
|
609
|
+
/\bfrom\s*["'](?:@tonycodes-ui\/mortar\/email|@react-email\/[^"']+)["']/;
|
|
610
|
+
// App components with an email counterpart, for the email-app-import fix.
|
|
611
|
+
const EMAIL_EQUIVALENT = {
|
|
612
|
+
Button: "EmailButton",
|
|
613
|
+
ActionLink: "EmailButton",
|
|
614
|
+
Notice: "EmailCallout",
|
|
615
|
+
Banner: "EmailCallout",
|
|
616
|
+
Divider: "EmailDivider",
|
|
617
|
+
OrderSummary: "EmailSummary",
|
|
618
|
+
Text: "EmailText",
|
|
619
|
+
PageHeading: "EmailHeading",
|
|
620
|
+
SectionHeading: "EmailHeading",
|
|
621
|
+
CodeInput: "EmailCode",
|
|
622
|
+
};
|
|
607
623
|
const DEEP =
|
|
608
624
|
/@tonycodes-ui\/mortar\/(src|dist)\b|node_modules\/@tonycodes-ui\/mortar\/(src|dist)\b/g;
|
|
609
625
|
const PALETTE =
|
|
@@ -685,6 +701,7 @@ export async function auditApp(path = ".", { data: bundled } = {}) {
|
|
|
685
701
|
const files = walk(root);
|
|
686
702
|
const hashes = data.agent.sourceHashes ?? {};
|
|
687
703
|
let usesMortar = false;
|
|
704
|
+
let usesEmail = false;
|
|
688
705
|
let stylesImported = false;
|
|
689
706
|
let themeProvider = false;
|
|
690
707
|
let firstMortarFile;
|
|
@@ -757,7 +774,9 @@ export async function auditApp(path = ".", { data: bundled } = {}) {
|
|
|
757
774
|
}
|
|
758
775
|
|
|
759
776
|
const src = blankComments(text);
|
|
760
|
-
|
|
777
|
+
// Email markup is tables by design, and has its own components.
|
|
778
|
+
const emailFile = EMAIL_FILE.test(src);
|
|
779
|
+
if (JSX.has(ext) && !emailFile) {
|
|
761
780
|
const jsx = blankStrings(src);
|
|
762
781
|
for (const m of jsx.matchAll(/<([a-z][a-z0-9]*)(?=[\s/>])/g)) {
|
|
763
782
|
const tagName = m[1];
|
|
@@ -788,7 +807,7 @@ export async function auditApp(path = ".", { data: bundled } = {}) {
|
|
|
788
807
|
"error",
|
|
789
808
|
file,
|
|
790
809
|
line(m.index),
|
|
791
|
-
`Reaches into ${m[0]}; only "${PKG}", "${PKG}/styles.css" and "${PKG}/
|
|
810
|
+
`Reaches into ${m[0]}; only "${PKG}", "${PKG}/styles.css", "${PKG}/brand" and "${PKG}/email" are public.`,
|
|
792
811
|
`Import from "${PKG}" instead, and remove any alias to the package's source.`,
|
|
793
812
|
);
|
|
794
813
|
}
|
|
@@ -807,7 +826,18 @@ export async function auditApp(path = ".", { data: bundled } = {}) {
|
|
|
807
826
|
);
|
|
808
827
|
}
|
|
809
828
|
for (const m of src.matchAll(SIDE_EFFECT))
|
|
810
|
-
if (m[2] === `${PKG}/styles.css`)
|
|
829
|
+
if (m[2] === `${PKG}/styles.css`) {
|
|
830
|
+
if (emailFile)
|
|
831
|
+
add(
|
|
832
|
+
"email-app-import",
|
|
833
|
+
"error",
|
|
834
|
+
file,
|
|
835
|
+
line(m.index),
|
|
836
|
+
"Imports Mortar's stylesheet into an email. Email clients don't load stylesheets.",
|
|
837
|
+
`Remove the import. The components from "${PKG}/email" carry their styles inline.`,
|
|
838
|
+
);
|
|
839
|
+
else stylesImported = true;
|
|
840
|
+
}
|
|
811
841
|
|
|
812
842
|
// Local name → export name for this file.
|
|
813
843
|
const locals = new Map();
|
|
@@ -815,6 +845,35 @@ export async function auditApp(path = ".", { data: bundled } = {}) {
|
|
|
815
845
|
let imported = false;
|
|
816
846
|
for (const m of src.matchAll(IMPORT)) {
|
|
817
847
|
const [, kind, typeOnly, clause, , spec] = m;
|
|
848
|
+
if (spec === `${PKG}/email`) {
|
|
849
|
+
usesEmail = true;
|
|
850
|
+
// Older releases' data has no email exports; skip the check then.
|
|
851
|
+
const known = data.agent.emailExports;
|
|
852
|
+
const named = clause.match(/\{([\s\S]*)\}/);
|
|
853
|
+
if (!known || !named) continue;
|
|
854
|
+
const names = new Set([...known.values, ...known.types]);
|
|
855
|
+
const offset = m.index + m[0].indexOf("{");
|
|
856
|
+
for (const raw of named[1].split(",")) {
|
|
857
|
+
const name = raw
|
|
858
|
+
.trim()
|
|
859
|
+
.replace(/^type\s+/, "")
|
|
860
|
+
.split(/\s+as\s+/)[0]
|
|
861
|
+
.trim();
|
|
862
|
+
if (!name || names.has(name)) continue;
|
|
863
|
+
const guess = closest(name, names, 3);
|
|
864
|
+
add(
|
|
865
|
+
"unknown-export",
|
|
866
|
+
"error",
|
|
867
|
+
file,
|
|
868
|
+
line(offset + named[0].indexOf(raw.trimStart() || raw)),
|
|
869
|
+
`${PKG}/email ${data.version} has no export "${name}".`,
|
|
870
|
+
guess
|
|
871
|
+
? `Import ${guess} instead.`
|
|
872
|
+
: "See the email components and templates (get_guide email).",
|
|
873
|
+
);
|
|
874
|
+
}
|
|
875
|
+
continue;
|
|
876
|
+
}
|
|
818
877
|
if (spec !== PKG) {
|
|
819
878
|
if (spec !== `${PKG}/brand` && spec !== `${PKG}/styles.css`)
|
|
820
879
|
if (!/\/(src|dist)\b/.test(spec))
|
|
@@ -828,8 +887,13 @@ export async function auditApp(path = ".", { data: bundled } = {}) {
|
|
|
828
887
|
);
|
|
829
888
|
continue;
|
|
830
889
|
}
|
|
831
|
-
imported =
|
|
832
|
-
|
|
890
|
+
imported = true;
|
|
891
|
+
// An email that imports app components is reported below; it doesn't
|
|
892
|
+
// make the email service an app that needs styles and a ThemeProvider.
|
|
893
|
+
if (!emailFile) {
|
|
894
|
+
usesMortar = true;
|
|
895
|
+
firstMortarFile ??= file;
|
|
896
|
+
}
|
|
833
897
|
const ns = clause.match(/\*\s*as\s+([\w$]+)/);
|
|
834
898
|
if (ns) namespaces.add(ns[1]);
|
|
835
899
|
const named = clause.match(/\{([\s\S]*)\}/);
|
|
@@ -859,6 +923,19 @@ export async function auditApp(path = ".", { data: bundled } = {}) {
|
|
|
859
923
|
);
|
|
860
924
|
continue;
|
|
861
925
|
}
|
|
926
|
+
if (!isType && emailFile) {
|
|
927
|
+
const equivalent = EMAIL_EQUIVALENT[name];
|
|
928
|
+
add(
|
|
929
|
+
"email-app-import",
|
|
930
|
+
"error",
|
|
931
|
+
file,
|
|
932
|
+
line(at),
|
|
933
|
+
`Uses the app component ${name} in an email. App components need Mortar's stylesheet, which email clients don't load.`,
|
|
934
|
+
equivalent
|
|
935
|
+
? `Use ${equivalent} from "${PKG}/email".`
|
|
936
|
+
: `Compose the email from "${PKG}/email" (get_guide email).`,
|
|
937
|
+
);
|
|
938
|
+
}
|
|
862
939
|
if (!isType && kind === "import") locals.set(alias ?? name, name);
|
|
863
940
|
}
|
|
864
941
|
}
|
|
@@ -1022,7 +1099,22 @@ export async function auditApp(path = ".", { data: bundled } = {}) {
|
|
|
1022
1099
|
pkgJson?.dependencies?.[PKG] ??
|
|
1023
1100
|
pkgJson?.devDependencies?.[PKG] ??
|
|
1024
1101
|
pkgJson?.peerDependencies?.[PKG];
|
|
1025
|
-
|
|
1102
|
+
const reactEmail = "@react-email/components";
|
|
1103
|
+
if (
|
|
1104
|
+
usesEmail &&
|
|
1105
|
+
pkgJson &&
|
|
1106
|
+
!pkgJson.dependencies?.[reactEmail] &&
|
|
1107
|
+
!pkgJson.devDependencies?.[reactEmail]
|
|
1108
|
+
)
|
|
1109
|
+
add(
|
|
1110
|
+
"email-peer-missing",
|
|
1111
|
+
"error",
|
|
1112
|
+
pkgFile,
|
|
1113
|
+
1,
|
|
1114
|
+
`${PKG}/email is imported, but its peer dependency ${reactEmail} is not in package.json.`,
|
|
1115
|
+
`npm install ${reactEmail}`,
|
|
1116
|
+
);
|
|
1117
|
+
if (usesMortar || usesEmail || range) {
|
|
1026
1118
|
if (!range && pkgJson)
|
|
1027
1119
|
add(
|
|
1028
1120
|
"not-declared",
|
package/cli/data.mjs
CHANGED
|
@@ -35,6 +35,11 @@ export const GUIDES = {
|
|
|
35
35
|
summary:
|
|
36
36
|
"Sign-in and registration: each step mapped to components, autocomplete values, validation, security and accessibility.",
|
|
37
37
|
},
|
|
38
|
+
email: {
|
|
39
|
+
file: "docs/email.md",
|
|
40
|
+
summary:
|
|
41
|
+
"Transactional email from @tonycodes-ui/mortar/email: emailTheme, the Email components, the templates (verify email, magic link, password reset, invite, receipt, notification) and renderEmail.",
|
|
42
|
+
},
|
|
38
43
|
"migrating-0.6": {
|
|
39
44
|
file: "docs/migrating-to-0.6.md",
|
|
40
45
|
summary: "Every prop and markup change from 0.5 to 0.6.",
|
package/cli/mcp.mjs
CHANGED
|
@@ -30,7 +30,7 @@ class RpcError extends Error {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
const INSTRUCTIONS =
|
|
33
|
-
"Mortar is an MIT React 19 + Tailwind 4 UI kit (@tonycodes-ui/mortar). Before writing UI, search_components (or list_kits) to find what to reuse, then get_build_packet for the components or the brief and compose from it: start from the purpose shell (AppShell, MarketingHeader, DocsShell, AuthLayout), use named imports and the exact props in each contract, theme through ThemeProvider and tokens, never copy components or override .m-* classes. Run audit_app on the application when done and fix its findings. Missing shared patterns are contributed to the kit by GitHub pull request (get_guide contributing).";
|
|
33
|
+
"Mortar is an MIT React 19 + Tailwind 4 UI kit (@tonycodes-ui/mortar). Before writing UI, search_components (or list_kits) to find what to reuse, then get_build_packet for the components or the brief and compose from it: start from the purpose shell (AppShell, MarketingHeader, DocsShell, AuthLayout), use named imports and the exact props in each contract, theme through ThemeProvider and tokens, never copy components or override .m-* classes. For transactional emails, use @tonycodes-ui/mortar/email (get_guide email), never the app components. Run audit_app on the application when done and fix its findings. Missing shared patterns are contributed to the kit by GitHub pull request (get_guide contributing).";
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Handle one parsed JSON-RPC message. Returns the response object, or
|
package/cli/packet.mjs
CHANGED
|
@@ -132,6 +132,11 @@ const PURPOSES = [
|
|
|
132
132
|
},
|
|
133
133
|
];
|
|
134
134
|
|
|
135
|
+
// A brief about emails the product sends. Emails use @tonycodes-ui/mortar/email,
|
|
136
|
+
// not the app components, so the packet points there.
|
|
137
|
+
const EMAIL_WORDS =
|
|
138
|
+
/\b(?:(?:transactional|verification|verify|welcome|invite|invitation|receipt|order confirmation|confirmation|password reset|reset|magic[\s-]link|sign[\s-]in|notification|digest|billing)\s+e-?mails?|e-?mail\s+templates?)\b/i;
|
|
139
|
+
|
|
135
140
|
/** Pick components for a free-text brief, with the reason for each. */
|
|
136
141
|
export function chooseForBrief(data, brief) {
|
|
137
142
|
const purposes = PURPOSES.filter((p) => p.words.test(brief));
|
|
@@ -207,6 +212,8 @@ export function buildPacket(data, { components: names = [], brief } = {}) {
|
|
|
207
212
|
const guides = ["design", "conventions", "theming"];
|
|
208
213
|
if (usesAuth || purposes.some((p) => p.id === "auth"))
|
|
209
214
|
guides.push("auth-flows");
|
|
215
|
+
const emails = !!brief && EMAIL_WORDS.test(brief);
|
|
216
|
+
if (emails) guides.push("email");
|
|
210
217
|
return {
|
|
211
218
|
package: data.packageName,
|
|
212
219
|
version: data.version,
|
|
@@ -256,6 +263,16 @@ export function buildPacket(data, { components: names = [], brief } = {}) {
|
|
|
256
263
|
instruction: p.instruction,
|
|
257
264
|
})),
|
|
258
265
|
conventions: data.guide("conventions"),
|
|
266
|
+
...(emails
|
|
267
|
+
? {
|
|
268
|
+
email: {
|
|
269
|
+
import: `${data.packageName}/email`,
|
|
270
|
+
install: "npm install @react-email/components",
|
|
271
|
+
notes:
|
|
272
|
+
"Emails can't use the app components or styles.css: email clients don't load stylesheets. Build them from the Email components and templates, themed with emailTheme(brand), and send both parts of renderEmail (get_guide email).",
|
|
273
|
+
},
|
|
274
|
+
}
|
|
275
|
+
: {}),
|
|
259
276
|
guides,
|
|
260
277
|
next: [
|
|
261
278
|
"Compose with named imports from the package; keep product names, data, routes and actions in props and slots.",
|