@samva/markup 0.9.0 → 0.10.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/AGENTS.md +48 -40
- package/CHANGELOG.md +345 -0
- package/README.md +6 -6
- package/dist/{brand-B-0bN_Ir.d.ts → assets-BIsyMQ92.d.ts} +41 -11
- package/dist/{email/brand.js → brand-C0MKTwmX.js} +64 -4
- package/dist/{theme-css.d.ts → brand.d.ts} +12 -3
- package/dist/brand.js +4 -0
- package/dist/compiler.d.ts +231 -11
- package/dist/compiler.js +1312 -13
- package/dist/components-BZCqegS8.js +1864 -0
- package/dist/diagnostic-model-DJtqbETd.js +38 -0
- package/dist/diagnostic-model-DxthUZBT.d.ts +31 -0
- package/dist/{email/diagnostics.js → diagnostics-CnKFefKz.js} +2 -2
- package/dist/diagnostics.d.ts +406 -27
- package/dist/diagnostics.js +402 -34
- package/dist/edit.d.ts +234 -0
- package/dist/{channel-edit.js → edit.js} +341 -3
- package/dist/email/jsx-dev-runtime.d.ts +1 -1
- package/dist/email/jsx-dev-runtime.js +1 -2
- package/dist/email/jsx-runtime.d.ts +1 -1
- package/dist/email/jsx-runtime.js +1 -85
- package/dist/{email/components.d.ts → email.d.ts} +2 -2
- package/dist/email.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{cascade-t6kxlgEI.js → ir-CLhlklKV.js} +8 -4
- package/dist/jsx-runtime-CBlexoeR.js +98 -0
- package/dist/{elements-cqldpaJt.d.ts → jsx-runtime-ylIOnaSf.d.ts} +74 -74
- package/dist/{profile-BH-OtdDA.js → profile-pWGtWZXF.js} +153 -20
- package/dist/render-BPonDpCl.d.ts +539 -0
- package/dist/{email/render.js → render-BQmfh94k.js} +102 -8
- package/dist/render.d.ts +35 -0
- package/dist/render.js +49 -0
- package/dist/sms.d.ts +1 -1
- package/dist/sms.js +1 -1
- package/dist/{template-_QE_rQND.d.ts → template-DMPwxMSq.d.ts} +2 -2
- package/dist/{template.js → template-zLUjcwfF.js} +2 -2
- package/dist/{theme-css-hFqcPSar.js → theme-css-JtRCm1fb.js} +2 -2
- package/dist/whatsapp.d.ts +1 -1
- package/dist/whatsapp.js +1 -1
- package/generated/contract.json +16 -10
- package/generated/reference.md +17 -10
- package/package.json +36 -119
- package/samva-brand.d.ts +4 -4
- package/skills/sml/SKILL.md +2 -2
- package/dist/assets-C5duwTya.d.ts +0 -40
- package/dist/channel-edit.d.ts +0 -121
- package/dist/channel-specs-B6M_HlaV.js +0 -29
- package/dist/compatibility-DbISoFIq.js +0 -589
- package/dist/css-BVQKICKC.d.ts +0 -109
- package/dist/diagnostic-codes.d.ts +0 -403
- package/dist/diagnostic-codes.js +0 -399
- package/dist/email/assets.d.ts +0 -2
- package/dist/email/assets.js +0 -63
- package/dist/email/brand-footer.d.ts +0 -34
- package/dist/email/brand-footer.js +0 -63
- package/dist/email/brand.d.ts +0 -2
- package/dist/email/components.js +0 -275
- package/dist/email/diagnostics.d.ts +0 -2
- package/dist/email/elements.d.ts +0 -2
- package/dist/email/elements.js +0 -299
- package/dist/email/html.d.ts +0 -2
- package/dist/email/html.js +0 -321
- package/dist/email/render.d.ts +0 -40
- package/dist/email/text.d.ts +0 -7
- package/dist/email/text.js +0 -100
- package/dist/html-BJepOwZ4.d.ts +0 -56
- package/dist/ir-aaqNE987.d.ts +0 -252
- package/dist/ir.d.ts +0 -2
- package/dist/ir.js +0 -7
- package/dist/preview-Ekdg1dXG.d.ts +0 -100
- package/dist/preview.d.ts +0 -2
- package/dist/preview.js +0 -160
- package/dist/render-ir.d.ts +0 -19
- package/dist/render-ir.js +0 -826
- package/dist/sms-segments.d.ts +0 -13
- package/dist/sms-segments.js +0 -46
- package/dist/source-edit.d.ts +0 -116
- package/dist/source-edit.js +0 -343
- package/dist/source-locations.d.ts +0 -2
- package/dist/source-locations.js +0 -16
- package/dist/static.d.ts +0 -57
- package/dist/static.js +0 -69
- package/dist/tailwind-CMYpZf1v.js +0 -614
- package/dist/template.d.ts +0 -2
- package/dist/theme-css.js +0 -2
- package/dist/theme-imports-lvBw3AD1.js +0 -109
- package/dist/transform-Ct2OMkFN.d.ts +0 -153
|
@@ -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
|