@samva/markup 0.1.0 → 0.1.2
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/dist/ast.js +1 -1
- package/dist/{checks-CW0nFj5n.js → checks-D-zFQt5R.js} +2 -2
- package/dist/checks.js +1 -1
- package/dist/compile-sms.d.ts +1 -1
- package/dist/compile-whatsapp.d.ts +1 -1
- package/dist/components.d.ts +3 -3
- package/dist/conditionals.js +1 -1
- package/dist/diagnostics.js +2 -2
- package/dist/jsx-dev-runtime.d.ts +1 -1
- package/dist/{jsx-runtime-fSxcvlx4.d.ts → jsx-runtime-eNIMY87F.d.ts} +2 -2
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/ops.js +2 -2
- package/dist/{parser-yzjUOGhc.d.ts → parser-DkQKIjDa.d.ts} +11 -2
- package/dist/parser.d.ts +2 -2
- package/dist/parser.js +48 -9
- package/dist/predicate-CvkzT-a2.js +539 -0
- package/dist/{predicate-DTtVtLK7.d.ts → predicate-G2SeSvoN.d.ts} +9 -2
- package/dist/predicate.d.ts +2 -2
- package/dist/predicate.js +2 -417
- package/dist/presets/category-mapping.d.ts +1 -1
- package/dist/presets/public-gallery.d.ts +2 -490
- package/dist/presets/public-gallery.js +2 -1
- package/dist/presets/public-handoff.d.ts +2 -68
- package/dist/presets/public-handoff.js +110 -24
- package/dist/presets/public-preview-artifacts.d.ts +2 -2
- package/dist/presets/public-preview.d.ts +2 -1168
- package/dist/presets/public-preview.js +17 -17
- package/dist/presets/sources.js +17 -17
- package/dist/public-gallery-D0Zv0pZE.d.ts +611 -0
- package/dist/public-preview-u1Z9aaGq.d.ts +1168 -0
- package/dist/render-template.d.ts +2 -2
- package/dist/render-template.js +1 -1
- package/dist/{variables-3NGLpNTB.d.ts → variables-if1VrV34.d.ts} +2 -2
- package/dist/variables.d.ts +1 -1
- package/dist/variables.js +1 -1
- package/generated/sml-email-language-reference.md +1 -1
- package/generated/sml-language-reference.md +1 -1
- package/package.json +6 -3
- package/dist/ast.js.map +0 -1
- package/dist/candidate.js.map +0 -1
- package/dist/checks-CW0nFj5n.js.map +0 -1
- package/dist/classes.js.map +0 -1
- package/dist/compile-sms.js.map +0 -1
- package/dist/compile-whatsapp.js.map +0 -1
- package/dist/compile.js.map +0 -1
- package/dist/components.js.map +0 -1
- package/dist/conditionals.js.map +0 -1
- package/dist/diagnostics.js.map +0 -1
- package/dist/emit.js.map +0 -1
- package/dist/footer.js.map +0 -1
- package/dist/interpolate.js.map +0 -1
- package/dist/jsx-dev-runtime.js.map +0 -1
- package/dist/jsx-runtime.js.map +0 -1
- package/dist/lexer.js.map +0 -1
- package/dist/model.js.map +0 -1
- package/dist/ops.js.map +0 -1
- package/dist/parser.js.map +0 -1
- package/dist/predicate.js.map +0 -1
- package/dist/presets/category-mapping.js.map +0 -1
- package/dist/presets/public-gallery.js.map +0 -1
- package/dist/presets/public-handoff.js.map +0 -1
- package/dist/presets/public-preview-artifacts.js.map +0 -1
- package/dist/presets/public-preview.js.map +0 -1
- package/dist/presets/sources.js.map +0 -1
- package/dist/presets.js.map +0 -1
- package/dist/printer.js.map +0 -1
- package/dist/registry.js.map +0 -1
- package/dist/render-template.js.map +0 -1
- package/dist/sms-segments.js.map +0 -1
- package/dist/theme-css.js.map +0 -1
- package/dist/theme.js.map +0 -1
- package/dist/tokens.js.map +0 -1
- package/dist/variables.js.map +0 -1
- package/dist/version-BITr58kk.js.map +0 -1
package/dist/ast.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SpanSchema } from "./diagnostics.js";
|
|
2
|
-
import {
|
|
2
|
+
import { i as parsePredicate, n as collectPredicateVariables } from "./predicate-CvkzT-a2.js";
|
|
3
3
|
import { Result, Schema } from "effect";
|
|
4
4
|
//#region src/ast.ts
|
|
5
5
|
const BLOCK_TAGS = [
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { formatDiagnostic } from "./diagnostics.js";
|
|
2
|
-
import { parsePredicate } from "./predicate.js";
|
|
2
|
+
import { i as parsePredicate } from "./predicate-CvkzT-a2.js";
|
|
3
3
|
import { stringAttribute } from "./ast.js";
|
|
4
4
|
import { parseCandidate, splitRoot } from "./candidate.js";
|
|
5
5
|
import { registryRoots, utilityRegistry } from "./registry.js";
|
|
@@ -58919,4 +58919,4 @@ function checkSmlCompatibility(input) {
|
|
|
58919
58919
|
//#endregion
|
|
58920
58920
|
export { worstCaseArtifactBytes as a, isBreakingCompatibilityCheck as i, checkSmlCompatibility as n, collectSmlFeatureSlugs as r, DEFAULT_EMAIL_TARGET_CLIENT_PROFILE as t };
|
|
58921
58921
|
|
|
58922
|
-
//# sourceMappingURL=checks-
|
|
58922
|
+
//# sourceMappingURL=checks-D-zFQt5R.js.map
|
package/dist/checks.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as worstCaseArtifactBytes, i as isBreakingCompatibilityCheck, n as checkSmlCompatibility, r as collectSmlFeatureSlugs, t as DEFAULT_EMAIL_TARGET_CLIENT_PROFILE } from "./checks-
|
|
1
|
+
import { a as worstCaseArtifactBytes, i as isBreakingCompatibilityCheck, n as checkSmlCompatibility, r as collectSmlFeatureSlugs, t as DEFAULT_EMAIL_TARGET_CLIENT_PROFILE } from "./checks-D-zFQt5R.js";
|
|
2
2
|
export { DEFAULT_EMAIL_TARGET_CLIENT_PROFILE, checkSmlCompatibility, collectSmlFeatureSlugs, isBreakingCompatibilityCheck, worstCaseArtifactBytes };
|
package/dist/compile-sms.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as Diagnostic } from "./diagnostics-oveE-laV.js";
|
|
2
2
|
import { m as ElementNode } from "./ast-DAhnAvQN.js";
|
|
3
|
-
import { a as SMS_TAG_SPECS } from "./parser-
|
|
3
|
+
import { a as SMS_TAG_SPECS } from "./parser-DkQKIjDa.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
1
|
import { a as SmlCompileError, t as Diagnostic } from "./diagnostics-oveE-laV.js";
|
|
2
2
|
import { m as ElementNode } from "./ast-DAhnAvQN.js";
|
|
3
|
-
import { l as WHATSAPP_TAG_SPECS } from "./parser-
|
|
3
|
+
import { l as WHATSAPP_TAG_SPECS } from "./parser-DkQKIjDa.js";
|
|
4
4
|
import { Result } from "effect";
|
|
5
5
|
//#region src/compile-whatsapp.d.ts
|
|
6
6
|
type WhatsAppSpecs = typeof WHATSAPP_TAG_SPECS;
|
package/dist/components.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { m as ElementNode } from "./ast-DAhnAvQN.js";
|
|
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-
|
|
2
|
+
import { i as EMAIL_TAG_SPECS, l as WHATSAPP_TAG_SPECS, o as TagSpec, t as AttributeSpec } from "./parser-DkQKIjDa.js";
|
|
3
|
+
import { r as PredicateRef, s as VariableRef } from "./variables-if1VrV34.js";
|
|
4
|
+
import { s as SmlChildren } from "./jsx-runtime-eNIMY87F.js";
|
|
5
5
|
//#region src/components.d.ts
|
|
6
6
|
/**
|
|
7
7
|
* The scalar type an attribute spec accepts. `level` narrows to the Heading
|
package/dist/conditionals.js
CHANGED
package/dist/diagnostics.js
CHANGED
|
@@ -21,12 +21,12 @@ const DiagnosticSchema = Schema.Struct({
|
|
|
21
21
|
span: SpanSchema,
|
|
22
22
|
repair: Schema.optional(DiagnosticRepairSchema)
|
|
23
23
|
});
|
|
24
|
-
var SmlParseError = class extends Schema.
|
|
24
|
+
var SmlParseError = class extends Schema.TaggedError()("SmlParseError", { diagnostics: Schema.Array(DiagnosticSchema) }) {
|
|
25
25
|
get message() {
|
|
26
26
|
return this.diagnostics.map((diagnostic) => diagnostic.message).join("\n");
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
|
-
var SmlCompileError = class extends Schema.
|
|
29
|
+
var SmlCompileError = class extends Schema.TaggedError()("SmlCompileError", { diagnostics: Schema.Array(DiagnosticSchema) }) {
|
|
30
30
|
get message() {
|
|
31
31
|
return this.diagnostics.map((diagnostic) => diagnostic.message).join("\n");
|
|
32
32
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as JsxResult, i as JSX, n as Fragment, t as Component } from "./jsx-runtime-
|
|
1
|
+
import { a as JsxResult, i as JSX, n as Fragment, t as Component } from "./jsx-runtime-eNIMY87F.js";
|
|
2
2
|
//#region src/jsx-dev-runtime.d.ts
|
|
3
3
|
interface JsxDevProps {
|
|
4
4
|
readonly children?: unknown;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { T as SmlNode, m as ElementNode, n as Attribute } from "./ast-DAhnAvQN.js";
|
|
2
|
-
import { s as VariableRef } from "./variables-
|
|
2
|
+
import { s as VariableRef } from "./variables-if1VrV34.js";
|
|
3
3
|
//#region src/jsx-runtime.d.ts
|
|
4
4
|
/** A component is a plain function of its props that returns a draft node. */
|
|
5
5
|
type Component<P> = (props: P) => SmlNode;
|
|
@@ -54,4 +54,4 @@ declare namespace JSX {
|
|
|
54
54
|
}
|
|
55
55
|
//#endregion
|
|
56
56
|
export { JsxResult as a, elementDraft as c, normalizeChildren as d, JSX as i, jsx as l, Fragment as n, SmlChild as o, FragmentDraft as r, SmlChildren as s, Component as t, jsxs as u };
|
|
57
|
-
//# sourceMappingURL=jsx-runtime-
|
|
57
|
+
//# sourceMappingURL=jsx-runtime-eNIMY87F.d.ts.map
|
package/dist/jsx-runtime.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as JsxResult, c as elementDraft, d as normalizeChildren, i as JSX, l as jsx, n as Fragment, o as SmlChild, r as FragmentDraft, s as SmlChildren, t as Component, u as jsxs } from "./jsx-runtime-
|
|
1
|
+
import { a as JsxResult, c as elementDraft, d as normalizeChildren, i as JSX, l as jsx, n as Fragment, o as SmlChild, r as FragmentDraft, s as SmlChildren, t as Component, u as jsxs } from "./jsx-runtime-eNIMY87F.js";
|
|
2
2
|
export { Component, Fragment, FragmentDraft, JSX, JsxResult, SmlChild, SmlChildren, elementDraft, jsx, jsxs, normalizeChildren };
|
package/dist/ops.js
CHANGED
|
@@ -2,7 +2,7 @@ import { DiagnosticSchema } from "./diagnostics.js";
|
|
|
2
2
|
import { AttributeValueSchema, SML_TAGS, SmlNodeSchema, documentChannel } from "./ast.js";
|
|
3
3
|
import { CHANNEL_TAG_SPECS, allowedChildren, parseSml } from "./parser.js";
|
|
4
4
|
import { compileSml } from "./compile.js";
|
|
5
|
-
import { i as isBreakingCompatibilityCheck, n as checkSmlCompatibility } from "./checks-
|
|
5
|
+
import { i as isBreakingCompatibilityCheck, n as checkSmlCompatibility } from "./checks-D-zFQt5R.js";
|
|
6
6
|
import { printSml } from "./printer.js";
|
|
7
7
|
import { Result, Schema } from "effect";
|
|
8
8
|
//#region src/ops.ts
|
|
@@ -74,7 +74,7 @@ const ApplyOpsResultSchema = Schema.Struct({
|
|
|
74
74
|
diagnostics: Schema.Array(DiagnosticSchema),
|
|
75
75
|
results: Schema.Array(SmlOpResultSchema)
|
|
76
76
|
});
|
|
77
|
-
var SmlOpError = class extends Schema.
|
|
77
|
+
var SmlOpError = class extends Schema.TaggedError()("SmlOpError", { diagnostics: Schema.Array(DiagnosticSchema) }) {
|
|
78
78
|
get message() {
|
|
79
79
|
return this.diagnostics.map((diagnostic) => diagnostic.message).join("\n");
|
|
80
80
|
}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { o as SmlParseError } from "./diagnostics-oveE-laV.js";
|
|
2
2
|
import { C as SmlDocument, D as SmlTag, d as Channel } from "./ast-DAhnAvQN.js";
|
|
3
3
|
import { Result } from "effect";
|
|
4
|
+
//#region src/limits.d.ts
|
|
5
|
+
/** Hard ceilings shared by SML documents and standalone predicate parsing. */
|
|
6
|
+
declare const SML_PARSER_LIMITS: {
|
|
7
|
+
readonly maxCharacters: 500000;
|
|
8
|
+
readonly maxUtf8Bytes: number;
|
|
9
|
+
readonly maxDepth: 64;
|
|
10
|
+
readonly maxNodes: 25000;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
4
13
|
//#region src/parser.d.ts
|
|
5
14
|
type ContentModel = "email" | "block" | "columns" | "list" | "image" | "if" | "inline" | "inline-nolink" | "preview" | "whatsapp" | "buttons" | "verbatim" | "verbatim-if" | "void";
|
|
6
15
|
interface AttributeSpec {
|
|
@@ -383,5 +392,5 @@ declare const UNIVERSAL_ATTRIBUTE_TAGS: ReadonlySet<SmlTag>;
|
|
|
383
392
|
declare const allowedChildren: (model: ContentModel) => ReadonlyArray<SmlTag>;
|
|
384
393
|
declare const parseSml: (source: string) => Result.Result<SmlDocument, SmlParseError>;
|
|
385
394
|
//#endregion
|
|
386
|
-
export { SMS_TAG_SPECS as a, UNIVERSAL_ATTRIBUTE_TAGS as c, parseSml as d, EMAIL_TAG_SPECS as i, WHATSAPP_TAG_SPECS as l, CHANNEL_TAG_SPECS as n, TagSpec as o, ContentModel as r, UNIVERSAL_ATTRIBUTES as s, AttributeSpec as t, allowedChildren as u };
|
|
387
|
-
//# sourceMappingURL=parser-
|
|
395
|
+
export { SMS_TAG_SPECS as a, UNIVERSAL_ATTRIBUTE_TAGS as c, parseSml as d, SML_PARSER_LIMITS as f, EMAIL_TAG_SPECS as i, WHATSAPP_TAG_SPECS as l, CHANNEL_TAG_SPECS as n, TagSpec as o, ContentModel as r, UNIVERSAL_ATTRIBUTES as s, AttributeSpec as t, allowedChildren as u };
|
|
396
|
+
//# sourceMappingURL=parser-DkQKIjDa.d.ts.map
|
package/dist/parser.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as SMS_TAG_SPECS, c as UNIVERSAL_ATTRIBUTE_TAGS, d as parseSml, i as EMAIL_TAG_SPECS, l as WHATSAPP_TAG_SPECS, n as CHANNEL_TAG_SPECS, o as TagSpec, r as ContentModel, s as UNIVERSAL_ATTRIBUTES, t as AttributeSpec, u as allowedChildren } from "./parser-
|
|
2
|
-
export { AttributeSpec, CHANNEL_TAG_SPECS, ContentModel, EMAIL_TAG_SPECS, SMS_TAG_SPECS, TagSpec, UNIVERSAL_ATTRIBUTES, UNIVERSAL_ATTRIBUTE_TAGS, WHATSAPP_TAG_SPECS, allowedChildren, parseSml };
|
|
1
|
+
import { a as SMS_TAG_SPECS, c as UNIVERSAL_ATTRIBUTE_TAGS, d as parseSml, f as SML_PARSER_LIMITS, i as EMAIL_TAG_SPECS, l as WHATSAPP_TAG_SPECS, n as CHANNEL_TAG_SPECS, o as TagSpec, r as ContentModel, s as UNIVERSAL_ATTRIBUTES, t as AttributeSpec, u as allowedChildren } from "./parser-DkQKIjDa.js";
|
|
2
|
+
export { AttributeSpec, CHANNEL_TAG_SPECS, ContentModel, EMAIL_TAG_SPECS, SML_PARSER_LIMITS, SMS_TAG_SPECS, TagSpec, UNIVERSAL_ATTRIBUTES, UNIVERSAL_ATTRIBUTE_TAGS, WHATSAPP_TAG_SPECS, allowedChildren, parseSml };
|
package/dist/parser.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { SmlParseError } from "./diagnostics.js";
|
|
2
|
-
import { parsePredicate,
|
|
2
|
+
import { a as printPredicate, i as parsePredicate, o as SML_PARSER_LIMITS } from "./predicate-CvkzT-a2.js";
|
|
3
3
|
import { CHANNEL_BY_ROOT_TAG, ROOT_TAGS, SML_TAGS, isRootTag } from "./ast.js";
|
|
4
4
|
import { TokenKind, createLexer } from "./lexer.js";
|
|
5
5
|
import { Result } from "effect";
|
|
6
6
|
//#region src/parser.ts
|
|
7
|
+
const parserLimitFailure = (code, message, sourceLength) => Result.fail(new SmlParseError({ diagnostics: [{
|
|
8
|
+
code,
|
|
9
|
+
message,
|
|
10
|
+
span: {
|
|
11
|
+
start: 0,
|
|
12
|
+
end: sourceLength
|
|
13
|
+
}
|
|
14
|
+
}] }));
|
|
7
15
|
const SMS_CATEGORIES = [
|
|
8
16
|
"transactional",
|
|
9
17
|
"promotional",
|
|
@@ -413,8 +421,12 @@ const WRAPPER_TAG_BY_MODEL = {
|
|
|
413
421
|
buttons: "Button"
|
|
414
422
|
};
|
|
415
423
|
const parseSml = (source) => {
|
|
424
|
+
if (source.length > SML_PARSER_LIMITS.maxCharacters) return parserLimitFailure("source-character-limit", `SML source exceeds the ${SML_PARSER_LIMITS.maxCharacters} character limit (${source.length} characters)`, source.length);
|
|
425
|
+
const sourceBytes = new TextEncoder().encode(source).byteLength;
|
|
426
|
+
if (sourceBytes > SML_PARSER_LIMITS.maxUtf8Bytes) return parserLimitFailure("source-byte-limit", `SML source exceeds the ${SML_PARSER_LIMITS.maxUtf8Bytes} byte UTF-8 limit (${sourceBytes} bytes)`, source.length);
|
|
416
427
|
const lexer = createLexer(source);
|
|
417
428
|
let diagnostic;
|
|
429
|
+
let nodeCount = 0;
|
|
418
430
|
let channel = null;
|
|
419
431
|
let specs = EMAIL_TAG_SPECS;
|
|
420
432
|
const fail = (code, message, span) => {
|
|
@@ -435,6 +447,15 @@ const parseSml = (source) => {
|
|
|
435
447
|
end: token.end
|
|
436
448
|
});
|
|
437
449
|
};
|
|
450
|
+
const countNode = (span) => {
|
|
451
|
+
const observed = nodeCount + 1;
|
|
452
|
+
if (observed > SML_PARSER_LIMITS.maxNodes) {
|
|
453
|
+
fail("node-limit", `SML document exceeds the ${SML_PARSER_LIMITS.maxNodes} node limit (${observed} nodes)`, span);
|
|
454
|
+
return false;
|
|
455
|
+
}
|
|
456
|
+
nodeCount = observed;
|
|
457
|
+
return true;
|
|
458
|
+
};
|
|
438
459
|
const parseAttributeValue = (tag, name, spec, nameToken) => {
|
|
439
460
|
const nameSpan = {
|
|
440
461
|
start: nameToken.start,
|
|
@@ -519,7 +540,11 @@ const parseSml = (source) => {
|
|
|
519
540
|
return true;
|
|
520
541
|
};
|
|
521
542
|
/** Called with the `<` already consumed; `lessThanToken` is that token. */
|
|
522
|
-
const parseElement = (lessThanToken) => {
|
|
543
|
+
const parseElement = (lessThanToken, depth) => {
|
|
544
|
+
if (depth > SML_PARSER_LIMITS.maxDepth) return fail("depth-limit", `SML nesting exceeds the maximum depth of ${SML_PARSER_LIMITS.maxDepth} (observed ${depth})`, {
|
|
545
|
+
start: lessThanToken.start,
|
|
546
|
+
end: lessThanToken.end
|
|
547
|
+
});
|
|
523
548
|
const tagToken = lexer.scanTagToken();
|
|
524
549
|
if (tagToken.kind !== TokenKind.Identifier) {
|
|
525
550
|
if (tagToken.kind === TokenKind.Unknown) return failToken(tagToken);
|
|
@@ -548,6 +573,10 @@ const parseSml = (source) => {
|
|
|
548
573
|
end: tagToken.end
|
|
549
574
|
});
|
|
550
575
|
}
|
|
576
|
+
if (!countNode({
|
|
577
|
+
start: lessThanToken.start,
|
|
578
|
+
end: tagToken.end
|
|
579
|
+
})) return null;
|
|
551
580
|
const element = {
|
|
552
581
|
kind: "element",
|
|
553
582
|
id: "",
|
|
@@ -662,6 +691,10 @@ const parseSml = (source) => {
|
|
|
662
691
|
start: token.start,
|
|
663
692
|
end: token.end
|
|
664
693
|
});
|
|
694
|
+
if (!countNode({
|
|
695
|
+
start: token.start,
|
|
696
|
+
end: token.end
|
|
697
|
+
})) return null;
|
|
665
698
|
element.children.push({
|
|
666
699
|
kind: "text",
|
|
667
700
|
id: "",
|
|
@@ -686,6 +719,10 @@ const parseSml = (source) => {
|
|
|
686
719
|
start: token.start,
|
|
687
720
|
end: token.end
|
|
688
721
|
});
|
|
722
|
+
if (!countNode({
|
|
723
|
+
start: token.start,
|
|
724
|
+
end: token.end
|
|
725
|
+
})) return null;
|
|
689
726
|
element.children.push({
|
|
690
727
|
kind: "interpolation",
|
|
691
728
|
id: "",
|
|
@@ -716,7 +753,7 @@ const parseSml = (source) => {
|
|
|
716
753
|
break;
|
|
717
754
|
}
|
|
718
755
|
const allowed = allowedChildren(model);
|
|
719
|
-
const child = parseElement(token);
|
|
756
|
+
const child = parseElement(token, depth + 1);
|
|
720
757
|
if (child === null) return null;
|
|
721
758
|
if (!allowed.includes(child.tag)) {
|
|
722
759
|
const message = child.tag === "Else" ? `<Else> is only valid as the last child of <If> — wrap this branch in <If>` : isInlineModel(model) ? child.tag === "a" ? `<a> is not allowed inside <${tag}> — links cannot nest inside links or buttons` : `<${child.tag}> is not allowed inside <${tag}> — only text, {{variables}}${allowed.length > 0 ? `, and ${listTags(allowed)}` : ""} may appear here` : `<${child.tag}> is not allowed inside <${tag}> — <${tag}> may contain only ${listTags(allowed)}`;
|
|
@@ -767,7 +804,7 @@ const parseSml = (source) => {
|
|
|
767
804
|
end: first.end
|
|
768
805
|
});
|
|
769
806
|
let root = null;
|
|
770
|
-
if (diagnostic === void 0) root = parseElement(first);
|
|
807
|
+
if (diagnostic === void 0) root = parseElement(first, 1);
|
|
771
808
|
if (root !== null) {
|
|
772
809
|
const trailing = skipBlankText();
|
|
773
810
|
if (trailing.kind !== TokenKind.EndOfFile) {
|
|
@@ -808,14 +845,16 @@ const normalizeInlineChildren = (element) => {
|
|
|
808
845
|
/** Stable ids in document order — identical source ⇒ identical ids. */
|
|
809
846
|
const assignNodeIds = (root) => {
|
|
810
847
|
let next = 0;
|
|
811
|
-
const
|
|
848
|
+
const pending = [root];
|
|
849
|
+
while (pending.length > 0) {
|
|
850
|
+
const node = pending.pop();
|
|
812
851
|
node.id = `n${next}`;
|
|
813
852
|
next++;
|
|
814
|
-
if (node.kind
|
|
815
|
-
|
|
816
|
-
|
|
853
|
+
if (node.kind !== "element") continue;
|
|
854
|
+
for (let index = node.children.length - 1; index >= 0; index--) pending.push(node.children[index]);
|
|
855
|
+
}
|
|
817
856
|
};
|
|
818
857
|
//#endregion
|
|
819
|
-
export { CHANNEL_TAG_SPECS, EMAIL_TAG_SPECS, SMS_TAG_SPECS, UNIVERSAL_ATTRIBUTES, UNIVERSAL_ATTRIBUTE_TAGS, WHATSAPP_TAG_SPECS, allowedChildren, parseSml };
|
|
858
|
+
export { CHANNEL_TAG_SPECS, EMAIL_TAG_SPECS, SML_PARSER_LIMITS, SMS_TAG_SPECS, UNIVERSAL_ATTRIBUTES, UNIVERSAL_ATTRIBUTE_TAGS, WHATSAPP_TAG_SPECS, allowedChildren, parseSml };
|
|
820
859
|
|
|
821
860
|
//# sourceMappingURL=parser.js.map
|