@samva/markup 0.5.0 → 0.7.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 +80 -45
- package/README.md +1 -1
- package/dist/{ast-BLybiDxp.d.ts → ast-BrDtApwS.d.ts} +2 -2
- package/dist/ast.d.ts +1 -1
- package/dist/ast.js +1 -1
- package/dist/{catalog-Db0UcCTg.d.ts → catalog-60eaYC7b.d.ts} +2 -2
- package/dist/{checks-CmmITP6j.js → checks-DBweSIPN.js} +12 -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 +3 -3
- package/dist/compile.d.ts +2 -2
- package/dist/compiler.d.ts +7 -4
- package/dist/compiler.js +67 -46
- package/dist/components.d.ts +5 -5
- package/dist/conditionals.js +55 -23
- package/dist/{corpus-CM7rKX41.d.ts → corpus-BjYMqOoY.d.ts} +2 -2
- package/dist/{css-DoNc7CiC.d.ts → css-COcFOT1y.d.ts} +3 -3
- package/dist/{diagnostics-eFM9A_TU.d.ts → diagnostics-BMYtBCQk.d.ts} +2 -2
- package/dist/{diagnostics-CqepLcpI.d.ts → diagnostics-OcQKQYSY.d.ts} +4 -2
- package/dist/diagnostics.d.ts +2 -2
- package/dist/diagnostics.js +10 -5
- package/dist/{elements-ChJULZlh.d.ts → elements-BzjjnoCS.d.ts} +3 -3
- package/dist/email/components.d.ts +1 -1
- package/dist/email/components.js +40 -10
- package/dist/email/diagnostics.d.ts +1 -1
- package/dist/email/elements.d.ts +1 -1
- package/dist/email/html.d.ts +2 -2
- package/dist/email/html.js +2 -1
- package/dist/email/jsx-dev-runtime.d.ts +2 -2
- package/dist/email/jsx-runtime.d.ts +1 -1
- package/dist/email/render.d.ts +4 -4
- package/dist/email/render.js +1 -1
- package/dist/email/selection.d.ts +1 -1
- package/dist/email/source-edit.d.ts +1 -1
- package/dist/email/stylesheets.d.ts +1 -1
- package/dist/email/text.d.ts +1 -1
- package/dist/emit.d.ts +2 -2
- package/dist/emit.js +2 -2
- package/dist/footer.d.ts +3 -3
- package/dist/footer.js +9 -6
- package/dist/jsx-dev-runtime.d.ts +2 -2
- package/dist/{jsx-runtime-BI4gI19E.d.ts → jsx-runtime-I-1nCtl2.d.ts} +3 -3
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/lexer.js +17 -5
- package/dist/model.d.ts +1 -1
- package/dist/ops-2aiiYO7m.js +630 -0
- package/dist/ops.d.ts +2 -2
- package/dist/ops.js +1 -479
- package/dist/{parser-b_Kp5MT6.d.ts → parser-t29cHLVL.d.ts} +4 -4
- package/dist/parser.d.ts +1 -1
- package/dist/parser.js +2 -3
- package/dist/{predicate-DwXzmqIY.js → predicate-BI6uRRM-.js} +14 -4
- package/dist/{predicate-Bmvgw7Ao.d.ts → predicate-M-05Nd7R.d.ts} +2 -2
- 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/public-gallery.d.ts +2 -2
- package/dist/presets/public-gallery.js +10 -2
- package/dist/presets/public-handoff.d.ts +2 -2
- package/dist/presets/public-preview-artifacts.d.ts +3 -1
- package/dist/presets/public-preview-artifacts.js +1 -0
- 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-T6IFPnP4.js → render-aaJBnsXK.js} +33 -16
- package/dist/render-template.d.ts +5 -5
- package/dist/render-template.js +1 -1
- package/dist/{showcase-dvJMn-Lo.d.ts → showcase-DGZAWn4Z.d.ts} +2 -2
- package/dist/{source-locations-D6Te6Gy1.d.ts → source-locations-DrCM82Ym.d.ts} +2 -2
- package/dist/source-locations.d.ts +1 -1
- package/dist/{template-G-QPcfmn.d.ts → template-DWftqh4x.d.ts} +2 -2
- package/dist/template.d.ts +1 -1
- package/dist/theme-css.d.ts +1 -1
- package/dist/theme.js +25 -2
- package/dist/tsx-source-instrumentation.d.ts +9 -0
- package/dist/tsx-source-instrumentation.js +20 -2
- package/dist/tsx-tracer.d.ts +1 -1
- package/dist/tsx-tracer.js +3 -3
- package/dist/{variables-BnKs1iqb.d.ts → variables-J_L3qxRa.d.ts} +2 -2
- package/dist/variables.d.ts +1 -1
- package/dist/variables.js +1 -1
- package/package.json +4 -4
package/AGENTS.md
CHANGED
|
@@ -1,45 +1,80 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
`
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
1
|
+
# @samva/markup agent guide
|
|
2
|
+
|
|
3
|
+
`@samva/markup` is the authoring language and compiler for Samva templates. Email templates are
|
|
4
|
+
TSX modules that default-export a `defineEmail` definition and render through a JSX runtime that
|
|
5
|
+
lowers to email-safe HTML and plain text. SMS and WhatsApp templates use the structured SML runtime.
|
|
6
|
+
The package is plain TypeScript with no application runtime; the local editor, project builds, and
|
|
7
|
+
exports live in `@samva/vite`.
|
|
8
|
+
|
|
9
|
+
## Entry points
|
|
10
|
+
|
|
11
|
+
- `@samva/markup/template` — `defineEmail`, `TemplateDefinition`, `TemplateInput`, and
|
|
12
|
+
`TEMPLATE_NAME_PATTERN`.
|
|
13
|
+
- `@samva/markup/email` — the JSX runtime. Set `jsxImportSource: "@samva/markup/email"` for email
|
|
14
|
+
entries.
|
|
15
|
+
- `@samva/markup/email/components` — email primitives (`Email`, `Section`, `Columns`, `Button`,
|
|
16
|
+
and the rest of its exports). They generate table layout and classic-Outlook fallbacks.
|
|
17
|
+
- `@samva/markup/email/render` — `renderEmail(template, data)`, which validates input and returns
|
|
18
|
+
subject, preheader, HTML, text, and the derived tree.
|
|
19
|
+
- `@samva/markup/email/diagnostics` — `EmailDiagnostic` and `EmailCompileError`.
|
|
20
|
+
- `@samva/markup/input-schema` — `inputSchema`, which turns any Standard JSON Schema into the
|
|
21
|
+
portable JSON Schema and validator a template's input is checked against.
|
|
22
|
+
- `@samva/markup/compiler` — `compileEmailProject`, the bundler-agnostic compile step. It imports no
|
|
23
|
+
Vite, esbuild, or Node builtins, so it runs in any JavaScript host.
|
|
24
|
+
- `jsxImportSource: "@samva/markup"` and `@samva/markup/components` — the structured SMS and
|
|
25
|
+
WhatsApp runtime and components. `parseSml` (`@samva/markup/parser`) and `compileSml` /
|
|
26
|
+
`compileSource` (`@samva/markup/compile`) work on SML source.
|
|
27
|
+
|
|
28
|
+
The package's `generated/` directory ships the SML and email language references and agent
|
|
29
|
+
contracts; read those before authoring. Import only subpaths declared in `package.json` `exports`.
|
|
30
|
+
|
|
31
|
+
## How you hurt yourself here
|
|
32
|
+
|
|
33
|
+
- **Passing a string where you want markup.** Nothing an author passes as a string becomes markup;
|
|
34
|
+
strings render as escaped text. There is no raw-HTML escape hatch: compatibility markup comes only
|
|
35
|
+
from the email primitives.
|
|
36
|
+
- **Using an element or attribute the serializer does not allow.** `@samva/markup/email/elements` is
|
|
37
|
+
the one table behind both the JSX intrinsic prop types and the serializer's allowlist, so an
|
|
38
|
+
unsupported element or attribute fails at typecheck and again at compile with a source location.
|
|
39
|
+
- **Naming a template or fixture like a path.** A template id and a fixture key are both written
|
|
40
|
+
into file paths, so each must match `TEMPLATE_NAME_PATTERN`, one plain path segment.
|
|
41
|
+
`defineEmail` throws a `TypeError` where the name is declared. Code that builds a path from these
|
|
42
|
+
names imports the pattern instead of restating it.
|
|
43
|
+
- **Reading the clock or randomness in a template.** Samva's hosted render has no ambient clock and
|
|
44
|
+
no entropy source: reading the current instant or a random value there throws unless the
|
|
45
|
+
definition declares the fixed value in its `runtime` (`TemplateRuntime`). A local render does not
|
|
46
|
+
enforce this, so a template that reads `Date.now()` can pass locally and fail once published. Take
|
|
47
|
+
times from validated input, or declare them.
|
|
48
|
+
- **Treating `renderEmail` as a sandbox.** It executes the template's TypeScript in the calling
|
|
49
|
+
process. Run untrusted template source in an isolated host.
|
|
50
|
+
- **Expecting the schema library to do the validation.** A template's input schema is converted to
|
|
51
|
+
a portable JSON Schema and validated by that document, not by the library that produced it. A
|
|
52
|
+
refinement that the converter cannot export is refused, and defaults are never inserted or values
|
|
53
|
+
coerced. The README lists the supported keywords.
|
|
54
|
+
|
|
55
|
+
## Rules
|
|
56
|
+
|
|
57
|
+
- **Email entries default-export a `defineEmail` definition** from a `.tsx` file. The definition
|
|
58
|
+
owns a stable, project-unique `id`, an input schema, named fixtures, and a synchronous `render`
|
|
59
|
+
that receives the validated JSON input unchanged. Helper modules are ordinary imports, not
|
|
60
|
+
catalog entries.
|
|
61
|
+
- **Email templates have no textual SML form.** The derived semantic tree lowers directly to HTML
|
|
62
|
+
and text through `@samva/markup/email/render`; SML is the SMS and WhatsApp language.
|
|
63
|
+
- **Structured SML is a closed grammar.** `parseSml` and `compileSml` reject anything outside it
|
|
64
|
+
rather than passing it through.
|
|
65
|
+
- **Failures are typed.** The SML surface returns a better-result `Result`; branch with
|
|
66
|
+
`Result.isOk` / `Result.isErr` and discriminate the `TaggedError` (`SmlParseError`,
|
|
67
|
+
`SmlCompileError`) by `_tag`. Email compilation reports `EmailDiagnostic` values: errors throw
|
|
68
|
+
`EmailCompileError`, warnings ride back on the render result. A declaration the compiler cannot
|
|
69
|
+
accept at all, such as an invalid name or a nonportable input schema, throws a `TypeError`.
|
|
70
|
+
- **Data models are plain types.** Markup's data models are TypeScript types, not schema
|
|
71
|
+
declarations, so there is no schema library to adopt to consume them. Unions discriminate on
|
|
72
|
+
`type` (an `EmailNode`, an `SmlOp`); only error classes carry `_tag`. The input schema is the one
|
|
73
|
+
place a Standard Schema is accepted, and which library produces it is yours to choose.
|
|
74
|
+
|
|
75
|
+
## Proving your setup
|
|
76
|
+
|
|
77
|
+
- `tsc --noEmit` over the template project catches unsupported elements, attributes, and props.
|
|
78
|
+
- `samva templates check` (from `@samva/cli`) compiles every entry and renders every fixture,
|
|
79
|
+
reporting findings with source locations.
|
|
80
|
+
- `renderEmail(template, fixture)` in a unit test proves one template's output without a build.
|
package/README.md
CHANGED
|
@@ -101,7 +101,7 @@ a value at import. `new Date(value)` with an explicit argument always works, so
|
|
|
101
101
|
takes its time from validated input or states it once as configuration. Locale (`en-US`) and time
|
|
102
102
|
zone (UTC) are publication-wide and back every `Intl` constructor and `toLocale*` call.
|
|
103
103
|
|
|
104
|
-
Portable validation uses `@cfworker/json-schema`
|
|
104
|
+
Portable validation uses `@cfworker/json-schema` without runtime code generation. The
|
|
105
105
|
2020-12 meta-schema is checked at every supported schema position, and the explicit profile rejects
|
|
106
106
|
keywords outside its contract before interpretation. The AJV dependency supplies static meta-schema
|
|
107
107
|
JSON; its code generator is not invoked in a loaded template.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as Span } from "./diagnostics-
|
|
1
|
+
import { a as Span } from "./diagnostics-OcQKQYSY.js";
|
|
2
2
|
//#region src/ast.d.ts
|
|
3
3
|
declare const BLOCK_TAGS: readonly ["Email", "Subject", "Preview", "Container", "Section", "Row", "Column", "Heading", "Text", "Button", "Image", "Divider", "Spacer", "List", "ListItem", "If", "Else"];
|
|
4
4
|
declare const INLINE_TAGS: readonly ["strong", "em", "a"];
|
|
@@ -104,4 +104,4 @@ declare const isHiddenNode: (node: ElementNode) => boolean;
|
|
|
104
104
|
declare const collectVariableReferences: (document: SmlDocument) => ReadonlySet<string>;
|
|
105
105
|
//#endregion
|
|
106
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-
|
|
107
|
+
//# sourceMappingURL=ast-BrDtApwS.d.ts.map
|
package/dist/ast.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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-
|
|
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-BrDtApwS.js";
|
|
2
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,4 +1,4 @@
|
|
|
1
|
-
import { i as parsePredicate, n as collectPredicateVariables } from "./predicate-
|
|
1
|
+
import { i as parsePredicate, n as collectPredicateVariables } from "./predicate-BI6uRRM-.js";
|
|
2
2
|
import { Result } from "better-result";
|
|
3
3
|
//#region src/ast.ts
|
|
4
4
|
const BLOCK_TAGS = [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as Channel } from "./ast-
|
|
1
|
+
import { l as Channel } from "./ast-BrDtApwS.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-60eaYC7b.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as parsePredicate } from "./predicate-
|
|
1
|
+
import { createDiagnosticFormatter } from "./diagnostics.js";
|
|
2
|
+
import { i as parsePredicate } from "./predicate-BI6uRRM-.js";
|
|
3
3
|
import { stringAttribute } from "./ast.js";
|
|
4
4
|
import { parseCandidate, splitRoot } from "./candidate.js";
|
|
5
5
|
import { registryRoots, utilityRegistry } from "./registry.js";
|
|
@@ -58830,7 +58830,7 @@ const predicateSource = (source, attribute) => {
|
|
|
58830
58830
|
})
|
|
58831
58831
|
};
|
|
58832
58832
|
};
|
|
58833
|
-
const predicateDiagnosticMessages = (source, document, declaredVariables) => {
|
|
58833
|
+
const predicateDiagnosticMessages = (source, document, declaredVariables, formatDiagnostic) => {
|
|
58834
58834
|
const messages = [];
|
|
58835
58835
|
const declared = declaredVariables === void 0 ? void 0 : new Set(declaredVariables);
|
|
58836
58836
|
const visit = (node) => {
|
|
@@ -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.isError(parsed)) for (const diagnostic of parsed.error) messages.push(`error: ${formatDiagnostic(
|
|
58843
|
+
if (Result.isError(parsed)) for (const diagnostic of parsed.error) messages.push(`error: ${formatDiagnostic(predicate.mapDiagnostic(diagnostic))}`);
|
|
58844
58844
|
else if (declared !== void 0) {
|
|
58845
|
-
for (const reference of collectPredicateVariableReferences(parsed.value)) if (!declared.has(reference.name)) messages.push(`error: ${formatDiagnostic(
|
|
58845
|
+
for (const reference of collectPredicateVariableReferences(parsed.value)) if (!declared.has(reference.name)) messages.push(`error: ${formatDiagnostic({
|
|
58846
58846
|
code: "predicate-unknown-variable",
|
|
58847
58847
|
message: `unknown predicate variable "${reference.name}" in <If test>`,
|
|
58848
58848
|
span: predicate.mapSpan(reference.span)
|
|
@@ -58855,11 +58855,7 @@ const predicateDiagnosticMessages = (source, document, declaredVariables) => {
|
|
|
58855
58855
|
visit(document.root);
|
|
58856
58856
|
return messages;
|
|
58857
58857
|
};
|
|
58858
|
-
const parseFailurePredicateMessages = (
|
|
58859
|
-
const parsed = parseSml(source);
|
|
58860
|
-
if (Result.isOk(parsed)) return [];
|
|
58861
|
-
return parsed.error.diagnostics.filter((diagnostic) => diagnostic.code.startsWith("predicate-")).map((diagnostic) => `error: ${formatDiagnostic(source, diagnostic)}`);
|
|
58862
|
-
};
|
|
58858
|
+
const parseFailurePredicateMessages = (diagnostics, formatDiagnostic) => diagnostics.filter((diagnostic) => diagnostic.code.startsWith("predicate-")).map((diagnostic) => `error: ${formatDiagnostic(diagnostic)}`);
|
|
58863
58859
|
const clientsByDarkBehavior = (profile, behavior) => profile.targets.filter((target) => target.darkBehavior === behavior).map(targetLabel).filter((label, index, labels) => labels.indexOf(label) === index);
|
|
58864
58860
|
const gmailForcedInvertClients = (profile) => profile.targets.filter((target) => target.family === "gmail" && target.darkBehavior === "force-inverts").map(targetLabel);
|
|
58865
58861
|
const formatClientList = (clients) => clients.join(", ");
|
|
@@ -58941,11 +58937,13 @@ function worstCaseArtifactBytes(html) {
|
|
|
58941
58937
|
function checkSmlCompatibility(input) {
|
|
58942
58938
|
const profile = input.profile ?? DEFAULT_EMAIL_TARGET_CLIENT_PROFILE;
|
|
58943
58939
|
const parsed = parseSml(input.source);
|
|
58944
|
-
|
|
58940
|
+
let formatter;
|
|
58941
|
+
const formatDiagnostic = (diagnostic) => (formatter ??= createDiagnosticFormatter(input.source))(diagnostic);
|
|
58942
|
+
if (Result.isError(parsed)) return parseFailurePredicateMessages(parsed.error.diagnostics, formatDiagnostic);
|
|
58945
58943
|
const analysis = analyzeDocument(parsed.value);
|
|
58946
58944
|
return [
|
|
58947
|
-
...predicateDiagnosticMessages(input.source, parsed.value, input.declaredVariables),
|
|
58948
|
-
...checkDeliveryAssetDiagnostics(input.source).map((diagnostic) => `error: ${formatDiagnostic(
|
|
58945
|
+
...predicateDiagnosticMessages(input.source, parsed.value, input.declaredVariables, formatDiagnostic),
|
|
58946
|
+
...checkDeliveryAssetDiagnostics(input.source).map((diagnostic) => `error: ${formatDiagnostic(diagnostic)}`),
|
|
58949
58947
|
...caniemailMessages(analysis.featureSlugs, profile),
|
|
58950
58948
|
...darkModeMessages(analysis, profile)
|
|
58951
58949
|
];
|
|
@@ -58953,4 +58951,4 @@ function checkSmlCompatibility(input) {
|
|
|
58953
58951
|
//#endregion
|
|
58954
58952
|
export { isBreakingCompatibilityCheck as a, collectSmlFeatureSlugs as i, checkDeliveryAssetDiagnostics as n, worstCaseArtifactBytes as o, checkSmlCompatibility as r, DEFAULT_EMAIL_TARGET_CLIENT_PROFILE as t };
|
|
58955
58953
|
|
|
58956
|
-
//# sourceMappingURL=checks-
|
|
58954
|
+
//# sourceMappingURL=checks-DBweSIPN.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-DBweSIPN.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 { a as Span, t as Diagnostic } from "./diagnostics-
|
|
1
|
+
import { a as Span, t as Diagnostic } from "./diagnostics-OcQKQYSY.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 { f as ElementNode } from "./ast-
|
|
3
|
-
import { a as SMS_TAG_SPECS } from "./parser-
|
|
1
|
+
import { t as Diagnostic } from "./diagnostics-OcQKQYSY.js";
|
|
2
|
+
import { f as ElementNode } from "./ast-BrDtApwS.js";
|
|
3
|
+
import { a as SMS_TAG_SPECS } from "./parser-t29cHLVL.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,6 +1,6 @@
|
|
|
1
|
-
import { r as SmlCompileError, t as Diagnostic } from "./diagnostics-
|
|
2
|
-
import { f as ElementNode } from "./ast-
|
|
3
|
-
import { l as WHATSAPP_TAG_SPECS } from "./parser-
|
|
1
|
+
import { r as SmlCompileError, t as Diagnostic } from "./diagnostics-OcQKQYSY.js";
|
|
2
|
+
import { f as ElementNode } from "./ast-BrDtApwS.js";
|
|
3
|
+
import { l as WHATSAPP_TAG_SPECS } from "./parser-t29cHLVL.js";
|
|
4
4
|
import { Result } from "better-result";
|
|
5
5
|
//#region src/compile-whatsapp.d.ts
|
|
6
6
|
type WhatsAppSpecs = typeof WHATSAPP_TAG_SPECS;
|
package/dist/compile.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as SmlParseError, r as SmlCompileError } from "./diagnostics-
|
|
2
|
-
import { b as SmlDocument } from "./ast-
|
|
1
|
+
import { i as SmlParseError, r as SmlCompileError } from "./diagnostics-OcQKQYSY.js";
|
|
2
|
+
import { b as SmlDocument } from "./ast-BrDtApwS.js";
|
|
3
3
|
import { CompiledSms } from "./compile-sms.js";
|
|
4
4
|
import { CompiledWhatsApp } from "./compile-whatsapp.js";
|
|
5
5
|
import { Result } from "better-result";
|
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-BMYtBCQk.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-BzjjnoCS.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-COcFOT1y.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";
|
|
@@ -104,7 +104,10 @@ declare const isExternalAsset: (reference: string) => boolean;
|
|
|
104
104
|
declare const checkAssetBase: (base: string) => readonly EmailDiagnostic[];
|
|
105
105
|
//#endregion
|
|
106
106
|
//#region src/email/css-values.d.ts
|
|
107
|
-
/**
|
|
107
|
+
/**
|
|
108
|
+
* Expand `var(--x, fallback)` against the collected custom properties.
|
|
109
|
+
* Values whose expansion exceeds the render-time budget are left as authored.
|
|
110
|
+
*/
|
|
108
111
|
declare const resolveVariables: (value: string, variables: Readonly<Record<string, string>>, depth?: number) => string;
|
|
109
112
|
/**
|
|
110
113
|
* Fold a constant `calc()` to a plain value. Tailwind writes every spacing
|
package/dist/compiler.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
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-
|
|
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-aaJBnsXK.js";
|
|
3
3
|
import { EMAIL_ELEMENTS, EMAIL_GLOBAL_ATTRIBUTES, emailElement, isUrlAttribute } from "./email/elements.js";
|
|
4
4
|
import { INSTANCE_PATH_ATTRIBUTE, emailAuthoringTarget, emailDefinitionInstances, emailSelectionAncestry, emailSelectionIndex, emailSelectionSiblings, emailSelections } from "./email/selection.js";
|
|
5
5
|
import { escapeAttribute, escapeText, serializeEmailHtml } from "./email/html.js";
|
|
@@ -7,7 +7,7 @@ import { EmailCompileError, formatEmailDiagnostic, hasBlockingDiagnostic } from
|
|
|
7
7
|
import { collectStylesheets, hasStylesheets, registerStylesheet, resetStylesheets } from "./email/stylesheets.js";
|
|
8
8
|
import { deriveEmailText } from "./email/text.js";
|
|
9
9
|
import { buildLineMap, lineColumn } from "./diagnostics.js";
|
|
10
|
-
import { instrumentTsxSourceForPreview } from "./tsx-source-instrumentation.js";
|
|
10
|
+
import { TsxSourceInstrumentationError, instrumentTsxSourceForPreview } from "./tsx-source-instrumentation.js";
|
|
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";
|
|
@@ -264,11 +264,10 @@ const EMAIL_CLIENT_MATRIX = [
|
|
|
264
264
|
}
|
|
265
265
|
];
|
|
266
266
|
const LABELS = new Map(EMAIL_CLIENT_MATRIX.map((target) => [target.id, target.label]));
|
|
267
|
-
const data = rawData;
|
|
268
267
|
const COMPATIBILITY_PROVENANCE = {
|
|
269
268
|
rules: "caniemail@2.0.2",
|
|
270
|
-
apiVersion:
|
|
271
|
-
lastUpdate:
|
|
269
|
+
apiVersion: rawData.api_version,
|
|
270
|
+
lastUpdate: rawData.last_update_date
|
|
272
271
|
};
|
|
273
272
|
/**
|
|
274
273
|
* The constructs whose loss actually breaks a message: the recipient reads
|
|
@@ -298,7 +297,7 @@ const ESSENTIAL_CONSTRUCTS = /* @__PURE__ */ new Set([
|
|
|
298
297
|
"mailto: links",
|
|
299
298
|
"Local anchors"
|
|
300
299
|
]);
|
|
301
|
-
const KNOWN_TITLES = new Set(
|
|
300
|
+
const KNOWN_TITLES = new Set(rawData.data.map((feature) => feature.title));
|
|
302
301
|
/** The innermost recorded node containing an offset, so a finding names its element. */
|
|
303
302
|
const originsAt = (positions, offset) => {
|
|
304
303
|
let best;
|
|
@@ -895,45 +894,6 @@ const compileSelector = (selector) => {
|
|
|
895
894
|
};
|
|
896
895
|
/** Substitute a nested rule's `&` against its parent selector. */
|
|
897
896
|
const nestSelector = (parent, child) => child.includes("&") ? child.replaceAll("&", parent) : `${parent} ${child}`;
|
|
898
|
-
const selectorFacts = /* @__PURE__ */ new Map();
|
|
899
|
-
/** Everything a rule needs from its selector, computed once per distinct string. */
|
|
900
|
-
const factsFor = (selector) => {
|
|
901
|
-
const cached = selectorFacts.get(selector);
|
|
902
|
-
if (cached !== void 0) return cached;
|
|
903
|
-
let facts;
|
|
904
|
-
try {
|
|
905
|
-
const node = parse$1(selector, {
|
|
906
|
-
context: "selector",
|
|
907
|
-
positions: false
|
|
908
|
-
});
|
|
909
|
-
const classes = /* @__PURE__ */ new Set();
|
|
910
|
-
walk(node, {
|
|
911
|
-
visit: "ClassSelector",
|
|
912
|
-
enter: (part) => {
|
|
913
|
-
classes.add(ident.decode(part.name));
|
|
914
|
-
}
|
|
915
|
-
});
|
|
916
|
-
facts = {
|
|
917
|
-
classes: [...classes],
|
|
918
|
-
specificity: specificityOf(node),
|
|
919
|
-
pseudo: hasPseudo(node),
|
|
920
|
-
matcher: compileSelector(selector)
|
|
921
|
-
};
|
|
922
|
-
} catch {
|
|
923
|
-
facts = {
|
|
924
|
-
classes: [],
|
|
925
|
-
specificity: [
|
|
926
|
-
0,
|
|
927
|
-
0,
|
|
928
|
-
0
|
|
929
|
-
],
|
|
930
|
-
pseudo: true,
|
|
931
|
-
matcher: void 0
|
|
932
|
-
};
|
|
933
|
-
}
|
|
934
|
-
selectorFacts.set(selector, facts);
|
|
935
|
-
return facts;
|
|
936
|
-
};
|
|
937
897
|
/** Parse one stylesheet into rules, keeping layer, order and conditions. */
|
|
938
898
|
const parseStylesheet = (source, options = {}) => {
|
|
939
899
|
const rules = [];
|
|
@@ -942,7 +902,46 @@ const parseStylesheet = (source, options = {}) => {
|
|
|
942
902
|
const conditionalVariables = /* @__PURE__ */ new Set();
|
|
943
903
|
const diagnostics = [];
|
|
944
904
|
const layers = /* @__PURE__ */ new Map();
|
|
905
|
+
const selectorFacts = /* @__PURE__ */ new Map();
|
|
945
906
|
let order = options.startOrder ?? 0;
|
|
907
|
+
/** Everything a rule needs from its selector, computed once per distinct string. */
|
|
908
|
+
const factsFor = (selector) => {
|
|
909
|
+
const cached = selectorFacts.get(selector);
|
|
910
|
+
if (cached !== void 0) return cached;
|
|
911
|
+
let facts;
|
|
912
|
+
try {
|
|
913
|
+
const node = parse$1(selector, {
|
|
914
|
+
context: "selector",
|
|
915
|
+
positions: false
|
|
916
|
+
});
|
|
917
|
+
const classes = /* @__PURE__ */ new Set();
|
|
918
|
+
walk(node, {
|
|
919
|
+
visit: "ClassSelector",
|
|
920
|
+
enter: (part) => {
|
|
921
|
+
classes.add(ident.decode(part.name));
|
|
922
|
+
}
|
|
923
|
+
});
|
|
924
|
+
facts = {
|
|
925
|
+
classes: [...classes],
|
|
926
|
+
specificity: specificityOf(node),
|
|
927
|
+
pseudo: hasPseudo(node),
|
|
928
|
+
matcher: compileSelector(selector)
|
|
929
|
+
};
|
|
930
|
+
} catch {
|
|
931
|
+
facts = {
|
|
932
|
+
classes: [],
|
|
933
|
+
specificity: [
|
|
934
|
+
0,
|
|
935
|
+
0,
|
|
936
|
+
0
|
|
937
|
+
],
|
|
938
|
+
pseudo: true,
|
|
939
|
+
matcher: void 0
|
|
940
|
+
};
|
|
941
|
+
}
|
|
942
|
+
selectorFacts.set(selector, facts);
|
|
943
|
+
return facts;
|
|
944
|
+
};
|
|
946
945
|
let ast;
|
|
947
946
|
try {
|
|
948
947
|
ast = parse$1(source, {
|
|
@@ -1246,6 +1245,28 @@ const stylesheetModule = (id, source, options) => {
|
|
|
1246
1245
|
};
|
|
1247
1246
|
};
|
|
1248
1247
|
/**
|
|
1248
|
+
* Authored TSX the parser refused is a finding about the source, located where
|
|
1249
|
+
* the parser stopped, so every host reports it the way it reports any other
|
|
1250
|
+
* compile error.
|
|
1251
|
+
*/
|
|
1252
|
+
const instrumentAuthoredTsx = (text, id) => {
|
|
1253
|
+
try {
|
|
1254
|
+
return instrumentTsxSourceForPreview(text, id, void 0, null);
|
|
1255
|
+
} catch (error) {
|
|
1256
|
+
if (!(error instanceof TsxSourceInstrumentationError)) throw error;
|
|
1257
|
+
throw new EmailCompileError({ diagnostics: [{
|
|
1258
|
+
code: "tsx-invalid-authored-source",
|
|
1259
|
+
severity: "error",
|
|
1260
|
+
message: error.message,
|
|
1261
|
+
origins: error.location === void 0 ? [] : [{
|
|
1262
|
+
fileName: id,
|
|
1263
|
+
lineNumber: error.location.line,
|
|
1264
|
+
columnNumber: error.location.column
|
|
1265
|
+
}]
|
|
1266
|
+
}] });
|
|
1267
|
+
}
|
|
1268
|
+
};
|
|
1269
|
+
/**
|
|
1249
1270
|
* Transform one project file into a JavaScript module.
|
|
1250
1271
|
*
|
|
1251
1272
|
* `.tsx`/`.ts` keep their authored semantics and gain source origins. A
|
|
@@ -1270,7 +1291,7 @@ const transformModule = async (id, source, options) => {
|
|
|
1270
1291
|
};
|
|
1271
1292
|
const discovered = options.tailwind === false ? void 0 : discoverClassCandidates(text, id);
|
|
1272
1293
|
return {
|
|
1273
|
-
code: JSX.test(id) ?
|
|
1294
|
+
code: JSX.test(id) ? instrumentAuthoredTsx(text, id) : text,
|
|
1274
1295
|
classes: discovered?.candidates,
|
|
1275
1296
|
diagnostics: discovered?.diagnostics ?? []
|
|
1276
1297
|
};
|
package/dist/components.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { f as ElementNode } from "./ast-
|
|
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-BrDtApwS.js";
|
|
2
|
+
import { i as EMAIL_TAG_SPECS, l as WHATSAPP_TAG_SPECS, o as TagSpec, t as AttributeSpec } from "./parser-t29cHLVL.js";
|
|
3
|
+
import { r as PredicateRef, s as VariableRef } from "./variables-J_L3qxRa.js";
|
|
4
|
+
import { s as SmlChildren } from "./jsx-runtime-I-1nCtl2.js";
|
|
5
5
|
//#region src/components.d.ts
|
|
6
6
|
/**
|
|
7
7
|
* The scalar type an attribute spec accepts. `level` narrows to the Heading
|
|
@@ -244,7 +244,7 @@ declare const WhatsApp: (props: PropsOf<{
|
|
|
244
244
|
readonly category: {
|
|
245
245
|
readonly type: "string";
|
|
246
246
|
readonly required: true;
|
|
247
|
-
readonly values: readonly ["marketing", "utility", "authentication"
|
|
247
|
+
readonly values: readonly ["marketing", "utility", "authentication"];
|
|
248
248
|
};
|
|
249
249
|
};
|
|
250
250
|
readonly content: "whatsapp";
|
package/dist/conditionals.js
CHANGED
|
@@ -1,31 +1,63 @@
|
|
|
1
|
-
import { i as parsePredicate, r as evaluatePredicate } from "./predicate-
|
|
1
|
+
import { i as parsePredicate, r as evaluatePredicate } from "./predicate-BI6uRRM-.js";
|
|
2
2
|
import { Result } from "better-result";
|
|
3
3
|
//#region src/conditionals.ts
|
|
4
4
|
const IF_MARKER = "<!--sml:if:";
|
|
5
5
|
const MARKER_CLOSE = "-->";
|
|
6
6
|
const resolve = (content, variables) => {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
7
|
+
const stack = [{
|
|
8
|
+
cursor: 0,
|
|
9
|
+
end: content.length,
|
|
10
|
+
trim: false,
|
|
11
|
+
chunks: []
|
|
12
|
+
}];
|
|
13
|
+
let resolved = content;
|
|
14
|
+
while (stack.length > 0) {
|
|
15
|
+
const frame = stack.at(-1);
|
|
16
|
+
const start = content.indexOf(IF_MARKER, frame.cursor);
|
|
17
|
+
if (start === -1 || start >= frame.end) {
|
|
18
|
+
frame.chunks.push(content.slice(frame.cursor, frame.end));
|
|
19
|
+
const value = frame.trim ? frame.chunks.join("").trim() : frame.chunks.join("");
|
|
20
|
+
stack.pop();
|
|
21
|
+
const parent = stack.at(-1);
|
|
22
|
+
if (parent === void 0) resolved = value;
|
|
23
|
+
else parent.chunks.push(value);
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const headEnd = content.indexOf(MARKER_CLOSE, start);
|
|
27
|
+
if (headEnd === -1 || headEnd >= frame.end) {
|
|
28
|
+
frame.chunks.push(content.slice(frame.cursor, frame.end));
|
|
29
|
+
frame.cursor = frame.end;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const header = content.slice(start + 11, headEnd);
|
|
33
|
+
const spaceIndex = header.indexOf(" ");
|
|
34
|
+
const id = spaceIndex === -1 ? header : header.slice(0, spaceIndex);
|
|
35
|
+
const predicateSource = spaceIndex === -1 ? "" : header.slice(spaceIndex + 1);
|
|
36
|
+
const elseMarker = `<!--sml:else:${id}-->`;
|
|
37
|
+
const endMarker = `<!--sml:endif:${id}-->`;
|
|
38
|
+
const bodyStart = headEnd + 3;
|
|
39
|
+
const endIndex = content.indexOf(endMarker, bodyStart);
|
|
40
|
+
if (endIndex === -1 || endIndex + endMarker.length > frame.end) {
|
|
41
|
+
frame.chunks.push(content.slice(frame.cursor, frame.end));
|
|
42
|
+
frame.cursor = frame.end;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const elseCandidate = content.indexOf(elseMarker, bodyStart);
|
|
46
|
+
const elseIndex = elseCandidate !== -1 && elseCandidate < endIndex ? elseCandidate : -1;
|
|
47
|
+
const parsed = parsePredicate(predicateSource);
|
|
48
|
+
const condition = Result.isOk(parsed) && evaluatePredicate(parsed.value, variables);
|
|
49
|
+
const branchStart = condition ? bodyStart : elseIndex === -1 ? endIndex : elseIndex + elseMarker.length;
|
|
50
|
+
const branchEnd = condition && elseIndex !== -1 ? elseIndex : endIndex;
|
|
51
|
+
frame.chunks.push(content.slice(frame.cursor, start));
|
|
52
|
+
frame.cursor = endIndex + endMarker.length;
|
|
53
|
+
stack.push({
|
|
54
|
+
cursor: branchStart,
|
|
55
|
+
end: branchEnd,
|
|
56
|
+
trim: true,
|
|
57
|
+
chunks: []
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return resolved;
|
|
29
61
|
};
|
|
30
62
|
/**
|
|
31
63
|
* Selects <If> branches in a compiled artifact (html or plain-text alt) for
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as OwnedShowcaseId, t as BrandRecreationShowcaseId } from "./showcase-
|
|
1
|
+
import { n as OwnedShowcaseId, t as BrandRecreationShowcaseId } from "./showcase-DGZAWn4Z.js";
|
|
2
2
|
import { Result } from "better-result";
|
|
3
3
|
//#region presets/corpus.d.ts
|
|
4
4
|
type TemplateCorpusKind = "owned-editable-sml" | "brand-recreation-sml" | "inspiration-reference";
|
|
@@ -103,4 +103,4 @@ type TemplateFacetQuery = Partial<TemplateFacetSet>;
|
|
|
103
103
|
declare const matchesTemplateFacets: (facets: TemplateFacetSet, query: TemplateFacetQuery) => boolean;
|
|
104
104
|
//#endregion
|
|
105
105
|
export { PublicCorpusRegistrationIssue as a, TemplateFacetQuery as c, matchesTemplateFacets as d, ownedPresetSourcePath as f, templateFacetOptions as h, PublicCorpusRegistration as i, TemplateFacetSet as l, registerPublicCorpusEntry as m, InspirationReference as n, TemplateCorpusKind as o, ownedShowcasePresetSources as p, OwnedEditablePreset as r, TemplateCorpusRecord as s, BrandRecreationPreset as t, brandRecreationProvenance as u };
|
|
106
|
-
//# sourceMappingURL=corpus-
|
|
106
|
+
//# sourceMappingURL=corpus-BjYMqOoY.d.ts.map
|