@samva/markup 0.8.0 → 0.9.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 (171) hide show
  1. package/AGENTS.md +90 -37
  2. package/README.md +188 -52
  3. package/dist/assets-C5duwTya.d.ts +40 -0
  4. package/dist/{brand-DcoVkh_S.d.ts → brand-B-0bN_Ir.d.ts} +2 -2
  5. package/dist/{render-vAv_4r9v.js → cascade-t6kxlgEI.js} +93 -280
  6. package/dist/channel-edit.d.ts +121 -0
  7. package/dist/channel-edit.js +609 -0
  8. package/dist/channel-specs-B6M_HlaV.js +29 -0
  9. package/dist/channel-specs-C2feJwuP.d.ts +13 -0
  10. package/dist/compatibility-DbISoFIq.js +589 -0
  11. package/dist/compiler.d.ts +10 -257
  12. package/dist/compiler.js +10 -730
  13. package/dist/{css-CS2jLID6.d.ts → css-BVQKICKC.d.ts} +3 -3
  14. package/dist/diagnostic-codes.d.ts +403 -0
  15. package/dist/diagnostic-codes.js +399 -0
  16. package/dist/{diagnostics-BMYtBCQk.d.ts → diagnostics-B-Gym34R.d.ts} +8 -4
  17. package/dist/diagnostics.d.ts +31 -2
  18. package/dist/diagnostics.js +1 -19
  19. package/dist/{elements-BzjjnoCS.d.ts → elements-cqldpaJt.d.ts} +3 -3
  20. package/dist/email/assets.d.ts +2 -40
  21. package/dist/email/brand-footer.d.ts +2 -2
  22. package/dist/email/brand-footer.js +4 -3
  23. package/dist/email/brand.d.ts +1 -1
  24. package/dist/email/brand.js +1 -1
  25. package/dist/email/components.d.ts +21 -10
  26. package/dist/email/components.js +46 -11
  27. package/dist/email/diagnostics.d.ts +2 -2
  28. package/dist/email/diagnostics.js +2 -1
  29. package/dist/email/elements.d.ts +1 -1
  30. package/dist/email/html.d.ts +2 -2
  31. package/dist/email/html.js +45 -2
  32. package/dist/email/jsx-dev-runtime.d.ts +2 -2
  33. package/dist/email/jsx-runtime.d.ts +1 -1
  34. package/dist/email/render.d.ts +8 -18
  35. package/dist/email/render.js +163 -3
  36. package/dist/email/text.d.ts +1 -1
  37. package/dist/fmt.d.ts +32 -0
  38. package/dist/fmt.js +174 -0
  39. package/dist/{html-Bl9BAdqc.d.ts → html-BJepOwZ4.d.ts} +19 -5
  40. package/dist/index.d.ts +2 -0
  41. package/dist/index.js +2 -0
  42. package/dist/ir-aaqNE987.d.ts +252 -0
  43. package/dist/ir.d.ts +2 -0
  44. package/dist/ir.js +7 -0
  45. package/dist/preview-Ekdg1dXG.d.ts +100 -0
  46. package/dist/preview.d.ts +2 -0
  47. package/dist/preview.js +160 -0
  48. package/dist/profile-BH-OtdDA.js +3670 -0
  49. package/dist/render-ir.d.ts +19 -0
  50. package/dist/render-ir.js +826 -0
  51. package/dist/sms-segments.d.ts +13 -2
  52. package/dist/sms.d.ts +16 -0
  53. package/dist/sms.js +12 -0
  54. package/dist/{email/source-edit.d.ts → source-edit.d.ts} +55 -6
  55. package/dist/source-edit.js +343 -0
  56. package/dist/source-locations-C8wCsiAy.d.ts +23 -0
  57. package/dist/source-locations.d.ts +2 -2
  58. package/dist/source-locations.js +3 -89
  59. package/dist/static.d.ts +57 -0
  60. package/dist/static.js +69 -0
  61. package/dist/tailwind-CMYpZf1v.js +614 -0
  62. package/dist/template-_QE_rQND.d.ts +65 -0
  63. package/dist/template.d.ts +2 -2
  64. package/dist/template.js +15 -10
  65. package/dist/theme-css.d.ts +1 -1
  66. package/dist/theme-imports-lvBw3AD1.js +109 -0
  67. package/dist/transform-Ct2OMkFN.d.ts +153 -0
  68. package/dist/whatsapp.d.ts +57 -0
  69. package/dist/whatsapp.js +22 -0
  70. package/generated/contract.json +1782 -0
  71. package/generated/reference.md +353 -0
  72. package/package.json +41 -151
  73. package/skills/sml/SKILL.md +123 -0
  74. package/dist/ast-BrDtApwS.d.ts +0 -107
  75. package/dist/ast.d.ts +0 -2
  76. package/dist/ast.js +0 -124
  77. package/dist/candidate.d.ts +0 -29
  78. package/dist/candidate.js +0 -88
  79. package/dist/catalog-CKuOooB8.d.ts +0 -354
  80. package/dist/checks-D73Xizbw.js +0 -59366
  81. package/dist/checks.d.ts +0 -33
  82. package/dist/checks.js +0 -2
  83. package/dist/classes.d.ts +0 -26
  84. package/dist/classes.js +0 -184
  85. package/dist/compile-sms.d.ts +0 -28
  86. package/dist/compile-sms.js +0 -44
  87. package/dist/compile-whatsapp.d.ts +0 -56
  88. package/dist/compile-whatsapp.js +0 -186
  89. package/dist/compile.d.ts +0 -18
  90. package/dist/compile.js +0 -29
  91. package/dist/components.d.ts +0 -289
  92. package/dist/components.js +0 -106
  93. package/dist/conditionals.d.ts +0 -10
  94. package/dist/conditionals.js +0 -74
  95. package/dist/corpus-CPPfgAHN.d.ts +0 -106
  96. package/dist/diagnostics-OcQKQYSY.d.ts +0 -49
  97. package/dist/email/selection.d.ts +0 -2
  98. package/dist/email/selection.js +0 -91
  99. package/dist/email/source-edit.js +0 -185
  100. package/dist/email/stylesheets.d.ts +0 -15
  101. package/dist/email/stylesheets.js +0 -48
  102. package/dist/emit.d.ts +0 -51
  103. package/dist/emit.js +0 -151
  104. package/dist/interpolate.d.ts +0 -24
  105. package/dist/interpolate.js +0 -43
  106. package/dist/jsx-dev-runtime.d.ts +0 -11
  107. package/dist/jsx-dev-runtime.js +0 -15
  108. package/dist/jsx-runtime-I-1nCtl2.d.ts +0 -57
  109. package/dist/jsx-runtime.d.ts +0 -2
  110. package/dist/jsx-runtime.js +0 -121
  111. package/dist/lexer.d.ts +0 -60
  112. package/dist/lexer.js +0 -281
  113. package/dist/model.d.ts +0 -24
  114. package/dist/model.js +0 -77
  115. package/dist/ops-BvwqHl7V.js +0 -630
  116. package/dist/ops.d.ts +0 -114
  117. package/dist/ops.js +0 -2
  118. package/dist/parser-t29cHLVL.d.ts +0 -396
  119. package/dist/parser.d.ts +0 -2
  120. package/dist/parser.js +0 -859
  121. package/dist/predicate-BI6uRRM-.js +0 -549
  122. package/dist/predicate-M-05Nd7R.d.ts +0 -56
  123. package/dist/predicate.d.ts +0 -2
  124. package/dist/predicate.js +0 -2
  125. package/dist/printer.d.ts +0 -6
  126. package/dist/printer.js +0 -122
  127. package/dist/registry-Dcp6QEK_.d.ts +0 -73
  128. package/dist/registry.d.ts +0 -2
  129. package/dist/registry.js +0 -646
  130. package/dist/render-template.d.ts +0 -45
  131. package/dist/render-template.js +0 -76
  132. package/dist/selection-CCArx9lU.d.ts +0 -91
  133. package/dist/showcase-egkusQBf.d.ts +0 -415
  134. package/dist/sms-segments-y4FpPilJ.d.ts +0 -13
  135. package/dist/source-locations-DrCM82Ym.d.ts +0 -67
  136. package/dist/starters/category-mapping.d.ts +0 -13
  137. package/dist/starters/category-mapping.js +0 -49
  138. package/dist/starters/corpus.d.ts +0 -2
  139. package/dist/starters/corpus.js +0 -194
  140. package/dist/starters/library.d.ts +0 -18
  141. package/dist/starters/library.js +0 -692
  142. package/dist/starters/public-gallery.d.ts +0 -266
  143. package/dist/starters/public-gallery.js +0 -916
  144. package/dist/starters/public-handoff.d.ts +0 -164
  145. package/dist/starters/public-handoff.js +0 -361
  146. package/dist/starters/public-preview-artifacts.d.ts +0 -43
  147. package/dist/starters/public-preview-artifacts.js +0 -104
  148. package/dist/starters/public-preview.d.ts +0 -61
  149. package/dist/starters/public-preview.js +0 -83
  150. package/dist/starters/showcase.d.ts +0 -2
  151. package/dist/starters/showcase.js +0 -335
  152. package/dist/starters/sources.d.ts +0 -45
  153. package/dist/starters/sources.js +0 -7762
  154. package/dist/starters/theme.d.ts +0 -45
  155. package/dist/starters/theme.js +0 -77
  156. package/dist/starters.d.ts +0 -2
  157. package/dist/starters.js +0 -874
  158. package/dist/tailwind-BYq7Lo6u.js +0 -727
  159. package/dist/template-DWftqh4x.d.ts +0 -60
  160. package/dist/tsx-source-instrumentation.d.ts +0 -30
  161. package/dist/tsx-source-instrumentation.js +0 -115
  162. package/dist/tsx-tracer.d.ts +0 -112
  163. package/dist/tsx-tracer.js +0 -985
  164. package/dist/variables-J_L3qxRa.d.ts +0 -77
  165. package/dist/variables.d.ts +0 -2
  166. package/dist/variables.js +0 -141
  167. package/dist/version-BITr58kk.js +0 -96
  168. package/generated/sml-agent-contract.json +0 -709
  169. package/generated/sml-email-agent-contract.json +0 -615
  170. package/generated/sml-email-language-reference.md +0 -94
  171. package/generated/sml-language-reference.md +0 -195
@@ -1,77 +0,0 @@
1
- import { r as PredicateAst } from "./predicate-M-05Nd7R.js";
2
- //#region src/variables.d.ts
3
- /** Brand carried by every VariableRef, keyed off a private symbol. */
4
- declare const VARIABLE_REF: unique symbol;
5
- /** Brand carried by every PredicateRef. */
6
- declare const PREDICATE_REF: unique symbol;
7
- interface VariableRefBrand {
8
- readonly path: string;
9
- /** The recorder shared across every ref/proxy from one template invocation. */
10
- readonly recorder: VariableRecorder;
11
- }
12
- /** Builders present on every VariableRef regardless of field type. */
13
- interface CommonPredicateBuilders {
14
- eq(value: string | number): PredicateRef;
15
- ne(value: string | number): PredicateRef;
16
- exists(): PredicateRef;
17
- notExists(): PredicateRef;
18
- }
19
- /** Ordering builders — only surfaced (by the `Variables<T>` mapping) on number fields. */
20
- interface NumericPredicateBuilders {
21
- gt(value: number): PredicateRef;
22
- gte(value: number): PredicateRef;
23
- lt(value: number): PredicateRef;
24
- lte(value: number): PredicateRef;
25
- }
26
- /** A recorded reference to a send-time variable. See module docs. */
27
- type VariableRef<T> = {
28
- readonly [VARIABLE_REF]: VariableRefBrand;
29
- } & CommonPredicateBuilders & (T extends number ? NumericPredicateBuilders : Record<never, never>);
30
- /** A recorded predicate expression for `<If test={...}>`; chains with and/or/not. */
31
- interface PredicateRef {
32
- readonly [PREDICATE_REF]: {
33
- readonly ast: PredicateAst;
34
- };
35
- and(other: PredicateRef): PredicateRef;
36
- or(other: PredicateRef): PredicateRef;
37
- not(): PredicateRef;
38
- }
39
- declare const isVariableRef: (value: unknown) => value is VariableRef<unknown>;
40
- declare const isPredicateRef: (value: unknown) => value is PredicateRef;
41
- /** The predicate source string (`test="..."`) for a PredicateRef. */
42
- declare const printPredicateRef: (ref: PredicateRef) => string;
43
- type VariableKind = "string" | "number" | "unknown";
44
- interface CollectedVariable {
45
- readonly name: string;
46
- readonly kind: VariableKind;
47
- }
48
- /**
49
- * Shared across every ref produced from one template invocation. Records which
50
- * variables were touched and the strongest kind evidence seen for each (a
51
- * numeric comparison implies `number`; a string comparison implies `string`;
52
- * bare interpolation/exists leaves it `unknown`).
53
- */
54
- declare class VariableRecorder {
55
- private readonly kinds;
56
- observe(name: string, kind: VariableKind): void;
57
- collected(): ReadonlyArray<CollectedVariable>;
58
- }
59
- /**
60
- * Maps a declared variable type to the recording-proxy shape a template
61
- * receives: `export default function Welcome(v: Variables<{ firstName: string }>)`.
62
- * Number fields additionally expose ordering builders.
63
- */
64
- type Variables<T extends Record<string, unknown>> = { readonly [K in keyof T]: VariableRef<T[K]>; };
65
- /**
66
- * Builds the recording proxy for a template invocation. Every top-level
67
- * property access records the variable (kind `unknown` until a typed comparison
68
- * refines it) and returns a VariableRef. Returns the proxy plus the shared
69
- * recorder so renderTemplate can read the collected schema.
70
- */
71
- declare const createVariablesProxy: <T extends Record<string, unknown>>() => {
72
- readonly proxy: Variables<T>;
73
- readonly recorder: VariableRecorder;
74
- };
75
- //#endregion
76
- export { VariableKind as a, VariableRefBrand as c, isPredicateRef as d, isVariableRef as f, VARIABLE_REF as i, Variables as l, PREDICATE_REF as n, VariableRecorder as o, printPredicateRef as p, PredicateRef as r, VariableRef as s, CollectedVariable as t, createVariablesProxy as u };
77
- //# sourceMappingURL=variables-J_L3qxRa.d.ts.map
@@ -1,2 +0,0 @@
1
- import { a as VariableKind, c as VariableRefBrand, d as isPredicateRef, f as isVariableRef, i as VARIABLE_REF, l as Variables, n as PREDICATE_REF, o as VariableRecorder, p as printPredicateRef, r as PredicateRef, s as VariableRef, t as CollectedVariable, u as createVariablesProxy } from "./variables-J_L3qxRa.js";
2
- export { CollectedVariable, PREDICATE_REF, PredicateRef, VARIABLE_REF, VariableKind, VariableRecorder, VariableRef, VariableRefBrand, Variables, createVariablesProxy, isPredicateRef, isVariableRef, printPredicateRef };
package/dist/variables.js DELETED
@@ -1,141 +0,0 @@
1
- import { t as hasProperty } from "./guards-eV1qLbf2.js";
2
- import { a as printPredicate } from "./predicate-BI6uRRM-.js";
3
- //#region src/variables.ts
4
- const PLACEHOLDER_SPAN = {
5
- start: 0,
6
- end: 0
7
- };
8
- /** Brand carried by every VariableRef, keyed off a private symbol. */
9
- const VARIABLE_REF = Symbol.for("@samva/markup/VariableRef");
10
- /** Brand carried by every PredicateRef. */
11
- const PREDICATE_REF = Symbol.for("@samva/markup/PredicateRef");
12
- const COERCION_MESSAGE = "variables are send-time values; branch on build-time data instead";
13
- const isVariableRef = (value) => hasProperty(value, VARIABLE_REF);
14
- const isPredicateRef = (value) => hasProperty(value, PREDICATE_REF);
15
- const literalFor = (value) => typeof value === "number" ? {
16
- kind: "number",
17
- value
18
- } : {
19
- kind: "string",
20
- value
21
- };
22
- const makePredicateRef = (ast) => ({
23
- [PREDICATE_REF]: { ast },
24
- and: (other) => makePredicateRef({
25
- kind: "and",
26
- left: ast,
27
- right: predicateAst(other),
28
- span: PLACEHOLDER_SPAN
29
- }),
30
- or: (other) => makePredicateRef({
31
- kind: "or",
32
- left: ast,
33
- right: predicateAst(other),
34
- span: PLACEHOLDER_SPAN
35
- }),
36
- not: () => makePredicateRef({
37
- kind: "not",
38
- operand: ast,
39
- span: PLACEHOLDER_SPAN
40
- })
41
- });
42
- const predicateAst = (ref) => ref[PREDICATE_REF].ast;
43
- /** The predicate source string (`test="..."`) for a PredicateRef. */
44
- const printPredicateRef = (ref) => printPredicate(predicateAst(ref));
45
- /**
46
- * Shared across every ref produced from one template invocation. Records which
47
- * variables were touched and the strongest kind evidence seen for each (a
48
- * numeric comparison implies `number`; a string comparison implies `string`;
49
- * bare interpolation/exists leaves it `unknown`).
50
- */
51
- var VariableRecorder = class {
52
- kinds = /* @__PURE__ */ new Map();
53
- observe(name, kind) {
54
- const existing = this.kinds.get(name);
55
- if (existing === void 0 || existing === "unknown") this.kinds.set(name, kind);
56
- }
57
- collected() {
58
- return [...this.kinds].map(([name, kind]) => ({
59
- name,
60
- kind
61
- }));
62
- }
63
- };
64
- const makeComparison = (brand, op, value) => {
65
- brand.recorder.observe(brand.path, typeof value === "number" ? "number" : "string");
66
- return makePredicateRef({
67
- kind: "comparison",
68
- name: brand.path,
69
- op,
70
- literal: literalFor(value),
71
- span: PLACEHOLDER_SPAN
72
- });
73
- };
74
- const makeVariableRef = (path, recorder) => {
75
- const brand = {
76
- path,
77
- recorder
78
- };
79
- const builders = {
80
- eq: (value) => makeComparison(brand, "==", value),
81
- ne: (value) => makeComparison(brand, "!=", value),
82
- gt: (value) => makeComparison(brand, ">", value),
83
- gte: (value) => makeComparison(brand, ">=", value),
84
- lt: (value) => makeComparison(brand, "<", value),
85
- lte: (value) => makeComparison(brand, "<=", value),
86
- exists: () => {
87
- recorder.observe(path, "unknown");
88
- return makePredicateRef({
89
- kind: "name",
90
- name: path,
91
- span: PLACEHOLDER_SPAN
92
- });
93
- },
94
- notExists: () => {
95
- recorder.observe(path, "unknown");
96
- return makePredicateRef({
97
- kind: "not",
98
- operand: {
99
- kind: "name",
100
- name: path,
101
- span: PLACEHOLDER_SPAN
102
- },
103
- span: PLACEHOLDER_SPAN
104
- });
105
- }
106
- };
107
- const target = {
108
- [VARIABLE_REF]: brand,
109
- ...builders
110
- };
111
- return new Proxy(target, { get(base, key, receiver) {
112
- if (key === Symbol.toPrimitive || key === "valueOf" || key === "toString") return () => {
113
- throw new TypeError(COERCION_MESSAGE);
114
- };
115
- if (key === VARIABLE_REF || key in base) return Reflect.get(base, key, receiver);
116
- if (key === Symbol.toStringTag) return "VariableRef";
117
- if (typeof key === "string") return makeVariableRef(`${path}.${key}`, recorder);
118
- return Reflect.get(base, key, receiver);
119
- } });
120
- };
121
- /**
122
- * Builds the recording proxy for a template invocation. Every top-level
123
- * property access records the variable (kind `unknown` until a typed comparison
124
- * refines it) and returns a VariableRef. Returns the proxy plus the shared
125
- * recorder so renderTemplate can read the collected schema.
126
- */
127
- const createVariablesProxy = () => {
128
- const recorder = new VariableRecorder();
129
- return {
130
- proxy: new Proxy({}, { get(_base, key) {
131
- if (typeof key !== "string") return void 0;
132
- recorder.observe(key, "unknown");
133
- return makeVariableRef(key, recorder);
134
- } }),
135
- recorder
136
- };
137
- };
138
- //#endregion
139
- export { PREDICATE_REF, VARIABLE_REF, VariableRecorder, createVariablesProxy, isPredicateRef, isVariableRef, printPredicateRef };
140
-
141
- //# sourceMappingURL=variables.js.map
@@ -1,96 +0,0 @@
1
- import { stringAttribute } from "./ast.js";
2
- //#region src/channel-text.ts
3
- const interpolationText = (node, width) => {
4
- if (width === "literal") return node.syntax === "curly" ? `{{${node.name}}}` : `\${${node.name}}`;
5
- return "x".repeat(width.worstCaseChars);
6
- };
7
- const ifBranches = (node) => {
8
- const elseNode = node.children.find((child) => child.kind === "element" && child.tag === "Else");
9
- return {
10
- then: node.children.filter((child) => !(child.kind === "element" && child.tag === "Else")),
11
- otherwise: elseNode?.children ?? []
12
- };
13
- };
14
- /** Verbatim flow → compiled text with `sml:` conditional markers embedded. */
15
- const flattenChannelText = (nodes) => {
16
- let result = "";
17
- for (const node of nodes) {
18
- if (node.kind === "text") {
19
- result += node.value;
20
- continue;
21
- }
22
- if (node.kind === "interpolation") {
23
- result += interpolationText(node, "literal");
24
- continue;
25
- }
26
- const test = stringAttribute(node, "test") ?? "";
27
- const { then, otherwise } = ifBranches(node);
28
- result += `<!--sml:if:${node.id} ${test}-->${flattenChannelText(then)}`;
29
- if (otherwise.length > 0) result += `<!--sml:else:${node.id}-->${flattenChannelText(otherwise)}`;
30
- result += `<!--sml:endif:${node.id}-->`;
31
- }
32
- return result;
33
- };
34
- /** Safety valve: beyond this many branch combinations, stop forking. */
35
- const MAX_VARIANTS = 256;
36
- /**
37
- * Every possible send-time rendering of a verbatim flow (each `<If>` resolved
38
- * both ways), marker-free. Selected branches are trimmed exactly like
39
- * resolveArtifactConditionals trims them, so measured lengths match what a
40
- * recipient can actually receive. Capped at MAX_VARIANTS combinations —
41
- * beyond the cap later `<If>`s stop forking (their true branch is kept),
42
- * which keeps worst-case analysis approximate instead of exponential.
43
- */
44
- const channelTextVariants = (nodes, width) => {
45
- let variants = [""];
46
- const append = (suffixes) => {
47
- if (suffixes.length === 1) {
48
- variants = variants.map((variant) => variant + suffixes[0]);
49
- return;
50
- }
51
- const next = [];
52
- for (const variant of variants) {
53
- for (const suffix of suffixes) {
54
- next.push(variant + suffix);
55
- if (next.length >= MAX_VARIANTS) break;
56
- }
57
- if (next.length >= MAX_VARIANTS) break;
58
- }
59
- variants = next;
60
- };
61
- for (const node of nodes) {
62
- if (node.kind === "text") {
63
- append([node.value]);
64
- continue;
65
- }
66
- if (node.kind === "interpolation") {
67
- append([interpolationText(node, width)]);
68
- continue;
69
- }
70
- const { then, otherwise } = ifBranches(node);
71
- const thenVariants = channelTextVariants(then, width).map((variant) => variant.trim());
72
- const elseVariants = channelTextVariants(otherwise, width).map((variant) => variant.trim());
73
- const branchVariants = [.../* @__PURE__ */ new Set([...thenVariants, ...elseVariants])];
74
- append(variants.length * branchVariants.length > MAX_VARIANTS ? [thenVariants[0] ?? ""] : branchVariants);
75
- }
76
- return [...new Set(variants)];
77
- };
78
- /**
79
- * The primary send-time rendering: every `<If>` takes its true branch (the
80
- * branch that carries the main copy by convention). Used for the single
81
- * `estimatedSegments` number and the opt-out check.
82
- */
83
- const primaryChannelText = (nodes, width) => {
84
- let result = "";
85
- for (const node of nodes) if (node.kind === "text") result += node.value;
86
- else if (node.kind === "interpolation") result += interpolationText(node, width);
87
- else result += primaryChannelText(ifBranches(node).then, width).trim();
88
- return result;
89
- };
90
- //#endregion
91
- //#region src/version.ts
92
- const COMPILER_VERSION = "0.1.0";
93
- //#endregion
94
- export { primaryChannelText as i, channelTextVariants as n, flattenChannelText as r, COMPILER_VERSION as t };
95
-
96
- //# sourceMappingURL=version-BITr58kk.js.map