@samva/markup 0.8.0 → 0.10.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 +107 -46
- package/CHANGELOG.md +345 -0
- package/README.md +188 -52
- package/dist/{brand-DcoVkh_S.d.ts → assets-BIsyMQ92.d.ts} +41 -11
- package/dist/{email/brand.js → brand-C0MKTwmX.js} +64 -4
- package/dist/{theme-css.d.ts → brand.d.ts} +12 -3
- package/dist/brand.js +4 -0
- package/dist/channel-specs-C2feJwuP.d.ts +13 -0
- package/dist/compiler.d.ts +88 -115
- package/dist/compiler.js +750 -171
- package/dist/components-BZCqegS8.js +1864 -0
- package/dist/diagnostic-model-DJtqbETd.js +38 -0
- package/dist/{diagnostics-OcQKQYSY.d.ts → diagnostic-model-DxthUZBT.d.ts} +3 -21
- package/dist/{diagnostics-BMYtBCQk.d.ts → diagnostics-B-Gym34R.d.ts} +8 -4
- package/dist/{email/diagnostics.js → diagnostics-CnKFefKz.js} +4 -3
- package/dist/diagnostics.d.ts +410 -2
- package/dist/diagnostics.js +402 -52
- package/dist/edit.d.ts +234 -0
- package/dist/edit.js +947 -0
- package/dist/email/jsx-dev-runtime.d.ts +2 -2
- package/dist/email/jsx-dev-runtime.js +1 -2
- package/dist/email/jsx-runtime.d.ts +1 -1
- package/dist/email/jsx-runtime.js +1 -85
- package/dist/{email/components.d.ts → email.d.ts} +22 -11
- package/dist/email.js +2 -0
- package/dist/fmt.d.ts +32 -0
- package/dist/fmt.js +174 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/{render-vAv_4r9v.js → ir-CLhlklKV.js} +96 -279
- package/dist/jsx-runtime-CBlexoeR.js +98 -0
- package/dist/{elements-BzjjnoCS.d.ts → jsx-runtime-ylIOnaSf.d.ts} +76 -76
- package/dist/profile-pWGtWZXF.js +3803 -0
- package/dist/render-BPonDpCl.d.ts +539 -0
- package/dist/render-BQmfh94k.js +257 -0
- package/dist/render.d.ts +35 -0
- package/dist/render.js +49 -0
- package/dist/sms.d.ts +16 -0
- package/dist/sms.js +12 -0
- package/dist/source-locations-C8wCsiAy.d.ts +23 -0
- package/dist/template-DMPwxMSq.d.ts +65 -0
- package/dist/template-zLUjcwfF.js +42 -0
- package/dist/{theme-css-hFqcPSar.js → theme-css-JtRCm1fb.js} +2 -2
- package/dist/whatsapp.d.ts +57 -0
- package/dist/whatsapp.js +22 -0
- package/generated/contract.json +1788 -0
- package/generated/reference.md +360 -0
- package/package.json +46 -239
- package/samva-brand.d.ts +4 -4
- 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/css-CS2jLID6.d.ts +0 -109
- package/dist/email/assets.d.ts +0 -40
- package/dist/email/assets.js +0 -63
- package/dist/email/brand-footer.d.ts +0 -34
- package/dist/email/brand-footer.js +0 -62
- package/dist/email/brand.d.ts +0 -2
- package/dist/email/components.js +0 -240
- package/dist/email/diagnostics.d.ts +0 -2
- package/dist/email/elements.d.ts +0 -2
- package/dist/email/elements.js +0 -299
- package/dist/email/html.d.ts +0 -2
- package/dist/email/html.js +0 -278
- package/dist/email/render.d.ts +0 -50
- package/dist/email/render.js +0 -3
- package/dist/email/selection.d.ts +0 -2
- package/dist/email/selection.js +0 -91
- package/dist/email/source-edit.d.ts +0 -67
- 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/email/text.d.ts +0 -7
- package/dist/email/text.js +0 -100
- package/dist/emit.d.ts +0 -51
- package/dist/emit.js +0 -151
- package/dist/html-Bl9BAdqc.d.ts +0 -42
- 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/sms-segments.d.ts +0 -2
- package/dist/sms-segments.js +0 -46
- package/dist/source-locations-DrCM82Ym.d.ts +0 -67
- package/dist/source-locations.d.ts +0 -2
- package/dist/source-locations.js +0 -102
- 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/template.d.ts +0 -2
- package/dist/template.js +0 -37
- package/dist/theme-css.js +0 -2
- 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
package/dist/emit.js
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { sameTemplateSourceLocations } from "./source-locations.js";
|
|
2
|
-
import { isRootTag } from "./ast.js";
|
|
3
|
-
import { createVariablesProxy } from "./variables.js";
|
|
4
|
-
import { renderTemplate } from "./render-template.js";
|
|
5
|
-
import { Result } from "better-result";
|
|
6
|
-
//#region src/emit.ts
|
|
7
|
-
/**
|
|
8
|
-
* emitModule — the module-level emit boundary for the TSX authoring layer.
|
|
9
|
-
* The vite plugin does the importing: TSX runs at the
|
|
10
|
-
* USER's build time and this receives the already-evaluated module object (a
|
|
11
|
-
* record of its exports). emitModule stays bundler-agnostic — it never touches
|
|
12
|
-
* the filesystem, esbuild, or vite. It reads only `moduleExports.default`,
|
|
13
|
-
* runs that function through renderTemplate (print → parse validation), and
|
|
14
|
-
* additionally renders it TWICE to guard emission determinism (a build-time
|
|
15
|
-
* clock or RNG produces a different second emission and is reported as
|
|
16
|
-
* unstable).
|
|
17
|
-
*
|
|
18
|
-
* Named exports are ordinary helpers and are never inspected or invoked. A
|
|
19
|
-
* missing or invalid default is a module-level diagnostic (the common "forgot
|
|
20
|
-
* to default-export the function" / "imported the wrong file" mistake).
|
|
21
|
-
*
|
|
22
|
-
* Default-export classification
|
|
23
|
-
*
|
|
24
|
-
* This recorder recognizes function exports returning a channel root element.
|
|
25
|
-
* SMS and WhatsApp use the recorded AST; legacy Email roots remain recognizable
|
|
26
|
-
* so the compiler can report the executable defineEmail requirement. Executable
|
|
27
|
-
* email definitions are discovered by their definition marker before this path.
|
|
28
|
-
* Structured function exports have no marker and are classified by probing.
|
|
29
|
-
*
|
|
30
|
-
* The proxy makes the probe cheap and side-effect-free for well-formed
|
|
31
|
-
* templates: property accesses record variables and return refs; no network,
|
|
32
|
-
* no I/O. A default export that throws when called with a proxy, or that
|
|
33
|
-
* returns a non-root node, is `invalid-default-export` rather than a crash.
|
|
34
|
-
*
|
|
35
|
-
* A genuine template whose body throws (a real authoring bug — coercing a
|
|
36
|
-
* variable, a malformed child) is therefore classified as an invalid default.
|
|
37
|
-
* That is acceptable because the same bug breaks the template's real emit
|
|
38
|
-
* regardless. Confirmed templates are rendered by renderTemplate, so a
|
|
39
|
-
* template function must be a pure builder of its AST — which the
|
|
40
|
-
* recording-proxy model already requires.
|
|
41
|
-
*/
|
|
42
|
-
/** Probe the default export: is it a function that yields a channel root document? */
|
|
43
|
-
const isTemplateFunction = (value) => {
|
|
44
|
-
if (typeof value !== "function") return false;
|
|
45
|
-
const { proxy } = createVariablesProxy();
|
|
46
|
-
let result;
|
|
47
|
-
try {
|
|
48
|
-
result = value(proxy);
|
|
49
|
-
} catch {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
return result !== null && typeof result === "object" && result.kind === "element" && isRootTag(result.tag);
|
|
53
|
-
};
|
|
54
|
-
const MISSING_DEFAULT = {
|
|
55
|
-
code: "missing-default-export",
|
|
56
|
-
message: "no default export — a structured template must default-export a function returning <Sms> or <WhatsApp>. Email templates must default-export defineEmail with an input schema and fixtures. Named exports are ignored.",
|
|
57
|
-
span: {
|
|
58
|
-
start: 0,
|
|
59
|
-
end: 0
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
const INVALID_DEFAULT = {
|
|
63
|
-
code: "invalid-default-export",
|
|
64
|
-
message: "the default export is not a structured Samva template returning <Sms> or <WhatsApp>. Email templates must default-export defineEmail with an input schema and fixtures.",
|
|
65
|
-
span: {
|
|
66
|
-
start: 0,
|
|
67
|
-
end: 0
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
const unstableDiagnostic = (name) => ({
|
|
71
|
-
code: "unstable-emission",
|
|
72
|
-
message: `template "${name}" emits different source on each render — its output depends on non-deterministic build-time data (a clock or random source); templates must be pure functions of their variables`,
|
|
73
|
-
span: {
|
|
74
|
-
start: 0,
|
|
75
|
-
end: 0
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
/**
|
|
79
|
-
* Emits the one supported template from an already-evaluated module object:
|
|
80
|
-
* `moduleExports.default`. Named exports are never probed. `moduleExports` is
|
|
81
|
-
* a plain record of the module's exports (the vite plugin imports the TSX;
|
|
82
|
-
* this stays bundler-agnostic and pure).
|
|
83
|
-
*
|
|
84
|
-
* A missing default yields `missing-default-export`. A present default that
|
|
85
|
-
* is not a template function yields `invalid-default-export`. Both fail the
|
|
86
|
-
* aggregate with an empty `templates` array.
|
|
87
|
-
*/
|
|
88
|
-
const emitModule = (moduleExports) => {
|
|
89
|
-
if (!Object.hasOwn(moduleExports, "default")) return {
|
|
90
|
-
ok: false,
|
|
91
|
-
templates: [],
|
|
92
|
-
diagnostics: [MISSING_DEFAULT]
|
|
93
|
-
};
|
|
94
|
-
const value = moduleExports.default;
|
|
95
|
-
if (!isTemplateFunction(value)) return {
|
|
96
|
-
ok: false,
|
|
97
|
-
templates: [],
|
|
98
|
-
diagnostics: [INVALID_DEFAULT]
|
|
99
|
-
};
|
|
100
|
-
const template = emitOne("default", value);
|
|
101
|
-
return {
|
|
102
|
-
ok: template.ok,
|
|
103
|
-
templates: [template],
|
|
104
|
-
diagnostics: []
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
|
-
/**
|
|
108
|
-
* Renders one confirmed template with the determinism guard. The first render is
|
|
109
|
-
* the authoritative emission; the second exists only to detect instability
|
|
110
|
-
* (a build-time clock or random source). Both renders run at BUILD time only
|
|
111
|
-
* (the plugin) —
|
|
112
|
-
* runtime send-path rendering never double-renders. For a deterministic template
|
|
113
|
-
* the second render is pure redundant work at build time; that is the accepted
|
|
114
|
-
* cost of the guard, paid once per template per build.
|
|
115
|
-
*/
|
|
116
|
-
const emitOne = (name, template) => {
|
|
117
|
-
const first = renderTemplate(template);
|
|
118
|
-
if (Result.isError(first)) return {
|
|
119
|
-
name,
|
|
120
|
-
ok: false,
|
|
121
|
-
source: void 0,
|
|
122
|
-
variables: [],
|
|
123
|
-
sourceLocations: {
|
|
124
|
-
kind: "unavailable",
|
|
125
|
-
reason: "render-failed"
|
|
126
|
-
},
|
|
127
|
-
diagnostics: first.error.diagnostics
|
|
128
|
-
};
|
|
129
|
-
const rendered = first.value;
|
|
130
|
-
const second = renderTemplate(template);
|
|
131
|
-
if (Result.isOk(second) && second.value.source === rendered.source && sameTemplateSourceLocations(second.value.sourceLocations, rendered.sourceLocations)) return {
|
|
132
|
-
name,
|
|
133
|
-
ok: true,
|
|
134
|
-
source: rendered.source,
|
|
135
|
-
variables: rendered.variables,
|
|
136
|
-
sourceLocations: rendered.sourceLocations,
|
|
137
|
-
diagnostics: []
|
|
138
|
-
};
|
|
139
|
-
return {
|
|
140
|
-
name,
|
|
141
|
-
ok: false,
|
|
142
|
-
source: rendered.source,
|
|
143
|
-
variables: rendered.variables,
|
|
144
|
-
sourceLocations: rendered.sourceLocations,
|
|
145
|
-
diagnostics: [unstableDiagnostic(name)]
|
|
146
|
-
};
|
|
147
|
-
};
|
|
148
|
-
//#endregion
|
|
149
|
-
export { emitModule };
|
|
150
|
-
|
|
151
|
-
//# sourceMappingURL=emit.js.map
|
package/dist/html-Bl9BAdqc.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { r as EmailDiagnostic } from "./diagnostics-BMYtBCQk.js";
|
|
2
|
-
import { m as EmailNode } from "./elements-BzjjnoCS.js";
|
|
3
|
-
import { n as EmittedPosition } from "./selection-CCArx9lU.js";
|
|
4
|
-
//#region src/email/html.d.ts
|
|
5
|
-
/** Escape a value for element content. */
|
|
6
|
-
declare const escapeText: (value: string) => string;
|
|
7
|
-
/** Escape a value for a double-quoted attribute. */
|
|
8
|
-
declare const escapeAttribute: (value: string) => string;
|
|
9
|
-
/** camelCase to kebab-case; already-kebab names pass through unchanged. */
|
|
10
|
-
declare const kebab: (property: string) => string;
|
|
11
|
-
/** A bare number is pixels for every property that takes a length. */
|
|
12
|
-
declare const declarationValue: (property: string, value: string | number) => string;
|
|
13
|
-
interface EmailHtmlOutput {
|
|
14
|
-
readonly html: string;
|
|
15
|
-
readonly diagnostics: readonly EmailDiagnostic[];
|
|
16
|
-
/**
|
|
17
|
-
* Each emitted element's offset range and origins. A compatibility finding
|
|
18
|
-
* carries a position in the emitted document, and this is what turns that
|
|
19
|
-
* back into the authoring element the author can edit.
|
|
20
|
-
*/
|
|
21
|
-
readonly positions: readonly EmittedPosition[];
|
|
22
|
-
}
|
|
23
|
-
/** How this document will be consumed. Delivery is the default; export is opt-in. */
|
|
24
|
-
interface SerializeEmailOptions {
|
|
25
|
-
/**
|
|
26
|
-
* Accept relative references. A local export serves assets from a relative
|
|
27
|
-
* base beside the file; a delivered message has no directory to resolve one
|
|
28
|
-
* against, so this stays off for anything that will be sent.
|
|
29
|
-
*/
|
|
30
|
-
readonly relativeUrls?: boolean | undefined;
|
|
31
|
-
/**
|
|
32
|
-
* Stamp every element with its instance path, so an editor preview can
|
|
33
|
-
* resolve a click in the rendered document to exactly one rendered element.
|
|
34
|
-
* A delivered message never carries it.
|
|
35
|
-
*/
|
|
36
|
-
readonly instancePaths?: boolean | undefined;
|
|
37
|
-
}
|
|
38
|
-
/** Lower the derived tree to email HTML, reporting every unsupported construct with its origin. */
|
|
39
|
-
declare const serializeEmailHtml: (node: EmailNode, options?: SerializeEmailOptions) => EmailHtmlOutput;
|
|
40
|
-
//#endregion
|
|
41
|
-
export { escapeText as a, escapeAttribute as i, SerializeEmailOptions as n, kebab as o, declarationValue as r, serializeEmailHtml as s, EmailHtmlOutput as t };
|
|
42
|
-
//# sourceMappingURL=html-Bl9BAdqc.d.ts.map
|
package/dist/interpolate.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
//#region src/interpolate.d.ts
|
|
2
|
-
type DocumentVariableType = "string" | "number" | "boolean" | "date" | "array" | "object";
|
|
3
|
-
/** One entry of a template's declared variable schema. */
|
|
4
|
-
interface DocumentVariable {
|
|
5
|
-
readonly name: string;
|
|
6
|
-
readonly type: DocumentVariableType;
|
|
7
|
-
readonly required: boolean;
|
|
8
|
-
readonly default?: unknown;
|
|
9
|
-
readonly description?: string | undefined;
|
|
10
|
-
}
|
|
11
|
-
declare const variableReferencePattern: RegExp;
|
|
12
|
-
declare const getVariableValue: (variables: Record<string, unknown>, variableSchema: ReadonlyArray<DocumentVariable>, name: string) => unknown;
|
|
13
|
-
declare const stringifyVariable: (value: unknown) => string;
|
|
14
|
-
interface InterpolationResult {
|
|
15
|
-
readonly rendered: string;
|
|
16
|
-
/** Required variables that resolved to nothing (no value, no default). */
|
|
17
|
-
readonly missing: ReadonlySet<string>;
|
|
18
|
-
}
|
|
19
|
-
declare const interpolate: (text: string, variables: Record<string, unknown>, variableSchema: ReadonlyArray<DocumentVariable>) => InterpolationResult;
|
|
20
|
-
declare const variableReferences: (text: string) => Set<string>;
|
|
21
|
-
declare const addVariableReferences: (target: Set<string>, text: string) => void;
|
|
22
|
-
//#endregion
|
|
23
|
-
export { DocumentVariable, DocumentVariableType, InterpolationResult, addVariableReferences, getVariableValue, interpolate, stringifyVariable, variableReferencePattern, variableReferences };
|
|
24
|
-
//# sourceMappingURL=interpolate.d.ts.map
|
package/dist/interpolate.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
//#region src/interpolate.ts
|
|
2
|
-
const variableReferencePattern = /\$\{\s*\/?([\w.]+)\s*\}|\{\{\s*([\w.]+)\s*\}\}/g;
|
|
3
|
-
const getVariableValue = (variables, variableSchema, name) => {
|
|
4
|
-
const schema = variableSchema.find((item) => item.name === name);
|
|
5
|
-
const value = variables[name];
|
|
6
|
-
if (value !== void 0 && value !== null) return value;
|
|
7
|
-
return schema?.default;
|
|
8
|
-
};
|
|
9
|
-
const stringifyVariable = (value) => {
|
|
10
|
-
if (value === void 0 || value === null) return "";
|
|
11
|
-
if (value instanceof Date) return value.toISOString();
|
|
12
|
-
if (Array.isArray(value)) return value.join(", ");
|
|
13
|
-
if (typeof value === "object") return JSON.stringify(value);
|
|
14
|
-
return String(value);
|
|
15
|
-
};
|
|
16
|
-
const interpolate = (text, variables, variableSchema) => {
|
|
17
|
-
const missing = /* @__PURE__ */ new Set();
|
|
18
|
-
const substitute = (name) => {
|
|
19
|
-
const value = getVariableValue(variables, variableSchema, name);
|
|
20
|
-
const schema = variableSchema.find((item) => item.name === name);
|
|
21
|
-
if ((value === void 0 || value === null) && schema?.required) missing.add(name);
|
|
22
|
-
return stringifyVariable(value);
|
|
23
|
-
};
|
|
24
|
-
return {
|
|
25
|
-
rendered: text.replace(variableReferencePattern, (_match, dollarName, braceName) => substitute(dollarName ?? braceName ?? "")),
|
|
26
|
-
missing
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
const variableReferences = (text) => {
|
|
30
|
-
const names = /* @__PURE__ */ new Set();
|
|
31
|
-
for (const match of text.matchAll(variableReferencePattern)) {
|
|
32
|
-
const name = match[1] ?? match[2];
|
|
33
|
-
if (name !== void 0 && name !== "") names.add(name);
|
|
34
|
-
}
|
|
35
|
-
return names;
|
|
36
|
-
};
|
|
37
|
-
const addVariableReferences = (target, text) => {
|
|
38
|
-
variableReferences(text).forEach((name) => target.add(name));
|
|
39
|
-
};
|
|
40
|
-
//#endregion
|
|
41
|
-
export { addVariableReferences, getVariableValue, interpolate, stringifyVariable, variableReferencePattern, variableReferences };
|
|
42
|
-
|
|
43
|
-
//# sourceMappingURL=interpolate.js.map
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
//#region src/jsx-dev-runtime.d.ts
|
|
4
|
-
interface JsxDevProps {
|
|
5
|
-
readonly children?: unknown;
|
|
6
|
-
readonly [key: string]: unknown;
|
|
7
|
-
}
|
|
8
|
-
declare const jsxDEV: <P>(type: Component<P> | typeof Fragment, props: P, _key?: string | number | null, _isStaticChildren?: boolean, source?: JsxSource | null, _self?: unknown) => JsxResult;
|
|
9
|
-
//#endregion
|
|
10
|
-
export { Fragment, type JSX, JsxDevProps, jsxDEV };
|
|
11
|
-
//# sourceMappingURL=jsx-dev-runtime.d.ts.map
|
package/dist/jsx-dev-runtime.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { attachJsxSourceLocation, completeJsxSourceLocation } from "./source-locations.js";
|
|
2
|
-
import { Fragment, jsx } from "./jsx-runtime.js";
|
|
3
|
-
//#region src/jsx-dev-runtime.ts
|
|
4
|
-
const jsxDEV = (type, props, _key, _isStaticChildren, source, _self) => {
|
|
5
|
-
const result = jsx(type, props);
|
|
6
|
-
if (type !== Fragment && result.kind === "element") {
|
|
7
|
-
const location = completeJsxSourceLocation(source);
|
|
8
|
-
if (location !== void 0) attachJsxSourceLocation(result, location);
|
|
9
|
-
}
|
|
10
|
-
return result;
|
|
11
|
-
};
|
|
12
|
-
//#endregion
|
|
13
|
-
export { Fragment, jsxDEV };
|
|
14
|
-
|
|
15
|
-
//# sourceMappingURL=jsx-dev-runtime.js.map
|
|
@@ -1,57 +0,0 @@
|
|
|
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
|
-
//#region src/jsx-runtime.d.ts
|
|
4
|
-
/** A component is a plain function of its props that returns a draft node. */
|
|
5
|
-
type Component<P> = (props: P) => SmlNode;
|
|
6
|
-
/**
|
|
7
|
-
* What may appear in a component's `children`. Booleans/null/undefined are
|
|
8
|
-
* skipped (so `{cond && <X/>}` and `{cond ? <A/> : null}` are BUILD-TIME
|
|
9
|
-
* conditionals that evaluate away); strings/numbers become text; VariableRefs
|
|
10
|
-
* become `{{interpolation}}` nodes; arrays flatten; nested nodes nest. Anything
|
|
11
|
-
* else is a typed authoring error.
|
|
12
|
-
*/
|
|
13
|
-
type SmlChild = SmlNode | FragmentDraft | VariableRef<unknown> | string | number | boolean | null | undefined | ReadonlyArray<SmlChild>;
|
|
14
|
-
type SmlChildren = SmlChild | ReadonlyArray<SmlChild>;
|
|
15
|
-
/** Fragment children pass through un-wrapped — a Fragment is not an element. */
|
|
16
|
-
interface FragmentDraft {
|
|
17
|
-
readonly kind: "fragment";
|
|
18
|
-
readonly children: ReadonlyArray<SmlNode>;
|
|
19
|
-
}
|
|
20
|
-
type JsxResult = SmlNode | FragmentDraft;
|
|
21
|
-
/**
|
|
22
|
-
* Flattens and normalizes a component's raw `children` prop into AST child
|
|
23
|
-
* nodes. Fragments splice their children in; booleans/null/undefined drop out.
|
|
24
|
-
*/
|
|
25
|
-
declare const normalizeChildren: (children: unknown) => Array<SmlNode>;
|
|
26
|
-
/**
|
|
27
|
-
* Builds an element draft from a tag, attribute list (already in authored
|
|
28
|
-
* order), and normalized children. Kept here so the runtime owns the AST shape;
|
|
29
|
-
* ./components maps typed props onto attributes and calls this.
|
|
30
|
-
*/
|
|
31
|
-
declare const elementDraft: (tag: ElementNode["tag"], attributes: ReadonlyArray<Attribute>, children: ReadonlyArray<SmlNode>) => ElementNode;
|
|
32
|
-
interface JsxProps {
|
|
33
|
-
readonly children?: unknown;
|
|
34
|
-
readonly [key: string]: unknown;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* The automatic-runtime entry point. `type` is always one of our typed
|
|
38
|
-
* component functions (or `Fragment`); we invoke it with its props. The JSX
|
|
39
|
-
* transform routes single-child elements here and multi-child elements to
|
|
40
|
-
* `jsxs` — behaviour is identical for us (components normalize their own
|
|
41
|
-
* children), so `jsxs` re-exports this.
|
|
42
|
-
*/
|
|
43
|
-
declare const jsx: (type: Component<JsxProps> | typeof Fragment, props: JsxProps) => JsxResult;
|
|
44
|
-
declare const jsxs: typeof jsx;
|
|
45
|
-
/** Groups children without an element wrapper. Its children splice into the parent. */
|
|
46
|
-
declare const Fragment: unique symbol;
|
|
47
|
-
declare namespace JSX {
|
|
48
|
-
type Element = JsxResult;
|
|
49
|
-
type ElementType = Component<never> | typeof Fragment;
|
|
50
|
-
interface ElementChildrenAttribute {
|
|
51
|
-
readonly children: object;
|
|
52
|
-
}
|
|
53
|
-
type IntrinsicElements = Record<string, never>;
|
|
54
|
-
}
|
|
55
|
-
//#endregion
|
|
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-I-1nCtl2.d.ts.map
|
package/dist/jsx-runtime.d.ts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
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
|
-
export { Component, Fragment, FragmentDraft, JSX, JsxResult, SmlChild, SmlChildren, elementDraft, jsx, jsxs, normalizeChildren };
|
package/dist/jsx-runtime.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { t as hasProperty } from "./guards-eV1qLbf2.js";
|
|
2
|
-
import { JSX_SOURCE_LOCATION_PROP, attachJsxSourceLocation, completeJsxSourceLocation } from "./source-locations.js";
|
|
3
|
-
import { VARIABLE_REF, isVariableRef } from "./variables.js";
|
|
4
|
-
//#region src/jsx-runtime.ts
|
|
5
|
-
const PLACEHOLDER_SPAN = {
|
|
6
|
-
start: 0,
|
|
7
|
-
end: 0
|
|
8
|
-
};
|
|
9
|
-
const isFragmentDraft = (value) => hasProperty(value, "kind") && value.kind === "fragment";
|
|
10
|
-
const isSmlNode = (value) => {
|
|
11
|
-
if (!hasProperty(value, "kind")) return false;
|
|
12
|
-
const kind = value.kind;
|
|
13
|
-
return kind === "element" || kind === "text" || kind === "interpolation";
|
|
14
|
-
};
|
|
15
|
-
const textNode = (value) => ({
|
|
16
|
-
kind: "text",
|
|
17
|
-
id: "",
|
|
18
|
-
value,
|
|
19
|
-
span: PLACEHOLDER_SPAN
|
|
20
|
-
});
|
|
21
|
-
const interpolationNode = (ref) => ({
|
|
22
|
-
kind: "interpolation",
|
|
23
|
-
id: "",
|
|
24
|
-
name: ref[VARIABLE_REF].path,
|
|
25
|
-
syntax: "curly",
|
|
26
|
-
span: PLACEHOLDER_SPAN
|
|
27
|
-
});
|
|
28
|
-
/**
|
|
29
|
-
* Flattens and normalizes a component's raw `children` prop into AST child
|
|
30
|
-
* nodes. Fragments splice their children in; booleans/null/undefined drop out.
|
|
31
|
-
*/
|
|
32
|
-
const normalizeChildren = (children) => {
|
|
33
|
-
const out = [];
|
|
34
|
-
const push = (child) => {
|
|
35
|
-
if (child === null || child === void 0 || typeof child === "boolean") return;
|
|
36
|
-
if (typeof child === "string") {
|
|
37
|
-
out.push(textNode(child));
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
if (typeof child === "number") {
|
|
41
|
-
out.push(textNode(String(child)));
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
if (Array.isArray(child)) {
|
|
45
|
-
for (const item of child) push(item);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
if (isVariableRef(child)) {
|
|
49
|
-
out.push(interpolationNode(child));
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
if (isFragmentDraft(child)) {
|
|
53
|
-
for (const node of child.children) out.push(node);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
if (isSmlNode(child)) {
|
|
57
|
-
out.push(child);
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
throw new TypeError(`invalid SML child: ${describe(child)} — children may be text, numbers, variables, elements, arrays of these, or false/null/undefined (which are skipped)`);
|
|
61
|
-
};
|
|
62
|
-
push(children);
|
|
63
|
-
return out;
|
|
64
|
-
};
|
|
65
|
-
const describe = (value) => {
|
|
66
|
-
if (typeof value === "function") return "a function (did you pass a component instead of an element?)";
|
|
67
|
-
if (typeof value === "object") return `an object (${JSON.stringify(value)})`;
|
|
68
|
-
return `${typeof value} (${JSON.stringify(value)})`;
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* Builds an element draft from a tag, attribute list (already in authored
|
|
72
|
-
* order), and normalized children. Kept here so the runtime owns the AST shape;
|
|
73
|
-
* ./components maps typed props onto attributes and calls this.
|
|
74
|
-
*/
|
|
75
|
-
const elementDraft = (tag, attributes, children) => ({
|
|
76
|
-
kind: "element",
|
|
77
|
-
id: "",
|
|
78
|
-
tag,
|
|
79
|
-
attributes,
|
|
80
|
-
children,
|
|
81
|
-
span: PLACEHOLDER_SPAN
|
|
82
|
-
});
|
|
83
|
-
const stripSourceLocation = (props) => {
|
|
84
|
-
const source = props[JSX_SOURCE_LOCATION_PROP];
|
|
85
|
-
if (source === void 0) return {
|
|
86
|
-
props,
|
|
87
|
-
source: void 0
|
|
88
|
-
};
|
|
89
|
-
const { [JSX_SOURCE_LOCATION_PROP]: _source, ...rest } = props;
|
|
90
|
-
return {
|
|
91
|
-
props: rest,
|
|
92
|
-
source
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
/**
|
|
96
|
-
* The automatic-runtime entry point. `type` is always one of our typed
|
|
97
|
-
* component functions (or `Fragment`); we invoke it with its props. The JSX
|
|
98
|
-
* transform routes single-child elements here and multi-child elements to
|
|
99
|
-
* `jsxs` — behaviour is identical for us (components normalize their own
|
|
100
|
-
* children), so `jsxs` re-exports this.
|
|
101
|
-
*/
|
|
102
|
-
const jsx = (type, props) => {
|
|
103
|
-
if (type === Fragment) return {
|
|
104
|
-
kind: "fragment",
|
|
105
|
-
children: normalizeChildren(props.children)
|
|
106
|
-
};
|
|
107
|
-
const { props: cleanProps, source } = stripSourceLocation(props);
|
|
108
|
-
const result = type(cleanProps);
|
|
109
|
-
if (source !== void 0 && result.kind === "element") {
|
|
110
|
-
const location = completeJsxSourceLocation(source);
|
|
111
|
-
if (location !== void 0) attachJsxSourceLocation(result, location);
|
|
112
|
-
}
|
|
113
|
-
return result;
|
|
114
|
-
};
|
|
115
|
-
const jsxs = jsx;
|
|
116
|
-
/** Groups children without an element wrapper. Its children splice into the parent. */
|
|
117
|
-
const Fragment = Symbol.for("@samva/markup/Fragment");
|
|
118
|
-
//#endregion
|
|
119
|
-
export { Fragment, elementDraft, jsx, jsxs, normalizeChildren };
|
|
120
|
-
|
|
121
|
-
//# sourceMappingURL=jsx-runtime.js.map
|
package/dist/lexer.d.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
//#region src/lexer.d.ts
|
|
2
|
-
declare const TokenKind: {
|
|
3
|
-
readonly EndOfFile: 0;
|
|
4
|
-
/** `<` opening a start tag (text mode). */
|
|
5
|
-
readonly LessThan: 1;
|
|
6
|
-
/** `</` opening a close tag (text mode). */
|
|
7
|
-
readonly LessThanSlash: 2;
|
|
8
|
-
readonly GreaterThan: 3;
|
|
9
|
-
readonly SlashGreaterThan: 4;
|
|
10
|
-
readonly Identifier: 5;
|
|
11
|
-
readonly Equals: 6;
|
|
12
|
-
/** Quoted attribute value; getStringValue decodes entities. */
|
|
13
|
-
readonly String: 7;
|
|
14
|
-
readonly OpenBrace: 8;
|
|
15
|
-
readonly CloseBrace: 9;
|
|
16
|
-
/** Unsigned integer inside a brace attribute value. */
|
|
17
|
-
readonly Number: 10;
|
|
18
|
-
/** Raw text run; getTextValue decodes entities. */
|
|
19
|
-
readonly Text: 11;
|
|
20
|
-
/** `{{name}}` or `${name}`; name/syntax carried on the token. */
|
|
21
|
-
readonly Interpolation: 12;
|
|
22
|
-
/** Lexically invalid input; error carried on the token. */
|
|
23
|
-
readonly Unknown: 13;
|
|
24
|
-
};
|
|
25
|
-
type TokenKind = (typeof TokenKind)[keyof typeof TokenKind];
|
|
26
|
-
interface TokenError {
|
|
27
|
-
readonly code: string;
|
|
28
|
-
readonly message: string;
|
|
29
|
-
}
|
|
30
|
-
interface Token {
|
|
31
|
-
readonly kind: TokenKind;
|
|
32
|
-
readonly start: number;
|
|
33
|
-
readonly end: number;
|
|
34
|
-
/** Interpolation only. */
|
|
35
|
-
readonly name?: string | undefined;
|
|
36
|
-
/** Interpolation only. */
|
|
37
|
-
readonly syntax?: "curly" | "dollar" | undefined;
|
|
38
|
-
/** Unknown only. */
|
|
39
|
-
readonly error?: TokenError | undefined;
|
|
40
|
-
}
|
|
41
|
-
/** Decodes entities in text that already passed `scanEntity` validation. */
|
|
42
|
-
declare const decodeEntities: (raw: string) => string;
|
|
43
|
-
interface Lexer {
|
|
44
|
-
/** Current scan position (start of the next token). */
|
|
45
|
-
readonly position: () => number;
|
|
46
|
-
/** Scan one token in text mode (between tags). */
|
|
47
|
-
readonly scanTextToken: () => Token;
|
|
48
|
-
/** Scan one token in tag mode (inside `<...>`), skipping whitespace. */
|
|
49
|
-
readonly scanTagToken: () => Token;
|
|
50
|
-
/** Lazy raw source slice for a token. */
|
|
51
|
-
readonly getText: (token: Token) => string;
|
|
52
|
-
/** Entity-decoded value of a Text token. */
|
|
53
|
-
readonly getTextValue: (token: Token) => string;
|
|
54
|
-
/** Entity-decoded contents of a String token (without quotes). */
|
|
55
|
-
readonly getStringValue: (token: Token) => string;
|
|
56
|
-
}
|
|
57
|
-
declare const createLexer: (source: string) => Lexer;
|
|
58
|
-
//#endregion
|
|
59
|
-
export { Lexer, Token, TokenError, TokenKind, createLexer, decodeEntities };
|
|
60
|
-
//# sourceMappingURL=lexer.d.ts.map
|