@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.
- package/AGENTS.md +104 -37
- package/README.md +188 -52
- package/dist/assets-C5duwTya.d.ts +40 -0
- package/dist/brand-B-0bN_Ir.d.ts +88 -0
- package/dist/{render-aaJBnsXK.js → cascade-t6kxlgEI.js} +130 -160
- package/dist/channel-edit.d.ts +121 -0
- package/dist/channel-edit.js +609 -0
- package/dist/channel-specs-B6M_HlaV.js +29 -0
- package/dist/channel-specs-C2feJwuP.d.ts +13 -0
- package/dist/compatibility-DbISoFIq.js +589 -0
- package/dist/compiler.d.ts +19 -249
- package/dist/compiler.js +10 -1408
- package/dist/{css-COcFOT1y.d.ts → css-BVQKICKC.d.ts} +30 -4
- package/dist/diagnostic-codes.d.ts +403 -0
- package/dist/diagnostic-codes.js +399 -0
- package/dist/{diagnostics-BMYtBCQk.d.ts → diagnostics-B-Gym34R.d.ts} +8 -4
- package/dist/diagnostics.d.ts +31 -2
- package/dist/diagnostics.js +1 -19
- package/dist/{elements-BzjjnoCS.d.ts → elements-cqldpaJt.d.ts} +3 -3
- package/dist/email/assets.d.ts +2 -0
- package/dist/email/assets.js +63 -0
- package/dist/email/brand-footer.d.ts +34 -0
- package/dist/email/brand-footer.js +63 -0
- package/dist/email/brand.d.ts +2 -0
- package/dist/email/brand.js +148 -0
- package/dist/email/components.d.ts +21 -10
- package/dist/email/components.js +46 -11
- package/dist/email/diagnostics.d.ts +2 -2
- package/dist/email/diagnostics.js +2 -1
- package/dist/email/elements.d.ts +1 -1
- package/dist/email/html.d.ts +2 -42
- package/dist/email/html.js +56 -2
- 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 +10 -13
- package/dist/email/render.js +163 -6
- package/dist/email/text.d.ts +1 -1
- package/dist/fmt.d.ts +32 -0
- package/dist/fmt.js +174 -0
- package/dist/html-BJepOwZ4.d.ts +56 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/ir-aaqNE987.d.ts +252 -0
- package/dist/ir.d.ts +2 -0
- package/dist/ir.js +7 -0
- package/dist/preview-Ekdg1dXG.d.ts +100 -0
- package/dist/preview.d.ts +2 -0
- package/dist/preview.js +160 -0
- package/dist/profile-BH-OtdDA.js +3670 -0
- package/dist/render-ir.d.ts +19 -0
- package/dist/render-ir.js +826 -0
- package/dist/sms-segments.d.ts +13 -2
- package/dist/sms.d.ts +16 -0
- package/dist/sms.js +12 -0
- package/dist/{email/source-edit.d.ts → source-edit.d.ts} +55 -6
- package/dist/source-edit.js +343 -0
- package/dist/source-locations-C8wCsiAy.d.ts +23 -0
- package/dist/source-locations.d.ts +2 -2
- package/dist/source-locations.js +3 -89
- package/dist/static.d.ts +57 -0
- package/dist/static.js +69 -0
- package/dist/tailwind-CMYpZf1v.js +614 -0
- package/dist/template-_QE_rQND.d.ts +65 -0
- package/dist/template.d.ts +2 -2
- package/dist/template.js +15 -10
- package/dist/theme-css-hFqcPSar.js +587 -0
- package/dist/theme-css.d.ts +57 -16
- package/dist/theme-css.js +2 -509
- package/dist/theme-imports-lvBw3AD1.js +109 -0
- package/dist/transform-Ct2OMkFN.d.ts +153 -0
- package/dist/unsubscribe-link-CoesnQDU.js +26 -0
- package/dist/whatsapp.d.ts +57 -0
- package/dist/whatsapp.js +22 -0
- package/generated/contract.json +1782 -0
- package/generated/reference.md +353 -0
- package/package.json +56 -154
- package/samva-brand.d.ts +14 -0
- package/skills/sml/SKILL.md +123 -0
- package/dist/ast-BrDtApwS.d.ts +0 -107
- package/dist/ast.d.ts +0 -2
- package/dist/ast.js +0 -124
- package/dist/candidate.d.ts +0 -29
- package/dist/candidate.js +0 -88
- package/dist/catalog-60eaYC7b.d.ts +0 -356
- package/dist/checks-DBweSIPN.js +0 -58954
- package/dist/checks.d.ts +0 -33
- package/dist/checks.js +0 -2
- package/dist/classes.d.ts +0 -27
- package/dist/classes.js +0 -184
- package/dist/compile-sms.d.ts +0 -28
- package/dist/compile-sms.js +0 -44
- package/dist/compile-whatsapp.d.ts +0 -56
- package/dist/compile-whatsapp.js +0 -186
- package/dist/compile.d.ts +0 -18
- package/dist/compile.js +0 -29
- package/dist/components.d.ts +0 -289
- package/dist/components.js +0 -106
- package/dist/conditionals.d.ts +0 -10
- package/dist/conditionals.js +0 -74
- package/dist/corpus-BjYMqOoY.d.ts +0 -106
- package/dist/diagnostics-OcQKQYSY.d.ts +0 -49
- package/dist/email/selection.d.ts +0 -91
- package/dist/email/selection.js +0 -91
- package/dist/email/source-edit.js +0 -185
- package/dist/email/stylesheets.d.ts +0 -15
- package/dist/email/stylesheets.js +0 -45
- package/dist/emit.d.ts +0 -51
- package/dist/emit.js +0 -151
- package/dist/footer.d.ts +0 -66
- package/dist/footer.js +0 -93
- package/dist/interpolate.d.ts +0 -24
- package/dist/interpolate.js +0 -43
- package/dist/jsx-dev-runtime.d.ts +0 -11
- package/dist/jsx-dev-runtime.js +0 -15
- package/dist/jsx-runtime-I-1nCtl2.d.ts +0 -57
- package/dist/jsx-runtime.d.ts +0 -2
- package/dist/jsx-runtime.js +0 -121
- package/dist/lexer.d.ts +0 -60
- package/dist/lexer.js +0 -281
- package/dist/model.d.ts +0 -24
- package/dist/model.js +0 -77
- package/dist/ops-2aiiYO7m.js +0 -630
- package/dist/ops.d.ts +0 -114
- package/dist/ops.js +0 -2
- package/dist/parser-t29cHLVL.d.ts +0 -396
- package/dist/parser.d.ts +0 -2
- package/dist/parser.js +0 -859
- package/dist/predicate-BI6uRRM-.js +0 -549
- package/dist/predicate-M-05Nd7R.d.ts +0 -56
- package/dist/predicate.d.ts +0 -2
- package/dist/predicate.js +0 -2
- package/dist/presets/category-mapping.d.ts +0 -13
- package/dist/presets/category-mapping.js +0 -49
- package/dist/presets/corpus.d.ts +0 -2
- package/dist/presets/corpus.js +0 -194
- package/dist/presets/public-gallery.d.ts +0 -266
- package/dist/presets/public-gallery.js +0 -916
- package/dist/presets/public-handoff.d.ts +0 -164
- package/dist/presets/public-handoff.js +0 -361
- package/dist/presets/public-preview-artifacts.d.ts +0 -43
- package/dist/presets/public-preview-artifacts.js +0 -104
- package/dist/presets/public-preview.d.ts +0 -61
- package/dist/presets/public-preview.js +0 -83
- package/dist/presets/showcase.d.ts +0 -2
- package/dist/presets/showcase.js +0 -627
- package/dist/presets/sources.d.ts +0 -38
- package/dist/presets/sources.js +0 -6083
- package/dist/presets.d.ts +0 -2
- package/dist/presets.js +0 -881
- package/dist/printer.d.ts +0 -6
- package/dist/printer.js +0 -122
- package/dist/registry.d.ts +0 -42
- package/dist/registry.js +0 -646
- package/dist/render-template.d.ts +0 -45
- package/dist/render-template.js +0 -76
- package/dist/showcase-DGZAWn4Z.d.ts +0 -456
- package/dist/sms-segments-y4FpPilJ.d.ts +0 -13
- package/dist/source-locations-DrCM82Ym.d.ts +0 -67
- package/dist/template-DWftqh4x.d.ts +0 -60
- package/dist/theme-6ApjjiBo.d.ts +0 -116
- package/dist/theme.d.ts +0 -2
- package/dist/theme.js +0 -118
- package/dist/tokens.d.ts +0 -6
- package/dist/tokens.js +0 -417
- package/dist/tsx-source-instrumentation.d.ts +0 -30
- package/dist/tsx-source-instrumentation.js +0 -115
- package/dist/tsx-tracer.d.ts +0 -112
- package/dist/tsx-tracer.js +0 -985
- package/dist/variables-J_L3qxRa.d.ts +0 -77
- package/dist/variables.d.ts +0 -2
- package/dist/variables.js +0 -141
- package/dist/version-BITr58kk.js +0 -96
- package/generated/sml-agent-contract.json +0 -709
- package/generated/sml-email-agent-contract.json +0 -615
- package/generated/sml-email-language-reference.md +0 -94
- 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
|
package/dist/variables.d.ts
DELETED
|
@@ -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
|
package/dist/version-BITr58kk.js
DELETED
|
@@ -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
|