@samva/markup 0.4.0 → 0.5.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 +17 -0
- package/dist/{ast-63I-VLQx.d.ts → ast-BLybiDxp.d.ts} +34 -60
- package/dist/ast.d.ts +2 -2
- package/dist/ast.js +4 -52
- package/dist/{catalog-Ck1tAGwO.d.ts → catalog-Db0UcCTg.d.ts} +2 -2
- package/dist/{checks-DXuERO4B.js → checks-CmmITP6j.js} +14 -14
- package/dist/checks.d.ts +1 -1
- package/dist/checks.js +1 -1
- package/dist/classes.d.ts +1 -1
- package/dist/compile-sms.d.ts +3 -3
- package/dist/compile-whatsapp.d.ts +5 -5
- package/dist/compile-whatsapp.js +3 -3
- package/dist/compile.d.ts +5 -5
- package/dist/compile.js +5 -5
- package/dist/compiler.d.ts +4 -4
- package/dist/compiler.js +6 -6
- package/dist/components.d.ts +4 -4
- package/dist/conditionals.js +3 -3
- package/dist/corpus-CM7rKX41.d.ts +106 -0
- package/dist/{css-ar2lU3NC.d.ts → css-DoNc7CiC.d.ts} +4 -5
- package/dist/diagnostics-CqepLcpI.d.ts +47 -0
- package/dist/diagnostics-eFM9A_TU.d.ts +46 -0
- package/dist/diagnostics.d.ts +2 -2
- package/dist/diagnostics.js +15 -29
- package/dist/{elements-DtwKlFVH.d.ts → elements-ChJULZlh.d.ts} +40 -161
- package/dist/email/components.d.ts +1 -1
- package/dist/email/diagnostics.d.ts +1 -1
- package/dist/email/diagnostics.js +8 -43
- package/dist/email/elements.d.ts +1 -1
- package/dist/email/html.d.ts +2 -2
- package/dist/email/html.js +9 -9
- package/dist/email/jsx-dev-runtime.d.ts +3 -21
- package/dist/email/jsx-runtime.d.ts +1 -1
- package/dist/email/jsx-runtime.js +29 -3
- package/dist/email/render.d.ts +4 -4
- package/dist/email/render.js +1 -1
- package/dist/email/selection.d.ts +20 -31
- package/dist/email/selection.js +1 -53
- package/dist/email/source-edit.d.ts +1 -1
- package/dist/email/source-edit.js +2 -2
- package/dist/email/stylesheets.d.ts +1 -1
- package/dist/email/text.d.ts +1 -1
- package/dist/email/text.js +3 -3
- package/dist/emit.d.ts +2 -2
- package/dist/emit.js +5 -5
- package/dist/guards-eV1qLbf2.js +9 -0
- package/dist/{input-schema-BIfzI63B.d.ts → input-schema-7dPFVvNE.d.ts} +2 -2
- package/dist/input-schema-zjkgrXn2.js +455 -0
- package/dist/input-schema.d.ts +1 -1
- package/dist/input-schema.js +1 -169
- package/dist/interpolate.d.ts +9 -12
- package/dist/interpolate.js +1 -19
- package/dist/jsx-dev-runtime.d.ts +2 -2
- package/dist/{jsx-runtime-C5k_Zq0A.d.ts → jsx-runtime-BI4gI19E.d.ts} +3 -3
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/jsx-runtime.js +3 -3
- package/dist/model.d.ts +18 -33
- package/dist/model.js +4 -17
- package/dist/ops.d.ts +78 -172
- package/dist/ops.js +51 -117
- package/dist/{parser-CGBS73Gz.d.ts → parser-b_Kp5MT6.d.ts} +5 -5
- package/dist/parser.d.ts +1 -1
- package/dist/parser.js +8 -8
- package/dist/{predicate-G2SeSvoN.d.ts → predicate-Bmvgw7Ao.d.ts} +4 -4
- package/dist/{predicate-CvkzT-a2.js → predicate-DwXzmqIY.js} +11 -11
- package/dist/predicate.d.ts +1 -1
- package/dist/predicate.js +1 -1
- package/dist/presets/category-mapping.d.ts +1 -1
- package/dist/presets/corpus.d.ts +1 -1
- package/dist/presets/corpus.js +74 -117
- package/dist/presets/public-gallery.d.ts +2 -2
- package/dist/presets/public-gallery.js +7 -7
- package/dist/presets/public-handoff.d.ts +4 -4
- package/dist/presets/public-handoff.js +10 -9
- package/dist/presets/public-preview-artifacts.d.ts +5 -5
- package/dist/presets/public-preview-artifacts.js +9 -9
- package/dist/presets/showcase.d.ts +1 -1
- package/dist/presets.d.ts +1 -1
- package/dist/printer.d.ts +1 -1
- package/dist/{render-ykQhtMs_.js → render-T6IFPnP4.js} +12 -12
- package/dist/render-template.d.ts +7 -7
- package/dist/render-template.js +6 -6
- package/dist/{showcase-C_xgl6hz.d.ts → showcase-dvJMn-Lo.d.ts} +2 -2
- package/dist/{source-locations-BCJQnIfU.d.ts → source-locations-D6Te6Gy1.d.ts} +4 -26
- package/dist/source-locations.d.ts +2 -2
- package/dist/source-locations.js +3 -26
- package/dist/{template-Dy5yOPyp.d.ts → template-G-QPcfmn.d.ts} +4 -4
- package/dist/template.d.ts +1 -1
- package/dist/template.js +3 -3
- package/dist/theme-css.d.ts +3 -3
- package/dist/theme-css.js +3 -3
- package/dist/tsx-source-instrumentation.d.ts +1 -3
- package/dist/tsx-source-instrumentation.js +6 -6
- package/dist/tsx-tracer.d.ts +7 -11
- package/dist/tsx-tracer.js +164 -164
- package/dist/{variables-if1VrV34.d.ts → variables-BnKs1iqb.d.ts} +2 -2
- package/dist/variables.d.ts +1 -1
- package/dist/variables.js +4 -4
- package/package.json +4 -3
- package/dist/corpus-U2EeALvS.d.ts +0 -234
- package/dist/diagnostics-Djd9ckLg.d.ts +0 -90
- package/dist/diagnostics-oveE-laV.d.ts +0 -79
package/AGENTS.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Samva Markup consumer guide
|
|
2
2
|
|
|
3
|
+
This package is plain TypeScript. It depends on no application runtime, so a template project
|
|
4
|
+
installs the compiler and nothing that comes with one. The structured SML surface — `parseSml`,
|
|
5
|
+
`compileSml`, `compileSource` — returns a better-result `Result` you branch on with `Result.isOk`
|
|
6
|
+
/ `Result.isErr`, carrying a `TaggedError` such as `SmlParseError` or `SmlCompileError` that you
|
|
7
|
+
discriminate by `_tag`. Email compilation reports through `EmailDiagnostic` values instead. A
|
|
8
|
+
declaration the compiler cannot accept at all throws a `TypeError`: a template id or fixture key
|
|
9
|
+
that is not one plain path segment, a nonportable input schema, a project holding a reserved
|
|
10
|
+
compiler path.
|
|
11
|
+
|
|
12
|
+
Markup's own data models are types and interfaces, not schema declarations, so there is no schema
|
|
13
|
+
library to adopt to consume them. Their unions discriminate on `type`: an `EmailNode` is `Text`,
|
|
14
|
+
`Element`, `Fragment` or `Raw`, and an `SmlOp` names its edit the same way.
|
|
15
|
+
Only the better-result error classes carry `_tag`. A template's JSON input contract is the one
|
|
16
|
+
exception to the no-schema rule, because it has to be checked against real input: `inputSchema`
|
|
17
|
+
accepts any Standard Schema through the `@standard-schema/spec` types and returns a portable JSON
|
|
18
|
+
Schema with its validator, so which schema library an author reaches for stays theirs.
|
|
19
|
+
|
|
3
20
|
Email entries default-export `defineEmail` definitions. SMS and WhatsApp use the structured
|
|
4
21
|
channel runtime at `@samva/markup` and components at `@samva/markup/components`.
|
|
5
22
|
Use documented package subpaths only. Template entry discovery is `.tsx` only.
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Schema } from "effect";
|
|
1
|
+
import { a as Span } from "./diagnostics-CqepLcpI.js";
|
|
3
2
|
//#region src/ast.d.ts
|
|
4
3
|
declare const BLOCK_TAGS: readonly ["Email", "Subject", "Preview", "Container", "Section", "Row", "Column", "Heading", "Text", "Button", "Image", "Divider", "Spacer", "List", "ListItem", "If", "Else"];
|
|
5
4
|
declare const INLINE_TAGS: readonly ["strong", "em", "a"];
|
|
@@ -41,74 +40,49 @@ declare const ROOT_TAGS: ReadonlyArray<RootTag>;
|
|
|
41
40
|
declare const isRootTag: (tag: string) => tag is RootTag;
|
|
42
41
|
/** The channel a parsed document targets, read off its root tag. */
|
|
43
42
|
declare const documentChannel: (document: SmlDocument) => Channel;
|
|
44
|
-
|
|
45
|
-
readonly kind:
|
|
46
|
-
readonly value:
|
|
47
|
-
}
|
|
48
|
-
readonly kind:
|
|
49
|
-
readonly value:
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
readonly
|
|
54
|
-
readonly value: Schema.Union<readonly [Schema.Struct<{
|
|
55
|
-
readonly kind: Schema.Literal<"string">;
|
|
56
|
-
readonly value: Schema.String;
|
|
57
|
-
}>, Schema.Struct<{
|
|
58
|
-
readonly kind: Schema.Literal<"number">;
|
|
59
|
-
readonly value: Schema.Finite;
|
|
60
|
-
}>]>;
|
|
43
|
+
type AttributeValue = {
|
|
44
|
+
readonly kind: "string";
|
|
45
|
+
readonly value: string;
|
|
46
|
+
} | {
|
|
47
|
+
readonly kind: "number";
|
|
48
|
+
readonly value: number;
|
|
49
|
+
};
|
|
50
|
+
interface Attribute {
|
|
51
|
+
readonly name: string;
|
|
52
|
+
readonly value: AttributeValue;
|
|
61
53
|
/** Span of the whole `name="value"` pair. */
|
|
62
|
-
readonly span:
|
|
63
|
-
readonly start: Schema.Finite;
|
|
64
|
-
readonly end: Schema.Finite;
|
|
65
|
-
}>;
|
|
54
|
+
readonly span: Span;
|
|
66
55
|
/** Span of the value contents (inside quotes/braces) — class diagnostics point here. */
|
|
67
|
-
readonly valueSpan:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
readonly
|
|
77
|
-
readonly
|
|
78
|
-
|
|
79
|
-
readonly end: Schema.Finite;
|
|
80
|
-
}>;
|
|
81
|
-
}>;
|
|
82
|
-
interface TextNode extends Schema.Schema.Type<typeof TextNodeSchema> {}
|
|
83
|
-
declare const InterpolationNodeSchema: Schema.Struct<{
|
|
84
|
-
readonly kind: Schema.Literal<"interpolation">;
|
|
85
|
-
readonly id: Schema.String;
|
|
86
|
-
readonly name: Schema.String;
|
|
56
|
+
readonly valueSpan: Span;
|
|
57
|
+
}
|
|
58
|
+
interface TextNode {
|
|
59
|
+
readonly kind: "text";
|
|
60
|
+
readonly id: string;
|
|
61
|
+
readonly value: string;
|
|
62
|
+
readonly span: Span;
|
|
63
|
+
}
|
|
64
|
+
interface InterpolationNode {
|
|
65
|
+
readonly kind: "interpolation";
|
|
66
|
+
readonly id: string;
|
|
67
|
+
readonly name: string;
|
|
87
68
|
/** {{name}} vs ${name} — both today's syntaxes, preserved through print. */
|
|
88
|
-
readonly syntax:
|
|
89
|
-
readonly span:
|
|
90
|
-
|
|
91
|
-
readonly end: Schema.Finite;
|
|
92
|
-
}>;
|
|
93
|
-
}>;
|
|
94
|
-
interface InterpolationNode extends Schema.Schema.Type<typeof InterpolationNodeSchema> {}
|
|
69
|
+
readonly syntax: "curly" | "dollar";
|
|
70
|
+
readonly span: Span;
|
|
71
|
+
}
|
|
95
72
|
interface ElementNode {
|
|
96
73
|
readonly kind: "element";
|
|
97
74
|
readonly id: string;
|
|
98
75
|
readonly tag: SmlTag;
|
|
99
76
|
readonly attributes: ReadonlyArray<Attribute>;
|
|
100
77
|
readonly children: ReadonlyArray<SmlNode>;
|
|
101
|
-
readonly span:
|
|
78
|
+
readonly span: Span;
|
|
102
79
|
}
|
|
103
80
|
type SmlNode = ElementNode | TextNode | InterpolationNode;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
declare const SmlDocumentSchema: Schema.Struct<{
|
|
107
|
-
readonly kind: Schema.Literal<"document">;
|
|
81
|
+
interface SmlDocument {
|
|
82
|
+
readonly kind: "document";
|
|
108
83
|
/** Always a root element: `<Email>`, `<Sms>`, or `<WhatsApp>`. */
|
|
109
|
-
readonly root:
|
|
110
|
-
}
|
|
111
|
-
interface SmlDocument extends Schema.Schema.Type<typeof SmlDocumentSchema> {}
|
|
84
|
+
readonly root: ElementNode;
|
|
85
|
+
}
|
|
112
86
|
declare const attributeValue: (node: ElementNode, name: string) => AttributeValue | undefined;
|
|
113
87
|
declare const stringAttribute: (node: ElementNode, name: string) => string | undefined;
|
|
114
88
|
declare const numberAttribute: (node: ElementNode, name: string) => number | undefined;
|
|
@@ -129,5 +103,5 @@ declare const isHiddenNode: (node: ElementNode) => boolean;
|
|
|
129
103
|
*/
|
|
130
104
|
declare const collectVariableReferences: (document: SmlDocument) => ReadonlySet<string>;
|
|
131
105
|
//#endregion
|
|
132
|
-
export {
|
|
133
|
-
//# sourceMappingURL=ast-
|
|
106
|
+
export { nodeLabel as A, TextNode as C, documentChannel as D, componentNameForSmlTag as E, smlTagForComponentName as M, stringAttribute as N, isHiddenNode as O, SmlTag as S, collectVariableReferences as T, RootTag as _, BLOCK_TAGS as a, SmlDocument as b, CHANNEL_TAGS as c, DEFAULT_EMAIL_WIDTH as d, ElementNode as f, ROOT_TAGS as g, InterpolationNode as h, AuxiliaryTag as i, numberAttribute as j, isRootTag as k, Channel as l, InlineTag as m, Attribute as n, BlockTag as o, INLINE_TAGS as p, AttributeValue as r, CHANNEL_BY_ROOT_TAG as s, AUXILIARY_TAGS as t, ChannelTag as u, SML_TAGS as v, attributeValue as w, SmlNode as x, SML_TAG_BY_COMPONENT_NAME as y };
|
|
107
|
+
//# sourceMappingURL=ast-BLybiDxp.d.ts.map
|
package/dist/ast.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
export { AUXILIARY_TAGS, Attribute,
|
|
1
|
+
import { A as nodeLabel, C as TextNode, D as documentChannel, E as componentNameForSmlTag, M as smlTagForComponentName, N as stringAttribute, O as isHiddenNode, S as SmlTag, T as collectVariableReferences, _ as RootTag, a as BLOCK_TAGS, b as SmlDocument, c as CHANNEL_TAGS, d as DEFAULT_EMAIL_WIDTH, f as ElementNode, g as ROOT_TAGS, h as InterpolationNode, i as AuxiliaryTag, j as numberAttribute, k as isRootTag, l as Channel, m as InlineTag, n as Attribute, o as BlockTag, p as INLINE_TAGS, r as AttributeValue, s as CHANNEL_BY_ROOT_TAG, t as AUXILIARY_TAGS, u as ChannelTag, v as SML_TAGS, w as attributeValue, x as SmlNode, y as SML_TAG_BY_COMPONENT_NAME } from "./ast-BLybiDxp.js";
|
|
2
|
+
export { AUXILIARY_TAGS, Attribute, AttributeValue, AuxiliaryTag, BLOCK_TAGS, BlockTag, CHANNEL_BY_ROOT_TAG, CHANNEL_TAGS, Channel, ChannelTag, DEFAULT_EMAIL_WIDTH, ElementNode, INLINE_TAGS, InlineTag, InterpolationNode, ROOT_TAGS, RootTag, SML_TAGS, SML_TAG_BY_COMPONENT_NAME, SmlDocument, SmlNode, SmlTag, TextNode, attributeValue, collectVariableReferences, componentNameForSmlTag, documentChannel, isHiddenNode, isRootTag, nodeLabel, numberAttribute, smlTagForComponentName, stringAttribute };
|
package/dist/ast.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Result, Schema } from "effect";
|
|
1
|
+
import { i as parsePredicate, n as collectPredicateVariables } from "./predicate-DwXzmqIY.js";
|
|
2
|
+
import { Result } from "better-result";
|
|
4
3
|
//#region src/ast.ts
|
|
5
4
|
const BLOCK_TAGS = [
|
|
6
5
|
"Email",
|
|
@@ -68,53 +67,6 @@ const ROOT_TAGS = Object.keys(CHANNEL_BY_ROOT_TAG);
|
|
|
68
67
|
const isRootTag = (tag) => tag in CHANNEL_BY_ROOT_TAG;
|
|
69
68
|
/** The channel a parsed document targets, read off its root tag. */
|
|
70
69
|
const documentChannel = (document) => CHANNEL_BY_ROOT_TAG[document.root.tag];
|
|
71
|
-
const AttributeValueSchema = Schema.Union([Schema.Struct({
|
|
72
|
-
kind: Schema.Literal("string"),
|
|
73
|
-
value: Schema.String
|
|
74
|
-
}), Schema.Struct({
|
|
75
|
-
kind: Schema.Literal("number"),
|
|
76
|
-
value: Schema.Finite
|
|
77
|
-
})]);
|
|
78
|
-
const AttributeSchema = Schema.Struct({
|
|
79
|
-
name: Schema.String,
|
|
80
|
-
value: AttributeValueSchema,
|
|
81
|
-
/** Span of the whole `name="value"` pair. */
|
|
82
|
-
span: SpanSchema,
|
|
83
|
-
/** Span of the value contents (inside quotes/braces) — class diagnostics point here. */
|
|
84
|
-
valueSpan: SpanSchema
|
|
85
|
-
});
|
|
86
|
-
const TextNodeSchema = Schema.Struct({
|
|
87
|
-
kind: Schema.Literal("text"),
|
|
88
|
-
id: Schema.String,
|
|
89
|
-
value: Schema.String,
|
|
90
|
-
span: SpanSchema
|
|
91
|
-
});
|
|
92
|
-
const InterpolationNodeSchema = Schema.Struct({
|
|
93
|
-
kind: Schema.Literal("interpolation"),
|
|
94
|
-
id: Schema.String,
|
|
95
|
-
name: Schema.String,
|
|
96
|
-
/** {{name}} vs ${name} — both today's syntaxes, preserved through print. */
|
|
97
|
-
syntax: Schema.Literals(["curly", "dollar"]),
|
|
98
|
-
span: SpanSchema
|
|
99
|
-
});
|
|
100
|
-
const ElementNodeSchema = Schema.Struct({
|
|
101
|
-
kind: Schema.Literal("element"),
|
|
102
|
-
id: Schema.String,
|
|
103
|
-
tag: Schema.Literals(SML_TAGS),
|
|
104
|
-
attributes: Schema.Array(AttributeSchema),
|
|
105
|
-
children: Schema.Array(Schema.suspend(() => SmlNodeSchema)),
|
|
106
|
-
span: SpanSchema
|
|
107
|
-
});
|
|
108
|
-
const SmlNodeSchema = Schema.Union([
|
|
109
|
-
ElementNodeSchema,
|
|
110
|
-
TextNodeSchema,
|
|
111
|
-
InterpolationNodeSchema
|
|
112
|
-
]);
|
|
113
|
-
const SmlDocumentSchema = Schema.Struct({
|
|
114
|
-
kind: Schema.Literal("document"),
|
|
115
|
-
/** Always a root element: `<Email>`, `<Sms>`, or `<WhatsApp>`. */
|
|
116
|
-
root: ElementNodeSchema
|
|
117
|
-
});
|
|
118
70
|
const attributeValue = (node, name) => node.attributes.find((attribute) => attribute.name === name)?.value;
|
|
119
71
|
const stringAttribute = (node, name) => {
|
|
120
72
|
const value = attributeValue(node, name);
|
|
@@ -153,7 +105,7 @@ const collectVariableReferences = (document) => {
|
|
|
153
105
|
if (attribute.value.kind !== "string") continue;
|
|
154
106
|
if (node.tag === "If" && attribute.name === "test") {
|
|
155
107
|
const parsed = parsePredicate(attribute.value.value);
|
|
156
|
-
if (Result.
|
|
108
|
+
if (Result.isOk(parsed)) for (const name of collectPredicateVariables(parsed.value)) names.add(name);
|
|
157
109
|
continue;
|
|
158
110
|
}
|
|
159
111
|
for (const match of attribute.value.value.matchAll(attributePattern)) {
|
|
@@ -167,6 +119,6 @@ const collectVariableReferences = (document) => {
|
|
|
167
119
|
return names;
|
|
168
120
|
};
|
|
169
121
|
//#endregion
|
|
170
|
-
export { AUXILIARY_TAGS,
|
|
122
|
+
export { AUXILIARY_TAGS, BLOCK_TAGS, CHANNEL_BY_ROOT_TAG, CHANNEL_TAGS, DEFAULT_EMAIL_WIDTH, INLINE_TAGS, ROOT_TAGS, SML_TAGS, SML_TAG_BY_COMPONENT_NAME, attributeValue, collectVariableReferences, componentNameForSmlTag, documentChannel, isHiddenNode, isRootTag, nodeLabel, numberAttribute, smlTagForComponentName, stringAttribute };
|
|
171
123
|
|
|
172
124
|
//# sourceMappingURL=ast.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { l as Channel } from "./ast-BLybiDxp.js";
|
|
2
2
|
import { o as TokenOverrides } from "./theme-6ApjjiBo.js";
|
|
3
3
|
//#region presets/catalog.d.ts
|
|
4
4
|
type PresetCategory = "transactional" | "digest" | "marketing" | "lifecycle";
|
|
@@ -353,4 +353,4 @@ type EmailPresetVariable = EmailPreset extends (infer Preset) ? Preset extends {
|
|
|
353
353
|
} ? Variable : never : never;
|
|
354
354
|
//#endregion
|
|
355
355
|
export { PresetMeta as a, presetCatalog as c, PresetId as i, EmailPresetVariable as n, PresetVariable as o, PresetCategory as r, RECOMMENDED_THEME as s, EmailPresetId as t };
|
|
356
|
-
//# sourceMappingURL=catalog-
|
|
356
|
+
//# sourceMappingURL=catalog-Db0UcCTg.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { formatDiagnostic } from "./diagnostics.js";
|
|
2
|
-
import { i as parsePredicate } from "./predicate-
|
|
2
|
+
import { i as parsePredicate } from "./predicate-DwXzmqIY.js";
|
|
3
3
|
import { stringAttribute } from "./ast.js";
|
|
4
4
|
import { parseCandidate, splitRoot } from "./candidate.js";
|
|
5
5
|
import { registryRoots, utilityRegistry } from "./registry.js";
|
|
@@ -7,7 +7,7 @@ import { resolveClasses } from "./classes.js";
|
|
|
7
7
|
import { decodeEntities } from "./lexer.js";
|
|
8
8
|
import { parseSml } from "./parser.js";
|
|
9
9
|
import { baseTokens } from "./tokens.js";
|
|
10
|
-
import { Result } from "
|
|
10
|
+
import { Result } from "better-result";
|
|
11
11
|
//#region src/caniemail-compact.ts
|
|
12
12
|
const caniemailCompactData = {
|
|
13
13
|
apiVersion: "1.0.4",
|
|
@@ -58604,7 +58604,7 @@ const DELIVERY_ASSET_ATTRIBUTES = {
|
|
|
58604
58604
|
*/
|
|
58605
58605
|
const checkDeliveryAssetDiagnostics = (source) => {
|
|
58606
58606
|
const parsed = parseSml(source);
|
|
58607
|
-
if (Result.
|
|
58607
|
+
if (Result.isError(parsed)) return [];
|
|
58608
58608
|
const diagnostics = [];
|
|
58609
58609
|
const visit = (node) => {
|
|
58610
58610
|
if (node.kind !== "element") return;
|
|
@@ -58621,7 +58621,7 @@ const checkDeliveryAssetDiagnostics = (source) => {
|
|
|
58621
58621
|
}
|
|
58622
58622
|
for (const child of node.children) visit(child);
|
|
58623
58623
|
};
|
|
58624
|
-
visit(parsed.
|
|
58624
|
+
visit(parsed.value.root);
|
|
58625
58625
|
return diagnostics;
|
|
58626
58626
|
};
|
|
58627
58627
|
function isBreakingCompatibilityCheck(message) {
|
|
@@ -58749,14 +58749,14 @@ const analyzeDocument = (document) => {
|
|
|
58749
58749
|
};
|
|
58750
58750
|
const analyzeSource = (source) => {
|
|
58751
58751
|
const parsed = parseSml(source);
|
|
58752
|
-
if (Result.
|
|
58752
|
+
if (Result.isError(parsed)) return {
|
|
58753
58753
|
featureSlugs: /* @__PURE__ */ new Set(),
|
|
58754
58754
|
hasDarkClasses: false,
|
|
58755
58755
|
hasImages: false,
|
|
58756
58756
|
hasPureBlackText: false,
|
|
58757
58757
|
styledElements: []
|
|
58758
58758
|
};
|
|
58759
|
-
return analyzeDocument(parsed.
|
|
58759
|
+
return analyzeDocument(parsed.value);
|
|
58760
58760
|
};
|
|
58761
58761
|
const collectPredicateVariableReferences = (ast) => {
|
|
58762
58762
|
const references = [];
|
|
@@ -58840,9 +58840,9 @@ const predicateDiagnosticMessages = (source, document, declaredVariables) => {
|
|
|
58840
58840
|
if (testAttribute?.value.kind === "string") {
|
|
58841
58841
|
const predicate = predicateSource(source, testAttribute);
|
|
58842
58842
|
const parsed = parsePredicate(predicate.text);
|
|
58843
|
-
if (Result.
|
|
58843
|
+
if (Result.isError(parsed)) for (const diagnostic of parsed.error) messages.push(`error: ${formatDiagnostic(source, predicate.mapDiagnostic(diagnostic))}`);
|
|
58844
58844
|
else if (declared !== void 0) {
|
|
58845
|
-
for (const reference of collectPredicateVariableReferences(parsed.
|
|
58845
|
+
for (const reference of collectPredicateVariableReferences(parsed.value)) if (!declared.has(reference.name)) messages.push(`error: ${formatDiagnostic(source, {
|
|
58846
58846
|
code: "predicate-unknown-variable",
|
|
58847
58847
|
message: `unknown predicate variable "${reference.name}" in <If test>`,
|
|
58848
58848
|
span: predicate.mapSpan(reference.span)
|
|
@@ -58857,8 +58857,8 @@ const predicateDiagnosticMessages = (source, document, declaredVariables) => {
|
|
|
58857
58857
|
};
|
|
58858
58858
|
const parseFailurePredicateMessages = (source) => {
|
|
58859
58859
|
const parsed = parseSml(source);
|
|
58860
|
-
if (Result.
|
|
58861
|
-
return parsed.
|
|
58860
|
+
if (Result.isOk(parsed)) return [];
|
|
58861
|
+
return parsed.error.diagnostics.filter((diagnostic) => diagnostic.code.startsWith("predicate-")).map((diagnostic) => `error: ${formatDiagnostic(source, diagnostic)}`);
|
|
58862
58862
|
};
|
|
58863
58863
|
const clientsByDarkBehavior = (profile, behavior) => profile.targets.filter((target) => target.darkBehavior === behavior).map(targetLabel).filter((label, index, labels) => labels.indexOf(label) === index);
|
|
58864
58864
|
const gmailForcedInvertClients = (profile) => profile.targets.filter((target) => target.family === "gmail" && target.darkBehavior === "force-inverts").map(targetLabel);
|
|
@@ -58941,10 +58941,10 @@ function worstCaseArtifactBytes(html) {
|
|
|
58941
58941
|
function checkSmlCompatibility(input) {
|
|
58942
58942
|
const profile = input.profile ?? DEFAULT_EMAIL_TARGET_CLIENT_PROFILE;
|
|
58943
58943
|
const parsed = parseSml(input.source);
|
|
58944
|
-
if (Result.
|
|
58945
|
-
const analysis = analyzeDocument(parsed.
|
|
58944
|
+
if (Result.isError(parsed)) return parseFailurePredicateMessages(input.source);
|
|
58945
|
+
const analysis = analyzeDocument(parsed.value);
|
|
58946
58946
|
return [
|
|
58947
|
-
...predicateDiagnosticMessages(input.source, parsed.
|
|
58947
|
+
...predicateDiagnosticMessages(input.source, parsed.value, input.declaredVariables),
|
|
58948
58948
|
...checkDeliveryAssetDiagnostics(input.source).map((diagnostic) => `error: ${formatDiagnostic(input.source, diagnostic)}`),
|
|
58949
58949
|
...caniemailMessages(analysis.featureSlugs, profile),
|
|
58950
58950
|
...darkModeMessages(analysis, profile)
|
|
@@ -58953,4 +58953,4 @@ function checkSmlCompatibility(input) {
|
|
|
58953
58953
|
//#endregion
|
|
58954
58954
|
export { isBreakingCompatibilityCheck as a, collectSmlFeatureSlugs as i, checkDeliveryAssetDiagnostics as n, worstCaseArtifactBytes as o, checkSmlCompatibility as r, DEFAULT_EMAIL_TARGET_CLIENT_PROFILE as t };
|
|
58955
58955
|
|
|
58956
|
-
//# sourceMappingURL=checks-
|
|
58956
|
+
//# sourceMappingURL=checks-CmmITP6j.js.map
|
package/dist/checks.d.ts
CHANGED
package/dist/checks.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as isBreakingCompatibilityCheck, i as collectSmlFeatureSlugs, n as checkDeliveryAssetDiagnostics, o as worstCaseArtifactBytes, r as checkSmlCompatibility, t as DEFAULT_EMAIL_TARGET_CLIENT_PROFILE } from "./checks-
|
|
1
|
+
import { a as isBreakingCompatibilityCheck, i as collectSmlFeatureSlugs, n as checkDeliveryAssetDiagnostics, o as worstCaseArtifactBytes, r as checkSmlCompatibility, t as DEFAULT_EMAIL_TARGET_CLIENT_PROFILE } from "./checks-CmmITP6j.js";
|
|
2
2
|
export { DEFAULT_EMAIL_TARGET_CLIENT_PROFILE, checkDeliveryAssetDiagnostics, checkSmlCompatibility, collectSmlFeatureSlugs, isBreakingCompatibilityCheck, worstCaseArtifactBytes };
|
package/dist/classes.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as Span, t as Diagnostic } from "./diagnostics-CqepLcpI.js";
|
|
2
2
|
import { s as TokenTable } from "./theme-6ApjjiBo.js";
|
|
3
3
|
import { Declaration } from "./registry.js";
|
|
4
4
|
//#region src/classes.d.ts
|
package/dist/compile-sms.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as Diagnostic } from "./diagnostics-
|
|
2
|
-
import {
|
|
3
|
-
import { a as SMS_TAG_SPECS } from "./parser-
|
|
1
|
+
import { t as Diagnostic } from "./diagnostics-CqepLcpI.js";
|
|
2
|
+
import { f as ElementNode } from "./ast-BLybiDxp.js";
|
|
3
|
+
import { a as SMS_TAG_SPECS } from "./parser-b_Kp5MT6.js";
|
|
4
4
|
import { t as SmsEncoding } from "./sms-segments-y4FpPilJ.js";
|
|
5
5
|
//#region src/compile-sms.d.ts
|
|
6
6
|
/** Documented worst-case rendered width of one `{{variable}}`. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { l as WHATSAPP_TAG_SPECS } from "./parser-
|
|
4
|
-
import { Result } from "
|
|
1
|
+
import { r as SmlCompileError, t as Diagnostic } from "./diagnostics-CqepLcpI.js";
|
|
2
|
+
import { f as ElementNode } from "./ast-BLybiDxp.js";
|
|
3
|
+
import { l as WHATSAPP_TAG_SPECS } from "./parser-b_Kp5MT6.js";
|
|
4
|
+
import { Result } from "better-result";
|
|
5
5
|
//#region src/compile-whatsapp.d.ts
|
|
6
6
|
type WhatsAppSpecs = typeof WHATSAPP_TAG_SPECS;
|
|
7
7
|
/** Mirrors whatsappTemplateCategoryEnum, derived from the grammar's closed set. */
|
|
@@ -50,7 +50,7 @@ interface CompiledWhatsApp {
|
|
|
50
50
|
readonly compilerVersion: string;
|
|
51
51
|
}
|
|
52
52
|
/** Root is a parsed `<WhatsApp>` element; the grammar already validated its anatomy. */
|
|
53
|
-
declare const compileWhatsAppRoot: (root: ElementNode) => Result
|
|
53
|
+
declare const compileWhatsAppRoot: (root: ElementNode) => Result<CompiledWhatsApp, SmlCompileError>;
|
|
54
54
|
//#endregion
|
|
55
55
|
export { CompiledWhatsApp, WhatsAppButtonPayload, WhatsAppExamples, WhatsAppHeaderMediaType, WhatsAppHeaderType, WhatsAppTemplateCategory, compileWhatsAppRoot };
|
|
56
56
|
//# sourceMappingURL=compile-whatsapp.d.ts.map
|
package/dist/compile-whatsapp.js
CHANGED
|
@@ -2,7 +2,7 @@ import { SmlCompileError } from "./diagnostics.js";
|
|
|
2
2
|
import { stringAttribute } from "./ast.js";
|
|
3
3
|
import { n as channelTextVariants, r as flattenChannelText, t as COMPILER_VERSION } from "./version-BITr58kk.js";
|
|
4
4
|
import { variableReferences } from "./interpolate.js";
|
|
5
|
-
import { Result } from "
|
|
5
|
+
import { Result } from "better-result";
|
|
6
6
|
//#region src/compile-whatsapp.ts
|
|
7
7
|
const WHATSAPP_BUTTON_LIMITS = {
|
|
8
8
|
URL: 2,
|
|
@@ -158,8 +158,8 @@ const compileWhatsAppRoot = (root) => {
|
|
|
158
158
|
message: "whatsapp mixes positional {{1}} and named {{var}} placeholders; Meta requires one style",
|
|
159
159
|
span: root.span
|
|
160
160
|
});
|
|
161
|
-
if (errors.length > 0) return Result.
|
|
162
|
-
return Result.
|
|
161
|
+
if (errors.length > 0) return Result.err(new SmlCompileError({ diagnostics: errors }));
|
|
162
|
+
return Result.ok({
|
|
163
163
|
channel: "whatsapp",
|
|
164
164
|
name: stringAttribute(root, "name"),
|
|
165
165
|
language: stringAttribute(root, "language"),
|
package/dist/compile.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { i as SmlParseError, r as SmlCompileError } from "./diagnostics-CqepLcpI.js";
|
|
2
|
+
import { b as SmlDocument } from "./ast-BLybiDxp.js";
|
|
3
3
|
import { CompiledSms } from "./compile-sms.js";
|
|
4
4
|
import { CompiledWhatsApp } from "./compile-whatsapp.js";
|
|
5
|
-
import { Result } from "
|
|
5
|
+
import { Result } from "better-result";
|
|
6
6
|
//#region src/version.d.ts
|
|
7
7
|
declare const COMPILER_VERSION = "0.1.0";
|
|
8
8
|
//#endregion
|
|
@@ -10,9 +10,9 @@ declare const COMPILER_VERSION = "0.1.0";
|
|
|
10
10
|
/** Structured channel payloads compiled from recorded SML. */
|
|
11
11
|
type CompiledTemplate = CompiledSms | CompiledWhatsApp;
|
|
12
12
|
/** Compile a structured document; email definitions execute through the email runtime. */
|
|
13
|
-
declare const compileSml: (document: SmlDocument) => Result
|
|
13
|
+
declare const compileSml: (document: SmlDocument) => Result<CompiledTemplate, SmlCompileError>;
|
|
14
14
|
/** Parse and compile a structured SMS or WhatsApp document. */
|
|
15
|
-
declare const compileSource: (source: string) => Result
|
|
15
|
+
declare const compileSource: (source: string) => Result<CompiledTemplate, SmlParseError | SmlCompileError>;
|
|
16
16
|
//#endregion
|
|
17
17
|
export { COMPILER_VERSION, CompiledTemplate, compileSml, compileSource };
|
|
18
18
|
//# sourceMappingURL=compile.d.ts.map
|
package/dist/compile.js
CHANGED
|
@@ -3,14 +3,14 @@ import { parseSml } from "./parser.js";
|
|
|
3
3
|
import { t as COMPILER_VERSION } from "./version-BITr58kk.js";
|
|
4
4
|
import { compileSmsRoot } from "./compile-sms.js";
|
|
5
5
|
import { compileWhatsAppRoot } from "./compile-whatsapp.js";
|
|
6
|
-
import { Result } from "
|
|
6
|
+
import { Result } from "better-result";
|
|
7
7
|
//#region src/compile.ts
|
|
8
8
|
/** Compile a structured document; email definitions execute through the email runtime. */
|
|
9
9
|
const compileSml = (document) => {
|
|
10
10
|
switch (document.root.tag) {
|
|
11
|
-
case "Sms": return Result.
|
|
11
|
+
case "Sms": return Result.ok(compileSmsRoot(document.root));
|
|
12
12
|
case "WhatsApp": return compileWhatsAppRoot(document.root);
|
|
13
|
-
default: return Result.
|
|
13
|
+
default: return Result.err(new SmlCompileError({ diagnostics: [{
|
|
14
14
|
code: "email-requires-object-template",
|
|
15
15
|
message: "Email templates must default-export defineEmail with an input schema and fixtures.",
|
|
16
16
|
span: document.root.span
|
|
@@ -20,8 +20,8 @@ const compileSml = (document) => {
|
|
|
20
20
|
/** Parse and compile a structured SMS or WhatsApp document. */
|
|
21
21
|
const compileSource = (source) => {
|
|
22
22
|
const parsed = parseSml(source);
|
|
23
|
-
if (Result.
|
|
24
|
-
return compileSml(parsed.
|
|
23
|
+
if (Result.isError(parsed)) return Result.err(parsed.error);
|
|
24
|
+
return compileSml(parsed.value);
|
|
25
25
|
};
|
|
26
26
|
//#endregion
|
|
27
27
|
export { COMPILER_VERSION, compileSml, compileSource };
|
package/dist/compiler.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { a as formatEmailDiagnostic, i as EmailDiagnosticSeverity, n as EmailCompileError, o as hasBlockingDiagnostic, r as EmailDiagnostic } from "./diagnostics-
|
|
2
|
-
import { a as EmailGlobalProps, c as EmailStyle, d as isUrlAttribute, i as EmailElementSpec, l as EmailTag, m as EmailNode, n as EMAIL_GLOBAL_ATTRIBUTES, o as EmailIntrinsicElements, r as EmailAttributeSpec, s as EmailLayout, t as EMAIL_ELEMENTS, u as emailElement } from "./elements-
|
|
1
|
+
import { a as formatEmailDiagnostic, i as EmailDiagnosticSeverity, n as EmailCompileError, o as hasBlockingDiagnostic, r as EmailDiagnostic } from "./diagnostics-eFM9A_TU.js";
|
|
2
|
+
import { a as EmailGlobalProps, c as EmailStyle, d as isUrlAttribute, i as EmailElementSpec, l as EmailTag, m as EmailNode, n as EMAIL_GLOBAL_ATTRIBUTES, o as EmailIntrinsicElements, r as EmailAttributeSpec, s as EmailLayout, t as EMAIL_ELEMENTS, u as emailElement } from "./elements-ChJULZlh.js";
|
|
3
3
|
import { EmailElementSelection, EmittedPosition, INSTANCE_PATH_ATTRIBUTE, emailAuthoringTarget, emailDefinitionInstances, emailSelectionAncestry, emailSelectionIndex, emailSelectionSiblings, emailSelections } from "./email/selection.js";
|
|
4
4
|
import { EmailHtmlOutput, SerializeEmailOptions, escapeAttribute, escapeText, serializeEmailHtml } from "./email/html.js";
|
|
5
5
|
import { deriveEmailText } from "./email/text.js";
|
|
6
|
-
import { a as compileSelector, c as CompiledSelector, d as matchesSelector, i as Stylesheet, l as Compound, n as CssRule, o as parseStylesheet, r as Specificity, s as Ancestry, t as CssDeclaration, u as classListOf } from "./css-
|
|
6
|
+
import { a as compileSelector, c as CompiledSelector, d as matchesSelector, i as Stylesheet, l as Compound, n as CssRule, o as parseStylesheet, r as Specificity, s as Ancestry, t as CssDeclaration, u as classListOf } from "./css-DoNc7CiC.js";
|
|
7
7
|
import { EMAIL_DOCTYPE, EmailCompileOutput, RenderedEmail, compileEmail, renderEmail } from "./email/render.js";
|
|
8
8
|
import { collectStylesheets, hasStylesheets, registerStylesheet, resetStylesheets } from "./email/stylesheets.js";
|
|
9
9
|
import { instrumentTsxSourceForPreview } from "./tsx-source-instrumentation.js";
|
|
@@ -299,5 +299,5 @@ interface CompiledEmailProject {
|
|
|
299
299
|
*/
|
|
300
300
|
declare const compileEmailProject: (source: Readonly<Record<string, string | Uint8Array>>, authoredEntry: string, options: TransformOptions) => Promise<CompiledEmailProject>;
|
|
301
301
|
//#endregion
|
|
302
|
-
export { ASSET_CONTENT_TYPES, type Ancestry, type AppliedStyles, type AssetEntry, type AssetManifest, COMPATIBILITY_PROVENANCE, type ClassDiscovery, type CompatibilityInput, type CompatibilityProvenance, type CompiledEmailProject, type CompiledSelector, type Compound, type CssDeclaration, type CssRule, EMAIL_CLIENT_MATRIX, EMAIL_DOCTYPE, EMAIL_ELEMENTS, EMAIL_ENTRY_WRAPPER, EMAIL_GLOBAL_ATTRIBUTES, EMAIL_RESET_MODULE, ESSENTIAL_CONSTRUCTS, type EmailAttributeSpec, type EmailClientTarget, EmailCompileError, type EmailCompileOutput, EmailDiagnostic, EmailDiagnosticSeverity, EmailElementSelection, type EmailElementSpec, type EmailGlobalProps, type EmailHtmlOutput, type EmailIntrinsicElements, type EmailLayout, type EmailStyle, type EmailTag, EmittedPosition, INSTANCE_PATH_ATTRIBUTE, type ModuleTransform, type ProjectTransform, type RenderedEmail, type SerializeEmailOptions, type Specificity, type Stylesheet, TAILWIND_MODULE_PATH, TAILWIND_VERSION, type TailwindLimits, type TailwindOptions, type TailwindOutput, type TransformOptions, applyStylesheet, assetEntry, assetUrl, checkAssetBase, checkEmailCompatibility, classListOf, collectStylesheets, compileEmail, compileEmailProject, compileSelector, compileTailwind, deriveEmailText, discoverClassCandidates, downlevelColors, downlevelMediaQuery, emailAuthoringTarget, emailDefinitionInstances, emailElement, emailEntryWrapper, emailResetModule, emailSelectionAncestry, emailSelectionIndex, emailSelectionSiblings, emailSelections, escapeAttribute, escapeText, finalizeValue, foldCalc, formatColor, formatEmailDiagnostic, hasBlockingCompatibility, hasBlockingDiagnostic, hasStylesheets, instrumentTsxSourceForPreview, isAssetPath, isExternalAsset, isUrlAttribute, matchesSelector, parseColor, parseStylesheet, registerStylesheet, renderEmail, renderHeadCss, resetStylesheets, resolveVariables, serializeEmailHtml, tailwindSpecifierFor, transformModule, transformProject, unknownCoverage, withLeadingImport };
|
|
302
|
+
export { ASSET_CONTENT_TYPES, type Ancestry, type AppliedStyles, type AssetEntry, type AssetManifest, COMPATIBILITY_PROVENANCE, type ClassDiscovery, type CompatibilityInput, type CompatibilityProvenance, type CompiledEmailProject, type CompiledSelector, type Compound, type CssDeclaration, type CssRule, EMAIL_CLIENT_MATRIX, EMAIL_DOCTYPE, EMAIL_ELEMENTS, EMAIL_ENTRY_WRAPPER, EMAIL_GLOBAL_ATTRIBUTES, EMAIL_RESET_MODULE, ESSENTIAL_CONSTRUCTS, type EmailAttributeSpec, type EmailClientTarget, EmailCompileError, type EmailCompileOutput, type EmailDiagnostic, type EmailDiagnosticSeverity, type EmailElementSelection, type EmailElementSpec, type EmailGlobalProps, type EmailHtmlOutput, type EmailIntrinsicElements, type EmailLayout, type EmailStyle, type EmailTag, type EmittedPosition, INSTANCE_PATH_ATTRIBUTE, type ModuleTransform, type ProjectTransform, type RenderedEmail, type SerializeEmailOptions, type Specificity, type Stylesheet, TAILWIND_MODULE_PATH, TAILWIND_VERSION, type TailwindLimits, type TailwindOptions, type TailwindOutput, type TransformOptions, applyStylesheet, assetEntry, assetUrl, checkAssetBase, checkEmailCompatibility, classListOf, collectStylesheets, compileEmail, compileEmailProject, compileSelector, compileTailwind, deriveEmailText, discoverClassCandidates, downlevelColors, downlevelMediaQuery, emailAuthoringTarget, emailDefinitionInstances, emailElement, emailEntryWrapper, emailResetModule, emailSelectionAncestry, emailSelectionIndex, emailSelectionSiblings, emailSelections, escapeAttribute, escapeText, finalizeValue, foldCalc, formatColor, formatEmailDiagnostic, hasBlockingCompatibility, hasBlockingDiagnostic, hasStylesheets, instrumentTsxSourceForPreview, isAssetPath, isExternalAsset, isUrlAttribute, matchesSelector, parseColor, parseStylesheet, registerStylesheet, renderEmail, renderHeadCss, resetStylesheets, resolveVariables, serializeEmailHtml, tailwindSpecifierFor, transformModule, transformProject, unknownCoverage, withLeadingImport };
|
|
303
303
|
//# sourceMappingURL=compiler.d.ts.map
|
package/dist/compiler.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as isObject } from "./guards-eV1qLbf2.js";
|
|
2
|
+
import { a as applyStylesheet, c as downlevelMediaQuery, d as renderHeadCss, f as resolveVariables, i as renderEmail, l as finalizeValue, o as classListOf, r as compileEmail, s as matchesSelector, t as EMAIL_DOCTYPE, u as foldCalc } from "./render-T6IFPnP4.js";
|
|
2
3
|
import { EMAIL_ELEMENTS, EMAIL_GLOBAL_ATTRIBUTES, emailElement, isUrlAttribute } from "./email/elements.js";
|
|
3
|
-
import {
|
|
4
|
+
import { INSTANCE_PATH_ATTRIBUTE, emailAuthoringTarget, emailDefinitionInstances, emailSelectionAncestry, emailSelectionIndex, emailSelectionSiblings, emailSelections } from "./email/selection.js";
|
|
4
5
|
import { escapeAttribute, escapeText, serializeEmailHtml } from "./email/html.js";
|
|
5
|
-
import { EmailCompileError,
|
|
6
|
+
import { EmailCompileError, formatEmailDiagnostic, hasBlockingDiagnostic } from "./email/diagnostics.js";
|
|
6
7
|
import { collectStylesheets, hasStylesheets, registerStylesheet, resetStylesheets } from "./email/stylesheets.js";
|
|
7
8
|
import { deriveEmailText } from "./email/text.js";
|
|
8
9
|
import { buildLineMap, lineColumn } from "./diagnostics.js";
|
|
9
10
|
import { instrumentTsxSourceForPreview } from "./tsx-source-instrumentation.js";
|
|
10
|
-
import { Predicate } from "effect";
|
|
11
11
|
import { parse } from "@babel/parser";
|
|
12
12
|
import { caniemail, parseHtml, rawData } from "caniemail";
|
|
13
13
|
import { generate, ident, parse as parse$1, walk } from "css-tree";
|
|
@@ -1134,7 +1134,7 @@ const compileTailwind = async (candidates, options = {}) => {
|
|
|
1134
1134
|
candidates: all
|
|
1135
1135
|
};
|
|
1136
1136
|
};
|
|
1137
|
-
const isRecord = (value) =>
|
|
1137
|
+
const isRecord = (value) => isObject(value) && !Array.isArray(value);
|
|
1138
1138
|
const isAstNode = (value) => isRecord(value) && typeof value.type === "string" && typeof value.start === "number" && typeof value.end === "number";
|
|
1139
1139
|
const walk$1 = (value, visit) => {
|
|
1140
1140
|
if (Array.isArray(value)) {
|
|
@@ -1385,6 +1385,6 @@ const compileEmailProject = async (source, authoredEntry, options) => {
|
|
|
1385
1385
|
};
|
|
1386
1386
|
};
|
|
1387
1387
|
//#endregion
|
|
1388
|
-
export { ASSET_CONTENT_TYPES, COMPATIBILITY_PROVENANCE, EMAIL_CLIENT_MATRIX, EMAIL_DOCTYPE, EMAIL_ELEMENTS, EMAIL_ENTRY_WRAPPER, EMAIL_GLOBAL_ATTRIBUTES, EMAIL_RESET_MODULE, ESSENTIAL_CONSTRUCTS, EmailCompileError,
|
|
1388
|
+
export { ASSET_CONTENT_TYPES, COMPATIBILITY_PROVENANCE, EMAIL_CLIENT_MATRIX, EMAIL_DOCTYPE, EMAIL_ELEMENTS, EMAIL_ENTRY_WRAPPER, EMAIL_GLOBAL_ATTRIBUTES, EMAIL_RESET_MODULE, ESSENTIAL_CONSTRUCTS, EmailCompileError, INSTANCE_PATH_ATTRIBUTE, TAILWIND_MODULE_PATH, TAILWIND_VERSION, applyStylesheet, assetEntry, assetUrl, checkAssetBase, checkEmailCompatibility, classListOf, collectStylesheets, compileEmail, compileEmailProject, compileSelector, compileTailwind, deriveEmailText, discoverClassCandidates, downlevelColors, downlevelMediaQuery, emailAuthoringTarget, emailDefinitionInstances, emailElement, emailEntryWrapper, emailResetModule, emailSelectionAncestry, emailSelectionIndex, emailSelectionSiblings, emailSelections, escapeAttribute, escapeText, finalizeValue, foldCalc, formatColor, formatEmailDiagnostic, hasBlockingCompatibility, hasBlockingDiagnostic, hasStylesheets, instrumentTsxSourceForPreview, isAssetPath, isExternalAsset, isUrlAttribute, matchesSelector, parseColor, parseStylesheet, registerStylesheet, renderEmail, renderHeadCss, resetStylesheets, resolveVariables, serializeEmailHtml, tailwindSpecifierFor, transformModule, transformProject, unknownCoverage, withLeadingImport };
|
|
1389
1389
|
|
|
1390
1390
|
//# sourceMappingURL=compiler.js.map
|
package/dist/components.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as EMAIL_TAG_SPECS, l as WHATSAPP_TAG_SPECS, o as TagSpec, t as AttributeSpec } from "./parser-
|
|
3
|
-
import { r as PredicateRef, s as VariableRef } from "./variables-
|
|
4
|
-
import { s as SmlChildren } from "./jsx-runtime-
|
|
1
|
+
import { f as ElementNode } from "./ast-BLybiDxp.js";
|
|
2
|
+
import { i as EMAIL_TAG_SPECS, l as WHATSAPP_TAG_SPECS, o as TagSpec, t as AttributeSpec } from "./parser-b_Kp5MT6.js";
|
|
3
|
+
import { r as PredicateRef, s as VariableRef } from "./variables-BnKs1iqb.js";
|
|
4
|
+
import { s as SmlChildren } from "./jsx-runtime-BI4gI19E.js";
|
|
5
5
|
//#region src/components.d.ts
|
|
6
6
|
/**
|
|
7
7
|
* The scalar type an attribute spec accepts. `level` narrows to the Heading
|
package/dist/conditionals.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as parsePredicate, r as evaluatePredicate } from "./predicate-
|
|
2
|
-
import { Result } from "
|
|
1
|
+
import { i as parsePredicate, r as evaluatePredicate } from "./predicate-DwXzmqIY.js";
|
|
2
|
+
import { Result } from "better-result";
|
|
3
3
|
//#region src/conditionals.ts
|
|
4
4
|
const IF_MARKER = "<!--sml:if:";
|
|
5
5
|
const MARKER_CLOSE = "-->";
|
|
@@ -20,7 +20,7 @@ const resolve = (content, variables) => {
|
|
|
20
20
|
const elseCandidate = content.indexOf(elseMarker, bodyStart);
|
|
21
21
|
const elseIndex = elseCandidate !== -1 && elseCandidate < endIndex ? elseCandidate : -1;
|
|
22
22
|
const parsed = parsePredicate(predicateSource);
|
|
23
|
-
const condition = Result.
|
|
23
|
+
const condition = Result.isOk(parsed) && evaluatePredicate(parsed.value, variables);
|
|
24
24
|
const branchA = content.slice(bodyStart, elseIndex === -1 ? endIndex : elseIndex);
|
|
25
25
|
const branchB = elseIndex === -1 ? "" : content.slice(elseIndex + elseMarker.length, endIndex);
|
|
26
26
|
const selected = resolve(condition ? branchA : branchB, variables).trim();
|