@samva/markup 0.3.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.
Files changed (108) hide show
  1. package/AGENTS.md +17 -0
  2. package/dist/{ast-63I-VLQx.d.ts → ast-BLybiDxp.d.ts} +34 -60
  3. package/dist/ast.d.ts +2 -2
  4. package/dist/ast.js +4 -52
  5. package/dist/catalog-Db0UcCTg.d.ts +356 -0
  6. package/dist/{checks-DXuERO4B.js → checks-CmmITP6j.js} +14 -14
  7. package/dist/checks.d.ts +1 -1
  8. package/dist/checks.js +1 -1
  9. package/dist/classes.d.ts +1 -1
  10. package/dist/compile-sms.d.ts +3 -3
  11. package/dist/compile-whatsapp.d.ts +5 -5
  12. package/dist/compile-whatsapp.js +3 -3
  13. package/dist/compile.d.ts +5 -5
  14. package/dist/compile.js +5 -5
  15. package/dist/compiler.d.ts +4 -4
  16. package/dist/compiler.js +6 -6
  17. package/dist/components.d.ts +4 -4
  18. package/dist/conditionals.js +3 -3
  19. package/dist/corpus-CM7rKX41.d.ts +106 -0
  20. package/dist/{css-ar2lU3NC.d.ts → css-DoNc7CiC.d.ts} +4 -5
  21. package/dist/diagnostics-CqepLcpI.d.ts +47 -0
  22. package/dist/diagnostics-eFM9A_TU.d.ts +46 -0
  23. package/dist/diagnostics.d.ts +2 -2
  24. package/dist/diagnostics.js +15 -29
  25. package/dist/{elements-DtwKlFVH.d.ts → elements-ChJULZlh.d.ts} +40 -161
  26. package/dist/email/components.d.ts +1 -1
  27. package/dist/email/diagnostics.d.ts +1 -1
  28. package/dist/email/diagnostics.js +8 -43
  29. package/dist/email/elements.d.ts +1 -1
  30. package/dist/email/html.d.ts +2 -2
  31. package/dist/email/html.js +9 -9
  32. package/dist/email/jsx-dev-runtime.d.ts +3 -21
  33. package/dist/email/jsx-runtime.d.ts +1 -1
  34. package/dist/email/jsx-runtime.js +29 -3
  35. package/dist/email/render.d.ts +4 -4
  36. package/dist/email/render.js +1 -1
  37. package/dist/email/selection.d.ts +20 -31
  38. package/dist/email/selection.js +1 -53
  39. package/dist/email/source-edit.d.ts +1 -1
  40. package/dist/email/source-edit.js +2 -2
  41. package/dist/email/stylesheets.d.ts +1 -1
  42. package/dist/email/text.d.ts +1 -1
  43. package/dist/email/text.js +3 -3
  44. package/dist/emit.d.ts +2 -2
  45. package/dist/emit.js +5 -5
  46. package/dist/guards-eV1qLbf2.js +9 -0
  47. package/dist/{input-schema-BIfzI63B.d.ts → input-schema-7dPFVvNE.d.ts} +2 -2
  48. package/dist/input-schema-zjkgrXn2.js +455 -0
  49. package/dist/input-schema.d.ts +1 -1
  50. package/dist/input-schema.js +1 -169
  51. package/dist/interpolate.d.ts +9 -12
  52. package/dist/interpolate.js +1 -19
  53. package/dist/jsx-dev-runtime.d.ts +2 -2
  54. package/dist/{jsx-runtime-C5k_Zq0A.d.ts → jsx-runtime-BI4gI19E.d.ts} +3 -3
  55. package/dist/jsx-runtime.d.ts +1 -1
  56. package/dist/jsx-runtime.js +3 -3
  57. package/dist/model.d.ts +18 -33
  58. package/dist/model.js +4 -17
  59. package/dist/ops.d.ts +78 -172
  60. package/dist/ops.js +51 -117
  61. package/dist/{parser-CGBS73Gz.d.ts → parser-b_Kp5MT6.d.ts} +5 -5
  62. package/dist/parser.d.ts +1 -1
  63. package/dist/parser.js +8 -8
  64. package/dist/{predicate-G2SeSvoN.d.ts → predicate-Bmvgw7Ao.d.ts} +4 -4
  65. package/dist/{predicate-CvkzT-a2.js → predicate-DwXzmqIY.js} +11 -11
  66. package/dist/predicate.d.ts +1 -1
  67. package/dist/predicate.js +1 -1
  68. package/dist/presets/category-mapping.d.ts +1 -1
  69. package/dist/presets/corpus.d.ts +1 -1
  70. package/dist/presets/corpus.js +87 -140
  71. package/dist/presets/public-gallery.d.ts +106 -130
  72. package/dist/presets/public-gallery.js +131 -209
  73. package/dist/presets/public-handoff.d.ts +4 -4
  74. package/dist/presets/public-handoff.js +13 -11
  75. package/dist/presets/public-preview-artifacts.d.ts +5 -5
  76. package/dist/presets/public-preview-artifacts.js +9 -9
  77. package/dist/presets/public-preview.d.ts +0 -4
  78. package/dist/presets/public-preview.js +37 -362
  79. package/dist/presets/showcase.d.ts +2 -0
  80. package/dist/presets/showcase.js +627 -0
  81. package/dist/presets/sources.d.ts +1 -1
  82. package/dist/presets/sources.js +5767 -2023
  83. package/dist/presets.d.ts +2 -384
  84. package/dist/presets.js +299 -765
  85. package/dist/printer.d.ts +1 -1
  86. package/dist/{render-ykQhtMs_.js → render-T6IFPnP4.js} +12 -12
  87. package/dist/render-template.d.ts +7 -7
  88. package/dist/render-template.js +6 -6
  89. package/dist/showcase-dvJMn-Lo.d.ts +456 -0
  90. package/dist/{source-locations-BCJQnIfU.d.ts → source-locations-D6Te6Gy1.d.ts} +4 -26
  91. package/dist/source-locations.d.ts +2 -2
  92. package/dist/source-locations.js +3 -26
  93. package/dist/{template-Dy5yOPyp.d.ts → template-G-QPcfmn.d.ts} +4 -4
  94. package/dist/template.d.ts +1 -1
  95. package/dist/template.js +3 -3
  96. package/dist/theme-css.d.ts +3 -3
  97. package/dist/theme-css.js +3 -3
  98. package/dist/tsx-source-instrumentation.d.ts +1 -3
  99. package/dist/tsx-source-instrumentation.js +6 -6
  100. package/dist/tsx-tracer.d.ts +7 -11
  101. package/dist/tsx-tracer.js +164 -164
  102. package/dist/{variables-if1VrV34.d.ts → variables-BnKs1iqb.d.ts} +2 -2
  103. package/dist/variables.d.ts +1 -1
  104. package/dist/variables.js +4 -4
  105. package/package.json +8 -3
  106. package/dist/corpus-qrUD5O6r.d.ts +0 -254
  107. package/dist/diagnostics-Djd9ckLg.d.ts +0 -90
  108. package/dist/diagnostics-oveE-laV.d.ts +0 -79
@@ -1,169 +1,48 @@
1
- import { i as JsxSourceLocation } from "./source-locations-BCJQnIfU.js";
2
- import { r as EmailDiagnostic } from "./diagnostics-Djd9ckLg.js";
3
- import { Data } from "effect";
1
+ import { i as JsxSourceLocation } from "./source-locations-D6Te6Gy1.js";
2
+ import { r as EmailDiagnostic } from "./diagnostics-eFM9A_TU.js";
4
3
  //#region src/email/jsx-runtime.d.ts
5
4
  /** Derived authoring tree; source stays canonical. Origins run from inner element to component call sites. */
6
- type EmailNode = Data.TaggedEnum<{
7
- Text: {
8
- readonly value: string;
9
- };
10
- Element: {
11
- readonly tag: string;
12
- readonly props: Readonly<Record<string, unknown>>;
13
- readonly children: readonly EmailNode[];
14
- readonly origins: readonly JsxSourceLocation[];
15
- /**
16
- * True when this element is written at `origins[0]`; false when a compiler
17
- * primitive generated it and `origins[0]` is the call site that asked for
18
- * it. Both point at the same authoring target, but only an authored element
19
- * can have its own props edited there.
20
- */
21
- readonly authored: boolean;
22
- };
23
- Fragment: {
24
- readonly children: readonly EmailNode[];
25
- };
5
+ type EmailNode = {
6
+ readonly type: "Text";
7
+ readonly value: string;
8
+ } | {
9
+ readonly type: "Element";
10
+ readonly tag: string;
11
+ readonly props: Readonly<Record<string, unknown>>;
12
+ readonly children: readonly EmailNode[];
13
+ readonly origins: readonly JsxSourceLocation[];
26
14
  /**
27
- * Compatibility markup a compiler primitive emits verbatim — conditional
28
- * comments and VML. Only the primitives in `./components` construct it;
29
- * nothing an author passes as a string reaches this node.
15
+ * True when this element is written at `origins[0]`; false when a compiler
16
+ * primitive generated it and `origins[0]` is the call site that asked for
17
+ * it. Both point at the same authoring target, but only an authored element
18
+ * can have its own props edited there.
30
19
  */
31
- Raw: {
32
- readonly html: string;
33
- readonly text: string;
34
- readonly origins: readonly JsxSourceLocation[];
35
- };
20
+ readonly authored: boolean;
21
+ } | {
22
+ readonly type: "Fragment";
23
+ readonly children: readonly EmailNode[];
24
+ } |
25
+ /**
26
+ * Compatibility markup a compiler primitive emits verbatim — conditional
27
+ * comments and VML. Only the primitives in `./components` construct it;
28
+ * nothing an author passes as a string reaches this node.
29
+ */
30
+ {
31
+ readonly type: "Raw";
32
+ readonly html: string;
33
+ readonly text: string;
34
+ readonly origins: readonly JsxSourceLocation[];
35
+ };
36
+ type EmailNodeOf<Type extends EmailNode["type"]> = Extract<EmailNode, {
37
+ readonly type: Type;
36
38
  }>;
39
+ type EmailNodeFields<Type extends EmailNode["type"]> = Omit<EmailNodeOf<Type>, "type">;
40
+ /** Constructors for the authoring tree. The tree is data; nothing here validates it. */
37
41
  declare const EmailNode: {
38
- readonly $is: <Tag extends "Element" | "Fragment" | "Raw" | "Text">(tag: Tag) => (u: unknown) => u is Extract<{
39
- readonly _tag: "Element";
40
- readonly tag: string;
41
- readonly props: Readonly<Record<string, unknown>>;
42
- readonly children: readonly EmailNode[];
43
- readonly origins: readonly JsxSourceLocation[];
44
- readonly authored: boolean;
45
- }, {
46
- readonly _tag: Tag;
47
- }> | Extract<{
48
- readonly _tag: "Fragment";
49
- readonly children: readonly EmailNode[];
50
- }, {
51
- readonly _tag: Tag;
52
- }> | Extract<{
53
- readonly _tag: "Raw";
54
- readonly html: string;
55
- readonly text: string;
56
- readonly origins: readonly JsxSourceLocation[];
57
- }, {
58
- readonly _tag: Tag;
59
- }> | Extract<{
60
- readonly _tag: "Text";
61
- readonly value: string;
62
- }, {
63
- readonly _tag: Tag;
64
- }>;
65
- readonly $match: {
66
- <Cases extends { readonly [Tag in "Element" | "Fragment" | "Raw" | "Text"]: (args: Extract<{
67
- readonly _tag: "Element";
68
- readonly tag: string;
69
- readonly props: Readonly<Record<string, unknown>>;
70
- readonly children: readonly EmailNode[];
71
- readonly origins: readonly JsxSourceLocation[];
72
- readonly authored: boolean;
73
- } | {
74
- readonly _tag: "Fragment";
75
- readonly children: readonly EmailNode[];
76
- } | {
77
- readonly _tag: "Raw";
78
- readonly html: string;
79
- readonly text: string;
80
- readonly origins: readonly JsxSourceLocation[];
81
- } | {
82
- readonly _tag: "Text";
83
- readonly value: string;
84
- }, {
85
- readonly _tag: Tag;
86
- }>) => any; }>(cases: Cases): (value: {
87
- readonly _tag: "Element";
88
- readonly tag: string;
89
- readonly props: Readonly<Record<string, unknown>>;
90
- readonly children: readonly EmailNode[];
91
- readonly origins: readonly JsxSourceLocation[];
92
- readonly authored: boolean;
93
- } | {
94
- readonly _tag: "Fragment";
95
- readonly children: readonly EmailNode[];
96
- } | {
97
- readonly _tag: "Raw";
98
- readonly html: string;
99
- readonly text: string;
100
- readonly origins: readonly JsxSourceLocation[];
101
- } | {
102
- readonly _tag: "Text";
103
- readonly value: string;
104
- }) => import("effect/Unify").Unify<ReturnType<Cases["Element" | "Fragment" | "Raw" | "Text"]>>;
105
- <Cases extends { readonly [Tag in "Element" | "Fragment" | "Raw" | "Text"]: (args: Extract<{
106
- readonly _tag: "Element";
107
- readonly tag: string;
108
- readonly props: Readonly<Record<string, unknown>>;
109
- readonly children: readonly EmailNode[];
110
- readonly origins: readonly JsxSourceLocation[];
111
- readonly authored: boolean;
112
- } | {
113
- readonly _tag: "Fragment";
114
- readonly children: readonly EmailNode[];
115
- } | {
116
- readonly _tag: "Raw";
117
- readonly html: string;
118
- readonly text: string;
119
- readonly origins: readonly JsxSourceLocation[];
120
- } | {
121
- readonly _tag: "Text";
122
- readonly value: string;
123
- }, {
124
- readonly _tag: Tag;
125
- }>) => any; }>(value: {
126
- readonly _tag: "Element";
127
- readonly tag: string;
128
- readonly props: Readonly<Record<string, unknown>>;
129
- readonly children: readonly EmailNode[];
130
- readonly origins: readonly JsxSourceLocation[];
131
- readonly authored: boolean;
132
- } | {
133
- readonly _tag: "Fragment";
134
- readonly children: readonly EmailNode[];
135
- } | {
136
- readonly _tag: "Raw";
137
- readonly html: string;
138
- readonly text: string;
139
- readonly origins: readonly JsxSourceLocation[];
140
- } | {
141
- readonly _tag: "Text";
142
- readonly value: string;
143
- }, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["Element" | "Fragment" | "Raw" | "Text"]>>;
144
- };
145
- readonly Element: Data.TaggedEnum.ConstructorFrom<{
146
- readonly _tag: "Element";
147
- readonly tag: string;
148
- readonly props: Readonly<Record<string, unknown>>;
149
- readonly children: readonly EmailNode[];
150
- readonly origins: readonly JsxSourceLocation[];
151
- readonly authored: boolean;
152
- }, "_tag">;
153
- readonly Fragment: Data.TaggedEnum.ConstructorFrom<{
154
- readonly _tag: "Fragment";
155
- readonly children: readonly EmailNode[];
156
- }, "_tag">;
157
- readonly Raw: Data.TaggedEnum.ConstructorFrom<{
158
- readonly _tag: "Raw";
159
- readonly html: string;
160
- readonly text: string;
161
- readonly origins: readonly JsxSourceLocation[];
162
- }, "_tag">;
163
- readonly Text: Data.TaggedEnum.ConstructorFrom<{
164
- readonly _tag: "Text";
165
- readonly value: string;
166
- }, "_tag">;
42
+ readonly Text: (fields: EmailNodeFields<"Text">) => EmailNodeOf<"Text">;
43
+ readonly Element: (fields: EmailNodeFields<"Element">) => EmailNodeOf<"Element">;
44
+ readonly Fragment: (fields: EmailNodeFields<"Fragment">) => EmailNodeOf<"Fragment">;
45
+ readonly Raw: (fields: EmailNodeFields<"Raw">) => EmailNodeOf<"Raw">;
167
46
  };
168
47
  type EmailChild = EmailNode | string | number | boolean | null | undefined | readonly EmailChild[];
169
48
  type EmailComponent<P = never> = (props: P) => EmailChild;
@@ -817,4 +696,4 @@ type ChildrenProp<Content extends EmailElementSpec["content"]> = Content extends
817
696
  type EmailIntrinsicElements = { readonly [Tag in EmailTag]: EmailGlobalProps & AttributeProps<typeof EMAIL_GLOBAL_ATTRIBUTES> & AttributeProps<(typeof EMAIL_ELEMENTS)[Tag]["attributes"]> & ChildrenProp<(typeof EMAIL_ELEMENTS)[Tag]["content"]>; };
818
697
  //#endregion
819
698
  export { reportEmailDiagnostic as C, rawMarkup as S, currentEmailOrigins as _, EmailGlobalProps as a, jsxs as b, EmailStyle as c, isUrlAttribute as d, EmailChild as f, JSX as g, Fragment as h, EmailElementSpec as i, EmailTag as l, EmailNode as m, EMAIL_GLOBAL_ATTRIBUTES as n, EmailIntrinsicElements as o, EmailComponent as p, EmailAttributeSpec as r, EmailLayout as s, EMAIL_ELEMENTS as t, emailElement as u, drainEmailDiagnostics as v, normalizeChildren as x, jsx as y };
820
- //# sourceMappingURL=elements-DtwKlFVH.d.ts.map
699
+ //# sourceMappingURL=elements-ChJULZlh.d.ts.map
@@ -1,4 +1,4 @@
1
- import { c as EmailStyle, f as EmailChild, m as EmailNode } from "../elements-DtwKlFVH.js";
1
+ import { c as EmailStyle, f as EmailChild, m as EmailNode } from "../elements-ChJULZlh.js";
2
2
  //#region src/email/components.d.ts
3
3
  /** Marks the hidden preview block so the renderer can read it back and the text lane can keep it. */
4
4
  declare const PREHEADER_ATTRIBUTE = "data-samva-preheader";
@@ -1,2 +1,2 @@
1
- import { a as formatEmailDiagnostic, i as EmailDiagnosticSeverity, n as EmailCompileError, o as hasBlockingDiagnostic, r as EmailDiagnostic, t as EmailCompatibilityAssessment } from "../diagnostics-Djd9ckLg.js";
1
+ import { a as formatEmailDiagnostic, i as EmailDiagnosticSeverity, n as EmailCompileError, o as hasBlockingDiagnostic, r as EmailDiagnostic, t as EmailCompatibilityAssessment } from "../diagnostics-eFM9A_TU.js";
2
2
  export { EmailCompatibilityAssessment, EmailCompileError, EmailDiagnostic, EmailDiagnosticSeverity, formatEmailDiagnostic, hasBlockingDiagnostic };
@@ -1,46 +1,11 @@
1
- import { JsxSourceLocation } from "../source-locations.js";
2
- import { Schema } from "effect";
1
+ import { TaggedError } from "better-result";
3
2
  //#region src/email/diagnostics.ts
4
- const EmailDiagnosticSeverity = Schema.Literals([
5
- "error",
6
- "warning",
7
- "info"
8
- ]);
9
- /** What the emitted document establishes beyond the client feature matrix. */
10
- const EmailCompatibilityAssessment = Schema.Struct({
11
- assessment: Schema.Literals([
12
- "risk",
13
- "degradation",
14
- "unverified",
15
- "not-applicable"
16
- ]),
17
- /** A short description of the consequence or the remaining verification. */
18
- title: Schema.String
19
- });
20
- const EmailDiagnostic = Schema.Struct({
21
- /** Stable identifier, e.g. `unsupported-element` or `caniemail/css-border-radius`. */
22
- code: Schema.String,
23
- severity: EmailDiagnosticSeverity,
24
- /** States what is wrong and what to write instead. */
25
- message: Schema.String,
26
- /** Innermost authoring element first, then each enclosing component call site. */
27
- origins: Schema.Array(JsxSourceLocation),
28
- /** Target clients a compatibility finding applies to. */
29
- clients: Schema.optional(Schema.Array(Schema.String)),
30
- /** Partial-support notes and other caveats a client matrix carries. */
31
- notes: Schema.optional(Schema.String),
32
- /** Which pinned rule data produced the finding. */
33
- provenance: Schema.optional(Schema.String),
34
- /** Declared fixtures whose rendered output produced this finding. */
35
- fixtures: Schema.optional(Schema.Array(Schema.String)),
36
- /** Source chains for every located emitted occurrence; origins identifies the first. */
37
- occurrences: Schema.optional(Schema.Array(Schema.Array(JsxSourceLocation))),
38
- /** Compatibility observations are not automatically defects or proof of client rendering. */
39
- compatibility: Schema.optional(EmailCompatibilityAssessment)
40
- });
41
- var EmailCompileError = class extends Schema.TaggedError()("EmailCompileError", { diagnostics: Schema.Array(EmailDiagnostic) }) {
42
- get message() {
43
- return this.diagnostics.map(formatEmailDiagnostic).join("\n");
3
+ var EmailCompileError = class extends TaggedError("EmailCompileError") {
4
+ constructor(args) {
5
+ super({
6
+ diagnostics: args.diagnostics,
7
+ message: args.diagnostics.map(formatEmailDiagnostic).join("\n")
8
+ });
44
9
  }
45
10
  };
46
11
  /** `emails/welcome.tsx:12:3 unsupported-element: …` — the shape agents iterate on. */
@@ -51,6 +16,6 @@ const formatEmailDiagnostic = (diagnostic) => {
51
16
  /** True when a set of findings must stop the compile or refuse a publication. */
52
17
  const hasBlockingDiagnostic = (diagnostics) => diagnostics.some((diagnostic) => diagnostic.severity === "error");
53
18
  //#endregion
54
- export { EmailCompatibilityAssessment, EmailCompileError, EmailDiagnostic, EmailDiagnosticSeverity, formatEmailDiagnostic, hasBlockingDiagnostic };
19
+ export { EmailCompileError, formatEmailDiagnostic, hasBlockingDiagnostic };
55
20
 
56
21
  //# sourceMappingURL=diagnostics.js.map
@@ -1,2 +1,2 @@
1
- import { a as EmailGlobalProps, c as EmailStyle, d as isUrlAttribute, i as EmailElementSpec, l as EmailTag, n as EMAIL_GLOBAL_ATTRIBUTES, o as EmailIntrinsicElements, r as EmailAttributeSpec, s as EmailLayout, t as EMAIL_ELEMENTS, u as emailElement } from "../elements-DtwKlFVH.js";
1
+ import { a as EmailGlobalProps, c as EmailStyle, d as isUrlAttribute, i as EmailElementSpec, l as EmailTag, 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";
2
2
  export { EMAIL_ELEMENTS, EMAIL_GLOBAL_ATTRIBUTES, EmailAttributeSpec, EmailElementSpec, EmailGlobalProps, EmailIntrinsicElements, EmailLayout, EmailStyle, EmailTag, emailElement, isUrlAttribute };
@@ -1,5 +1,5 @@
1
- import { r as EmailDiagnostic } from "../diagnostics-Djd9ckLg.js";
2
- import { m as EmailNode } from "../elements-DtwKlFVH.js";
1
+ import { r as EmailDiagnostic } from "../diagnostics-eFM9A_TU.js";
2
+ import { m as EmailNode } from "../elements-ChJULZlh.js";
3
3
  import { EmittedPosition } from "./selection.js";
4
4
  //#region src/email/html.d.ts
5
5
  /** Escape a value for element content. */
@@ -1,6 +1,6 @@
1
+ import { n as isObject } from "../guards-eV1qLbf2.js";
1
2
  import { EMAIL_ELEMENTS, EMAIL_GLOBAL_ATTRIBUTES, emailElement } from "./elements.js";
2
3
  import { INSTANCE_PATH_ATTRIBUTE } from "./selection.js";
3
- import { Predicate } from "effect";
4
4
  //#region src/email/html.ts
5
5
  /** Escape a value for element content. */
6
6
  const escapeText = (value) => value.replace(/[&<>]/g, (character) => ({
@@ -136,7 +136,7 @@ const attributes = (sink, tag, spec, props, origins) => {
136
136
  }
137
137
  if (name === "style") {
138
138
  if (value === void 0 || value === null) continue;
139
- if (!Predicate.isObject(value) || Array.isArray(value)) {
139
+ if (!isObject(value) || Array.isArray(value)) {
140
140
  report(sink, "invalid-style", `<${tag} style> must be a property object, for example style={{ backgroundColor: "#fff" }}.`, origins);
141
141
  continue;
142
142
  }
@@ -172,24 +172,24 @@ const attributes = (sink, tag, spec, props, origins) => {
172
172
  return emitted.join("");
173
173
  };
174
174
  /** Fragments are transparent to a content model; raw compatibility markup is not content. */
175
- const contentChildren = (children) => children.flatMap((child) => child._tag === "Fragment" ? contentChildren(child.children) : [child]);
175
+ const contentChildren = (children) => children.flatMap((child) => child.type === "Fragment" ? contentChildren(child.children) : [child]);
176
176
  const checkContentModel = (sink, tag, spec, children, origins) => {
177
177
  if (spec.content === "void") {
178
178
  if (contentChildren(children).length > 0) report(sink, "void-element-children", `<${tag}> cannot have children.`, origins);
179
179
  return;
180
180
  }
181
181
  if (spec.content === "text" || spec.content === "raw") {
182
- for (const child of contentChildren(children)) if (child._tag !== "Text") report(sink, "invalid-content", `<${tag}> accepts text only.`, child._tag === "Element" ? child.origins : origins);
182
+ for (const child of contentChildren(children)) if (child.type !== "Text") report(sink, "invalid-content", `<${tag}> accepts text only.`, child.type === "Element" ? child.origins : origins);
183
183
  return;
184
184
  }
185
185
  if (spec.childElements === void 0) return;
186
186
  for (const child of contentChildren(children)) {
187
- if (child._tag === "Raw") continue;
188
- if (child._tag === "Text") {
187
+ if (child.type === "Raw") continue;
188
+ if (child.type === "Text") {
189
189
  if (child.value.trim() !== "") report(sink, "invalid-content", `<${tag}> cannot contain text directly; put it inside <${spec.childElements[0]}>.`, origins);
190
190
  continue;
191
191
  }
192
- if (child._tag === "Element" && !spec.childElements.includes(child.tag)) report(sink, "invalid-content", `<${tag}> accepts only ${spec.childElements.map((name) => `<${name}>`).join(", ")}; found <${child.tag}>.`, child.origins);
192
+ if (child.type === "Element" && !spec.childElements.includes(child.tag)) report(sink, "invalid-content", `<${tag}> accepts only ${spec.childElements.map((name) => `<${name}>`).join(", ")}; found <${child.tag}>.`, child.origins);
193
193
  }
194
194
  };
195
195
  /** Every write goes through here so `sink.written` stays the emitted offset. */
@@ -198,7 +198,7 @@ const emit = (sink, text) => {
198
198
  return text;
199
199
  };
200
200
  const serialize = (sink, node, parentPath, counter) => {
201
- switch (node._tag) {
201
+ switch (node.type) {
202
202
  case "Text": return emit(sink, escapeText(node.value));
203
203
  case "Raw": return emit(sink, node.html);
204
204
  case "Fragment": return node.children.map((child) => serialize(sink, child, parentPath, counter)).join("");
@@ -215,7 +215,7 @@ const serialize = (sink, node, parentPath, counter) => {
215
215
  }
216
216
  checkContentModel(sink, node.tag, spec, node.children, node.origins);
217
217
  if (spec.content === "raw") {
218
- const css = node.children.map((child) => child._tag === "Text" ? child.value : "").join("");
218
+ const css = node.children.map((child) => child.type === "Text" ? child.value : "").join("");
219
219
  if (/<\/|<!--/i.test(css)) {
220
220
  report(sink, "unsafe-raw-text", `<${node.tag}> content cannot contain markup.`, node.origins);
221
221
  return "";
@@ -1,26 +1,8 @@
1
- import { i as JsxSourceLocation, r as JsxSource } from "../source-locations-BCJQnIfU.js";
2
- import { g as JSX, h as Fragment, m as EmailNode, p as EmailComponent } from "../elements-DtwKlFVH.js";
1
+ import { r as JsxSource } from "../source-locations-D6Te6Gy1.js";
2
+ import { g as JSX, h as Fragment, m as EmailNode, p as EmailComponent } from "../elements-ChJULZlh.js";
3
3
  //#region src/email/jsx-dev-runtime.d.ts
4
4
  /** Development JSX retains compiler-provided origins directly on the semantic tree. */
5
- declare const jsxDEV: (type: string | EmailComponent<Record<string, unknown>> | typeof Fragment, props: Record<string, unknown> | null, _key?: unknown, _staticChildren?: boolean, source?: JsxSource) => {
6
- readonly _tag: "Element";
7
- readonly tag: string;
8
- readonly props: Readonly<Record<string, unknown>>;
9
- readonly children: readonly EmailNode[];
10
- readonly origins: readonly JsxSourceLocation[];
11
- readonly authored: boolean;
12
- } | {
13
- readonly _tag: "Fragment";
14
- readonly children: readonly EmailNode[];
15
- } | {
16
- readonly _tag: "Raw";
17
- readonly html: string;
18
- readonly text: string;
19
- readonly origins: readonly JsxSourceLocation[];
20
- } | {
21
- readonly _tag: "Text";
22
- readonly value: string;
23
- };
5
+ declare const jsxDEV: (type: string | EmailComponent<Record<string, unknown>> | typeof Fragment, props: Record<string, unknown> | null, _key?: unknown, _staticChildren?: boolean, source?: JsxSource) => EmailNode;
24
6
  //#endregion
25
7
  export { Fragment, type JSX, jsxDEV };
26
8
  //# sourceMappingURL=jsx-dev-runtime.d.ts.map
@@ -1,2 +1,2 @@
1
- import { C as reportEmailDiagnostic, S as rawMarkup, _ as currentEmailOrigins, b as jsxs, f as EmailChild, g as JSX, h as Fragment, m as EmailNode, p as EmailComponent, v as drainEmailDiagnostics, x as normalizeChildren, y as jsx } from "../elements-DtwKlFVH.js";
1
+ import { C as reportEmailDiagnostic, S as rawMarkup, _ as currentEmailOrigins, b as jsxs, f as EmailChild, g as JSX, h as Fragment, m as EmailNode, p as EmailComponent, v as drainEmailDiagnostics, x as normalizeChildren, y as jsx } from "../elements-ChJULZlh.js";
2
2
  export { EmailChild, EmailComponent, EmailNode, Fragment, JSX, currentEmailOrigins, drainEmailDiagnostics, jsx, jsxs, normalizeChildren, rawMarkup, reportEmailDiagnostic };
@@ -1,7 +1,33 @@
1
+ import { t as hasProperty } from "../guards-eV1qLbf2.js";
1
2
  import { JSX_SOURCE_LOCATION_PROP, completeJsxSourceLocation } from "../source-locations.js";
2
- import { Data, Predicate } from "effect";
3
3
  //#region src/email/jsx-runtime.ts
4
- const EmailNode = Data.taggedEnum();
4
+ /** Constructors for the authoring tree. The tree is data; nothing here validates it. */
5
+ const EmailNode = {
6
+ Text: (fields) => ({
7
+ type: "Text",
8
+ ...fields
9
+ }),
10
+ Element: (fields) => ({
11
+ type: "Element",
12
+ ...fields
13
+ }),
14
+ Fragment: (fields) => ({
15
+ type: "Fragment",
16
+ ...fields
17
+ }),
18
+ Raw: (fields) => ({
19
+ type: "Raw",
20
+ ...fields
21
+ })
22
+ };
23
+ const EMAIL_NODE_TYPES = /* @__PURE__ */ new Set([
24
+ "Text",
25
+ "Element",
26
+ "Fragment",
27
+ "Raw"
28
+ ]);
29
+ /** True for a node this runtime built; anything else is not a child it can place. */
30
+ const isEmailNode = (input) => hasProperty(input, "type") && typeof input.type === "string" && EMAIL_NODE_TYPES.has(input.type);
5
31
  const Fragment = Symbol.for("@samva/markup/email/Fragment");
6
32
  const callSites = [];
7
33
  /** Call sites enclosing the element being built, innermost first. */
@@ -22,7 +48,7 @@ const normalizeChildren = (input) => {
22
48
  if (typeof input === "string") return [EmailNode.Text({ value: input })];
23
49
  if (typeof input === "number" && Number.isFinite(input)) return [EmailNode.Text({ value: String(input) })];
24
50
  if (Array.isArray(input)) return input.flatMap(normalizeChildren);
25
- if (Predicate.isTagged(input, "Text") || Predicate.isTagged(input, "Element") || Predicate.isTagged(input, "Fragment") || Predicate.isTagged(input, "Raw")) return [input];
51
+ if (isEmailNode(input)) return [input];
26
52
  throw new TypeError("Email children must be synchronous text, finite numbers, elements, or arrays");
27
53
  };
28
54
  /** Compatibility markup emitted by a compiler primitive, with the text it stands for. */
@@ -1,9 +1,9 @@
1
- import { r as EmailDiagnostic } from "../diagnostics-Djd9ckLg.js";
2
- import { m as EmailNode } from "../elements-DtwKlFVH.js";
1
+ import { r as EmailDiagnostic } from "../diagnostics-eFM9A_TU.js";
2
+ import { m as EmailNode } from "../elements-ChJULZlh.js";
3
3
  import { EmittedPosition } from "./selection.js";
4
4
  import { SerializeEmailOptions } from "./html.js";
5
- import { r as TemplateDefinition } from "../template-Dy5yOPyp.js";
6
- import { i as Stylesheet } from "../css-ar2lU3NC.js";
5
+ import { r as TemplateDefinition } from "../template-G-QPcfmn.js";
6
+ import { i as Stylesheet } from "../css-DoNc7CiC.js";
7
7
  //#region src/email/render.d.ts
8
8
  /** Classic Outlook lays a document out correctly only under a transitional doctype. */
9
9
  declare const EMAIL_DOCTYPE = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
@@ -1,4 +1,4 @@
1
- import { i as renderEmail, n as bindStylesheets, r as compileEmail, t as EMAIL_DOCTYPE } from "../render-ykQhtMs_.js";
1
+ import { i as renderEmail, n as bindStylesheets, r as compileEmail, t as EMAIL_DOCTYPE } from "../render-T6IFPnP4.js";
2
2
  import "./html.js";
3
3
  import "./diagnostics.js";
4
4
  import "./stylesheets.js";
@@ -1,5 +1,4 @@
1
- import { i as JsxSourceLocation } from "../source-locations-BCJQnIfU.js";
2
- import { Schema } from "effect";
1
+ import { i as JsxSourceLocation } from "../source-locations-D6Te6Gy1.js";
3
2
  //#region src/email/selection.d.ts
4
3
  /**
5
4
  * The attribute a preview stamps so a click in a rendered document resolves to
@@ -7,65 +6,55 @@ import { Schema } from "effect";
7
6
  */
8
7
  declare const INSTANCE_PATH_ATTRIBUTE = "data-samva-instance";
9
8
  /** Where one element sits in the emitted document, with the authoring that produced it. */
10
- declare const EmittedPosition: Schema.Struct<{
11
- readonly start: Schema.Int;
12
- readonly end: Schema.Int;
13
- readonly origins: Schema.$Array<Schema.Struct<{
14
- readonly fileName: Schema.String;
15
- readonly lineNumber: Schema.Int;
16
- readonly columnNumber: Schema.Int;
17
- }>>;
9
+ interface EmittedPosition {
10
+ readonly start: number;
11
+ readonly end: number;
12
+ readonly origins: ReadonlyArray<JsxSourceLocation>;
18
13
  /**
19
14
  * Dot-separated element indices from the document root, assigned as the
20
15
  * document is written. It is the identity of one rendered instance.
21
16
  */
22
- readonly instancePath: Schema.String;
23
- readonly tag: Schema.String;
17
+ readonly instancePath: string;
18
+ readonly tag: string;
24
19
  /** False when a compiler primitive generated this element. */
25
- readonly authored: Schema.Boolean;
26
- }>;
27
- interface EmittedPosition extends Schema.Schema.Type<typeof EmittedPosition> {}
20
+ readonly authored: boolean;
21
+ }
28
22
  /** One rendered element, and the authoring it came from. */
29
- declare const EmailElementSelection: Schema.Struct<{
23
+ interface EmailElementSelection {
30
24
  /**
31
25
  * Dot-separated element indices from the document root. It is the identity
32
26
  * of one rendered instance, which is what tells two iterations of the same
33
27
  * authored element apart: their origins are identical.
34
28
  */
35
- readonly instancePath: Schema.String;
36
- readonly tag: Schema.String;
29
+ readonly instancePath: string;
30
+ readonly tag: string;
37
31
  /**
38
32
  * The authored JSX element first, then each enclosing component call site,
39
33
  * innermost first. Empty when the compiler generated this element with no
40
34
  * authoring on the stack — the hidden preheader block, for instance.
41
35
  */
42
- readonly origins: Schema.$Array<Schema.Struct<{
43
- readonly fileName: Schema.String;
44
- readonly lineNumber: Schema.Int;
45
- readonly columnNumber: Schema.Int;
46
- }>>;
36
+ readonly origins: ReadonlyArray<JsxSourceLocation>;
47
37
  /**
48
38
  * False when a compiler primitive generated this element. `origins[0]` is
49
39
  * then the authoring element that asked for it rather than this element
50
40
  * itself, so the wrapper selects the primitive the author wrote.
51
41
  */
52
- readonly authored: Schema.Boolean;
42
+ readonly authored: boolean;
53
43
  /** 1-based position among the rendered elements sharing this origin chain and tag. */
54
- readonly occurrence: Schema.Int;
44
+ readonly occurrence: number;
55
45
  /**
56
46
  * How many rendered elements share that chain and tag. Above one, one piece
57
47
  * of authoring produced several rendered elements — a loop over a component,
58
48
  * or a primitive that generates a repeated cell — so an edit there changes
59
49
  * all of them.
60
50
  */
61
- readonly occurrences: Schema.Int;
51
+ readonly occurrences: number;
62
52
  /** Absent for the document root. */
63
- readonly parentPath: Schema.optionalKey<Schema.String>;
53
+ readonly parentPath?: string;
64
54
  /** Offset range in the rendered HTML this selection was taken from. */
65
- readonly start: Schema.Int;
66
- readonly end: Schema.Int;
67
- }>;
68
- interface EmailElementSelection extends Schema.Schema.Type<typeof EmailElementSelection> {}
55
+ readonly start: number;
56
+ readonly end: number;
57
+ }
69
58
  /**
70
59
  * Turn one render's emitted positions into selections, in document order.
71
60
  *
@@ -1,61 +1,9 @@
1
- import { JsxSourceLocation } from "../source-locations.js";
2
- import { Schema } from "effect";
3
1
  //#region src/email/selection.ts
4
2
  /**
5
3
  * The attribute a preview stamps so a click in a rendered document resolves to
6
4
  * exactly one rendered element. A delivered message never carries it.
7
5
  */
8
6
  const INSTANCE_PATH_ATTRIBUTE = "data-samva-instance";
9
- /** Where one element sits in the emitted document, with the authoring that produced it. */
10
- const EmittedPosition = Schema.Struct({
11
- start: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
12
- end: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
13
- origins: Schema.Array(JsxSourceLocation),
14
- /**
15
- * Dot-separated element indices from the document root, assigned as the
16
- * document is written. It is the identity of one rendered instance.
17
- */
18
- instancePath: Schema.String.check(Schema.isMinLength(1)),
19
- tag: Schema.String.check(Schema.isMinLength(1)),
20
- /** False when a compiler primitive generated this element. */
21
- authored: Schema.Boolean
22
- });
23
- /** One rendered element, and the authoring it came from. */
24
- const EmailElementSelection = Schema.Struct({
25
- /**
26
- * Dot-separated element indices from the document root. It is the identity
27
- * of one rendered instance, which is what tells two iterations of the same
28
- * authored element apart: their origins are identical.
29
- */
30
- instancePath: Schema.String.check(Schema.isMinLength(1)),
31
- tag: Schema.String.check(Schema.isMinLength(1)),
32
- /**
33
- * The authored JSX element first, then each enclosing component call site,
34
- * innermost first. Empty when the compiler generated this element with no
35
- * authoring on the stack — the hidden preheader block, for instance.
36
- */
37
- origins: Schema.Array(JsxSourceLocation),
38
- /**
39
- * False when a compiler primitive generated this element. `origins[0]` is
40
- * then the authoring element that asked for it rather than this element
41
- * itself, so the wrapper selects the primitive the author wrote.
42
- */
43
- authored: Schema.Boolean,
44
- /** 1-based position among the rendered elements sharing this origin chain and tag. */
45
- occurrence: Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)),
46
- /**
47
- * How many rendered elements share that chain and tag. Above one, one piece
48
- * of authoring produced several rendered elements — a loop over a component,
49
- * or a primitive that generates a repeated cell — so an edit there changes
50
- * all of them.
51
- */
52
- occurrences: Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)),
53
- /** Absent for the document root. */
54
- parentPath: Schema.optionalKey(Schema.String),
55
- /** Offset range in the rendered HTML this selection was taken from. */
56
- start: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
57
- end: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))
58
- });
59
7
  const locationKey = (origin) => `${origin.fileName}:${origin.lineNumber}:${origin.columnNumber}`;
60
8
  /** One call site: the authored element and every component call enclosing it. */
61
9
  const callSiteKey = (selection) => `${selection.tag}\u0000${selection.origins.map(locationKey).join("\0")}`;
@@ -138,6 +86,6 @@ const emailDefinitionInstances = (selections, selection) => {
138
86
  return selections.filter((candidate) => definitionKey(candidate) === key);
139
87
  };
140
88
  //#endregion
141
- export { EmailElementSelection, EmittedPosition, INSTANCE_PATH_ATTRIBUTE, emailAuthoringTarget, emailDefinitionInstances, emailSelectionAncestry, emailSelectionIndex, emailSelectionSiblings, emailSelections };
89
+ export { INSTANCE_PATH_ATTRIBUTE, emailAuthoringTarget, emailDefinitionInstances, emailSelectionAncestry, emailSelectionIndex, emailSelectionSiblings, emailSelections };
142
90
 
143
91
  //# sourceMappingURL=selection.js.map
@@ -1,4 +1,4 @@
1
- import { i as JsxSourceLocation } from "../source-locations-BCJQnIfU.js";
1
+ import { i as JsxSourceLocation } from "../source-locations-D6Te6Gy1.js";
2
2
  //#region src/email/source-edit.d.ts
3
3
  /** One exact source replacement; before text guards against concurrent changes. */
4
4
  interface SourceReplacement {