@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,109 +0,0 @@
1
- import { buildLineMap, lineColumn } from "./diagnostics.js";
2
- import { parse } from "css-tree";
3
- //#region src/email/theme-imports.ts
4
- /** The CSS and TSX specifier a template uses to reach its organization's brand. */
5
- const BRAND_SPECIFIER = "samva:brand";
6
- const BRAND_IMPORT = /^samva:brand(?:\/([a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?))?$/;
7
- /** The brand a `samva:brand` specifier names: `undefined` slug means the default brand. */
8
- const parseBrandSpecifier = (specifier) => {
9
- const match = BRAND_IMPORT.exec(specifier);
10
- return match === null ? void 0 : { slug: match[1] };
11
- };
12
- /** The directory part of a project path, with no trailing slash (`""` at the root). */
13
- const projectDirectory = (path) => path.includes("/") ? path.slice(0, path.lastIndexOf("/")) : "";
14
- /** A relative or root-absolute stylesheet reference, resolved from a project directory. */
15
- const resolveFromDirectory = (directory, reference) => {
16
- const segments = reference.startsWith("/") || directory === "" ? [] : directory.split("/");
17
- for (const segment of reference.split("/")) {
18
- if (segment === "" || segment === ".") continue;
19
- if (segment === "..") {
20
- if (segments.length === 0) return void 0;
21
- segments.pop();
22
- } else segments.push(segment);
23
- }
24
- return segments.length === 0 ? void 0 : segments.join("/");
25
- };
26
- const importTarget = (node) => {
27
- if (node.type !== "Atrule" || node.prelude === null || node.prelude.type !== "AtrulePrelude") return { extra: true };
28
- const parts = [...node.prelude.children].filter((part) => part.type !== "WhiteSpace");
29
- const first = parts[0];
30
- const target = first?.type === "String" ? first.value : first?.type === "Url" ? first.value : void 0;
31
- return target === void 0 ? { extra: true } : {
32
- target,
33
- extra: parts.length > 1
34
- };
35
- };
36
- /**
37
- * Walk the theme's `@import` graph. Project `.css` files resolve from the
38
- * importing file's directory; `samva:brand` and `samva:brand/<slug>` are
39
- * recorded for the brand the build supplies. Anything else is an error.
40
- */
41
- const resolveThemeImports = (themePath, themeCss, files) => {
42
- const stylesheets = /* @__PURE__ */ new Map([[themePath, themeCss]]);
43
- const brandSpecifiers = /* @__PURE__ */ new Set();
44
- const diagnostics = [];
45
- const visit = (path, source, chain) => {
46
- const lineMap = buildLineMap(source);
47
- const ast = parse(source, {
48
- positions: true,
49
- parseValue: false,
50
- parseRulePrelude: false
51
- });
52
- if (ast.type !== "StyleSheet") return;
53
- for (const node of ast.children) {
54
- if (node.type !== "Atrule" || node.name.toLowerCase() !== "import") continue;
55
- const position = lineColumn(lineMap, node.loc?.start.offset ?? 0);
56
- const origins = [{
57
- fileName: path,
58
- lineNumber: position.line,
59
- columnNumber: position.column
60
- }];
61
- const refuse = (message) => diagnostics.push({
62
- code: "css-import-unresolved",
63
- severity: "error",
64
- message,
65
- origins
66
- });
67
- const { target, extra } = importTarget(node);
68
- if (target === void 0) {
69
- refuse(`${path}: @import needs a quoted stylesheet path or "samva:brand".`);
70
- continue;
71
- }
72
- if (extra) {
73
- refuse(`${path}: @import ${JSON.stringify(target)} takes no layer, supports or media conditions; the import order is the layering.`);
74
- continue;
75
- }
76
- if (parseBrandSpecifier(target) !== void 0) {
77
- brandSpecifiers.add(target);
78
- continue;
79
- }
80
- if (!/^\.{0,2}\//.test(target) || !/\.css$/i.test(target.replace(/[?#].*$/, ""))) {
81
- refuse(`${path}: @import ${JSON.stringify(target)} is not a project stylesheet or "samva:brand". The compiler supplies Tailwind itself; import project .css files by relative path.`);
82
- continue;
83
- }
84
- const resolved = resolveFromDirectory(projectDirectory(path), target.replace(/[?#].*$/, ""));
85
- const content = resolved === void 0 ? void 0 : files[resolved];
86
- if (resolved === void 0 || typeof content !== "string") {
87
- refuse(`${path}: @import ${JSON.stringify(target)} names no stylesheet in the project.`);
88
- continue;
89
- }
90
- if (chain.includes(resolved)) {
91
- refuse(`${path}: @import ${JSON.stringify(target)} imports itself through ${chain.join(" → ")}.`);
92
- continue;
93
- }
94
- if (stylesheets.has(resolved)) continue;
95
- stylesheets.set(resolved, content);
96
- visit(resolved, content, [...chain, resolved]);
97
- }
98
- };
99
- visit(themePath, themeCss, [themePath]);
100
- return {
101
- stylesheets,
102
- brandSpecifiers: [...brandSpecifiers].sort(),
103
- diagnostics
104
- };
105
- };
106
- //#endregion
107
- export { resolveThemeImports as a, resolveFromDirectory as i, parseBrandSpecifier as n, projectDirectory as r, BRAND_SPECIFIER as t };
108
-
109
- //# sourceMappingURL=theme-imports-lvBw3AD1.js.map
@@ -1,153 +0,0 @@
1
- import { r as EmailDiagnostic } from "./diagnostics-B-Gym34R.js";
2
- import { n as EmittedPosition } from "./preview-Ekdg1dXG.js";
3
- import { i as Stylesheet } from "./css-BVQKICKC.js";
4
- import { n as AssetEntry } from "./assets-C5duwTya.js";
5
- import { a as EmailBrand } from "./brand-B-0bN_Ir.js";
6
- import { caniemail } from "caniemail";
7
- //#region src/email/compatibility.d.ts
8
- type CaniemailClient = Parameters<typeof caniemail>[0]["clients"][number];
9
- /** One client this compiler makes claims about. */
10
- interface EmailClientTarget {
11
- readonly id: CaniemailClient;
12
- readonly label: string;
13
- }
14
- /**
15
- * The pinned matrix. Every finding is reported per client, and a client absent
16
- * from this list is a client Samva makes no claim about.
17
- */
18
- declare const EMAIL_CLIENT_MATRIX: readonly EmailClientTarget[];
19
- interface CompatibilityProvenance {
20
- /** The exact rules package a finding came from. */
21
- readonly rules: string;
22
- readonly apiVersion: string;
23
- /** The day caniemail last changed the data this build was checked against. */
24
- readonly lastUpdate: string;
25
- }
26
- declare const COMPATIBILITY_PROVENANCE: CompatibilityProvenance;
27
- /**
28
- * The constructs whose loss actually breaks a message: the recipient reads
29
- * something different, in a different order, follows a link that does not work,
30
- * or sees a layout that has collapsed. A target client dropping one of these
31
- * blocks publication.
32
- *
33
- * The list is deliberately short and enumerated, because the contract is to
34
- * block *known* failures. Nonessential differences require an assessment of
35
- * emitted values: a concrete risk warns, expected differences and unverified
36
- * behavior remain compatibility observations.
37
- */
38
- declare const ESSENTIAL_CONSTRUCTS: ReadonlySet<string>;
39
- interface CompatibilityInput {
40
- /** The document the recipient receives. */
41
- readonly html: string;
42
- /** The declared fixture checked by this invocation. */
43
- readonly fixture?: string | undefined;
44
- /** Retained head rules, when they are not already inside the HTML. */
45
- readonly css?: string | undefined;
46
- /** Emitted-offset ranges with the origins of the node that produced them. */
47
- readonly positions?: readonly EmittedPosition[] | undefined;
48
- readonly clients?: readonly EmailClientTarget[] | undefined;
49
- }
50
- /**
51
- * Check the emitted document against the pinned matrix.
52
- *
53
- * Findings are grouped by construct rather than repeated per client, so one
54
- * unsupported property is one diagnostic naming every client that drops it.
55
- */
56
- declare const checkEmailCompatibility: (input: CompatibilityInput) => readonly EmailDiagnostic[];
57
- /**
58
- * Constructs the pinned data says nothing about for a target client. These are
59
- * reported so "we did not check that" is never mistaken for "that works".
60
- */
61
- declare const unknownCoverage: (titles: Iterable<string>) => readonly EmailDiagnostic[];
62
- /** A publication carrying one of these is refused; the message would arrive broken. */
63
- declare const hasBlockingCompatibility: (findings: readonly EmailDiagnostic[]) => boolean;
64
- //#endregion
65
- //#region src/email/tailwind.d.ts
66
- interface TailwindOptions {
67
- /**
68
- * Project CSS appended to the compiled entry: `@theme` overrides, `@utility`
69
- * definitions and ordinary rules. This is the project's pinned configuration.
70
- */
71
- readonly css?: string | undefined;
72
- /**
73
- * The project path `css` was read from (`theme.css` by default). Its
74
- * relative `@import`s resolve from this file's directory.
75
- */
76
- readonly cssPath?: string | undefined;
77
- /** Classes the compiler cannot discover, declared by the project on purpose. */
78
- readonly safelist?: readonly string[] | undefined;
79
- /** Tailwind's browser reset is off by default; email clients do not want it. */
80
- readonly preflight?: boolean | undefined;
81
- /**
82
- * Bounds on what the compiler may generate. Class discovery reads authored
83
- * source, so a project can hand it an unbounded candidate set and get an
84
- * unbounded stylesheet back — inside a build that has a wall clock and a
85
- * bundle a Worker then has to load. A host that publishes supplies these.
86
- */
87
- readonly limits?: TailwindLimits | undefined;
88
- }
89
- interface TailwindLimits {
90
- /** Distinct classes handed to the compiler. */
91
- readonly candidates: number;
92
- /** Bytes of generated CSS. */
93
- readonly cssBytes: number;
94
- }
95
- interface TailwindOutput {
96
- readonly css: string;
97
- readonly version: string;
98
- /** Every candidate handed to the compiler, sorted, for the build manifest. */
99
- readonly candidates: readonly string[];
100
- }
101
- /**
102
- * What the project theme's `@import`s resolve to, already checked by
103
- * `resolveThemeImports`: project stylesheets by path, and the brand theme
104
- * `samva:brand` stands for.
105
- */
106
- interface TailwindImports {
107
- readonly stylesheets: ReadonlyMap<string, string>;
108
- readonly brandCss?: string | undefined;
109
- }
110
- /** Compile the discovered class set into CSS with the pinned Tailwind release. */
111
- declare const compileTailwind: (candidates: Iterable<string>, options?: TailwindOptions, imports?: TailwindImports) => Promise<TailwindOutput>;
112
- interface ClassDiscovery {
113
- readonly candidates: readonly string[];
114
- readonly diagnostics: readonly EmailDiagnostic[];
115
- }
116
- /**
117
- * Collect the class names one module states literally, and report the positions
118
- * where a class is assembled from values the compiler cannot see.
119
- */
120
- declare const discoverClassCandidates: (source: string, fileName: string) => ClassDiscovery;
121
- //#endregion
122
- //#region src/email/transform.d.ts
123
- /** Where this build serves assets from, and how Tailwind is configured. */
124
- interface TransformOptions {
125
- readonly assetBase: string;
126
- /** `false` compiles no Tailwind at all. */
127
- readonly tailwind?: TailwindOptions | false | undefined;
128
- /**
129
- * The brand `samva:brand` resolves to, supplied by the host. A project that
130
- * imports `samva:brand` with no brand here fails to compile.
131
- */
132
- readonly brand?: EmailBrand | undefined;
133
- }
134
- interface ProjectTransform {
135
- readonly assets: readonly AssetEntry[];
136
- /** The compiled Tailwind sheet, when the project used any utility class. */
137
- readonly tailwindSheet: Stylesheet | undefined;
138
- /** Every project stylesheet, parsed, by path. */
139
- readonly stylesheets: ReadonlyMap<string, Stylesheet>;
140
- readonly diagnostics: readonly EmailDiagnostic[];
141
- }
142
- /**
143
- * The `samva:brand` specifier a project imports — from its theme's `@import`s
144
- * or its TSX — so a host can fetch that brand before it compiles. `undefined`
145
- * when the project imports no brand. A project that names two brands gets the
146
- * first here and a refusal from the compile.
147
- */
148
- declare const projectBrandSpecifier: (files: Readonly<Record<string, string | Uint8Array>>, themePath?: string) => string | undefined;
149
- /** Read a whole project, then compile the classes its scripts used. */
150
- declare const transformProject: (files: Readonly<Record<string, string | Uint8Array>>, options: TransformOptions) => Promise<ProjectTransform>;
151
- //#endregion
152
- export { checkEmailCompatibility as _, ClassDiscovery as a, TailwindOutput as c, COMPATIBILITY_PROVENANCE as d, CompatibilityInput as f, EmailClientTarget as g, ESSENTIAL_CONSTRUCTS as h, transformProject as i, compileTailwind as l, EMAIL_CLIENT_MATRIX as m, TransformOptions as n, TailwindLimits as o, CompatibilityProvenance as p, projectBrandSpecifier as r, TailwindOptions as s, ProjectTransform as t, discoverClassCandidates as u, hasBlockingCompatibility as v, unknownCoverage as y };
153
- //# sourceMappingURL=transform-Ct2OMkFN.d.ts.map
@@ -1,26 +0,0 @@
1
- //#region src/internal/unsubscribe-link.ts
2
- /**
3
- * Marks the one link the serializer lets carry the unsubscribe placeholder as
4
- * its href. Only `BrandFooter` sets it; nothing public exports it, so no
5
- * author-written link can claim the exemption.
6
- */
7
- const UNSUBSCRIBE_LINK = Symbol("samva.unsubscribe-link");
8
- /**
9
- * The per-recipient unsubscribe URL is not known at render: the send path
10
- * substitutes each delivery's link for this placeholder, or removes the
11
- * unsubscribe row when the send resolved no unsubscribe group.
12
- */
13
- const UNSUBSCRIBE_URL_PLACEHOLDER = "%samva:unsubscribe-url%";
14
- /**
15
- * Marks the elements `BrandFooter` writes the send path's footer markers on.
16
- * The serializer emits `data-samva-footer` and `data-samva-unsubscribe` only
17
- * for an element carrying it, so an author cannot claim a footer the send
18
- * path would then not append.
19
- */
20
- const BRAND_FOOTER_MARKER = Symbol("samva.brand-footer-marker");
21
- /** The attributes only `BrandFooter` writes. */
22
- const RESERVED_FOOTER_ATTRIBUTES = /* @__PURE__ */ new Set(["data-samva-footer", "data-samva-unsubscribe"]);
23
- //#endregion
24
- export { UNSUBSCRIBE_URL_PLACEHOLDER as i, RESERVED_FOOTER_ATTRIBUTES as n, UNSUBSCRIBE_LINK as r, BRAND_FOOTER_MARKER as t };
25
-
26
- //# sourceMappingURL=unsubscribe-link-CoesnQDU.js.map