@samva/markup 0.7.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 (176) hide show
  1. package/AGENTS.md +104 -37
  2. package/README.md +188 -52
  3. package/dist/assets-C5duwTya.d.ts +40 -0
  4. package/dist/brand-B-0bN_Ir.d.ts +88 -0
  5. package/dist/{render-aaJBnsXK.js → cascade-t6kxlgEI.js} +130 -160
  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 +19 -249
  12. package/dist/compiler.js +10 -1408
  13. package/dist/{css-COcFOT1y.d.ts → css-BVQKICKC.d.ts} +30 -4
  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 -0
  21. package/dist/email/assets.js +63 -0
  22. package/dist/email/brand-footer.d.ts +34 -0
  23. package/dist/email/brand-footer.js +63 -0
  24. package/dist/email/brand.d.ts +2 -0
  25. package/dist/email/brand.js +148 -0
  26. package/dist/email/components.d.ts +21 -10
  27. package/dist/email/components.js +46 -11
  28. package/dist/email/diagnostics.d.ts +2 -2
  29. package/dist/email/diagnostics.js +2 -1
  30. package/dist/email/elements.d.ts +1 -1
  31. package/dist/email/html.d.ts +2 -42
  32. package/dist/email/html.js +56 -2
  33. package/dist/email/jsx-dev-runtime.d.ts +2 -2
  34. package/dist/email/jsx-runtime.d.ts +1 -1
  35. package/dist/email/render.d.ts +10 -13
  36. package/dist/email/render.js +163 -6
  37. package/dist/email/text.d.ts +1 -1
  38. package/dist/fmt.d.ts +32 -0
  39. package/dist/fmt.js +174 -0
  40. package/dist/html-BJepOwZ4.d.ts +56 -0
  41. package/dist/index.d.ts +2 -0
  42. package/dist/index.js +2 -0
  43. package/dist/ir-aaqNE987.d.ts +252 -0
  44. package/dist/ir.d.ts +2 -0
  45. package/dist/ir.js +7 -0
  46. package/dist/preview-Ekdg1dXG.d.ts +100 -0
  47. package/dist/preview.d.ts +2 -0
  48. package/dist/preview.js +160 -0
  49. package/dist/profile-BH-OtdDA.js +3670 -0
  50. package/dist/render-ir.d.ts +19 -0
  51. package/dist/render-ir.js +826 -0
  52. package/dist/sms-segments.d.ts +13 -2
  53. package/dist/sms.d.ts +16 -0
  54. package/dist/sms.js +12 -0
  55. package/dist/{email/source-edit.d.ts → source-edit.d.ts} +55 -6
  56. package/dist/source-edit.js +343 -0
  57. package/dist/source-locations-C8wCsiAy.d.ts +23 -0
  58. package/dist/source-locations.d.ts +2 -2
  59. package/dist/source-locations.js +3 -89
  60. package/dist/static.d.ts +57 -0
  61. package/dist/static.js +69 -0
  62. package/dist/tailwind-CMYpZf1v.js +614 -0
  63. package/dist/template-_QE_rQND.d.ts +65 -0
  64. package/dist/template.d.ts +2 -2
  65. package/dist/template.js +15 -10
  66. package/dist/theme-css-hFqcPSar.js +587 -0
  67. package/dist/theme-css.d.ts +57 -16
  68. package/dist/theme-css.js +2 -509
  69. package/dist/theme-imports-lvBw3AD1.js +109 -0
  70. package/dist/transform-Ct2OMkFN.d.ts +153 -0
  71. package/dist/unsubscribe-link-CoesnQDU.js +26 -0
  72. package/dist/whatsapp.d.ts +57 -0
  73. package/dist/whatsapp.js +22 -0
  74. package/generated/contract.json +1782 -0
  75. package/generated/reference.md +353 -0
  76. package/package.json +56 -154
  77. package/samva-brand.d.ts +14 -0
  78. package/skills/sml/SKILL.md +123 -0
  79. package/dist/ast-BrDtApwS.d.ts +0 -107
  80. package/dist/ast.d.ts +0 -2
  81. package/dist/ast.js +0 -124
  82. package/dist/candidate.d.ts +0 -29
  83. package/dist/candidate.js +0 -88
  84. package/dist/catalog-60eaYC7b.d.ts +0 -356
  85. package/dist/checks-DBweSIPN.js +0 -58954
  86. package/dist/checks.d.ts +0 -33
  87. package/dist/checks.js +0 -2
  88. package/dist/classes.d.ts +0 -27
  89. package/dist/classes.js +0 -184
  90. package/dist/compile-sms.d.ts +0 -28
  91. package/dist/compile-sms.js +0 -44
  92. package/dist/compile-whatsapp.d.ts +0 -56
  93. package/dist/compile-whatsapp.js +0 -186
  94. package/dist/compile.d.ts +0 -18
  95. package/dist/compile.js +0 -29
  96. package/dist/components.d.ts +0 -289
  97. package/dist/components.js +0 -106
  98. package/dist/conditionals.d.ts +0 -10
  99. package/dist/conditionals.js +0 -74
  100. package/dist/corpus-BjYMqOoY.d.ts +0 -106
  101. package/dist/diagnostics-OcQKQYSY.d.ts +0 -49
  102. package/dist/email/selection.d.ts +0 -91
  103. package/dist/email/selection.js +0 -91
  104. package/dist/email/source-edit.js +0 -185
  105. package/dist/email/stylesheets.d.ts +0 -15
  106. package/dist/email/stylesheets.js +0 -45
  107. package/dist/emit.d.ts +0 -51
  108. package/dist/emit.js +0 -151
  109. package/dist/footer.d.ts +0 -66
  110. package/dist/footer.js +0 -93
  111. package/dist/interpolate.d.ts +0 -24
  112. package/dist/interpolate.js +0 -43
  113. package/dist/jsx-dev-runtime.d.ts +0 -11
  114. package/dist/jsx-dev-runtime.js +0 -15
  115. package/dist/jsx-runtime-I-1nCtl2.d.ts +0 -57
  116. package/dist/jsx-runtime.d.ts +0 -2
  117. package/dist/jsx-runtime.js +0 -121
  118. package/dist/lexer.d.ts +0 -60
  119. package/dist/lexer.js +0 -281
  120. package/dist/model.d.ts +0 -24
  121. package/dist/model.js +0 -77
  122. package/dist/ops-2aiiYO7m.js +0 -630
  123. package/dist/ops.d.ts +0 -114
  124. package/dist/ops.js +0 -2
  125. package/dist/parser-t29cHLVL.d.ts +0 -396
  126. package/dist/parser.d.ts +0 -2
  127. package/dist/parser.js +0 -859
  128. package/dist/predicate-BI6uRRM-.js +0 -549
  129. package/dist/predicate-M-05Nd7R.d.ts +0 -56
  130. package/dist/predicate.d.ts +0 -2
  131. package/dist/predicate.js +0 -2
  132. package/dist/presets/category-mapping.d.ts +0 -13
  133. package/dist/presets/category-mapping.js +0 -49
  134. package/dist/presets/corpus.d.ts +0 -2
  135. package/dist/presets/corpus.js +0 -194
  136. package/dist/presets/public-gallery.d.ts +0 -266
  137. package/dist/presets/public-gallery.js +0 -916
  138. package/dist/presets/public-handoff.d.ts +0 -164
  139. package/dist/presets/public-handoff.js +0 -361
  140. package/dist/presets/public-preview-artifacts.d.ts +0 -43
  141. package/dist/presets/public-preview-artifacts.js +0 -104
  142. package/dist/presets/public-preview.d.ts +0 -61
  143. package/dist/presets/public-preview.js +0 -83
  144. package/dist/presets/showcase.d.ts +0 -2
  145. package/dist/presets/showcase.js +0 -627
  146. package/dist/presets/sources.d.ts +0 -38
  147. package/dist/presets/sources.js +0 -6083
  148. package/dist/presets.d.ts +0 -2
  149. package/dist/presets.js +0 -881
  150. package/dist/printer.d.ts +0 -6
  151. package/dist/printer.js +0 -122
  152. package/dist/registry.d.ts +0 -42
  153. package/dist/registry.js +0 -646
  154. package/dist/render-template.d.ts +0 -45
  155. package/dist/render-template.js +0 -76
  156. package/dist/showcase-DGZAWn4Z.d.ts +0 -456
  157. package/dist/sms-segments-y4FpPilJ.d.ts +0 -13
  158. package/dist/source-locations-DrCM82Ym.d.ts +0 -67
  159. package/dist/template-DWftqh4x.d.ts +0 -60
  160. package/dist/theme-6ApjjiBo.d.ts +0 -116
  161. package/dist/theme.d.ts +0 -2
  162. package/dist/theme.js +0 -118
  163. package/dist/tokens.d.ts +0 -6
  164. package/dist/tokens.js +0 -417
  165. package/dist/tsx-source-instrumentation.d.ts +0 -30
  166. package/dist/tsx-source-instrumentation.js +0 -115
  167. package/dist/tsx-tracer.d.ts +0 -112
  168. package/dist/tsx-tracer.js +0 -985
  169. package/dist/variables-J_L3qxRa.d.ts +0 -77
  170. package/dist/variables.d.ts +0 -2
  171. package/dist/variables.js +0 -141
  172. package/dist/version-BITr58kk.js +0 -96
  173. package/generated/sml-agent-contract.json +0 -709
  174. package/generated/sml-email-agent-contract.json +0 -615
  175. package/generated/sml-email-language-reference.md +0 -94
  176. package/generated/sml-language-reference.md +0 -195
@@ -0,0 +1,65 @@
1
+ import { m as EmailNode } from "./elements-cqldpaJt.js";
2
+ import { r as InputSchema } from "./input-schema-7dPFVvNE.js";
3
+ import { StandardJSONSchemaV1 } from "@standard-schema/spec";
4
+ //#region src/template.d.ts
5
+ /** One actual-input render owns all of a message's authored content. */
6
+ interface EmailContent {
7
+ readonly subject: string;
8
+ readonly preheader?: string;
9
+ readonly body: EmailNode;
10
+ readonly text?: string;
11
+ }
12
+ /**
13
+ * The one naming contract for a template id and a fixture key: a letter, a digit or `_` first,
14
+ * then those plus `.`, `_` and `-`.
15
+ *
16
+ * Both names are written into file paths — a local export writes one page at
17
+ * `templates/<id>/<fixture>.html` — so each has to be a single plain path segment. The rule lives
18
+ * at the declaration, so a project that could not be exported is refused where the name is
19
+ * written rather than at the end of a build. Consumers that resolve a path from these names
20
+ * import this pattern; they do not restate it.
21
+ */
22
+ declare const TEMPLATE_NAME_PATTERN: RegExp;
23
+ /** Caller input for generated references and separate authoring consumers. */
24
+ type TemplateInput<T extends {
25
+ readonly schema: unknown;
26
+ }> = T["schema"] extends InputSchema<infer Input> ? Input : never;
27
+ /**
28
+ * The one naming contract for a template `id`: lowercase kebab-case, the same rule as the CLI and
29
+ * API slug, so the id a definition declares is the handle a caller sends by.
30
+ */
31
+ declare const TEMPLATE_ID_PATTERN: RegExp;
32
+ /** The email channel of a template: an envelope and a body, each a function of the input. */
33
+ interface EmailChannel<Input> {
34
+ readonly subject: (input: Input) => string;
35
+ readonly preheader?: ((input: Input) => string | undefined) | undefined;
36
+ readonly body: (input: Input) => EmailNode;
37
+ }
38
+ /** A template as `defineTemplate` returns it: its identity, input contract and each channel it declares. */
39
+ interface SmlTemplate<Input> {
40
+ readonly id: string;
41
+ readonly schema: InputSchema<Input>;
42
+ readonly fixtures: Readonly<Record<string, Input>>;
43
+ readonly locale?: string | undefined;
44
+ readonly email?: EmailChannel<Input> | undefined;
45
+ readonly sms?: ((input: Input) => EmailNode) | undefined;
46
+ readonly whatsapp?: ((input: Input) => EmailNode) | undefined;
47
+ }
48
+ /**
49
+ * Define a template: one id, one input schema, named fixtures and one body per channel. Every
50
+ * function in it receives the validated input and returns JSX or a string; a compiler reads them
51
+ * without running them, so nothing here executes at send time. Types are inferred from the
52
+ * Standard JSON Schema input.
53
+ */
54
+ declare const defineTemplate: <S extends StandardJSONSchemaV1>(definition: {
55
+ readonly id: string;
56
+ readonly schema: S;
57
+ readonly fixtures: Readonly<Record<string, NoInfer<StandardJSONSchemaV1.InferInput<S>>>>;
58
+ readonly locale?: string | undefined;
59
+ readonly email?: EmailChannel<NoInfer<StandardJSONSchemaV1.InferInput<S>>> | undefined;
60
+ readonly sms?: ((input: NoInfer<StandardJSONSchemaV1.InferInput<S>>) => EmailNode) | undefined;
61
+ readonly whatsapp?: ((input: NoInfer<StandardJSONSchemaV1.InferInput<S>>) => EmailNode) | undefined;
62
+ }) => SmlTemplate<StandardJSONSchemaV1.InferInput<S>>;
63
+ //#endregion
64
+ export { TEMPLATE_NAME_PATTERN as a, TEMPLATE_ID_PATTERN as i, EmailContent as n, TemplateInput as o, SmlTemplate as r, defineTemplate as s, EmailChannel as t };
65
+ //# sourceMappingURL=template-_QE_rQND.d.ts.map
@@ -1,2 +1,2 @@
1
- import { a as TemplateRuntime, i as TemplateInput, n as TEMPLATE_NAME_PATTERN, o as defineEmail, r as TemplateDefinition, s as isTemplateDefinition, t as EmailContent } from "./template-DWftqh4x.js";
2
- export { EmailContent, TEMPLATE_NAME_PATTERN, TemplateDefinition, TemplateInput, TemplateRuntime, defineEmail, isTemplateDefinition };
1
+ import { a as TEMPLATE_NAME_PATTERN, i as TEMPLATE_ID_PATTERN, n as EmailContent, o as TemplateInput, r as SmlTemplate, s as defineTemplate, t as EmailChannel } from "./template-_QE_rQND.js";
2
+ export { EmailChannel, EmailContent, SmlTemplate, TEMPLATE_ID_PATTERN, TEMPLATE_NAME_PATTERN, TemplateInput, defineTemplate };
package/dist/template.js CHANGED
@@ -1,8 +1,5 @@
1
- import { n as isObject } from "./guards-eV1qLbf2.js";
2
1
  import { n as inputSchema } from "./input-schema-zjkgrXn2.js";
3
2
  //#region src/template.ts
4
- /** Classify an evaluated module export without executing helpers as templates. */
5
- const isTemplateDefinition = (value) => isObject(value) && typeof value.id === "string" && typeof value.render === "function" && isObject(value.schema);
6
3
  /**
7
4
  * The one naming contract for a template id and a fixture key: a letter, a digit or `_` first,
8
5
  * then those plus `.`, `_` and `-`.
@@ -19,19 +16,27 @@ const checkTemplateName = (kind, value) => {
19
16
  throw new TypeError(`${kind} ${JSON.stringify(value)} is not one path segment. A template id and a fixture key are written into file paths, so each must start with a letter, a digit or "_" and continue with letters, digits, ".", "_" or "-".`);
20
17
  };
21
18
  /**
22
- * Define an email template with caller-input inference from a Standard JSON Schema converter. The
23
- * helper is named for its channel because its render result is email content; `TemplateDefinition`
24
- * and `TemplateInput` stay channel-neutral.
19
+ * The one naming contract for a template `id`: lowercase kebab-case, the same rule as the CLI and
20
+ * API slug, so the id a definition declares is the handle a caller sends by.
25
21
  */
26
- const defineEmail = (definition) => {
27
- checkTemplateName("Template id", definition.id);
28
- for (const fixture of Object.keys(definition.fixtures)) checkTemplateName("Fixture key", fixture);
22
+ const TEMPLATE_ID_PATTERN = /^(?=.{1,100}$)[a-z0-9]+(?:-[a-z0-9]+)*$/;
23
+ /**
24
+ * Define a template: one id, one input schema, named fixtures and one body per channel. Every
25
+ * function in it receives the validated input and returns JSX or a string; a compiler reads them
26
+ * without running them, so nothing here executes at send time. Types are inferred from the
27
+ * Standard JSON Schema input.
28
+ */
29
+ const defineTemplate = (definition) => {
30
+ if (!TEMPLATE_ID_PATTERN.test(definition.id)) throw new TypeError(`Template id ${JSON.stringify(definition.id)} is not lowercase kebab-case. The id is the handle a send names, so write lowercase letters and digits joined by single hyphens, for example "order-shipped".`);
31
+ const fixtureNames = Object.keys(definition.fixtures);
32
+ if (fixtureNames.length === 0) throw new TypeError(`Template ${definition.id} declares no fixtures. Fixtures are the preview, the agent's render targets and the publish check; declare at least one.`);
33
+ for (const fixture of fixtureNames) checkTemplateName("Fixture key", fixture);
29
34
  return {
30
35
  ...definition,
31
36
  schema: inputSchema(definition.schema)
32
37
  };
33
38
  };
34
39
  //#endregion
35
- export { TEMPLATE_NAME_PATTERN, defineEmail, isTemplateDefinition };
40
+ export { TEMPLATE_ID_PATTERN, TEMPLATE_NAME_PATTERN, defineTemplate };
36
41
 
37
42
  //# sourceMappingURL=template.js.map