@samva/markup 0.8.0 → 0.9.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 +90 -37
- package/README.md +188 -52
- package/dist/assets-C5duwTya.d.ts +40 -0
- package/dist/{brand-DcoVkh_S.d.ts → brand-B-0bN_Ir.d.ts} +2 -2
- package/dist/{render-vAv_4r9v.js → cascade-t6kxlgEI.js} +93 -280
- package/dist/channel-edit.d.ts +121 -0
- package/dist/channel-edit.js +609 -0
- package/dist/channel-specs-B6M_HlaV.js +29 -0
- package/dist/channel-specs-C2feJwuP.d.ts +13 -0
- package/dist/compatibility-DbISoFIq.js +589 -0
- package/dist/compiler.d.ts +10 -257
- package/dist/compiler.js +10 -730
- package/dist/{css-CS2jLID6.d.ts → css-BVQKICKC.d.ts} +3 -3
- package/dist/diagnostic-codes.d.ts +403 -0
- package/dist/diagnostic-codes.js +399 -0
- package/dist/{diagnostics-BMYtBCQk.d.ts → diagnostics-B-Gym34R.d.ts} +8 -4
- package/dist/diagnostics.d.ts +31 -2
- package/dist/diagnostics.js +1 -19
- package/dist/{elements-BzjjnoCS.d.ts → elements-cqldpaJt.d.ts} +3 -3
- package/dist/email/assets.d.ts +2 -40
- package/dist/email/brand-footer.d.ts +2 -2
- package/dist/email/brand-footer.js +4 -3
- package/dist/email/brand.d.ts +1 -1
- package/dist/email/brand.js +1 -1
- package/dist/email/components.d.ts +21 -10
- package/dist/email/components.js +46 -11
- package/dist/email/diagnostics.d.ts +2 -2
- package/dist/email/diagnostics.js +2 -1
- package/dist/email/elements.d.ts +1 -1
- package/dist/email/html.d.ts +2 -2
- package/dist/email/html.js +45 -2
- package/dist/email/jsx-dev-runtime.d.ts +2 -2
- package/dist/email/jsx-runtime.d.ts +1 -1
- package/dist/email/render.d.ts +8 -18
- package/dist/email/render.js +163 -3
- package/dist/email/text.d.ts +1 -1
- package/dist/fmt.d.ts +32 -0
- package/dist/fmt.js +174 -0
- package/dist/{html-Bl9BAdqc.d.ts → html-BJepOwZ4.d.ts} +19 -5
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/ir-aaqNE987.d.ts +252 -0
- package/dist/ir.d.ts +2 -0
- package/dist/ir.js +7 -0
- package/dist/preview-Ekdg1dXG.d.ts +100 -0
- package/dist/preview.d.ts +2 -0
- package/dist/preview.js +160 -0
- package/dist/profile-BH-OtdDA.js +3670 -0
- package/dist/render-ir.d.ts +19 -0
- package/dist/render-ir.js +826 -0
- package/dist/sms-segments.d.ts +13 -2
- package/dist/sms.d.ts +16 -0
- package/dist/sms.js +12 -0
- package/dist/{email/source-edit.d.ts → source-edit.d.ts} +55 -6
- package/dist/source-edit.js +343 -0
- package/dist/source-locations-C8wCsiAy.d.ts +23 -0
- package/dist/source-locations.d.ts +2 -2
- package/dist/source-locations.js +3 -89
- package/dist/static.d.ts +57 -0
- package/dist/static.js +69 -0
- package/dist/tailwind-CMYpZf1v.js +614 -0
- package/dist/template-_QE_rQND.d.ts +65 -0
- package/dist/template.d.ts +2 -2
- package/dist/template.js +15 -10
- package/dist/theme-css.d.ts +1 -1
- package/dist/theme-imports-lvBw3AD1.js +109 -0
- package/dist/transform-Ct2OMkFN.d.ts +153 -0
- package/dist/whatsapp.d.ts +57 -0
- package/dist/whatsapp.js +22 -0
- package/generated/contract.json +1782 -0
- package/generated/reference.md +353 -0
- package/package.json +41 -151
- package/skills/sml/SKILL.md +123 -0
- package/dist/ast-BrDtApwS.d.ts +0 -107
- package/dist/ast.d.ts +0 -2
- package/dist/ast.js +0 -124
- package/dist/candidate.d.ts +0 -29
- package/dist/candidate.js +0 -88
- package/dist/catalog-CKuOooB8.d.ts +0 -354
- package/dist/checks-D73Xizbw.js +0 -59366
- package/dist/checks.d.ts +0 -33
- package/dist/checks.js +0 -2
- package/dist/classes.d.ts +0 -26
- package/dist/classes.js +0 -184
- package/dist/compile-sms.d.ts +0 -28
- package/dist/compile-sms.js +0 -44
- package/dist/compile-whatsapp.d.ts +0 -56
- package/dist/compile-whatsapp.js +0 -186
- package/dist/compile.d.ts +0 -18
- package/dist/compile.js +0 -29
- package/dist/components.d.ts +0 -289
- package/dist/components.js +0 -106
- package/dist/conditionals.d.ts +0 -10
- package/dist/conditionals.js +0 -74
- package/dist/corpus-CPPfgAHN.d.ts +0 -106
- package/dist/diagnostics-OcQKQYSY.d.ts +0 -49
- package/dist/email/selection.d.ts +0 -2
- package/dist/email/selection.js +0 -91
- package/dist/email/source-edit.js +0 -185
- package/dist/email/stylesheets.d.ts +0 -15
- package/dist/email/stylesheets.js +0 -48
- package/dist/emit.d.ts +0 -51
- package/dist/emit.js +0 -151
- package/dist/interpolate.d.ts +0 -24
- package/dist/interpolate.js +0 -43
- package/dist/jsx-dev-runtime.d.ts +0 -11
- package/dist/jsx-dev-runtime.js +0 -15
- package/dist/jsx-runtime-I-1nCtl2.d.ts +0 -57
- package/dist/jsx-runtime.d.ts +0 -2
- package/dist/jsx-runtime.js +0 -121
- package/dist/lexer.d.ts +0 -60
- package/dist/lexer.js +0 -281
- package/dist/model.d.ts +0 -24
- package/dist/model.js +0 -77
- package/dist/ops-BvwqHl7V.js +0 -630
- package/dist/ops.d.ts +0 -114
- package/dist/ops.js +0 -2
- package/dist/parser-t29cHLVL.d.ts +0 -396
- package/dist/parser.d.ts +0 -2
- package/dist/parser.js +0 -859
- package/dist/predicate-BI6uRRM-.js +0 -549
- package/dist/predicate-M-05Nd7R.d.ts +0 -56
- package/dist/predicate.d.ts +0 -2
- package/dist/predicate.js +0 -2
- package/dist/printer.d.ts +0 -6
- package/dist/printer.js +0 -122
- package/dist/registry-Dcp6QEK_.d.ts +0 -73
- package/dist/registry.d.ts +0 -2
- package/dist/registry.js +0 -646
- package/dist/render-template.d.ts +0 -45
- package/dist/render-template.js +0 -76
- package/dist/selection-CCArx9lU.d.ts +0 -91
- package/dist/showcase-egkusQBf.d.ts +0 -415
- package/dist/sms-segments-y4FpPilJ.d.ts +0 -13
- package/dist/source-locations-DrCM82Ym.d.ts +0 -67
- package/dist/starters/category-mapping.d.ts +0 -13
- package/dist/starters/category-mapping.js +0 -49
- package/dist/starters/corpus.d.ts +0 -2
- package/dist/starters/corpus.js +0 -194
- package/dist/starters/library.d.ts +0 -18
- package/dist/starters/library.js +0 -692
- package/dist/starters/public-gallery.d.ts +0 -266
- package/dist/starters/public-gallery.js +0 -916
- package/dist/starters/public-handoff.d.ts +0 -164
- package/dist/starters/public-handoff.js +0 -361
- package/dist/starters/public-preview-artifacts.d.ts +0 -43
- package/dist/starters/public-preview-artifacts.js +0 -104
- package/dist/starters/public-preview.d.ts +0 -61
- package/dist/starters/public-preview.js +0 -83
- package/dist/starters/showcase.d.ts +0 -2
- package/dist/starters/showcase.js +0 -335
- package/dist/starters/sources.d.ts +0 -45
- package/dist/starters/sources.js +0 -7762
- package/dist/starters/theme.d.ts +0 -45
- package/dist/starters/theme.js +0 -77
- package/dist/starters.d.ts +0 -2
- package/dist/starters.js +0 -874
- package/dist/tailwind-BYq7Lo6u.js +0 -727
- package/dist/template-DWftqh4x.d.ts +0 -60
- package/dist/tsx-source-instrumentation.d.ts +0 -30
- package/dist/tsx-source-instrumentation.js +0 -115
- package/dist/tsx-tracer.d.ts +0 -112
- package/dist/tsx-tracer.js +0 -985
- package/dist/variables-J_L3qxRa.d.ts +0 -77
- package/dist/variables.d.ts +0 -2
- package/dist/variables.js +0 -141
- package/dist/version-BITr58kk.js +0 -96
- package/generated/sml-agent-contract.json +0 -709
- package/generated/sml-email-agent-contract.json +0 -615
- package/generated/sml-email-language-reference.md +0 -94
- package/generated/sml-language-reference.md +0 -195
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { m as EmailNode } from "./elements-BzjjnoCS.js";
|
|
2
|
-
import { r as InputSchema } from "./input-schema-7dPFVvNE.js";
|
|
3
|
-
import { StandardJSONSchemaV1 } from "@standard-schema/spec";
|
|
4
|
-
//#region src/template.d.ts
|
|
5
|
-
/** One actual-input render owns all of a message's authored content. */
|
|
6
|
-
interface EmailContent {
|
|
7
|
-
readonly subject: string;
|
|
8
|
-
readonly preheader?: string;
|
|
9
|
-
readonly body: EmailNode;
|
|
10
|
-
readonly text?: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Fixed ambient values a template declares. Rendering has no clock and no entropy source: reading
|
|
14
|
-
* the current instant or a random value throws unless the matching value is declared here, so a
|
|
15
|
-
* message either takes time and randomness from its input or states them once as configuration.
|
|
16
|
-
*/
|
|
17
|
-
interface TemplateRuntime {
|
|
18
|
-
readonly now?: number;
|
|
19
|
-
readonly randomSeed?: number;
|
|
20
|
-
}
|
|
21
|
-
/** Explicit template identity distinguishes entries from imported helper modules. */
|
|
22
|
-
interface TemplateDefinition<Input> {
|
|
23
|
-
readonly id: string;
|
|
24
|
-
readonly schema: InputSchema<Input>;
|
|
25
|
-
readonly fixtures: Readonly<Record<string, Input>>;
|
|
26
|
-
readonly render: (input: Input) => EmailContent;
|
|
27
|
-
readonly runtime?: TemplateRuntime;
|
|
28
|
-
}
|
|
29
|
-
/** Classify an evaluated module export without executing helpers as templates. */
|
|
30
|
-
declare const isTemplateDefinition: (value: unknown) => value is TemplateDefinition<unknown>;
|
|
31
|
-
/**
|
|
32
|
-
* The one naming contract for a template id and a fixture key: a letter, a digit or `_` first,
|
|
33
|
-
* then those plus `.`, `_` and `-`.
|
|
34
|
-
*
|
|
35
|
-
* Both names are written into file paths — a local export writes one page at
|
|
36
|
-
* `templates/<id>/<fixture>.html` — so each has to be a single plain path segment. The rule lives
|
|
37
|
-
* at the declaration, so a project that could not be exported is refused where the name is
|
|
38
|
-
* written rather than at the end of a build. Consumers that resolve a path from these names
|
|
39
|
-
* import this pattern; they do not restate it.
|
|
40
|
-
*/
|
|
41
|
-
declare const TEMPLATE_NAME_PATTERN: RegExp;
|
|
42
|
-
/**
|
|
43
|
-
* Define an email template with caller-input inference from a Standard JSON Schema converter. The
|
|
44
|
-
* helper is named for its channel because its render result is email content; `TemplateDefinition`
|
|
45
|
-
* and `TemplateInput` stay channel-neutral.
|
|
46
|
-
*/
|
|
47
|
-
declare const defineEmail: <S extends StandardJSONSchemaV1>(definition: {
|
|
48
|
-
readonly id: string;
|
|
49
|
-
readonly schema: S;
|
|
50
|
-
readonly fixtures: Readonly<Record<string, NoInfer<StandardJSONSchemaV1.InferInput<S>>>>;
|
|
51
|
-
readonly render: (input: NoInfer<StandardJSONSchemaV1.InferInput<S>>) => EmailContent;
|
|
52
|
-
readonly runtime?: TemplateRuntime;
|
|
53
|
-
}) => TemplateDefinition<StandardJSONSchemaV1.InferInput<S>>;
|
|
54
|
-
/** Caller input for generated references and separate authoring consumers. */
|
|
55
|
-
type TemplateInput<T extends {
|
|
56
|
-
readonly render: (input: never) => EmailContent;
|
|
57
|
-
}> = Parameters<T["render"]>[0];
|
|
58
|
-
//#endregion
|
|
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-DWftqh4x.d.ts.map
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
//#region src/tsx-source-instrumentation.d.ts
|
|
2
|
-
declare const TsxSourceInstrumentationError_base: import("better-result").TaggedErrorClass<"TsxSourceInstrumentationError">;
|
|
3
|
-
/**
|
|
4
|
-
* The authored TSX could not be instrumented. `location` is the 1-based line
|
|
5
|
-
* and column the refusal points at, when the parser or the offending attribute
|
|
6
|
-
* names one.
|
|
7
|
-
*/
|
|
8
|
-
declare class TsxSourceInstrumentationError extends TsxSourceInstrumentationError_base<{
|
|
9
|
-
readonly message: string;
|
|
10
|
-
readonly location: {
|
|
11
|
-
readonly line: number;
|
|
12
|
-
readonly column: number;
|
|
13
|
-
} | undefined;
|
|
14
|
-
readonly cause?: unknown;
|
|
15
|
-
}> {}
|
|
16
|
-
/**
|
|
17
|
-
* Add ephemeral source-origin props to one known TSX entry before a hosted
|
|
18
|
-
* editor preview is bundled. The returned source is a build input only: the
|
|
19
|
-
* caller must never persist it or expose it as authored source.
|
|
20
|
-
*
|
|
21
|
-
* Every JSX element is marked, including custom components. The markup runtime
|
|
22
|
-
* strips the marker and keeps an inner element's sidecar when a custom
|
|
23
|
-
* component renders JSX of its own. JSX fragments have no element output and
|
|
24
|
-
* are therefore intentionally skipped. Pass a null import source to preserve
|
|
25
|
-
* authored JSX pragmas in executable email builds.
|
|
26
|
-
*/
|
|
27
|
-
declare const instrumentTsxSourceForPreview: (source: string, fileName: string, token?: string, jsxImportSource?: string | null) => string;
|
|
28
|
-
//#endregion
|
|
29
|
-
export { TsxSourceInstrumentationError, instrumentTsxSourceForPreview };
|
|
30
|
-
//# sourceMappingURL=tsx-source-instrumentation.d.ts.map
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { n as isObject } from "./guards-eV1qLbf2.js";
|
|
2
|
-
import { JSX_SOURCE_LOCATION_PROP } from "./source-locations.js";
|
|
3
|
-
import { buildLineMap, lineColumn } from "./diagnostics.js";
|
|
4
|
-
import { TaggedError } from "better-result";
|
|
5
|
-
import { parse } from "@babel/parser";
|
|
6
|
-
//#region src/tsx-source-instrumentation.ts
|
|
7
|
-
/**
|
|
8
|
-
* The authored TSX could not be instrumented. `location` is the 1-based line
|
|
9
|
-
* and column the refusal points at, when the parser or the offending attribute
|
|
10
|
-
* names one.
|
|
11
|
-
*/
|
|
12
|
-
var TsxSourceInstrumentationError = class extends TaggedError("TsxSourceInstrumentationError") {};
|
|
13
|
-
const isAstNode = (value) => isObject(value) && typeof value.type === "string" && typeof value.start === "number" && typeof value.end === "number";
|
|
14
|
-
const walkAst = (value, visit) => {
|
|
15
|
-
if (Array.isArray(value)) {
|
|
16
|
-
for (const item of value) walkAst(item, visit);
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
if (!isObject(value)) return;
|
|
20
|
-
if (isAstNode(value)) visit(value);
|
|
21
|
-
for (const [key, child] of Object.entries(value)) {
|
|
22
|
-
if (key === "loc" || key === "extra" || key === "comments" || key === "tokens") continue;
|
|
23
|
-
walkAst(child, visit);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
const jsxIdentifier = (value) => {
|
|
27
|
-
if (!isAstNode(value) || value.type !== "JSXIdentifier") return void 0;
|
|
28
|
-
return typeof value.name === "string" ? value.name : void 0;
|
|
29
|
-
};
|
|
30
|
-
const parseErrorMessage = (error) => isObject(error) && typeof error.message === "string" ? error.message : "The authored TSX could not be parsed for preview instrumentation.";
|
|
31
|
-
/** Babel reports a 1-based line and a 0-based column. */
|
|
32
|
-
const parseErrorLocation = (error) => {
|
|
33
|
-
if (!isObject(error) || !isObject(error.loc)) return void 0;
|
|
34
|
-
const { line, column } = error.loc;
|
|
35
|
-
return typeof line === "number" && typeof column === "number" ? {
|
|
36
|
-
line,
|
|
37
|
-
column: column + 1
|
|
38
|
-
} : void 0;
|
|
39
|
-
};
|
|
40
|
-
const marker = (fileName, source, offset, token) => {
|
|
41
|
-
const position = lineColumn(buildLineMap(source), offset);
|
|
42
|
-
return ` ${JSX_SOURCE_LOCATION_PROP}={${JSON.stringify({
|
|
43
|
-
fileName,
|
|
44
|
-
lineNumber: position.line,
|
|
45
|
-
columnNumber: position.column,
|
|
46
|
-
...token === void 0 ? {} : { token }
|
|
47
|
-
})}}`;
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* Add ephemeral source-origin props to one known TSX entry before a hosted
|
|
51
|
-
* editor preview is bundled. The returned source is a build input only: the
|
|
52
|
-
* caller must never persist it or expose it as authored source.
|
|
53
|
-
*
|
|
54
|
-
* Every JSX element is marked, including custom components. The markup runtime
|
|
55
|
-
* strips the marker and keeps an inner element's sidecar when a custom
|
|
56
|
-
* component renders JSX of its own. JSX fragments have no element output and
|
|
57
|
-
* are therefore intentionally skipped. Pass a null import source to preserve
|
|
58
|
-
* authored JSX pragmas in executable email builds.
|
|
59
|
-
*/
|
|
60
|
-
const instrumentTsxSourceForPreview = (source, fileName, token, jsxImportSource = "@samva/preview-runtime") => {
|
|
61
|
-
let parsed;
|
|
62
|
-
try {
|
|
63
|
-
parsed = parse(source, {
|
|
64
|
-
plugins: ["typescript", "jsx"],
|
|
65
|
-
sourceType: "module"
|
|
66
|
-
});
|
|
67
|
-
} catch (error) {
|
|
68
|
-
throw new TsxSourceInstrumentationError({
|
|
69
|
-
cause: error,
|
|
70
|
-
message: parseErrorMessage(error),
|
|
71
|
-
location: parseErrorLocation(error)
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
const edits = [];
|
|
75
|
-
for (const comment of jsxImportSource === null ? [] : parsed.comments ?? []) {
|
|
76
|
-
const commentStart = comment.start;
|
|
77
|
-
const commentEnd = comment.end;
|
|
78
|
-
if (commentStart === void 0 || commentEnd === void 0) continue;
|
|
79
|
-
const commentSource = source.slice(commentStart, commentEnd);
|
|
80
|
-
for (const match of commentSource.matchAll(/@jsxImportSource\s+[^\s*]+/gu)) {
|
|
81
|
-
if (match.index === void 0) continue;
|
|
82
|
-
edits.push({
|
|
83
|
-
start: commentStart + match.index,
|
|
84
|
-
end: commentStart + match.index + match[0].length,
|
|
85
|
-
value: `@jsxImportSource ${jsxImportSource}`
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
walkAst(parsed.program, (node) => {
|
|
90
|
-
if (node.type !== "JSXElement") return;
|
|
91
|
-
const openingElement = node.openingElement;
|
|
92
|
-
if (!isAstNode(openingElement)) return;
|
|
93
|
-
const attributes = openingElement.attributes;
|
|
94
|
-
if (Array.isArray(attributes)) for (const attribute of attributes) {
|
|
95
|
-
if (!isAstNode(attribute) || attribute.type !== "JSXAttribute") continue;
|
|
96
|
-
if (jsxIdentifier(attribute.name) === "__samva_source_location") throw new TsxSourceInstrumentationError({
|
|
97
|
-
message: `The reserved JSX prop ${JSX_SOURCE_LOCATION_PROP} cannot be authored directly.`,
|
|
98
|
-
location: lineColumn(buildLineMap(source), attribute.start)
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
const closingLength = source.slice(openingElement.end - 2, openingElement.end) === "/>" ? 2 : 1;
|
|
102
|
-
edits.push({
|
|
103
|
-
start: openingElement.end - closingLength,
|
|
104
|
-
end: openingElement.end - closingLength,
|
|
105
|
-
value: marker(fileName, source, openingElement.start, token)
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
let instrumented = source;
|
|
109
|
-
for (const edit of edits.toSorted((left, right) => right.start - left.start)) instrumented = instrumented.slice(0, edit.start) + edit.value + instrumented.slice(edit.end);
|
|
110
|
-
return instrumented;
|
|
111
|
-
};
|
|
112
|
-
//#endregion
|
|
113
|
-
export { TsxSourceInstrumentationError, instrumentTsxSourceForPreview };
|
|
114
|
-
|
|
115
|
-
//# sourceMappingURL=tsx-source-instrumentation.js.map
|
package/dist/tsx-tracer.d.ts
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { a as Span } from "./diagnostics-OcQKQYSY.js";
|
|
2
|
-
import { SmlOp } from "./ops.js";
|
|
3
|
-
import { Result } from "better-result";
|
|
4
|
-
//#region src/tsx-tracer.d.ts
|
|
5
|
-
/** The closed set of reasons a rendered heading cannot be mapped safely. */
|
|
6
|
-
type TsxHeadingDiagnosticCode = "tsx-invalid-authored-source" | "tsx-invalid-emitted-source" | "tsx-target-not-found" | "tsx-unsupported-target" | "tsx-ambiguous-target" | "tsx-dynamic-target";
|
|
7
|
-
interface TsxHeadingDiagnostic {
|
|
8
|
-
readonly code: TsxHeadingDiagnosticCode;
|
|
9
|
-
readonly message: string;
|
|
10
|
-
readonly span: Span;
|
|
11
|
-
}
|
|
12
|
-
declare const TsxHeadingTraceError_base: import("better-result").TaggedErrorClass<"TsxHeadingTraceError">;
|
|
13
|
-
declare class TsxHeadingTraceError extends TsxHeadingTraceError_base<{
|
|
14
|
-
readonly diagnostics: ReadonlyArray<TsxHeadingDiagnostic>;
|
|
15
|
-
}> {}
|
|
16
|
-
/**
|
|
17
|
-
* Source metadata attached to a rendered JSX node by the development JSX
|
|
18
|
-
* transform, or an equivalent exact source span from a host.
|
|
19
|
-
*
|
|
20
|
-
* `lineNumber`/`columnNumber` use the JSX transform convention: both are
|
|
21
|
-
* one-based and identify the opening `<` of the element. A span locator is
|
|
22
|
-
* useful to hosts that already have absolute offsets and must match the whole
|
|
23
|
-
* JSX element span exactly.
|
|
24
|
-
*/
|
|
25
|
-
type TsxSourceLocator = {
|
|
26
|
-
readonly fileName: string;
|
|
27
|
-
readonly lineNumber: number;
|
|
28
|
-
readonly columnNumber: number;
|
|
29
|
-
} | {
|
|
30
|
-
readonly fileName: string;
|
|
31
|
-
readonly span: Span;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* How an authored static text child spells itself. `jsx-text` is bare text
|
|
35
|
-
* between tags; `string-literal` is a `{"…"}` expression container holding a
|
|
36
|
-
* string literal, or a template literal with no expressions. An edit writes a
|
|
37
|
-
* child back in the form it already had.
|
|
38
|
-
*/
|
|
39
|
-
type StaticTextForm = "jsx-text" | "string-literal";
|
|
40
|
-
/** A source range containing only the text bytes that an edit is allowed to replace. */
|
|
41
|
-
interface TsxHeadingSourceTarget {
|
|
42
|
-
readonly nodeId: string;
|
|
43
|
-
readonly text: string;
|
|
44
|
-
readonly span: Span;
|
|
45
|
-
/** The spelling to preserve when the range is rewritten. */
|
|
46
|
-
readonly form: StaticTextForm;
|
|
47
|
-
}
|
|
48
|
-
interface TraceTsxHeadingInput {
|
|
49
|
-
/** The canonical TSX entry file path. */
|
|
50
|
-
readonly authoredFile: string;
|
|
51
|
-
/** The canonical TSX entry file. */
|
|
52
|
-
readonly authoredSource: string;
|
|
53
|
-
/** The last-good SML preview derived from that entry file. */
|
|
54
|
-
readonly emittedSource: string;
|
|
55
|
-
/** The selected semantic SML node id. */
|
|
56
|
-
readonly nodeId: string;
|
|
57
|
-
/** Exact runtime/source-map provenance for the selected JSX node. */
|
|
58
|
-
readonly sourceLocator?: TsxSourceLocator | undefined;
|
|
59
|
-
}
|
|
60
|
-
interface ReplaceTsxHeadingTextInput extends TraceTsxHeadingInput {
|
|
61
|
-
readonly text: string;
|
|
62
|
-
}
|
|
63
|
-
type TsxHeadingTrace = Result<TsxHeadingSourceTarget, TsxHeadingTraceError>;
|
|
64
|
-
type TsxHeadingEdit = Result<string, TsxHeadingTraceError>;
|
|
65
|
-
/** Resolve one rendered Heading to one direct-literal JSX text range. */
|
|
66
|
-
declare const traceTsxHeadingTarget: (input: TraceTsxHeadingInput) => TsxHeadingTrace;
|
|
67
|
-
/** Replace only the mapped literal bytes; all other authored TSX stays untouched. */
|
|
68
|
-
declare const replaceTsxHeadingText: (input: ReplaceTsxHeadingTextInput) => TsxHeadingEdit;
|
|
69
|
-
/**
|
|
70
|
-
* The closed set of failures returned by {@link applyTsxSmlOps}. The editor
|
|
71
|
-
* deliberately treats these as a typed "not safe to edit" response: it can
|
|
72
|
-
* keep showing the preview and offer source editing without guessing at a
|
|
73
|
-
* byte range in a user's project.
|
|
74
|
-
*/
|
|
75
|
-
type TsxSmlDiagnosticCode = TsxHeadingDiagnosticCode | "tsx-invalid-snippet" | "tsx-unsupported-operation";
|
|
76
|
-
interface TsxSmlDiagnostic {
|
|
77
|
-
readonly code: TsxSmlDiagnosticCode;
|
|
78
|
-
readonly message: string;
|
|
79
|
-
readonly span: Span;
|
|
80
|
-
}
|
|
81
|
-
declare const TsxSmlOpsError_base: import("better-result").TaggedErrorClass<"TsxSmlOpsError">;
|
|
82
|
-
declare class TsxSmlOpsError extends TsxSmlOpsError_base<{
|
|
83
|
-
readonly diagnostics: ReadonlyArray<TsxSmlDiagnostic>;
|
|
84
|
-
}> {}
|
|
85
|
-
interface ApplyTsxSmlOpsInput {
|
|
86
|
-
/** The canonical TSX entry file path. */
|
|
87
|
-
readonly authoredFile: string;
|
|
88
|
-
/** The canonical TSX entry file. */
|
|
89
|
-
readonly authoredSource: string;
|
|
90
|
-
/** The last-good SML preview derived from that entry file. */
|
|
91
|
-
readonly emittedSource: string;
|
|
92
|
-
/** Revision-fenced JSX origins for the SML ids in `emittedSource`. */
|
|
93
|
-
readonly sourceLocations: {
|
|
94
|
-
readonly byNodeId: Readonly<Record<string, TsxSourceLocator>>;
|
|
95
|
-
};
|
|
96
|
-
/** SML operations evaluated against the emitted-source id snapshot. */
|
|
97
|
-
readonly ops: ReadonlyArray<SmlOp>;
|
|
98
|
-
}
|
|
99
|
-
type TsxSmlOpsResult = Result<string, TsxSmlOpsError>;
|
|
100
|
-
/**
|
|
101
|
-
* Apply semantic editor operations to the authored TSX entry.
|
|
102
|
-
*
|
|
103
|
-
* The emitted SML document remains the validation oracle: operations are
|
|
104
|
-
* preflighted through the same markup op implementation first, then each
|
|
105
|
-
* mapped target is checked against the authored JSX AST and exact source
|
|
106
|
-
* provenance. The mutable source tree below only moves original AST nodes or
|
|
107
|
-
* inserts validated raw fragments; it never reprints the user's module.
|
|
108
|
-
*/
|
|
109
|
-
declare const applyTsxSmlOps: (input: ApplyTsxSmlOpsInput) => TsxSmlOpsResult;
|
|
110
|
-
//#endregion
|
|
111
|
-
export { ApplyTsxSmlOpsInput, ReplaceTsxHeadingTextInput, StaticTextForm, TraceTsxHeadingInput, TsxHeadingDiagnostic, TsxHeadingDiagnosticCode, TsxHeadingEdit, TsxHeadingSourceTarget, TsxHeadingTrace, TsxHeadingTraceError, TsxSmlDiagnostic, TsxSmlDiagnosticCode, TsxSmlOpsError, TsxSmlOpsResult, TsxSourceLocator, applyTsxSmlOps, replaceTsxHeadingText, traceTsxHeadingTarget };
|
|
112
|
-
//# sourceMappingURL=tsx-tracer.d.ts.map
|