@samva/markup 0.4.0 → 0.5.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 +17 -0
- package/dist/{ast-63I-VLQx.d.ts → ast-BLybiDxp.d.ts} +34 -60
- package/dist/ast.d.ts +2 -2
- package/dist/ast.js +4 -52
- package/dist/{catalog-Ck1tAGwO.d.ts → catalog-Db0UcCTg.d.ts} +2 -2
- package/dist/{checks-DXuERO4B.js → checks-CmmITP6j.js} +14 -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 +5 -5
- package/dist/compile-whatsapp.js +3 -3
- package/dist/compile.d.ts +5 -5
- package/dist/compile.js +5 -5
- package/dist/compiler.d.ts +4 -4
- package/dist/compiler.js +6 -6
- package/dist/components.d.ts +4 -4
- package/dist/conditionals.js +3 -3
- package/dist/corpus-CM7rKX41.d.ts +106 -0
- package/dist/{css-ar2lU3NC.d.ts → css-DoNc7CiC.d.ts} +4 -5
- package/dist/diagnostics-CqepLcpI.d.ts +47 -0
- package/dist/diagnostics-eFM9A_TU.d.ts +46 -0
- package/dist/diagnostics.d.ts +2 -2
- package/dist/diagnostics.js +15 -29
- package/dist/{elements-DtwKlFVH.d.ts → elements-ChJULZlh.d.ts} +40 -161
- package/dist/email/components.d.ts +1 -1
- package/dist/email/diagnostics.d.ts +1 -1
- package/dist/email/diagnostics.js +8 -43
- package/dist/email/elements.d.ts +1 -1
- package/dist/email/html.d.ts +2 -2
- package/dist/email/html.js +9 -9
- package/dist/email/jsx-dev-runtime.d.ts +3 -21
- package/dist/email/jsx-runtime.d.ts +1 -1
- package/dist/email/jsx-runtime.js +29 -3
- package/dist/email/render.d.ts +4 -4
- package/dist/email/render.js +1 -1
- package/dist/email/selection.d.ts +20 -31
- package/dist/email/selection.js +1 -53
- package/dist/email/source-edit.d.ts +1 -1
- package/dist/email/source-edit.js +2 -2
- package/dist/email/stylesheets.d.ts +1 -1
- package/dist/email/text.d.ts +1 -1
- package/dist/email/text.js +3 -3
- package/dist/emit.d.ts +2 -2
- package/dist/emit.js +5 -5
- package/dist/guards-eV1qLbf2.js +9 -0
- package/dist/{input-schema-BIfzI63B.d.ts → input-schema-7dPFVvNE.d.ts} +2 -2
- package/dist/input-schema-zjkgrXn2.js +455 -0
- package/dist/input-schema.d.ts +1 -1
- package/dist/input-schema.js +1 -169
- package/dist/interpolate.d.ts +9 -12
- package/dist/interpolate.js +1 -19
- package/dist/jsx-dev-runtime.d.ts +2 -2
- package/dist/{jsx-runtime-C5k_Zq0A.d.ts → jsx-runtime-BI4gI19E.d.ts} +3 -3
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/jsx-runtime.js +3 -3
- package/dist/model.d.ts +18 -33
- package/dist/model.js +4 -17
- package/dist/ops.d.ts +78 -172
- package/dist/ops.js +51 -117
- package/dist/{parser-CGBS73Gz.d.ts → parser-b_Kp5MT6.d.ts} +5 -5
- package/dist/parser.d.ts +1 -1
- package/dist/parser.js +8 -8
- package/dist/{predicate-G2SeSvoN.d.ts → predicate-Bmvgw7Ao.d.ts} +4 -4
- package/dist/{predicate-CvkzT-a2.js → predicate-DwXzmqIY.js} +11 -11
- 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/corpus.js +74 -117
- package/dist/presets/public-gallery.d.ts +2 -2
- package/dist/presets/public-gallery.js +7 -7
- package/dist/presets/public-handoff.d.ts +4 -4
- package/dist/presets/public-handoff.js +10 -9
- package/dist/presets/public-preview-artifacts.d.ts +5 -5
- package/dist/presets/public-preview-artifacts.js +9 -9
- 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-ykQhtMs_.js → render-T6IFPnP4.js} +12 -12
- package/dist/render-template.d.ts +7 -7
- package/dist/render-template.js +6 -6
- package/dist/{showcase-C_xgl6hz.d.ts → showcase-dvJMn-Lo.d.ts} +2 -2
- package/dist/{source-locations-BCJQnIfU.d.ts → source-locations-D6Te6Gy1.d.ts} +4 -26
- package/dist/source-locations.d.ts +2 -2
- package/dist/source-locations.js +3 -26
- package/dist/{template-Dy5yOPyp.d.ts → template-G-QPcfmn.d.ts} +4 -4
- package/dist/template.d.ts +1 -1
- package/dist/template.js +3 -3
- package/dist/theme-css.d.ts +3 -3
- package/dist/theme-css.js +3 -3
- package/dist/tsx-source-instrumentation.d.ts +1 -3
- package/dist/tsx-source-instrumentation.js +6 -6
- package/dist/tsx-tracer.d.ts +7 -11
- package/dist/tsx-tracer.js +164 -164
- package/dist/{variables-if1VrV34.d.ts → variables-BnKs1iqb.d.ts} +2 -2
- package/dist/variables.d.ts +1 -1
- package/dist/variables.js +4 -4
- package/package.json +4 -3
- package/dist/corpus-U2EeALvS.d.ts +0 -234
- package/dist/diagnostics-Djd9ckLg.d.ts +0 -90
- package/dist/diagnostics-oveE-laV.d.ts +0 -79
package/dist/interpolate.js
CHANGED
|
@@ -1,22 +1,4 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
2
1
|
//#region src/interpolate.ts
|
|
3
|
-
const limitedString = (maxLength) => Schema.String.check(Schema.isMaxLength(maxLength));
|
|
4
|
-
const DocumentVariableTypeSchema = Schema.Literals([
|
|
5
|
-
"string",
|
|
6
|
-
"number",
|
|
7
|
-
"boolean",
|
|
8
|
-
"date",
|
|
9
|
-
"array",
|
|
10
|
-
"object"
|
|
11
|
-
]);
|
|
12
|
-
/** One entry of a template's declared variable schema. */
|
|
13
|
-
const DocumentVariableSchema = Schema.Struct({
|
|
14
|
-
name: limitedString(128),
|
|
15
|
-
type: DocumentVariableTypeSchema,
|
|
16
|
-
required: Schema.Boolean,
|
|
17
|
-
default: Schema.optional(Schema.Unknown),
|
|
18
|
-
description: Schema.optional(limitedString(512))
|
|
19
|
-
});
|
|
20
2
|
const variableReferencePattern = /\$\{\s*\/?([\w.]+)\s*\}|\{\{\s*([\w.]+)\s*\}\}/g;
|
|
21
3
|
const getVariableValue = (variables, variableSchema, name) => {
|
|
22
4
|
const schema = variableSchema.find((item) => item.name === name);
|
|
@@ -56,6 +38,6 @@ const addVariableReferences = (target, text) => {
|
|
|
56
38
|
variableReferences(text).forEach((name) => target.add(name));
|
|
57
39
|
};
|
|
58
40
|
//#endregion
|
|
59
|
-
export {
|
|
41
|
+
export { addVariableReferences, getVariableValue, interpolate, stringifyVariable, variableReferencePattern, variableReferences };
|
|
60
42
|
|
|
61
43
|
//# sourceMappingURL=interpolate.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as JsxSource } from "./source-locations-
|
|
2
|
-
import { a as JsxResult, i as JSX, n as Fragment, t as Component } from "./jsx-runtime-
|
|
1
|
+
import { r as JsxSource } from "./source-locations-D6Te6Gy1.js";
|
|
2
|
+
import { a as JsxResult, i as JSX, n as Fragment, t as Component } from "./jsx-runtime-BI4gI19E.js";
|
|
3
3
|
//#region src/jsx-dev-runtime.d.ts
|
|
4
4
|
interface JsxDevProps {
|
|
5
5
|
readonly children?: unknown;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { s as VariableRef } from "./variables-
|
|
1
|
+
import { f as ElementNode, n as Attribute, x as SmlNode } from "./ast-BLybiDxp.js";
|
|
2
|
+
import { s as VariableRef } from "./variables-BnKs1iqb.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-BI4gI19E.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-BI4gI19E.js";
|
|
2
2
|
export { Component, Fragment, FragmentDraft, JSX, JsxResult, SmlChild, SmlChildren, elementDraft, jsx, jsxs, normalizeChildren };
|
package/dist/jsx-runtime.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
import { t as hasProperty } from "./guards-eV1qLbf2.js";
|
|
1
2
|
import { JSX_SOURCE_LOCATION_PROP, attachJsxSourceLocation, completeJsxSourceLocation } from "./source-locations.js";
|
|
2
3
|
import { VARIABLE_REF, isVariableRef } from "./variables.js";
|
|
3
|
-
import { Predicate } from "effect";
|
|
4
4
|
//#region src/jsx-runtime.ts
|
|
5
5
|
const PLACEHOLDER_SPAN = {
|
|
6
6
|
start: 0,
|
|
7
7
|
end: 0
|
|
8
8
|
};
|
|
9
|
-
const isFragmentDraft = (value) =>
|
|
9
|
+
const isFragmentDraft = (value) => hasProperty(value, "kind") && value.kind === "fragment";
|
|
10
10
|
const isSmlNode = (value) => {
|
|
11
|
-
if (!
|
|
11
|
+
if (!hasProperty(value, "kind")) return false;
|
|
12
12
|
const kind = value.kind;
|
|
13
13
|
return kind === "element" || kind === "text" || kind === "interpolation";
|
|
14
14
|
};
|
package/dist/model.d.ts
CHANGED
|
@@ -1,39 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Result
|
|
1
|
+
import { S as SmlTag, b as SmlDocument } from "./ast-BLybiDxp.js";
|
|
2
|
+
import { Result } from "better-result";
|
|
3
3
|
//#region src/model.d.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
readonly
|
|
8
|
-
readonly order: Schema.Finite;
|
|
9
|
-
readonly parentId: Schema.NullOr<Schema.String>;
|
|
10
|
-
readonly childIndex: Schema.Finite;
|
|
11
|
-
readonly depth: Schema.Finite;
|
|
12
|
-
readonly path: Schema.String;
|
|
13
|
-
readonly textPreview: Schema.String;
|
|
14
|
-
readonly attrs: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Finite]>>;
|
|
15
|
-
}>;
|
|
16
|
-
type SmlNodeIndexEntry = typeof SmlNodeIndexEntrySchema.Type & {
|
|
4
|
+
/** The subset of an element's attributes the navigator and agent tools read. */
|
|
5
|
+
type SmlNodeKeyAttrs = Readonly<Record<string, string | number>>;
|
|
6
|
+
interface SmlNodeIndexEntry {
|
|
7
|
+
readonly id: string;
|
|
17
8
|
readonly tag: SmlTag;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
readonly
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
readonly path: Schema.String;
|
|
28
|
-
readonly textPreview: Schema.String;
|
|
29
|
-
readonly attrs: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Finite]>>;
|
|
30
|
-
}>>;
|
|
31
|
-
}>;
|
|
32
|
-
type SmlNodeIndex = typeof SmlNodeIndexSchema.Type & {
|
|
9
|
+
readonly order: number;
|
|
10
|
+
readonly parentId: string | null;
|
|
11
|
+
readonly childIndex: number;
|
|
12
|
+
readonly depth: number;
|
|
13
|
+
readonly path: string;
|
|
14
|
+
readonly textPreview: string;
|
|
15
|
+
readonly attrs: SmlNodeKeyAttrs;
|
|
16
|
+
}
|
|
17
|
+
interface SmlNodeIndex {
|
|
33
18
|
readonly nodes: readonly SmlNodeIndexEntry[];
|
|
34
|
-
}
|
|
19
|
+
}
|
|
35
20
|
declare const deriveNodeIndexFromDocument: (document: SmlDocument) => SmlNodeIndex;
|
|
36
|
-
declare const deriveNodeIndex: (source: string) => Result
|
|
21
|
+
declare const deriveNodeIndex: (source: string) => Result<SmlNodeIndex, string>;
|
|
37
22
|
//#endregion
|
|
38
|
-
export { SmlNodeIndex, SmlNodeIndexEntry,
|
|
23
|
+
export { SmlNodeIndex, SmlNodeIndexEntry, SmlNodeKeyAttrs, deriveNodeIndex, deriveNodeIndexFromDocument };
|
|
39
24
|
//# sourceMappingURL=model.d.ts.map
|
package/dist/model.js
CHANGED
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
import { parseSml } from "./parser.js";
|
|
2
|
-
import { Result
|
|
2
|
+
import { Result } from "better-result";
|
|
3
3
|
//#region src/model.ts
|
|
4
|
-
const SmlNodeKeyAttrsSchema = Schema.Record(Schema.String, Schema.Union([Schema.String, Schema.Finite]));
|
|
5
|
-
const SmlNodeIndexEntrySchema = Schema.Struct({
|
|
6
|
-
id: Schema.String,
|
|
7
|
-
tag: Schema.String,
|
|
8
|
-
order: Schema.Finite,
|
|
9
|
-
parentId: Schema.NullOr(Schema.String),
|
|
10
|
-
childIndex: Schema.Finite,
|
|
11
|
-
depth: Schema.Finite,
|
|
12
|
-
path: Schema.String,
|
|
13
|
-
textPreview: Schema.String,
|
|
14
|
-
attrs: SmlNodeKeyAttrsSchema
|
|
15
|
-
});
|
|
16
|
-
const SmlNodeIndexSchema = Schema.Struct({ nodes: Schema.Array(SmlNodeIndexEntrySchema) });
|
|
17
4
|
const KEY_ATTRS = /* @__PURE__ */ new Set([
|
|
18
5
|
"alt",
|
|
19
6
|
"class",
|
|
@@ -81,10 +68,10 @@ const deriveNodeIndexFromDocument = (document) => {
|
|
|
81
68
|
};
|
|
82
69
|
const deriveNodeIndex = (source) => {
|
|
83
70
|
const parsed = parseSml(source);
|
|
84
|
-
if (Result.
|
|
85
|
-
return Result.
|
|
71
|
+
if (Result.isError(parsed)) return Result.err(parsed.error.diagnostics.map((diagnostic) => diagnostic.message).join("\n"));
|
|
72
|
+
return Result.ok(deriveNodeIndexFromDocument(parsed.value));
|
|
86
73
|
};
|
|
87
74
|
//#endregion
|
|
88
|
-
export {
|
|
75
|
+
export { deriveNodeIndex, deriveNodeIndexFromDocument };
|
|
89
76
|
|
|
90
77
|
//# sourceMappingURL=model.js.map
|
package/dist/ops.d.ts
CHANGED
|
@@ -1,184 +1,90 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Result
|
|
1
|
+
import { i as SmlParseError, t as Diagnostic } from "./diagnostics-CqepLcpI.js";
|
|
2
|
+
import { S as SmlTag, r as AttributeValue, x as SmlNode } from "./ast-BLybiDxp.js";
|
|
3
|
+
import { Result } from "better-result";
|
|
4
4
|
//#region src/ops.d.ts
|
|
5
|
+
/** Where an inserted node lands relative to its reference node. */
|
|
6
|
+
type SmlInsertPosition = "before" | "after" | "inside";
|
|
7
|
+
interface SetPropOp {
|
|
8
|
+
readonly type: "setProp";
|
|
9
|
+
readonly nodeId: string;
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly value: AttributeValue | null;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Replace a node's complete child list. The normal print → parse → compile
|
|
15
|
+
* preflight remains the authority on whether the replacement satisfies the
|
|
16
|
+
* target's content model.
|
|
17
|
+
*/
|
|
18
|
+
interface SetChildrenOp {
|
|
19
|
+
readonly type: "setChildren";
|
|
20
|
+
readonly nodeId: string;
|
|
21
|
+
readonly children: ReadonlyArray<SmlNode>;
|
|
22
|
+
}
|
|
23
|
+
interface InsertBlockOp {
|
|
24
|
+
readonly type: "insertBlock";
|
|
25
|
+
readonly tag: SmlTag;
|
|
26
|
+
readonly referenceId: string | null;
|
|
27
|
+
readonly position: SmlInsertPosition;
|
|
28
|
+
}
|
|
29
|
+
interface InsertSnippetOp {
|
|
30
|
+
readonly type: "insertSnippet";
|
|
31
|
+
readonly snippet: string;
|
|
32
|
+
readonly referenceId: string | null;
|
|
33
|
+
readonly position: SmlInsertPosition;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* `insertionIndex` is an element-child index into `targetParentId` evaluated
|
|
37
|
+
* AFTER the moved node has left its old position — the lifted-out model, so a
|
|
38
|
+
* same-parent caller must compute the index against the sibling list without
|
|
39
|
+
* the node. Indexes past the end append.
|
|
40
|
+
*/
|
|
41
|
+
interface MoveNodeOp {
|
|
42
|
+
readonly type: "moveNode";
|
|
43
|
+
readonly nodeId: string;
|
|
44
|
+
readonly targetParentId: string;
|
|
45
|
+
readonly insertionIndex: number;
|
|
46
|
+
}
|
|
47
|
+
interface DuplicateNodeOp {
|
|
48
|
+
readonly type: "duplicateNode";
|
|
49
|
+
readonly nodeId: string;
|
|
50
|
+
}
|
|
51
|
+
interface RemoveNodeOp {
|
|
52
|
+
readonly type: "removeNode";
|
|
53
|
+
readonly nodeId: string;
|
|
54
|
+
}
|
|
5
55
|
/**
|
|
6
56
|
* A single edit against SML source. `nodeId` (and `referenceId` /
|
|
7
57
|
* `targetParentId`) are positional ids from the source the caller last read;
|
|
8
58
|
* within a batch they always resolve against that snapshot — see {@link applyOps}.
|
|
9
59
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
readonly
|
|
13
|
-
readonly
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
readonly
|
|
22
|
-
|
|
23
|
-
}>, Schema.TaggedStruct<"insertBlock", {
|
|
24
|
-
readonly tag: Schema.Literals<readonly ["Email", "Subject", "Preview", "Container", "Section", "Row", "Column", "Heading", "Text", "Button", "Image", "Divider", "Spacer", "List", "ListItem", "If", "Else", "strong", "em", "a", "Source", "Sms", "WhatsApp", "Header", "Body", "Footer", "Buttons"]>;
|
|
25
|
-
readonly referenceId: Schema.NullOr<Schema.String>;
|
|
26
|
-
readonly position: Schema.Literals<readonly ["before", "after", "inside"]>;
|
|
27
|
-
}>, Schema.TaggedStruct<"insertSnippet", {
|
|
28
|
-
readonly snippet: Schema.String;
|
|
29
|
-
readonly referenceId: Schema.NullOr<Schema.String>;
|
|
30
|
-
readonly position: Schema.Literals<readonly ["before", "after", "inside"]>;
|
|
31
|
-
}>, Schema.TaggedStruct<"moveNode", {
|
|
32
|
-
readonly nodeId: Schema.String;
|
|
33
|
-
readonly targetParentId: Schema.String;
|
|
34
|
-
readonly insertionIndex: Schema.Finite;
|
|
35
|
-
}>, Schema.TaggedStruct<"duplicateNode", {
|
|
36
|
-
readonly nodeId: Schema.String;
|
|
37
|
-
}>, Schema.TaggedStruct<"removeNode", {
|
|
38
|
-
readonly nodeId: Schema.String;
|
|
39
|
-
}>]>;
|
|
40
|
-
type SmlOp = typeof SmlOpSchema.Type;
|
|
41
|
-
declare const SmlOpResultSchema: Schema.Struct<{
|
|
42
|
-
readonly index: Schema.Finite;
|
|
43
|
-
readonly status: Schema.Literals<readonly ["applied", "failed"]>;
|
|
44
|
-
readonly op: Schema.Union<readonly [Schema.TaggedStruct<"setProp", {
|
|
45
|
-
readonly nodeId: Schema.String;
|
|
46
|
-
readonly name: Schema.String;
|
|
47
|
-
readonly value: Schema.NullOr<Schema.Union<readonly [Schema.Struct<{
|
|
48
|
-
readonly kind: Schema.Literal<"string">;
|
|
49
|
-
readonly value: Schema.String;
|
|
50
|
-
}>, Schema.Struct<{
|
|
51
|
-
readonly kind: Schema.Literal<"number">;
|
|
52
|
-
readonly value: Schema.Finite;
|
|
53
|
-
}>]>>;
|
|
54
|
-
}>, Schema.TaggedStruct<"setChildren", {
|
|
55
|
-
readonly nodeId: Schema.String;
|
|
56
|
-
readonly children: Schema.$Array<Schema.Codec<SmlNode, SmlNode, never, never>>;
|
|
57
|
-
}>, Schema.TaggedStruct<"insertBlock", {
|
|
58
|
-
readonly tag: Schema.Literals<readonly ["Email", "Subject", "Preview", "Container", "Section", "Row", "Column", "Heading", "Text", "Button", "Image", "Divider", "Spacer", "List", "ListItem", "If", "Else", "strong", "em", "a", "Source", "Sms", "WhatsApp", "Header", "Body", "Footer", "Buttons"]>;
|
|
59
|
-
readonly referenceId: Schema.NullOr<Schema.String>;
|
|
60
|
-
readonly position: Schema.Literals<readonly ["before", "after", "inside"]>;
|
|
61
|
-
}>, Schema.TaggedStruct<"insertSnippet", {
|
|
62
|
-
readonly snippet: Schema.String;
|
|
63
|
-
readonly referenceId: Schema.NullOr<Schema.String>;
|
|
64
|
-
readonly position: Schema.Literals<readonly ["before", "after", "inside"]>;
|
|
65
|
-
}>, Schema.TaggedStruct<"moveNode", {
|
|
66
|
-
readonly nodeId: Schema.String;
|
|
67
|
-
readonly targetParentId: Schema.String;
|
|
68
|
-
readonly insertionIndex: Schema.Finite;
|
|
69
|
-
}>, Schema.TaggedStruct<"duplicateNode", {
|
|
70
|
-
readonly nodeId: Schema.String;
|
|
71
|
-
}>, Schema.TaggedStruct<"removeNode", {
|
|
72
|
-
readonly nodeId: Schema.String;
|
|
73
|
-
}>]>;
|
|
74
|
-
readonly diagnostics: Schema.$Array<Schema.Struct<{
|
|
75
|
-
readonly code: Schema.String;
|
|
76
|
-
readonly message: Schema.String;
|
|
77
|
-
readonly span: Schema.Struct<{
|
|
78
|
-
readonly start: Schema.Finite;
|
|
79
|
-
readonly end: Schema.Finite;
|
|
80
|
-
}>;
|
|
81
|
-
readonly repair: Schema.optional<Schema.Struct<{
|
|
82
|
-
readonly kind: Schema.Literals<readonly ["replace-class", "remove-class", "rewrite-node", "use-primitive"]>;
|
|
83
|
-
readonly raw: Schema.optional<Schema.String>;
|
|
84
|
-
readonly suggestions: Schema.$Array<Schema.String>;
|
|
85
|
-
readonly explanation: Schema.String;
|
|
86
|
-
}>>;
|
|
87
|
-
}>>;
|
|
88
|
-
}>;
|
|
89
|
-
interface SmlOpResult extends Schema.Schema.Type<typeof SmlOpResultSchema> {}
|
|
90
|
-
declare const ApplyOpsResultSchema: Schema.Struct<{
|
|
91
|
-
readonly source: Schema.String;
|
|
92
|
-
readonly revision: Schema.String;
|
|
93
|
-
readonly diagnostics: Schema.$Array<Schema.Struct<{
|
|
94
|
-
readonly code: Schema.String;
|
|
95
|
-
readonly message: Schema.String;
|
|
96
|
-
readonly span: Schema.Struct<{
|
|
97
|
-
readonly start: Schema.Finite;
|
|
98
|
-
readonly end: Schema.Finite;
|
|
99
|
-
}>;
|
|
100
|
-
readonly repair: Schema.optional<Schema.Struct<{
|
|
101
|
-
readonly kind: Schema.Literals<readonly ["replace-class", "remove-class", "rewrite-node", "use-primitive"]>;
|
|
102
|
-
readonly raw: Schema.optional<Schema.String>;
|
|
103
|
-
readonly suggestions: Schema.$Array<Schema.String>;
|
|
104
|
-
readonly explanation: Schema.String;
|
|
105
|
-
}>>;
|
|
106
|
-
}>>;
|
|
107
|
-
readonly results: Schema.$Array<Schema.Struct<{
|
|
108
|
-
readonly index: Schema.Finite;
|
|
109
|
-
readonly status: Schema.Literals<readonly ["applied", "failed"]>;
|
|
110
|
-
readonly op: Schema.Union<readonly [Schema.TaggedStruct<"setProp", {
|
|
111
|
-
readonly nodeId: Schema.String;
|
|
112
|
-
readonly name: Schema.String;
|
|
113
|
-
readonly value: Schema.NullOr<Schema.Union<readonly [Schema.Struct<{
|
|
114
|
-
readonly kind: Schema.Literal<"string">;
|
|
115
|
-
readonly value: Schema.String;
|
|
116
|
-
}>, Schema.Struct<{
|
|
117
|
-
readonly kind: Schema.Literal<"number">;
|
|
118
|
-
readonly value: Schema.Finite;
|
|
119
|
-
}>]>>;
|
|
120
|
-
}>, Schema.TaggedStruct<"setChildren", {
|
|
121
|
-
readonly nodeId: Schema.String;
|
|
122
|
-
readonly children: Schema.$Array<Schema.Codec<SmlNode, SmlNode, never, never>>;
|
|
123
|
-
}>, Schema.TaggedStruct<"insertBlock", {
|
|
124
|
-
readonly tag: Schema.Literals<readonly ["Email", "Subject", "Preview", "Container", "Section", "Row", "Column", "Heading", "Text", "Button", "Image", "Divider", "Spacer", "List", "ListItem", "If", "Else", "strong", "em", "a", "Source", "Sms", "WhatsApp", "Header", "Body", "Footer", "Buttons"]>;
|
|
125
|
-
readonly referenceId: Schema.NullOr<Schema.String>;
|
|
126
|
-
readonly position: Schema.Literals<readonly ["before", "after", "inside"]>;
|
|
127
|
-
}>, Schema.TaggedStruct<"insertSnippet", {
|
|
128
|
-
readonly snippet: Schema.String;
|
|
129
|
-
readonly referenceId: Schema.NullOr<Schema.String>;
|
|
130
|
-
readonly position: Schema.Literals<readonly ["before", "after", "inside"]>;
|
|
131
|
-
}>, Schema.TaggedStruct<"moveNode", {
|
|
132
|
-
readonly nodeId: Schema.String;
|
|
133
|
-
readonly targetParentId: Schema.String;
|
|
134
|
-
readonly insertionIndex: Schema.Finite;
|
|
135
|
-
}>, Schema.TaggedStruct<"duplicateNode", {
|
|
136
|
-
readonly nodeId: Schema.String;
|
|
137
|
-
}>, Schema.TaggedStruct<"removeNode", {
|
|
138
|
-
readonly nodeId: Schema.String;
|
|
139
|
-
}>]>;
|
|
140
|
-
readonly diagnostics: Schema.$Array<Schema.Struct<{
|
|
141
|
-
readonly code: Schema.String;
|
|
142
|
-
readonly message: Schema.String;
|
|
143
|
-
readonly span: Schema.Struct<{
|
|
144
|
-
readonly start: Schema.Finite;
|
|
145
|
-
readonly end: Schema.Finite;
|
|
146
|
-
}>;
|
|
147
|
-
readonly repair: Schema.optional<Schema.Struct<{
|
|
148
|
-
readonly kind: Schema.Literals<readonly ["replace-class", "remove-class", "rewrite-node", "use-primitive"]>;
|
|
149
|
-
readonly raw: Schema.optional<Schema.String>;
|
|
150
|
-
readonly suggestions: Schema.$Array<Schema.String>;
|
|
151
|
-
readonly explanation: Schema.String;
|
|
152
|
-
}>>;
|
|
153
|
-
}>>;
|
|
154
|
-
}>>;
|
|
155
|
-
}>;
|
|
156
|
-
interface ApplyOpsResult extends Schema.Schema.Type<typeof ApplyOpsResultSchema> {}
|
|
60
|
+
type SmlOp = SetPropOp | SetChildrenOp | InsertBlockOp | InsertSnippetOp | MoveNodeOp | DuplicateNodeOp | RemoveNodeOp;
|
|
61
|
+
interface SmlOpResult {
|
|
62
|
+
readonly index: number;
|
|
63
|
+
readonly status: "applied" | "failed";
|
|
64
|
+
readonly op: SmlOp;
|
|
65
|
+
readonly diagnostics: ReadonlyArray<Diagnostic>;
|
|
66
|
+
}
|
|
67
|
+
interface ApplyOpsResult {
|
|
68
|
+
readonly source: string;
|
|
69
|
+
readonly revision: string;
|
|
70
|
+
readonly diagnostics: ReadonlyArray<Diagnostic>;
|
|
71
|
+
readonly results: ReadonlyArray<SmlOpResult>;
|
|
72
|
+
}
|
|
157
73
|
interface ApplyOpsOptions {
|
|
158
74
|
readonly expectedRevision?: string | number | undefined;
|
|
159
75
|
readonly currentRevision?: string | number | undefined;
|
|
160
76
|
}
|
|
161
|
-
declare const SmlOpError_base:
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
readonly repair: Schema.optional<Schema.Struct<{
|
|
170
|
-
readonly kind: Schema.Literals<readonly ["replace-class", "remove-class", "rewrite-node", "use-primitive"]>;
|
|
171
|
-
readonly raw: Schema.optional<Schema.String>;
|
|
172
|
-
readonly suggestions: Schema.$Array<Schema.String>;
|
|
173
|
-
readonly explanation: Schema.String;
|
|
174
|
-
}>>;
|
|
175
|
-
}>>;
|
|
176
|
-
}>, import("effect/Cause").YieldableError>;
|
|
177
|
-
declare class SmlOpError extends SmlOpError_base {
|
|
178
|
-
get message(): string;
|
|
77
|
+
declare const SmlOpError_base: import("better-result").TaggedErrorClass<"SmlOpError">;
|
|
78
|
+
declare class SmlOpError extends SmlOpError_base<{
|
|
79
|
+
readonly diagnostics: ReadonlyArray<Diagnostic>;
|
|
80
|
+
readonly message: string;
|
|
81
|
+
}> {
|
|
82
|
+
constructor(args: {
|
|
83
|
+
readonly diagnostics: ReadonlyArray<Diagnostic>;
|
|
84
|
+
});
|
|
179
85
|
}
|
|
180
86
|
declare const sourceRevision: (source: string) => string;
|
|
181
|
-
declare const normalizeSml: (source: string) => Result
|
|
87
|
+
declare const normalizeSml: (source: string) => Result<string, SmlParseError>;
|
|
182
88
|
/**
|
|
183
89
|
* Apply a batch of ops to SML source, returning the rewritten source, its new
|
|
184
90
|
* revision, and a per-op result.
|
|
@@ -201,8 +107,8 @@ declare const normalizeSml: (source: string) => Result.Result<string, SmlParseEr
|
|
|
201
107
|
* as an independent validity gate; a failing op is recorded as `failed` and
|
|
202
108
|
* does not advance the working document.
|
|
203
109
|
*/
|
|
204
|
-
declare const applyOps: (source: string, ops: readonly SmlOp[], options?: ApplyOpsOptions) => Result
|
|
205
|
-
declare const applyOp: (source: string, op: SmlOp, options?: ApplyOpsOptions) => Result
|
|
110
|
+
declare const applyOps: (source: string, ops: readonly SmlOp[], options?: ApplyOpsOptions) => Result<ApplyOpsResult, SmlOpError>;
|
|
111
|
+
declare const applyOp: (source: string, op: SmlOp, options?: ApplyOpsOptions) => Result<ApplyOpsResult, SmlOpError>;
|
|
206
112
|
//#endregion
|
|
207
|
-
export { ApplyOpsOptions, ApplyOpsResult,
|
|
113
|
+
export { ApplyOpsOptions, ApplyOpsResult, DuplicateNodeOp, InsertBlockOp, InsertSnippetOp, MoveNodeOp, RemoveNodeOp, SetChildrenOp, SetPropOp, SmlInsertPosition, SmlOp, SmlOpError, SmlOpResult, applyOp, applyOps, normalizeSml, sourceRevision };
|
|
208
114
|
//# sourceMappingURL=ops.d.ts.map
|