@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.
- package/AGENTS.md +19 -0
- package/dist/{ast-63I-VLQx.d.ts → ast-BrDtApwS.d.ts} +34 -60
- package/dist/ast.d.ts +2 -2
- package/dist/ast.js +4 -52
- package/dist/{catalog-Ck1tAGwO.d.ts → catalog-60eaYC7b.d.ts} +2 -2
- package/dist/{checks-DXuERO4B.js → checks-DBweSIPN.js} +18 -20
- 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 +8 -5
- package/dist/compiler.js +45 -45
- package/dist/components.d.ts +4 -4
- package/dist/conditionals.js +56 -24
- package/dist/corpus-BjYMqOoY.d.ts +106 -0
- package/dist/{css-ar2lU3NC.d.ts → css-COcFOT1y.d.ts} +4 -5
- package/dist/diagnostics-BMYtBCQk.d.ts +46 -0
- package/dist/diagnostics-OcQKQYSY.d.ts +49 -0
- package/dist/diagnostics.d.ts +2 -2
- package/dist/diagnostics.js +24 -33
- package/dist/{elements-DtwKlFVH.d.ts → elements-BzjjnoCS.d.ts} +40 -161
- 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/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 +11 -10
- 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/footer.js +7 -4
- 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-I-1nCtl2.d.ts} +3 -3
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/jsx-runtime.js +3 -3
- package/dist/lexer.js +17 -5
- package/dist/model.d.ts +18 -33
- package/dist/model.js +4 -17
- package/dist/ops-2aiiYO7m.js +630 -0
- package/dist/ops.d.ts +78 -172
- package/dist/ops.js +2 -546
- package/dist/{parser-CGBS73Gz.d.ts → parser-CQcASEyy.d.ts} +5 -5
- package/dist/parser.d.ts +1 -1
- package/dist/parser.js +8 -8
- package/dist/{predicate-CvkzT-a2.js → predicate-BI6uRRM-.js} +24 -14
- package/dist/{predicate-G2SeSvoN.d.ts → predicate-M-05Nd7R.d.ts} +4 -4
- 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 +17 -9
- 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 +7 -5
- package/dist/presets/public-preview-artifacts.js +10 -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-aaJBnsXK.js} +44 -27
- package/dist/render-template.d.ts +7 -7
- package/dist/render-template.js +6 -6
- package/dist/{showcase-C_xgl6hz.d.ts → showcase-DGZAWn4Z.d.ts} +2 -2
- package/dist/{source-locations-BCJQnIfU.d.ts → source-locations-DrCM82Ym.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-DWftqh4x.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/theme.js +25 -2
- 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 +165 -165
- package/dist/{variables-if1VrV34.d.ts → variables-J_L3qxRa.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-DrCM82Ym.js";
|
|
2
|
+
import { a as JsxResult, i as JSX, n as Fragment, t as Component } from "./jsx-runtime-I-1nCtl2.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-BrDtApwS.js";
|
|
2
|
+
import { s as VariableRef } from "./variables-J_L3qxRa.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-I-1nCtl2.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-I-1nCtl2.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/lexer.js
CHANGED
|
@@ -21,6 +21,7 @@ const CHAR_UNDERSCORE = 95;
|
|
|
21
21
|
const CHAR_0 = 48;
|
|
22
22
|
const CHAR_9 = 57;
|
|
23
23
|
const CHAR_UPPER_A = 65;
|
|
24
|
+
const CHAR_UPPER_X = 88;
|
|
24
25
|
const CHAR_UPPER_Z = 90;
|
|
25
26
|
const CHAR_LOWER_A = 97;
|
|
26
27
|
const CHAR_LOWER_X = 120;
|
|
@@ -60,6 +61,10 @@ const NAMED_ENTITIES = {
|
|
|
60
61
|
apos: "'",
|
|
61
62
|
nbsp: "\xA0"
|
|
62
63
|
};
|
|
64
|
+
const numericEntityCodePoint = (digits, radix) => {
|
|
65
|
+
const codePoint = Number.parseInt(digits, radix);
|
|
66
|
+
return Number.isFinite(codePoint) && codePoint <= 1114111 ? codePoint : void 0;
|
|
67
|
+
};
|
|
63
68
|
/**
|
|
64
69
|
* Validates the entity starting at `offset` (which points at `&`).
|
|
65
70
|
* Returns the end offset (past `;`) or -1 when malformed.
|
|
@@ -68,7 +73,8 @@ const scanEntity = (source, offset) => {
|
|
|
68
73
|
let index = offset + 1;
|
|
69
74
|
if (source.charCodeAt(index) === CHAR_HASH) {
|
|
70
75
|
index++;
|
|
71
|
-
const
|
|
76
|
+
const marker = source.charCodeAt(index);
|
|
77
|
+
const hex = marker === CHAR_LOWER_X || marker === CHAR_UPPER_X;
|
|
72
78
|
if (hex) index++;
|
|
73
79
|
const digitsStart = index;
|
|
74
80
|
while (index < source.length) {
|
|
@@ -77,11 +83,13 @@ const scanEntity = (source, offset) => {
|
|
|
77
83
|
index++;
|
|
78
84
|
}
|
|
79
85
|
if (index === digitsStart) return -1;
|
|
86
|
+
if (numericEntityCodePoint(source.slice(digitsStart, index), hex ? 16 : 10) === void 0) return -1;
|
|
80
87
|
return source.charCodeAt(index) === CHAR_SEMICOLON ? index + 1 : -1;
|
|
81
88
|
}
|
|
82
89
|
const nameStart = index;
|
|
83
90
|
while (index < source.length && isLetter(source.charCodeAt(index))) index++;
|
|
84
|
-
|
|
91
|
+
const name = source.slice(nameStart, index);
|
|
92
|
+
if (!Object.hasOwn(NAMED_ENTITIES, name)) return -1;
|
|
85
93
|
return source.charCodeAt(index) === CHAR_SEMICOLON ? index + 1 : -1;
|
|
86
94
|
};
|
|
87
95
|
/** Decodes entities in text that already passed `scanEntity` validation. */
|
|
@@ -102,9 +110,13 @@ const decodeEntities = (raw) => {
|
|
|
102
110
|
break;
|
|
103
111
|
}
|
|
104
112
|
const body = raw.slice(ampersand + 1, semicolon);
|
|
105
|
-
if (body.startsWith("#x") || body.startsWith("#X"))
|
|
106
|
-
|
|
107
|
-
|
|
113
|
+
if (body.startsWith("#x") || body.startsWith("#X")) {
|
|
114
|
+
const codePoint = numericEntityCodePoint(body.slice(2), 16);
|
|
115
|
+
result += codePoint === void 0 ? raw.slice(ampersand, semicolon + 1) : String.fromCodePoint(codePoint);
|
|
116
|
+
} else if (body.startsWith("#")) {
|
|
117
|
+
const codePoint = numericEntityCodePoint(body.slice(1), 10);
|
|
118
|
+
result += codePoint === void 0 ? raw.slice(ampersand, semicolon + 1) : String.fromCodePoint(codePoint);
|
|
119
|
+
} else result += Object.hasOwn(NAMED_ENTITIES, body) ? NAMED_ENTITIES[body] : raw.slice(ampersand, semicolon + 1);
|
|
108
120
|
index = semicolon + 1;
|
|
109
121
|
}
|
|
110
122
|
return result;
|
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-BrDtApwS.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
|