@samva/markup 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/AGENTS.md +19 -0
  2. package/dist/{ast-63I-VLQx.d.ts → ast-BrDtApwS.d.ts} +34 -60
  3. package/dist/ast.d.ts +2 -2
  4. package/dist/ast.js +4 -52
  5. package/dist/{catalog-Ck1tAGwO.d.ts → catalog-60eaYC7b.d.ts} +2 -2
  6. package/dist/{checks-DXuERO4B.js → checks-DBweSIPN.js} +18 -20
  7. package/dist/checks.d.ts +1 -1
  8. package/dist/checks.js +1 -1
  9. package/dist/classes.d.ts +1 -1
  10. package/dist/compile-sms.d.ts +3 -3
  11. package/dist/compile-whatsapp.d.ts +5 -5
  12. package/dist/compile-whatsapp.js +3 -3
  13. package/dist/compile.d.ts +5 -5
  14. package/dist/compile.js +5 -5
  15. package/dist/compiler.d.ts +8 -5
  16. package/dist/compiler.js +45 -45
  17. package/dist/components.d.ts +4 -4
  18. package/dist/conditionals.js +56 -24
  19. package/dist/corpus-BjYMqOoY.d.ts +106 -0
  20. package/dist/{css-ar2lU3NC.d.ts → css-COcFOT1y.d.ts} +4 -5
  21. package/dist/diagnostics-BMYtBCQk.d.ts +46 -0
  22. package/dist/diagnostics-OcQKQYSY.d.ts +49 -0
  23. package/dist/diagnostics.d.ts +2 -2
  24. package/dist/diagnostics.js +24 -33
  25. package/dist/{elements-DtwKlFVH.d.ts → elements-BzjjnoCS.d.ts} +40 -161
  26. package/dist/email/components.d.ts +1 -1
  27. package/dist/email/components.js +40 -10
  28. package/dist/email/diagnostics.d.ts +1 -1
  29. package/dist/email/diagnostics.js +8 -43
  30. package/dist/email/elements.d.ts +1 -1
  31. package/dist/email/html.d.ts +2 -2
  32. package/dist/email/html.js +11 -10
  33. package/dist/email/jsx-dev-runtime.d.ts +3 -21
  34. package/dist/email/jsx-runtime.d.ts +1 -1
  35. package/dist/email/jsx-runtime.js +29 -3
  36. package/dist/email/render.d.ts +4 -4
  37. package/dist/email/render.js +1 -1
  38. package/dist/email/selection.d.ts +20 -31
  39. package/dist/email/selection.js +1 -53
  40. package/dist/email/source-edit.d.ts +1 -1
  41. package/dist/email/source-edit.js +2 -2
  42. package/dist/email/stylesheets.d.ts +1 -1
  43. package/dist/email/text.d.ts +1 -1
  44. package/dist/email/text.js +3 -3
  45. package/dist/emit.d.ts +2 -2
  46. package/dist/emit.js +5 -5
  47. package/dist/footer.js +7 -4
  48. package/dist/guards-eV1qLbf2.js +9 -0
  49. package/dist/{input-schema-BIfzI63B.d.ts → input-schema-7dPFVvNE.d.ts} +2 -2
  50. package/dist/input-schema-zjkgrXn2.js +455 -0
  51. package/dist/input-schema.d.ts +1 -1
  52. package/dist/input-schema.js +1 -169
  53. package/dist/interpolate.d.ts +9 -12
  54. package/dist/interpolate.js +1 -19
  55. package/dist/jsx-dev-runtime.d.ts +2 -2
  56. package/dist/{jsx-runtime-C5k_Zq0A.d.ts → jsx-runtime-I-1nCtl2.d.ts} +3 -3
  57. package/dist/jsx-runtime.d.ts +1 -1
  58. package/dist/jsx-runtime.js +3 -3
  59. package/dist/lexer.js +17 -5
  60. package/dist/model.d.ts +18 -33
  61. package/dist/model.js +4 -17
  62. package/dist/ops-2aiiYO7m.js +630 -0
  63. package/dist/ops.d.ts +78 -172
  64. package/dist/ops.js +2 -546
  65. package/dist/{parser-CGBS73Gz.d.ts → parser-CQcASEyy.d.ts} +5 -5
  66. package/dist/parser.d.ts +1 -1
  67. package/dist/parser.js +8 -8
  68. package/dist/{predicate-CvkzT-a2.js → predicate-BI6uRRM-.js} +24 -14
  69. package/dist/{predicate-G2SeSvoN.d.ts → predicate-M-05Nd7R.d.ts} +4 -4
  70. package/dist/predicate.d.ts +1 -1
  71. package/dist/predicate.js +1 -1
  72. package/dist/presets/category-mapping.d.ts +1 -1
  73. package/dist/presets/corpus.d.ts +1 -1
  74. package/dist/presets/corpus.js +74 -117
  75. package/dist/presets/public-gallery.d.ts +2 -2
  76. package/dist/presets/public-gallery.js +17 -9
  77. package/dist/presets/public-handoff.d.ts +4 -4
  78. package/dist/presets/public-handoff.js +10 -9
  79. package/dist/presets/public-preview-artifacts.d.ts +7 -5
  80. package/dist/presets/public-preview-artifacts.js +10 -9
  81. package/dist/presets/showcase.d.ts +1 -1
  82. package/dist/presets.d.ts +1 -1
  83. package/dist/printer.d.ts +1 -1
  84. package/dist/{render-ykQhtMs_.js → render-aaJBnsXK.js} +44 -27
  85. package/dist/render-template.d.ts +7 -7
  86. package/dist/render-template.js +6 -6
  87. package/dist/{showcase-C_xgl6hz.d.ts → showcase-DGZAWn4Z.d.ts} +2 -2
  88. package/dist/{source-locations-BCJQnIfU.d.ts → source-locations-DrCM82Ym.d.ts} +4 -26
  89. package/dist/source-locations.d.ts +2 -2
  90. package/dist/source-locations.js +3 -26
  91. package/dist/{template-Dy5yOPyp.d.ts → template-DWftqh4x.d.ts} +4 -4
  92. package/dist/template.d.ts +1 -1
  93. package/dist/template.js +3 -3
  94. package/dist/theme-css.d.ts +3 -3
  95. package/dist/theme-css.js +3 -3
  96. package/dist/theme.js +25 -2
  97. package/dist/tsx-source-instrumentation.d.ts +1 -3
  98. package/dist/tsx-source-instrumentation.js +6 -6
  99. package/dist/tsx-tracer.d.ts +7 -11
  100. package/dist/tsx-tracer.js +165 -165
  101. package/dist/{variables-if1VrV34.d.ts → variables-J_L3qxRa.d.ts} +2 -2
  102. package/dist/variables.d.ts +1 -1
  103. package/dist/variables.js +4 -4
  104. package/package.json +4 -3
  105. package/dist/corpus-U2EeALvS.d.ts +0 -234
  106. package/dist/diagnostics-Djd9ckLg.d.ts +0 -90
  107. package/dist/diagnostics-oveE-laV.d.ts +0 -79
package/dist/ops.d.ts CHANGED
@@ -1,184 +1,90 @@
1
- import { o as SmlParseError } from "./diagnostics-oveE-laV.js";
2
- import { E as SmlNode } from "./ast-63I-VLQx.js";
3
- import { Result, Schema } from "effect";
1
+ import { i as SmlParseError, t as Diagnostic } from "./diagnostics-OcQKQYSY.js";
2
+ import { S as SmlTag, r as AttributeValue, x as SmlNode } from "./ast-BrDtApwS.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
- declare const SmlOpSchema: Schema.Union<readonly [Schema.TaggedStruct<"setProp", {
11
- readonly nodeId: Schema.String;
12
- readonly name: Schema.String;
13
- readonly value: Schema.NullOr<Schema.Union<readonly [Schema.Struct<{
14
- readonly kind: Schema.Literal<"string">;
15
- readonly value: Schema.String;
16
- }>, Schema.Struct<{
17
- readonly kind: Schema.Literal<"number">;
18
- readonly value: Schema.Finite;
19
- }>]>>;
20
- }>, Schema.TaggedStruct<"setChildren", {
21
- readonly nodeId: Schema.String;
22
- readonly children: Schema.$Array<Schema.Codec<SmlNode, SmlNode, never, never>>;
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: Schema.Class<SmlOpError, Schema.TaggedStruct<"SmlOpError", {
162
- readonly diagnostics: Schema.$Array<Schema.Struct<{
163
- readonly code: Schema.String;
164
- readonly message: Schema.String;
165
- readonly span: Schema.Struct<{
166
- readonly start: Schema.Finite;
167
- readonly end: Schema.Finite;
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.Result<string, SmlParseError>;
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.Result<ApplyOpsResult, SmlOpError>;
205
- declare const applyOp: (source: string, op: SmlOp, options?: ApplyOpsOptions) => Result.Result<ApplyOpsResult, SmlOpError>;
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, ApplyOpsResultSchema, SmlOp, SmlOpError, SmlOpResult, SmlOpResultSchema, SmlOpSchema, applyOp, applyOps, normalizeSml, sourceRevision };
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