@samva/markup 0.3.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-Db0UcCTg.d.ts +356 -0
- 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 +87 -140
- package/dist/presets/public-gallery.d.ts +106 -130
- package/dist/presets/public-gallery.js +131 -209
- package/dist/presets/public-handoff.d.ts +4 -4
- package/dist/presets/public-handoff.js +13 -11
- package/dist/presets/public-preview-artifacts.d.ts +5 -5
- package/dist/presets/public-preview-artifacts.js +9 -9
- package/dist/presets/public-preview.d.ts +0 -4
- package/dist/presets/public-preview.js +37 -362
- package/dist/presets/showcase.d.ts +2 -0
- package/dist/presets/showcase.js +627 -0
- package/dist/presets/sources.d.ts +1 -1
- package/dist/presets/sources.js +5767 -2023
- package/dist/presets.d.ts +2 -384
- package/dist/presets.js +299 -765
- 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-dvJMn-Lo.d.ts +456 -0
- 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 +8 -3
- package/dist/corpus-qrUD5O6r.d.ts +0 -254
- package/dist/diagnostics-Djd9ckLg.d.ts +0 -90
- package/dist/diagnostics-oveE-laV.d.ts +0 -79
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Schema } from "effect";
|
|
1
|
+
import { f as ElementNode, x as SmlNode } from "./ast-BLybiDxp.js";
|
|
3
2
|
//#region src/source-locations.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* The source payload emitted by the JSX development transform. The transform
|
|
@@ -17,14 +16,6 @@ interface JsxSourceLocation {
|
|
|
17
16
|
readonly lineNumber: number;
|
|
18
17
|
readonly columnNumber: number;
|
|
19
18
|
}
|
|
20
|
-
/** JSON-safe source location shape shared by preview and editor contracts. */
|
|
21
|
-
declare const JsxSourceLocation: Schema.Struct<{
|
|
22
|
-
readonly fileName: Schema.String;
|
|
23
|
-
readonly lineNumber: Schema.Int;
|
|
24
|
-
readonly columnNumber: Schema.Int;
|
|
25
|
-
}>;
|
|
26
|
-
/** Reasons a preview cannot safely expose an authored source map. */
|
|
27
|
-
declare const SourceLocationUnavailableReason: Schema.Literals<readonly ["no-source-metadata", "structure-mismatch", "duplicate-source-origin", "render-failed", "stale-preview"]>;
|
|
28
19
|
/**
|
|
29
20
|
* Runtime-only carrier for JSX source metadata. It is global so separately
|
|
30
21
|
* bundled `jsx-dev-runtime` and `render-template` entries still agree on the
|
|
@@ -38,7 +29,7 @@ declare const JSX_SOURCE_LOCATION_PROP: "__samva_source_location";
|
|
|
38
29
|
* currently provide no source metadata, so that path reports a typed absence
|
|
39
30
|
* rather than guessing from output order.
|
|
40
31
|
*/
|
|
41
|
-
type SourceLocationUnavailableReason =
|
|
32
|
+
type SourceLocationUnavailableReason = "no-source-metadata" | "structure-mismatch" | "duplicate-source-origin" | "render-failed" | "stale-preview";
|
|
42
33
|
type UnboundTemplateSourceLocations = {
|
|
43
34
|
readonly kind: "available";
|
|
44
35
|
/** Parsed SML node id → the JSX origin that produced that element. */
|
|
@@ -57,19 +48,6 @@ type TemplateSourceLocations = {
|
|
|
57
48
|
readonly kind: "unavailable";
|
|
58
49
|
readonly reason: SourceLocationUnavailableReason;
|
|
59
50
|
};
|
|
60
|
-
/** JSON-safe schema for a parsed-node-id → JSX-origin map. */
|
|
61
|
-
declare const TemplateSourceLocationsSchema: Schema.Union<readonly [Schema.Struct<{
|
|
62
|
-
readonly kind: Schema.Literal<"available">;
|
|
63
|
-
readonly revision: Schema.String;
|
|
64
|
-
readonly byNodeId: Schema.$Record<Schema.String, Schema.Struct<{
|
|
65
|
-
readonly fileName: Schema.String;
|
|
66
|
-
readonly lineNumber: Schema.Int;
|
|
67
|
-
readonly columnNumber: Schema.Int;
|
|
68
|
-
}>>;
|
|
69
|
-
}>, Schema.Struct<{
|
|
70
|
-
readonly kind: Schema.Literal<"unavailable">;
|
|
71
|
-
readonly reason: Schema.Literals<readonly ["no-source-metadata", "structure-mismatch", "duplicate-source-origin", "render-failed", "stale-preview"]>;
|
|
72
|
-
}>]>;
|
|
73
51
|
/** Normalize the optional payload accepted by `jsxDEV`. */
|
|
74
52
|
declare const completeJsxSourceLocation: (source: JsxSource | null | undefined) => JsxSourceLocation | undefined;
|
|
75
53
|
/** Attach a source origin without changing the serialized draft shape. */
|
|
@@ -85,5 +63,5 @@ declare const mapJsxSourceLocations: (draft: ElementNode, parsed: ElementNode) =
|
|
|
85
63
|
/** Compare source-map statuses for the emission determinism guard. */
|
|
86
64
|
declare const sameTemplateSourceLocations: (left: UnboundTemplateSourceLocations, right: UnboundTemplateSourceLocations) => boolean;
|
|
87
65
|
//#endregion
|
|
88
|
-
export { SourceLocationUnavailableReason as a,
|
|
89
|
-
//# sourceMappingURL=source-locations-
|
|
66
|
+
export { SourceLocationUnavailableReason as a, attachJsxSourceLocation as c, mapJsxSourceLocations as d, sameTemplateSourceLocations as f, JsxSourceLocation as i, completeJsxSourceLocation as l, JSX_SOURCE_LOCATION_PROP as n, TemplateSourceLocations as o, JsxSource as r, UnboundTemplateSourceLocations as s, JSX_SOURCE_LOCATION as t, jsxSourceLocationOf as u };
|
|
67
|
+
//# sourceMappingURL=source-locations-D6Te6Gy1.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as SourceLocationUnavailableReason, c as
|
|
2
|
-
export { JSX_SOURCE_LOCATION, JSX_SOURCE_LOCATION_PROP, JsxSource, JsxSourceLocation, SourceLocationUnavailableReason, TemplateSourceLocations,
|
|
1
|
+
import { a as SourceLocationUnavailableReason, c as attachJsxSourceLocation, d as mapJsxSourceLocations, f as sameTemplateSourceLocations, i as JsxSourceLocation, l as completeJsxSourceLocation, n as JSX_SOURCE_LOCATION_PROP, o as TemplateSourceLocations, r as JsxSource, s as UnboundTemplateSourceLocations, t as JSX_SOURCE_LOCATION, u as jsxSourceLocationOf } from "./source-locations-D6Te6Gy1.js";
|
|
2
|
+
export { JSX_SOURCE_LOCATION, JSX_SOURCE_LOCATION_PROP, JsxSource, JsxSourceLocation, SourceLocationUnavailableReason, TemplateSourceLocations, UnboundTemplateSourceLocations, attachJsxSourceLocation, completeJsxSourceLocation, jsxSourceLocationOf, mapJsxSourceLocations, sameTemplateSourceLocations };
|
package/dist/source-locations.js
CHANGED
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as hasProperty } from "./guards-eV1qLbf2.js";
|
|
2
2
|
//#region src/source-locations.ts
|
|
3
|
-
/** JSON-safe source location shape shared by preview and editor contracts. */
|
|
4
|
-
const JsxSourceLocation = Schema.Struct({
|
|
5
|
-
fileName: Schema.String,
|
|
6
|
-
lineNumber: Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)),
|
|
7
|
-
columnNumber: Schema.Int.check(Schema.isGreaterThanOrEqualTo(1))
|
|
8
|
-
});
|
|
9
|
-
/** Reasons a preview cannot safely expose an authored source map. */
|
|
10
|
-
const SourceLocationUnavailableReason = Schema.Literals([
|
|
11
|
-
"no-source-metadata",
|
|
12
|
-
"structure-mismatch",
|
|
13
|
-
"duplicate-source-origin",
|
|
14
|
-
"render-failed",
|
|
15
|
-
"stale-preview"
|
|
16
|
-
]);
|
|
17
3
|
/**
|
|
18
4
|
* Runtime-only carrier for JSX source metadata. It is global so separately
|
|
19
5
|
* bundled `jsx-dev-runtime` and `render-template` entries still agree on the
|
|
@@ -22,15 +8,6 @@ const SourceLocationUnavailableReason = Schema.Literals([
|
|
|
22
8
|
const JSX_SOURCE_LOCATION = Symbol.for("@samva/markup/jsx-source-location");
|
|
23
9
|
/** Internal JSX prop used only by an editor preview source transform. */
|
|
24
10
|
const JSX_SOURCE_LOCATION_PROP = "__samva_source_location";
|
|
25
|
-
/** JSON-safe schema for a parsed-node-id → JSX-origin map. */
|
|
26
|
-
const TemplateSourceLocationsSchema = Schema.Union([Schema.Struct({
|
|
27
|
-
kind: Schema.Literal("available"),
|
|
28
|
-
revision: Schema.String,
|
|
29
|
-
byNodeId: Schema.Record(Schema.String, JsxSourceLocation)
|
|
30
|
-
}), Schema.Struct({
|
|
31
|
-
kind: Schema.Literal("unavailable"),
|
|
32
|
-
reason: SourceLocationUnavailableReason
|
|
33
|
-
})]);
|
|
34
11
|
/** Normalize the optional payload accepted by `jsxDEV`. */
|
|
35
12
|
const completeJsxSourceLocation = (source) => {
|
|
36
13
|
if (source?.fileName === void 0 || source.lineNumber === void 0 || source.columnNumber === void 0) return;
|
|
@@ -50,7 +27,7 @@ const attachJsxSourceLocation = (node, source) => {
|
|
|
50
27
|
writable: false
|
|
51
28
|
});
|
|
52
29
|
};
|
|
53
|
-
const isJsxSourceLocation = (value) =>
|
|
30
|
+
const isJsxSourceLocation = (value) => hasProperty(value, "fileName") && typeof value.fileName === "string" && hasProperty(value, "lineNumber") && typeof value.lineNumber === "number" && Number.isInteger(value.lineNumber) && hasProperty(value, "columnNumber") && typeof value.columnNumber === "number" && Number.isInteger(value.columnNumber);
|
|
54
31
|
/** Read the ephemeral origin, if this draft element has one. */
|
|
55
32
|
const jsxSourceLocationOf = (node) => {
|
|
56
33
|
if (node.kind !== "element") return void 0;
|
|
@@ -120,6 +97,6 @@ const sameTemplateSourceLocations = (left, right) => {
|
|
|
120
97
|
return true;
|
|
121
98
|
};
|
|
122
99
|
//#endregion
|
|
123
|
-
export { JSX_SOURCE_LOCATION, JSX_SOURCE_LOCATION_PROP,
|
|
100
|
+
export { JSX_SOURCE_LOCATION, JSX_SOURCE_LOCATION_PROP, attachJsxSourceLocation, completeJsxSourceLocation, jsxSourceLocationOf, mapJsxSourceLocations, sameTemplateSourceLocations };
|
|
124
101
|
|
|
125
102
|
//# sourceMappingURL=source-locations.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { m as EmailNode } from "./elements-
|
|
2
|
-
import { r as InputSchema } from "./input-schema-
|
|
3
|
-
import { StandardJSONSchemaV1 } from "
|
|
1
|
+
import { m as EmailNode } from "./elements-ChJULZlh.js";
|
|
2
|
+
import { r as InputSchema } from "./input-schema-7dPFVvNE.js";
|
|
3
|
+
import { StandardJSONSchemaV1 } from "@standard-schema/spec";
|
|
4
4
|
//#region src/template.d.ts
|
|
5
5
|
/** One actual-input render owns all of a message's authored content. */
|
|
6
6
|
interface EmailContent {
|
|
@@ -57,4 +57,4 @@ type TemplateInput<T extends {
|
|
|
57
57
|
}> = Parameters<T["render"]>[0];
|
|
58
58
|
//#endregion
|
|
59
59
|
export { TemplateRuntime as a, TemplateInput as i, TEMPLATE_NAME_PATTERN as n, defineEmail as o, TemplateDefinition as r, isTemplateDefinition as s, EmailContent as t };
|
|
60
|
-
//# sourceMappingURL=template-
|
|
60
|
+
//# sourceMappingURL=template-G-QPcfmn.d.ts.map
|
package/dist/template.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as TemplateRuntime, i as TemplateInput, n as TEMPLATE_NAME_PATTERN, o as defineEmail, r as TemplateDefinition, s as isTemplateDefinition, t as EmailContent } from "./template-
|
|
1
|
+
import { a as TemplateRuntime, i as TemplateInput, n as TEMPLATE_NAME_PATTERN, o as defineEmail, r as TemplateDefinition, s as isTemplateDefinition, t as EmailContent } from "./template-G-QPcfmn.js";
|
|
2
2
|
export { EmailContent, TEMPLATE_NAME_PATTERN, TemplateDefinition, TemplateInput, TemplateRuntime, defineEmail, isTemplateDefinition };
|
package/dist/template.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { n as isObject } from "./guards-eV1qLbf2.js";
|
|
2
|
+
import { n as inputSchema } from "./input-schema-zjkgrXn2.js";
|
|
3
3
|
//#region src/template.ts
|
|
4
4
|
/** Classify an evaluated module export without executing helpers as templates. */
|
|
5
|
-
const isTemplateDefinition = (value) =>
|
|
5
|
+
const isTemplateDefinition = (value) => isObject(value) && typeof value.id === "string" && typeof value.render === "function" && isObject(value.schema);
|
|
6
6
|
/**
|
|
7
7
|
* The one naming contract for a template id and a fixture key: a letter, a digit or `_` first,
|
|
8
8
|
* then those plus `.`, `_` and `-`.
|
package/dist/theme-css.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as Diagnostic } from "./diagnostics-
|
|
1
|
+
import { t as Diagnostic } from "./diagnostics-CqepLcpI.js";
|
|
2
2
|
import { o as TokenOverrides } from "./theme-6ApjjiBo.js";
|
|
3
|
-
import { Result } from "
|
|
3
|
+
import { Result } from "better-result";
|
|
4
4
|
//#region src/theme-css.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* `TokenOverrides` plus `tracking`. The compiler's `TokenOverrides` names its
|
|
@@ -12,7 +12,7 @@ interface ParsedTheme extends TokenOverrides {
|
|
|
12
12
|
/** tracking-{name} → letter-spacing in em (negative allowed). */
|
|
13
13
|
readonly tracking?: Readonly<Record<string, number>> | undefined;
|
|
14
14
|
}
|
|
15
|
-
declare const parseThemeCss: (css: string) => Result
|
|
15
|
+
declare const parseThemeCss: (css: string) => Result<ParsedTheme, ReadonlyArray<Diagnostic>>;
|
|
16
16
|
/**
|
|
17
17
|
* Serialize a ParsedTheme to `@theme` CSS. Light tokens go in the top-level
|
|
18
18
|
* `@theme` block; `colorsDark` (colors-only, matching the parser) goes in the
|
package/dist/theme-css.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Result } from "
|
|
1
|
+
import { Result } from "better-result";
|
|
2
2
|
//#region src/theme-css.ts
|
|
3
3
|
const CHAR_TAB = 9;
|
|
4
4
|
const CHAR_LINE_FEED = 10;
|
|
@@ -441,7 +441,7 @@ const parseThemeCss = (css) => {
|
|
|
441
441
|
start: 0,
|
|
442
442
|
end: Math.min(1, length)
|
|
443
443
|
});
|
|
444
|
-
if (diagnostics.length > 0) return Result.
|
|
444
|
+
if (diagnostics.length > 0) return Result.err(diagnostics);
|
|
445
445
|
const nonEmpty = (entries) => Object.keys(entries).length > 0 ? entries : void 0;
|
|
446
446
|
const colors = nonEmpty(accumulator.colors);
|
|
447
447
|
const colorsDark = nonEmpty(accumulator.colorsDark);
|
|
@@ -452,7 +452,7 @@ const parseThemeCss = (css) => {
|
|
|
452
452
|
const fontFamilies = nonEmpty(accumulator.fontFamilies);
|
|
453
453
|
const containerPx = nonEmpty(accumulator.containerPx);
|
|
454
454
|
const tracking = nonEmpty(accumulator.tracking);
|
|
455
|
-
return Result.
|
|
455
|
+
return Result.ok({
|
|
456
456
|
colors,
|
|
457
457
|
colorsDark,
|
|
458
458
|
spacingPx: accumulator.spacingPx,
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
//#region src/tsx-source-instrumentation.d.ts
|
|
2
|
-
declare const TsxSourceInstrumentationError_base:
|
|
3
|
-
readonly _tag: "TsxSourceInstrumentationError";
|
|
4
|
-
} & Readonly<A>;
|
|
2
|
+
declare const TsxSourceInstrumentationError_base: import("better-result").TaggedErrorClass<"TsxSourceInstrumentationError">;
|
|
5
3
|
declare class TsxSourceInstrumentationError extends TsxSourceInstrumentationError_base<{
|
|
6
4
|
readonly message: string;
|
|
7
5
|
readonly cause?: unknown;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
+
import { n as isObject } from "./guards-eV1qLbf2.js";
|
|
1
2
|
import { JSX_SOURCE_LOCATION_PROP } from "./source-locations.js";
|
|
2
3
|
import { buildLineMap, lineColumn } from "./diagnostics.js";
|
|
3
|
-
import {
|
|
4
|
+
import { TaggedError } from "better-result";
|
|
4
5
|
import { parse } from "@babel/parser";
|
|
5
6
|
//#region src/tsx-source-instrumentation.ts
|
|
6
|
-
var TsxSourceInstrumentationError = class extends
|
|
7
|
-
const
|
|
8
|
-
const isAstNode = (value) => isRecord(value) && typeof value.type === "string" && typeof value.start === "number" && typeof value.end === "number";
|
|
7
|
+
var TsxSourceInstrumentationError = class extends TaggedError("TsxSourceInstrumentationError") {};
|
|
8
|
+
const isAstNode = (value) => isObject(value) && typeof value.type === "string" && typeof value.start === "number" && typeof value.end === "number";
|
|
9
9
|
const walkAst = (value, visit) => {
|
|
10
10
|
if (Array.isArray(value)) {
|
|
11
11
|
for (const item of value) walkAst(item, visit);
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
|
-
if (!
|
|
14
|
+
if (!isObject(value)) return;
|
|
15
15
|
if (isAstNode(value)) visit(value);
|
|
16
16
|
for (const [key, child] of Object.entries(value)) {
|
|
17
17
|
if (key === "loc" || key === "extra" || key === "comments" || key === "tokens") continue;
|
|
@@ -22,7 +22,7 @@ const jsxIdentifier = (value) => {
|
|
|
22
22
|
if (!isAstNode(value) || value.type !== "JSXIdentifier") return void 0;
|
|
23
23
|
return typeof value.name === "string" ? value.name : void 0;
|
|
24
24
|
};
|
|
25
|
-
const parseErrorMessage = (error) =>
|
|
25
|
+
const parseErrorMessage = (error) => isObject(error) && typeof error.message === "string" ? error.message : "The authored TSX could not be parsed for preview instrumentation.";
|
|
26
26
|
const marker = (fileName, source, offset, token) => {
|
|
27
27
|
const position = lineColumn(buildLineMap(source), offset);
|
|
28
28
|
return ` ${JSX_SOURCE_LOCATION_PROP}={${JSON.stringify({
|
package/dist/tsx-tracer.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as Span } from "./diagnostics-CqepLcpI.js";
|
|
2
2
|
import { SmlOp } from "./ops.js";
|
|
3
|
-
import { Result } from "
|
|
3
|
+
import { Result } from "better-result";
|
|
4
4
|
//#region src/tsx-tracer.d.ts
|
|
5
5
|
/** The closed set of reasons a rendered heading cannot be mapped safely. */
|
|
6
6
|
type TsxHeadingDiagnosticCode = "tsx-invalid-authored-source" | "tsx-invalid-emitted-source" | "tsx-target-not-found" | "tsx-unsupported-target" | "tsx-ambiguous-target" | "tsx-dynamic-target";
|
|
@@ -9,9 +9,7 @@ interface TsxHeadingDiagnostic {
|
|
|
9
9
|
readonly message: string;
|
|
10
10
|
readonly span: Span;
|
|
11
11
|
}
|
|
12
|
-
declare const TsxHeadingTraceError_base:
|
|
13
|
-
readonly _tag: "TsxHeadingTraceError";
|
|
14
|
-
} & Readonly<A>;
|
|
12
|
+
declare const TsxHeadingTraceError_base: import("better-result").TaggedErrorClass<"TsxHeadingTraceError">;
|
|
15
13
|
declare class TsxHeadingTraceError extends TsxHeadingTraceError_base<{
|
|
16
14
|
readonly diagnostics: ReadonlyArray<TsxHeadingDiagnostic>;
|
|
17
15
|
}> {}
|
|
@@ -62,8 +60,8 @@ interface TraceTsxHeadingInput {
|
|
|
62
60
|
interface ReplaceTsxHeadingTextInput extends TraceTsxHeadingInput {
|
|
63
61
|
readonly text: string;
|
|
64
62
|
}
|
|
65
|
-
type TsxHeadingTrace = Result
|
|
66
|
-
type TsxHeadingEdit = Result
|
|
63
|
+
type TsxHeadingTrace = Result<TsxHeadingSourceTarget, TsxHeadingTraceError>;
|
|
64
|
+
type TsxHeadingEdit = Result<string, TsxHeadingTraceError>;
|
|
67
65
|
/** Resolve one rendered Heading to one direct-literal JSX text range. */
|
|
68
66
|
declare const traceTsxHeadingTarget: (input: TraceTsxHeadingInput) => TsxHeadingTrace;
|
|
69
67
|
/** Replace only the mapped literal bytes; all other authored TSX stays untouched. */
|
|
@@ -80,9 +78,7 @@ interface TsxSmlDiagnostic {
|
|
|
80
78
|
readonly message: string;
|
|
81
79
|
readonly span: Span;
|
|
82
80
|
}
|
|
83
|
-
declare const TsxSmlOpsError_base:
|
|
84
|
-
readonly _tag: "TsxSmlOpsError";
|
|
85
|
-
} & Readonly<A>;
|
|
81
|
+
declare const TsxSmlOpsError_base: import("better-result").TaggedErrorClass<"TsxSmlOpsError">;
|
|
86
82
|
declare class TsxSmlOpsError extends TsxSmlOpsError_base<{
|
|
87
83
|
readonly diagnostics: ReadonlyArray<TsxSmlDiagnostic>;
|
|
88
84
|
}> {}
|
|
@@ -100,7 +96,7 @@ interface ApplyTsxSmlOpsInput {
|
|
|
100
96
|
/** SML operations evaluated against the emitted-source id snapshot. */
|
|
101
97
|
readonly ops: ReadonlyArray<SmlOp>;
|
|
102
98
|
}
|
|
103
|
-
type TsxSmlOpsResult = Result
|
|
99
|
+
type TsxSmlOpsResult = Result<string, TsxSmlOpsError>;
|
|
104
100
|
/**
|
|
105
101
|
* Apply semantic editor operations to the authored TSX entry.
|
|
106
102
|
*
|