@samva/markup 0.9.0 → 0.11.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.
Files changed (92) hide show
  1. package/AGENTS.md +53 -41
  2. package/CHANGELOG.md +379 -0
  3. package/README.md +6 -6
  4. package/dist/assets-B0yseju_.d.ts +115 -0
  5. package/dist/brand-DTctcDmf.js +202 -0
  6. package/dist/brand-plugin-CHhcei-j.d.ts +32 -0
  7. package/dist/{theme-css.d.ts → brand.d.ts} +15 -4
  8. package/dist/brand.js +4 -0
  9. package/dist/compiler.d.ts +236 -18
  10. package/dist/compiler.js +1315 -13
  11. package/dist/{email/components.js → components-Bl6DT21n.js} +4 -4
  12. package/dist/diagnostic-model-DJtqbETd.js +38 -0
  13. package/dist/diagnostic-model-DxthUZBT.d.ts +31 -0
  14. package/dist/{email/diagnostics.js → diagnostics-CnKFefKz.js} +2 -2
  15. package/dist/diagnostics.d.ts +406 -27
  16. package/dist/diagnostics.js +402 -34
  17. package/dist/edit.d.ts +234 -0
  18. package/dist/{channel-edit.js → edit.js} +341 -3
  19. package/dist/email/jsx-dev-runtime.d.ts +1 -1
  20. package/dist/email/jsx-dev-runtime.js +1 -2
  21. package/dist/email/jsx-runtime.d.ts +1 -1
  22. package/dist/email/jsx-runtime.js +1 -85
  23. package/dist/{email/components.d.ts → email.d.ts} +2 -2
  24. package/dist/email.js +2 -0
  25. package/dist/html-DjPxwjLi.js +1637 -0
  26. package/dist/index.d.ts +1 -1
  27. package/dist/index.js +1 -1
  28. package/dist/{cascade-t6kxlgEI.js → ir-De6pTH51.js} +8 -4
  29. package/dist/jsx-runtime-CBlexoeR.js +98 -0
  30. package/dist/{elements-cqldpaJt.d.ts → jsx-runtime-ylIOnaSf.d.ts} +74 -74
  31. package/dist/{profile-BH-OtdDA.js → profile-PUfi3GPH.js} +166 -32
  32. package/dist/{email/render.js → render-D2ht57ZZ.js} +103 -8
  33. package/dist/render-DQKz4Aco.d.ts +548 -0
  34. package/dist/render.d.ts +35 -0
  35. package/dist/render.js +49 -0
  36. package/dist/sms.d.ts +1 -1
  37. package/dist/sms.js +1 -1
  38. package/dist/{template-_QE_rQND.d.ts → template-DMPwxMSq.d.ts} +2 -2
  39. package/dist/{template.js → template-zLUjcwfF.js} +2 -2
  40. package/dist/{theme-css-hFqcPSar.js → theme-css-CEUrDpqq.js} +3 -3
  41. package/dist/whatsapp.d.ts +1 -1
  42. package/dist/whatsapp.js +1 -1
  43. package/generated/contract.json +18 -12
  44. package/generated/reference.md +19 -12
  45. package/package.json +39 -122
  46. package/samva-brand.d.ts +4 -4
  47. package/skills/sml/SKILL.md +2 -2
  48. package/dist/assets-C5duwTya.d.ts +0 -40
  49. package/dist/brand-B-0bN_Ir.d.ts +0 -88
  50. package/dist/channel-edit.d.ts +0 -121
  51. package/dist/channel-specs-B6M_HlaV.js +0 -29
  52. package/dist/compatibility-DbISoFIq.js +0 -589
  53. package/dist/css-BVQKICKC.d.ts +0 -109
  54. package/dist/diagnostic-codes.d.ts +0 -403
  55. package/dist/diagnostic-codes.js +0 -399
  56. package/dist/email/assets.d.ts +0 -2
  57. package/dist/email/assets.js +0 -63
  58. package/dist/email/brand-footer.d.ts +0 -34
  59. package/dist/email/brand-footer.js +0 -63
  60. package/dist/email/brand.d.ts +0 -2
  61. package/dist/email/brand.js +0 -148
  62. package/dist/email/diagnostics.d.ts +0 -2
  63. package/dist/email/elements.d.ts +0 -2
  64. package/dist/email/elements.js +0 -299
  65. package/dist/email/html.d.ts +0 -2
  66. package/dist/email/html.js +0 -321
  67. package/dist/email/render.d.ts +0 -40
  68. package/dist/email/text.d.ts +0 -7
  69. package/dist/email/text.js +0 -100
  70. package/dist/html-BJepOwZ4.d.ts +0 -56
  71. package/dist/ir-aaqNE987.d.ts +0 -252
  72. package/dist/ir.d.ts +0 -2
  73. package/dist/ir.js +0 -7
  74. package/dist/preview-Ekdg1dXG.d.ts +0 -100
  75. package/dist/preview.d.ts +0 -2
  76. package/dist/preview.js +0 -160
  77. package/dist/render-ir.d.ts +0 -19
  78. package/dist/render-ir.js +0 -826
  79. package/dist/sms-segments.d.ts +0 -13
  80. package/dist/sms-segments.js +0 -46
  81. package/dist/source-edit.d.ts +0 -116
  82. package/dist/source-edit.js +0 -343
  83. package/dist/source-locations.d.ts +0 -2
  84. package/dist/source-locations.js +0 -16
  85. package/dist/static.d.ts +0 -57
  86. package/dist/static.js +0 -69
  87. package/dist/tailwind-CMYpZf1v.js +0 -614
  88. package/dist/template.d.ts +0 -2
  89. package/dist/theme-css.js +0 -2
  90. package/dist/theme-imports-lvBw3AD1.js +0 -109
  91. package/dist/transform-Ct2OMkFN.d.ts +0 -153
  92. package/dist/unsubscribe-link-CoesnQDU.js +0 -26
@@ -1,399 +0,0 @@
1
- //#region src/diagnostic-codes.ts
2
- const codes = (table) => table;
3
- const DIAGNOSTIC_CODES = codes({
4
- "no-template": {
5
- summary: "The entry does not default-export a template.",
6
- fix: "Default-export defineTemplate({ ... }) imported from @samva/markup."
7
- },
8
- "legacy-definition": {
9
- summary: "The entry default-exports something other than defineTemplate.",
10
- fix: "Import { defineTemplate } from \"@samva/markup\" and default-export defineTemplate({ ... }).",
11
- upgrade: [
12
- "Read the entry and its imports without executing them. For a default-exported defineEmail definition, import defineTemplate from \"@samva/markup\" and replace the definition call.",
13
- "Preserve the entry path, template id, schema, named fixtures, content, design, bindings, conditions, project partials, assets, theme and brand imports. Replace render(input) returning { subject, preheader?, body } with email: { subject: (input) => ..., preheader: (input) => ..., body: (input) => ... }, retaining its parameter bindings and each returned expression; omit preheader when absent.",
14
- "Inline module constants only when they are literal strings, numbers or booleans and their bindings are unambiguous; never substitute a fixture value for an input binding. Keep each channel function a single static-profile expression, and keep subject and preheader off <Email>.",
15
- "Helper calls, `Math.*`, general arithmetic, render statements, spreads, computed properties and runtime clock or seed have no direct conversion. Rewrite with static-profile bindings, conditions, .map, .filter, project partials or `fmt.*` where equivalent; arithmetic is allowed only in formatter arguments and conditions. Otherwise compute the value in the sender, declare a payload field in the schema and every fixture, and explain the required sender change. Never guess time, randomness or computed data.",
16
- "Explicit text has no email-channel field: plain text is derived from the body. If deriving it changes intended content, or another construct cannot be preserved, explain the tradeoff and ask rather than silently discard it. Do not drop fixtures, weaken validation or hide diagnostics.",
17
- "Convert every affected entry in the project at its existing path, including emails/ entries. Compile each entry, render every declared fixture and inspect the affected output. Resolve errors before requesting one saved version for the whole project, approved by the user; do not publish."
18
- ].join("\n\n")
19
- },
20
- "dynamic-definition": {
21
- summary: "A definition field is spread or computed instead of written out.",
22
- fix: "Write each field as name: value."
23
- },
24
- "invalid-template-id": {
25
- summary: "The template id is not a lowercase kebab-case string literal.",
26
- fix: "Write id: \"order-shipped\"."
27
- },
28
- "missing-schema": {
29
- summary: "The template declares no input schema.",
30
- fix: "Add schema: jsonSchema<Input>({ ... })."
31
- },
32
- "schema-not-static": {
33
- summary: "The schema cannot be read without running code.",
34
- fix: "Write the schema as a literal jsonSchema<Input>({ type: 'object', ... })."
35
- },
36
- "invalid-schema": {
37
- summary: "The schema uses JSON Schema keywords the compiler cannot validate against.",
38
- fix: "Use only the JSON Schema keywords the package README lists."
39
- },
40
- "missing-fixtures": {
41
- summary: "The template declares no fixtures.",
42
- fix: "Add fixtures: { default: { ... } } with at least one valid payload."
43
- },
44
- "fixtures-not-static": {
45
- summary: "A fixture is computed instead of written as data.",
46
- fix: "Write each fixture as a literal object; an imported asset is allowed."
47
- },
48
- "invalid-fixture-name": {
49
- summary: "A fixture key is not a single path segment.",
50
- fix: "Use letters, digits, '.', '_' and '-', starting with a letter or digit."
51
- },
52
- "fixture-invalid": {
53
- summary: "A fixture does not match the schema.",
54
- fix: "Change the fixture, or the schema, so every fixture is a payload a send could carry."
55
- },
56
- "invalid-locale": {
57
- summary: "The template's default locale is not a string literal.",
58
- fix: "Write locale: \"en-US\"."
59
- },
60
- "no-channel": {
61
- summary: "The template declares no channel body.",
62
- fix: "Add an email body."
63
- },
64
- "invalid-channel": {
65
- summary: "A channel field is not shaped as the channel requires.",
66
- fix: "Write email: { subject, preheader?, body } with each a function of the input."
67
- },
68
- "not-a-function": {
69
- summary: "A channel field is not a function of the input.",
70
- fix: "Write (input) => ... in place or declare the function in the project."
71
- },
72
- "missing-subject": {
73
- summary: "The email channel has no subject.",
74
- fix: "Add subject: (input) => ...."
75
- },
76
- "missing-body": {
77
- summary: "The email channel has no body.",
78
- fix: "Add body: (input) => (<Email>...</Email>)."
79
- },
80
- "multiple-roots": {
81
- summary: "The body renders nothing or more than one root.",
82
- fix: "Wrap the body in a single element such as <Email>."
83
- },
84
- "preheader-without-shell": {
85
- summary: "A preheader is set but the body has no <Email> shell to hold it.",
86
- fix: "Wrap the body in <Email>."
87
- },
88
- "wrong-channel": {
89
- summary: "A channel body does not return its own channel component.",
90
- fix: "Return one element imported from the channel package.",
91
- channelOnly: true
92
- },
93
- "syntax-error": {
94
- summary: "A project file does not parse as TSX.",
95
- fix: "Fix the syntax at the reported location."
96
- },
97
- "non-project-import": {
98
- summary: "The file imports something other than @samva/markup or a project file.",
99
- fix: "Remove the import, or copy the code you need into a project file."
100
- },
101
- "unresolved-import": {
102
- summary: "An import names no file in the project.",
103
- fix: "Check the path and the file extension."
104
- },
105
- "recursive-partial": {
106
- summary: "A partial renders itself; partials are inlined at compile time.",
107
- fix: "Flatten the recursion, or repeat the structure with .map."
108
- },
109
- "nesting-limit": {
110
- summary: "The template nests deeper than the compiler reads.",
111
- fix: "Flatten the structure."
112
- },
113
- "dynamic-expression": {
114
- summary: "An expression outside the static profile: a call other than fmt.* and .map, a computed value, or a spread.",
115
- fix: "Compute the value where the message is sent and bind it from the payload."
116
- },
117
- "statement-in-body": {
118
- summary: "A body contains a statement (const, if, a loop); a body is one expression.",
119
- fix: "Use cond && <X />, cond ? <A /> : <B /> and .map, or send the computed value in the payload."
120
- },
121
- "unsupported-pattern": {
122
- summary: "A parameter pattern or default value the profile cannot bind.",
123
- fix: "Use plain names or destructuring without defaults; declare the field required or guard it."
124
- },
125
- "hook-call": {
126
- summary: "A hook was called; templates have no state, effects or context.",
127
- fix: "Read the input through the function's parameter and send anything else in the payload."
128
- },
129
- "unknown-formatter": {
130
- summary: "fmt.<name> is not a formatter.",
131
- fix: "Use fmt.money, number, date, time, plural or list."
132
- },
133
- "formatter-arguments": {
134
- summary: "A formatter got the wrong number of arguments.",
135
- fix: "Match the formatter's signature in the contract."
136
- },
137
- "reserved-character": {
138
- summary: "Text contains a private-use character the compiler reserves.",
139
- fix: "Remove the characters U+E000 to U+E003."
140
- },
141
- "reserved-url": {
142
- summary: "A URL is the unsubscribe placeholder only BrandFooter can write.",
143
- fix: "Render <BrandFooter /> instead."
144
- },
145
- "reserved-attribute": {
146
- summary: "An attribute is written only by a brand component.",
147
- fix: "Render BrandFooter from samva:brand instead of marking an element as the footer."
148
- },
149
- "dynamic-class": {
150
- summary: "A class name is built at run time, and Tailwind cannot see it.",
151
- fix: "Write classes literally, or choose between literal lists: input.vip ? \"bg-amber-100\" : \"bg-white\"."
152
- },
153
- "too-many-class-variants": {
154
- summary: "A class list chooses between more literal lists than the compiler resolves.",
155
- fix: "Split the choice into fewer conditions, or move part of it to a partial."
156
- },
157
- "invalid-style": {
158
- summary: "A style prop is not a static property object.",
159
- fix: "Write style={{ backgroundColor: \"#fff\" }} with literal values, or use classes."
160
- },
161
- "unknown-field": {
162
- summary: "A binding names a field the schema does not declare.",
163
- fix: "Add the field to the schema, or bind a field it declares (the message suggests the nearest)."
164
- },
165
- "unguarded-optional": {
166
- summary: "An optional field is read outside a guard, so a send without it would render a blank.",
167
- fix: "Guard it with {input.field && ...}, or make the field required."
168
- },
169
- "invalid-binding-type": {
170
- summary: "A binding has the wrong type for where it is used.",
171
- fix: "Bind a field of the type the position needs, or send it in that type."
172
- },
173
- "unknown-component": {
174
- summary: "A component the profile cannot read.",
175
- fix: "Import components from @samva/markup/email/components, samva:brand, or the project."
176
- },
177
- "dynamic-numeric-prop": {
178
- summary: "A prop that sizes layout at compile time is not a number literal.",
179
- fix: "Write the number literally, for example height={44}."
180
- },
181
- "button-dynamic-label": {
182
- summary: "A Button label is read at render time, so classic Outlook cannot size it.",
183
- fix: "Give the button a width: <Button width={200}>."
184
- },
185
- "invalid-columns-each": {
186
- summary: "<Columns each> is not a list from the input.",
187
- fix: "Write each={input.items} with a callback returning <Column>."
188
- },
189
- "invalid-columns-per": {
190
- summary: "<Columns per> is not a positive integer literal.",
191
- fix: "Write per={2}."
192
- },
193
- "invalid-button-number": {
194
- summary: "A Button size prop is not a finite number.",
195
- fix: "Pass a finite number."
196
- },
197
- "unsupported-element": {
198
- summary: "An element outside the supported email vocabulary.",
199
- fix: "Use an element from the contract's element table."
200
- },
201
- "unsupported-attribute": {
202
- summary: "An attribute the element does not support.",
203
- fix: "Use a supported attribute, or data-* and aria-*."
204
- },
205
- "missing-attribute": {
206
- summary: "An element is missing a required attribute.",
207
- fix: "Add the attribute, for example alt on img."
208
- },
209
- "invalid-attribute-value": {
210
- summary: "An attribute value is not a string or number, or contains control characters.",
211
- fix: "Pass plain text."
212
- },
213
- "duplicate-attribute": {
214
- summary: "An attribute is written twice.",
215
- fix: "Keep one."
216
- },
217
- "invalid-content": {
218
- summary: "An element holds content its content model does not allow.",
219
- fix: "Move the child to a parent that accepts it."
220
- },
221
- "void-element-children": {
222
- summary: "A void element has children.",
223
- fix: "Remove the children."
224
- },
225
- "event-handler": {
226
- summary: "An event handler; email clients strip scripting.",
227
- fix: "Remove the handler; use a link for interaction."
228
- },
229
- "dangerous-html": {
230
- summary: "dangerouslySetInnerHTML; there is no raw-HTML escape hatch.",
231
- fix: "Write the markup as JSX."
232
- },
233
- "unsafe-url": {
234
- summary: "A URL uses a scheme email cannot send safely.",
235
- fix: "Use an https URL, a mailto: or tel: link, or a bound URL."
236
- },
237
- "unsafe-raw-text": {
238
- summary: "Raw text content contains markup that could end its element.",
239
- fix: "Remove the offending sequence."
240
- },
241
- "unsupported-style-property": {
242
- summary: "A style property name is not a CSS property.",
243
- fix: "Write camelCase (backgroundColor) or a custom property (--brand)."
244
- },
245
- "invalid-style-value": {
246
- summary: "A style value is not a string or number.",
247
- fix: "Pass a string or number."
248
- },
249
- "unsafe-style-value": {
250
- summary: "A style value contains CSS that could break out of its declaration.",
251
- fix: "Remove the offending characters."
252
- },
253
- "missing-head": {
254
- summary: "Styles that cannot be inlined need a <head> to live in.",
255
- fix: "Wrap the message in <Email>, or write those declarations inline."
256
- },
257
- "invalid-subject": {
258
- summary: "The subject is not one line of text.",
259
- fix: "Return a single-line string."
260
- },
261
- "invalid-preheader": {
262
- summary: "The preheader is not a string.",
263
- fix: "Return a string."
264
- },
265
- "invalid-text": {
266
- summary: "The plain-text body is not a string.",
267
- fix: "Return a string."
268
- },
269
- "button-outlook-fallback": {
270
- summary: "Classic Outlook needs a height and a plain string label to draw the button.",
271
- fix: "Give <Button> a height and a string label."
272
- },
273
- "unmatched-class": {
274
- summary: "A class produced no styles.",
275
- fix: "Use a class the theme or Tailwind defines, or write the style inline."
276
- },
277
- "tailwind-dynamic-class": {
278
- summary: "A class list is assembled at run time.",
279
- fix: "Write the classes literally."
280
- },
281
- "css-parse-error": {
282
- summary: "A stylesheet does not parse.",
283
- fix: "Fix the CSS at the reported location."
284
- },
285
- "css-import-unresolved": {
286
- summary: "A stylesheet @import cannot be resolved.",
287
- fix: "Import the stylesheet from the template module, or use the theme.css layers."
288
- },
289
- "css-unsupported-at-rule": {
290
- summary: "An at-rule is not applied to email output.",
291
- fix: "Remove it or move the declarations into a class rule."
292
- },
293
- "css-conditional-variable": {
294
- summary: "A custom property is redefined inside a conditional at-rule.",
295
- fix: "Keep the override on a class rule."
296
- },
297
- "email-font-fallback": {
298
- summary: "A font stack names a project font without a generic fallback.",
299
- fix: "End the stack with sans-serif, serif or monospace."
300
- },
301
- "email-font-family": {
302
- summary: "@font-face declares no font-family.",
303
- fix: "Add font-family."
304
- },
305
- "email-font-src": {
306
- summary: "@font-face declares no usable url() src.",
307
- fix: "Add a url() pointing at a .woff2 file."
308
- },
309
- "email-font-format": {
310
- summary: "@font-face uses a format other than WOFF2.",
311
- fix: "Convert the file to .woff2."
312
- },
313
- "email-font-missing": {
314
- summary: "@font-face names a file the project does not hold.",
315
- fix: "Add the file; paths resolve from the stylesheet's directory."
316
- },
317
- "invalid-asset-base": {
318
- summary: "The asset base is not an https URL or a path.",
319
- fix: "Use an https URL, an absolute path, or a relative path."
320
- },
321
- "brand-unavailable": {
322
- summary: "The build has no brand to resolve a samva:brand import.",
323
- fix: "Create or select the brand the import names."
324
- },
325
- "brand-import-conflict": {
326
- summary: "The project imports two different brands.",
327
- fix: "Import one brand specifier everywhere."
328
- },
329
- "caniemail/unknown-coverage": {
330
- summary: "A feature has no client-support data.",
331
- fix: "Verify it in the target clients."
332
- },
333
- "invalid-attribute": {
334
- summary: "A channel component attribute has a value the channel does not accept.",
335
- fix: "Use one of the listed values.",
336
- channelOnly: true
337
- },
338
- "unknown-attribute": {
339
- summary: "A channel component attribute the component does not have.",
340
- fix: "Use one of the listed attributes.",
341
- channelOnly: true
342
- },
343
- "sms-markup": {
344
- summary: "An SMS body contains an element; SMS is plain text.",
345
- fix: "Write text and bindings, with a newline for a line break.",
346
- channelOnly: true
347
- },
348
- "whatsapp-structure": {
349
- summary: "WhatsApp content sits outside Header, Body, Footer or Buttons.",
350
- fix: "Move it into <WhatsApp.Body>.",
351
- channelOnly: true
352
- },
353
- "whatsapp-body-required": {
354
- summary: "A WhatsApp template has no body.",
355
- fix: "Add <WhatsApp.Body>...</WhatsApp.Body>.",
356
- channelOnly: true
357
- },
358
- "whatsapp-conditional": {
359
- summary: "A WhatsApp part branches or contains elements; Meta registers its text once.",
360
- fix: "Choose the wording in the payload, or write separate templates.",
361
- channelOnly: true
362
- },
363
- "whatsapp-header-media": {
364
- summary: "A WhatsApp media header is not exactly one URL.",
365
- fix: "Write the URL as the only child: a literal or one binding.",
366
- channelOnly: true
367
- },
368
- "whatsapp-header-variables": {
369
- summary: "A WhatsApp header text takes more than one variable.",
370
- fix: "Keep one binding in the header and move the rest to the body.",
371
- channelOnly: true
372
- },
373
- "whatsapp-length": {
374
- summary: "A WhatsApp part exceeds Meta's length limit.",
375
- fix: "Shorten the text.",
376
- channelOnly: true
377
- },
378
- "whatsapp-button-text": {
379
- summary: "A WhatsApp button has no label or value between its tags.",
380
- fix: "Write the label or value as text between the tags.",
381
- channelOnly: true
382
- },
383
- "whatsapp-button-limit": {
384
- summary: "The conditions can produce more buttons of a kind than Meta allows.",
385
- fix: "Remove buttons, or split the template.",
386
- channelOnly: true
387
- }
388
- });
389
- /** Whether a diagnostic identifier selects an agent-driven format upgrade. */
390
- const hasUpgradeRecipe = (code) => Object.entries(DIAGNOSTIC_CODES).some(([identifier, spec]) => identifier === code && "upgrade" in spec);
391
- /** Families whose code carries a suffix chosen at run time. */
392
- const DIAGNOSTIC_CODE_FAMILIES = { "caniemail/": {
393
- summary: "A CSS property, HTML element or attribute that a target email client ignores or partly supports (from the caniemail.com data), reported as caniemail/<feature>.",
394
- fix: "Use the alternative the message names, such as an email component instead of display: flex."
395
- } };
396
- //#endregion
397
- export { DIAGNOSTIC_CODES, DIAGNOSTIC_CODE_FAMILIES, hasUpgradeRecipe };
398
-
399
- //# sourceMappingURL=diagnostic-codes.js.map
@@ -1,2 +0,0 @@
1
- import { a as assetUrl, c as isExternalAsset, i as assetEntry, n as AssetEntry, o as checkAssetBase, r as AssetManifest, s as isAssetPath, t as ASSET_CONTENT_TYPES } from "../assets-C5duwTya.js";
2
- export { ASSET_CONTENT_TYPES, AssetEntry, AssetManifest, assetEntry, assetUrl, checkAssetBase, isAssetPath, isExternalAsset };
@@ -1,63 +0,0 @@
1
- //#region src/email/assets.ts
2
- /** Files a template may import, and what they are served as. */
3
- const ASSET_CONTENT_TYPES = {
4
- ".png": "image/png",
5
- ".jpg": "image/jpeg",
6
- ".jpeg": "image/jpeg",
7
- ".gif": "image/gif",
8
- ".webp": "image/webp",
9
- ".avif": "image/avif",
10
- ".svg": "image/svg+xml",
11
- ".ico": "image/x-icon",
12
- ".woff": "font/woff",
13
- ".woff2": "font/woff2",
14
- ".ttf": "font/ttf",
15
- ".otf": "font/otf",
16
- ".pdf": "application/pdf",
17
- ".txt": "text/plain"
18
- };
19
- const extensionOf = (path) => {
20
- const dot = path.lastIndexOf(".");
21
- return dot < 0 ? "" : path.slice(dot).toLowerCase();
22
- };
23
- /** True when the compiler turns this import into a content-addressed asset. */
24
- const isAssetPath = (path) => Object.hasOwn(ASSET_CONTENT_TYPES, extensionOf(path));
25
- const hex = (buffer) => Array.from(new Uint8Array(buffer), (byte) => byte.toString(16).padStart(2, "0")).join("");
26
- /** Address one file by its content. */
27
- const assetEntry = async (path, bytes) => {
28
- const extension = extensionOf(path);
29
- const view = new Uint8Array(bytes.byteLength);
30
- view.set(bytes);
31
- const digest = hex(await crypto.subtle.digest("SHA-256", view));
32
- return {
33
- path,
34
- digest,
35
- bytes: bytes.byteLength,
36
- contentType: ASSET_CONTENT_TYPES[extension] ?? "application/octet-stream",
37
- fileName: `${digest}${extension}`
38
- };
39
- };
40
- /**
41
- * The URL an asset has under a base. The base is a build input: publication
42
- * passes its hosted origin, and a local export passes whatever it will serve
43
- * the exported files from.
44
- */
45
- const assetUrl = (entry, base) => `${base.replace(/\/+$/, "")}/${entry.fileName}`;
46
- const EXTERNAL_IMAGE = /^https:\/\//i;
47
- /** Record, but never fetch, a URL the template points at. */
48
- const isExternalAsset = (reference) => EXTERNAL_IMAGE.test(reference);
49
- /**
50
- * Reject an asset base that would produce URLs a client will not load. The
51
- * relative forms are the ones a page on disk resolves against its own
52
- * directory, which is what a local export writes.
53
- */
54
- const checkAssetBase = (base) => /^(https:\/\/|\.{1,2}\/|\/)/i.test(base) ? [] : [{
55
- code: "invalid-asset-base",
56
- severity: "error",
57
- message: `Asset base ${JSON.stringify(base)} must be an https URL, an absolute path, or a relative path for a local export.`,
58
- origins: []
59
- }];
60
- //#endregion
61
- export { ASSET_CONTENT_TYPES, assetEntry, assetUrl, checkAssetBase, isAssetPath, isExternalAsset };
62
-
63
- //# sourceMappingURL=assets.js.map
@@ -1,34 +0,0 @@
1
- import { n as EmailContent } from "../template-_QE_rQND.js";
2
- import { RenderedEmail } from "./render.js";
3
- import { a as EmailBrand, n as BrandComponents } from "../brand-B-0bN_Ir.js";
4
- //#region src/email/brand-footer.d.ts
5
- /** A footer block for the send path to append, and its plain-text tail. */
6
- interface RenderedBrandFooter {
7
- readonly html: string;
8
- readonly text: string;
9
- }
10
- /**
11
- * Render `BrandFooter` against a brand on its own, for the send path to
12
- * append to a message whose template renders no footer of its own. It
13
- * compiles the same component, styled by the same brand theme, a template
14
- * would get from `samva:brand`. Without `unsubscribe` the unsubscribe row is
15
- * left out.
16
- */
17
- declare const renderBrandFooter: (brand: EmailBrand, options: {
18
- readonly unsubscribe: boolean;
19
- }) => Promise<RenderedBrandFooter>;
20
- /**
21
- * Render content against a brand as a project whose `theme.css` is
22
- * `@import "samva:brand";` renders it: Tailwind compiles the brand theme for
23
- * the classes the content names, `BrandLogo` and `BrandFooter` are bound to the
24
- * brand, and the render inlines the result. A brand preview renders through
25
- * this, so it shows what a template importing the brand compiles to.
26
- */
27
- declare const renderBrandSample: (brand: EmailBrand, sample: {
28
- /** Every class the content names; nothing is discovered from source here. */
29
- readonly classes: readonly string[];
30
- readonly render: (components: BrandComponents) => EmailContent;
31
- }) => Promise<RenderedEmail>;
32
- //#endregion
33
- export { RenderedBrandFooter, renderBrandFooter, renderBrandSample };
34
- //# sourceMappingURL=brand-footer.d.ts.map
@@ -1,63 +0,0 @@
1
- import { EmailCompileError } from "./diagnostics.js";
2
- import { c as parseBrandCss, i as brandTailwindCss } from "../theme-css-hFqcPSar.js";
3
- import { BRAND_COMPONENT_CLASSES, brandComponents, withoutUnsubscribeRow } from "./brand.js";
4
- import { t as applyStylesheet } from "../cascade-t6kxlgEI.js";
5
- import { a as parseStylesheet, t as compileTailwind } from "../tailwind-CMYpZf1v.js";
6
- import { compileEmail, renderEmailContent } from "./render.js";
7
- //#region src/email/brand-footer.ts
8
- /** The brand theme as Tailwind compiles it; a theme outside the grammar is a compile refusal. */
9
- const brandTheme = (brand) => {
10
- const parsed = parseBrandCss(brand.css);
11
- if (parsed.isErr()) throw new EmailCompileError({ diagnostics: parsed.error.map((finding) => ({
12
- code: finding.code,
13
- severity: "error",
14
- message: `samva:brand: ${finding.message}`,
15
- origins: []
16
- })) });
17
- return brandTailwindCss(parsed.value);
18
- };
19
- /**
20
- * Render `BrandFooter` against a brand on its own, for the send path to
21
- * append to a message whose template renders no footer of its own. It
22
- * compiles the same component, styled by the same brand theme, a template
23
- * would get from `samva:brand`. Without `unsubscribe` the unsubscribe row is
24
- * left out.
25
- */
26
- const renderBrandFooter = async (brand, options) => {
27
- const tailwind = await compileTailwind(BRAND_COMPONENT_CLASSES, { css: brandTheme(brand) });
28
- const node = brandComponents(brand).BrandFooter({});
29
- if (node === null) return {
30
- html: "",
31
- text: ""
32
- };
33
- const styled = applyStylesheet(node, parseStylesheet(tailwind.css, { origin: "samva:brand" }));
34
- const compiled = compileEmail(styled.tree);
35
- const rendered = options.unsubscribe ? compiled : withoutUnsubscribeRow({
36
- html: compiled.html,
37
- text: compiled.text
38
- });
39
- const text = (rendered.text ?? "").trim();
40
- return {
41
- html: rendered.html ?? "",
42
- text: text === "" ? "" : `\n\n---\n${text}`
43
- };
44
- };
45
- /**
46
- * Render content against a brand as a project whose `theme.css` is
47
- * `@import "samva:brand";` renders it: Tailwind compiles the brand theme for
48
- * the classes the content names, `BrandLogo` and `BrandFooter` are bound to the
49
- * brand, and the render inlines the result. A brand preview renders through
50
- * this, so it shows what a template importing the brand compiles to.
51
- */
52
- const renderBrandSample = async (brand, sample) => {
53
- const tailwind = await compileTailwind([...BRAND_COMPONENT_CLASSES, ...sample.classes], { css: "@import \"samva:brand\";" }, {
54
- stylesheets: /* @__PURE__ */ new Map(),
55
- brandCss: brandTheme(brand)
56
- });
57
- const components = brandComponents(brand);
58
- return renderEmailContent(parseStylesheet(tailwind.css, { origin: "samva:brand" }), () => sample.render(components));
59
- };
60
- //#endregion
61
- export { renderBrandFooter, renderBrandSample };
62
-
63
- //# sourceMappingURL=brand-footer.js.map
@@ -1,2 +0,0 @@
1
- import { a as EmailBrand, c as EmailBrandFooter, d as RenderedFooterMarkers, f as UNSUBSCRIBE_ROW_ATTRIBUTE, g as UNSUBSCRIBE_URL_PLACEHOLDER, h as withoutUnsubscribeRow, i as BrandLogoProps, l as EmailBrandSocialLink, m as renderedFooterMarkers, n as BrandComponents, o as EmailBrandAddress, p as brandComponents, r as BrandFooterProps, s as EmailBrandAssets, t as BRAND_COMPONENT_CLASSES, u as FOOTER_ATTRIBUTE } from "../brand-B-0bN_Ir.js";
2
- export { BRAND_COMPONENT_CLASSES, BrandComponents, BrandFooterProps, BrandLogoProps, EmailBrand, EmailBrandAddress, EmailBrandAssets, EmailBrandFooter, EmailBrandSocialLink, FOOTER_ATTRIBUTE, RenderedFooterMarkers, UNSUBSCRIBE_ROW_ATTRIBUTE, UNSUBSCRIBE_URL_PLACEHOLDER, brandComponents, renderedFooterMarkers, withoutUnsubscribeRow };