@samva/markup 0.7.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 +104 -37
- package/README.md +188 -52
- package/dist/assets-C5duwTya.d.ts +40 -0
- package/dist/brand-B-0bN_Ir.d.ts +88 -0
- package/dist/{render-aaJBnsXK.js → cascade-t6kxlgEI.js} +130 -160
- 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 +19 -249
- package/dist/compiler.js +10 -1408
- package/dist/{css-COcFOT1y.d.ts → css-BVQKICKC.d.ts} +30 -4
- 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 -0
- package/dist/email/assets.js +63 -0
- package/dist/email/brand-footer.d.ts +34 -0
- package/dist/email/brand-footer.js +63 -0
- package/dist/email/brand.d.ts +2 -0
- package/dist/email/brand.js +148 -0
- 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 -42
- package/dist/email/html.js +56 -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 +10 -13
- package/dist/email/render.js +163 -6
- package/dist/email/text.d.ts +1 -1
- package/dist/fmt.d.ts +32 -0
- package/dist/fmt.js +174 -0
- package/dist/html-BJepOwZ4.d.ts +56 -0
- 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-hFqcPSar.js +587 -0
- package/dist/theme-css.d.ts +57 -16
- package/dist/theme-css.js +2 -509
- package/dist/theme-imports-lvBw3AD1.js +109 -0
- package/dist/transform-Ct2OMkFN.d.ts +153 -0
- package/dist/unsubscribe-link-CoesnQDU.js +26 -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 +56 -154
- package/samva-brand.d.ts +14 -0
- 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-60eaYC7b.d.ts +0 -356
- package/dist/checks-DBweSIPN.js +0 -58954
- package/dist/checks.d.ts +0 -33
- package/dist/checks.js +0 -2
- package/dist/classes.d.ts +0 -27
- 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-BjYMqOoY.d.ts +0 -106
- package/dist/diagnostics-OcQKQYSY.d.ts +0 -49
- package/dist/email/selection.d.ts +0 -91
- 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 -45
- package/dist/emit.d.ts +0 -51
- package/dist/emit.js +0 -151
- package/dist/footer.d.ts +0 -66
- package/dist/footer.js +0 -93
- 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-2aiiYO7m.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/presets/category-mapping.d.ts +0 -13
- package/dist/presets/category-mapping.js +0 -49
- package/dist/presets/corpus.d.ts +0 -2
- package/dist/presets/corpus.js +0 -194
- package/dist/presets/public-gallery.d.ts +0 -266
- package/dist/presets/public-gallery.js +0 -916
- package/dist/presets/public-handoff.d.ts +0 -164
- package/dist/presets/public-handoff.js +0 -361
- package/dist/presets/public-preview-artifacts.d.ts +0 -43
- package/dist/presets/public-preview-artifacts.js +0 -104
- package/dist/presets/public-preview.d.ts +0 -61
- package/dist/presets/public-preview.js +0 -83
- package/dist/presets/showcase.d.ts +0 -2
- package/dist/presets/showcase.js +0 -627
- package/dist/presets/sources.d.ts +0 -38
- package/dist/presets/sources.js +0 -6083
- package/dist/presets.d.ts +0 -2
- package/dist/presets.js +0 -881
- package/dist/printer.d.ts +0 -6
- package/dist/printer.js +0 -122
- package/dist/registry.d.ts +0 -42
- package/dist/registry.js +0 -646
- package/dist/render-template.d.ts +0 -45
- package/dist/render-template.js +0 -76
- package/dist/showcase-DGZAWn4Z.d.ts +0 -456
- package/dist/sms-segments-y4FpPilJ.d.ts +0 -13
- package/dist/source-locations-DrCM82Ym.d.ts +0 -67
- package/dist/template-DWftqh4x.d.ts +0 -60
- package/dist/theme-6ApjjiBo.d.ts +0 -116
- package/dist/theme.d.ts +0 -2
- package/dist/theme.js +0 -118
- package/dist/tokens.d.ts +0 -6
- package/dist/tokens.js +0 -417
- 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
|
package/dist/theme-6ApjjiBo.d.ts
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
//#region src/theme.d.ts
|
|
2
|
-
interface TextToken {
|
|
3
|
-
readonly sizePx: number;
|
|
4
|
-
readonly lineHeightPx: number;
|
|
5
|
-
}
|
|
6
|
-
/** One hosted @font-face: the served woff2 src + its weight/style, and the
|
|
7
|
-
* css2 unicode-range (absent for a whole-file upload). */
|
|
8
|
-
interface FontFace {
|
|
9
|
-
readonly weight: number;
|
|
10
|
-
readonly style: "normal" | "italic";
|
|
11
|
-
readonly src: string;
|
|
12
|
-
readonly unicodeRange?: string | undefined;
|
|
13
|
-
}
|
|
14
|
-
/** The @font-face set for one font token: the family the rules declare (and that
|
|
15
|
-
* the token's inline stack leads with) plus its hosted faces. */
|
|
16
|
-
interface FontFaceSet {
|
|
17
|
-
readonly family: string;
|
|
18
|
-
readonly faces: ReadonlyArray<FontFace>;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Escape a value interpolated inside a single-quoted CSS string — a
|
|
22
|
-
* `font-family` name or a `url('…')` src. A raw `'` closes the quote early (for
|
|
23
|
-
* a src that also lets a crafted value escape the `url()`), and a raw `\` is read
|
|
24
|
-
* as a CSS escape sequence. `family` and `src` are only min-length-validated
|
|
25
|
-
* upstream, so escaping both keeps every emitted CSS string grammar-safe. Used
|
|
26
|
-
* both here (the inline `font-{name}` stack) and by the compiler's @font-face
|
|
27
|
-
* block, so an escapable family never lands unescaped in either place.
|
|
28
|
-
*
|
|
29
|
-
* The `@font-face` block lives inside a `<style>` element, and an HTML parser
|
|
30
|
-
* scans raw-text elements for the literal `</style>` end tag BEFORE any CSS
|
|
31
|
-
* parsing. So a crafted `family`/`src` containing `</style>` would close the
|
|
32
|
-
* style element and let the remainder render as HTML in the delivered email
|
|
33
|
-
* (a stored-XSS breakout). Rewriting `</` to `<\/` neutralises this: in a
|
|
34
|
-
* quoted CSS string `\/` is identical to `/`, but the HTML tokenizer no longer
|
|
35
|
-
* matches `<\/style>` as a raw-text end tag.
|
|
36
|
-
*/
|
|
37
|
-
declare const escapeCssString: (value: string) => string;
|
|
38
|
-
/** A persisted font token: the family the inline stack leads with, the fallback
|
|
39
|
-
* appended after it, and (for a self-hosted webfont) the hosted faces. The
|
|
40
|
-
* public compiler owns the single flatten transform for this shape. */
|
|
41
|
-
interface FontToken {
|
|
42
|
-
readonly family: string;
|
|
43
|
-
readonly fallback: string;
|
|
44
|
-
readonly faces?: ReadonlyArray<FontFace> | undefined;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Flatten persisted font tokens into the compiler's two font fields, so the
|
|
48
|
-
* server (apps/api) and the in-browser canvas (apps/web) produce byte-identical
|
|
49
|
-
* output from ONE transform rather than two hand-synced copies:
|
|
50
|
-
* - `fontFamilies` = the inline stack the `font-{name}` utility emits — the
|
|
51
|
-
* family quoted (multi-word-safe) then the fallback (which the picker
|
|
52
|
-
* guarantees ends in a generic, so no client is ever fontless).
|
|
53
|
-
* - `fontFaces` = the @font-face set for tokens that self-host a webfont.
|
|
54
|
-
* Tokens without `faces` (system stacks) contribute a family but no face set.
|
|
55
|
-
*/
|
|
56
|
-
declare const flattenFontTokens: (tokens: Readonly<Record<string, FontToken>>) => {
|
|
57
|
-
fontFamilies: Record<string, string>;
|
|
58
|
-
fontFaces: Record<string, FontFaceSet>;
|
|
59
|
-
};
|
|
60
|
-
interface TokenTable {
|
|
61
|
-
/** Flattened color names ("red-500", "white", "brand") → 6-digit lowercase hex. */
|
|
62
|
-
readonly colors: Readonly<Record<string, string>>;
|
|
63
|
-
/**
|
|
64
|
-
* Dark counterparts, colors namespace only (dark radius/fonts are not a
|
|
65
|
-
* thing). Only tokens with a dark pair appear; a color-family utility that
|
|
66
|
-
* resolves a paired token also emits the dark head rule automatically.
|
|
67
|
-
*/
|
|
68
|
-
readonly colorsDark: Readonly<Record<string, string>>;
|
|
69
|
-
/** px per spacing unit (`p-4` → 4 × spacingPx). */
|
|
70
|
-
readonly spacingPx: number;
|
|
71
|
-
/** text-{size} → font-size / line-height px pair. */
|
|
72
|
-
readonly text: Readonly<Record<string, TextToken>>;
|
|
73
|
-
/** leading-{name} → unitless line-height ratio. */
|
|
74
|
-
readonly leading: Readonly<Record<string, number>>;
|
|
75
|
-
/** tracking-{name} → letter-spacing em. */
|
|
76
|
-
readonly trackingEm: Readonly<Record<string, number>>;
|
|
77
|
-
/** rounded-{name} → border-radius px. */
|
|
78
|
-
readonly radiusPx: Readonly<Record<string, number>>;
|
|
79
|
-
/** font-{name} → font-weight number. */
|
|
80
|
-
readonly fontWeights: Readonly<Record<string, number>>;
|
|
81
|
-
/** font-{name} → the resolved inline font-family stack (family + fallback,
|
|
82
|
-
* guaranteed to end in a generic). */
|
|
83
|
-
readonly fontFamilies: Readonly<Record<string, string>>;
|
|
84
|
-
/** font-{name} → its @font-face set, for tokens that self-host a webfont.
|
|
85
|
-
* Tokens with no faces (system stacks) are absent. */
|
|
86
|
-
readonly fontFaces: Readonly<Record<string, FontFaceSet>>;
|
|
87
|
-
/** max-w-{name} → px. */
|
|
88
|
-
readonly containerPx: Readonly<Record<string, number>>;
|
|
89
|
-
}
|
|
90
|
-
interface TokenOverrides {
|
|
91
|
-
readonly colors?: Readonly<Record<string, string>> | undefined;
|
|
92
|
-
readonly colorsDark?: Readonly<Record<string, string>> | undefined;
|
|
93
|
-
readonly spacingPx?: number | undefined;
|
|
94
|
-
readonly text?: Readonly<Record<string, TextToken>> | undefined;
|
|
95
|
-
readonly leading?: Readonly<Record<string, number>> | undefined;
|
|
96
|
-
readonly trackingEm?: Readonly<Record<string, number>> | undefined;
|
|
97
|
-
readonly radiusPx?: Readonly<Record<string, number>> | undefined;
|
|
98
|
-
readonly fontWeights?: Readonly<Record<string, number>> | undefined;
|
|
99
|
-
readonly fontFamilies?: Readonly<Record<string, string>> | undefined;
|
|
100
|
-
readonly fontFaces?: Readonly<Record<string, FontFaceSet>> | undefined;
|
|
101
|
-
readonly containerPx?: Readonly<Record<string, number>> | undefined;
|
|
102
|
-
}
|
|
103
|
-
interface ThemeLayers {
|
|
104
|
-
readonly base: TokenTable;
|
|
105
|
-
/**
|
|
106
|
-
* Ordered token-override layers, least → most specific (organization →
|
|
107
|
-
* domain → template). Each is merged onto the running table in turn, so a
|
|
108
|
-
* later layer's token wins. The caller (the settings cascade in apps/api)
|
|
109
|
-
* owns assembling this list from the effective design.
|
|
110
|
-
*/
|
|
111
|
-
readonly overrides?: ReadonlyArray<TokenOverrides> | undefined;
|
|
112
|
-
}
|
|
113
|
-
declare const resolveTokenTable: (layers: ThemeLayers) => TokenTable;
|
|
114
|
-
//#endregion
|
|
115
|
-
export { ThemeLayers as a, escapeCssString as c, TextToken as i, flattenFontTokens as l, FontFaceSet as n, TokenOverrides as o, FontToken as r, TokenTable as s, FontFace as t, resolveTokenTable as u };
|
|
116
|
-
//# sourceMappingURL=theme-6ApjjiBo.d.ts.map
|
package/dist/theme.d.ts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { a as ThemeLayers, c as escapeCssString, i as TextToken, l as flattenFontTokens, n as FontFaceSet, o as TokenOverrides, r as FontToken, s as TokenTable, t as FontFace, u as resolveTokenTable } from "./theme-6ApjjiBo.js";
|
|
2
|
-
export { FontFace, FontFaceSet, FontToken, TextToken, ThemeLayers, TokenOverrides, TokenTable, escapeCssString, flattenFontTokens, resolveTokenTable };
|
package/dist/theme.js
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
//#region src/theme.ts
|
|
2
|
-
/**
|
|
3
|
-
* Escape a value interpolated inside a single-quoted CSS string — a
|
|
4
|
-
* `font-family` name or a `url('…')` src. A raw `'` closes the quote early (for
|
|
5
|
-
* a src that also lets a crafted value escape the `url()`), and a raw `\` is read
|
|
6
|
-
* as a CSS escape sequence. `family` and `src` are only min-length-validated
|
|
7
|
-
* upstream, so escaping both keeps every emitted CSS string grammar-safe. Used
|
|
8
|
-
* both here (the inline `font-{name}` stack) and by the compiler's @font-face
|
|
9
|
-
* block, so an escapable family never lands unescaped in either place.
|
|
10
|
-
*
|
|
11
|
-
* The `@font-face` block lives inside a `<style>` element, and an HTML parser
|
|
12
|
-
* scans raw-text elements for the literal `</style>` end tag BEFORE any CSS
|
|
13
|
-
* parsing. So a crafted `family`/`src` containing `</style>` would close the
|
|
14
|
-
* style element and let the remainder render as HTML in the delivered email
|
|
15
|
-
* (a stored-XSS breakout). Rewriting `</` to `<\/` neutralises this: in a
|
|
16
|
-
* quoted CSS string `\/` is identical to `/`, but the HTML tokenizer no longer
|
|
17
|
-
* matches `<\/style>` as a raw-text end tag.
|
|
18
|
-
*/
|
|
19
|
-
const escapeCssString = (value) => value.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/[\u0000-\u001f\u007f]/g, (character) => `\\${character.charCodeAt(0).toString(16)} `).replace(/<\//g, "<\\/");
|
|
20
|
-
const FONT_FAMILY_NAME = /^-?[a-zA-Z][a-zA-Z0-9 -]*$/;
|
|
21
|
-
const SINGLE_QUOTED_FONT_FAMILY = /^'[^'\\<\u0000-\u001f\u007f]*'$/;
|
|
22
|
-
const DOUBLE_QUOTED_FONT_FAMILY = /^"[^"\\<\u0000-\u001f\u007f]*"$/;
|
|
23
|
-
const splitFontStack = (value) => {
|
|
24
|
-
const families = [];
|
|
25
|
-
let start = 0;
|
|
26
|
-
let quote;
|
|
27
|
-
for (let index = 0; index < value.length; index++) {
|
|
28
|
-
const character = value[index];
|
|
29
|
-
if (quote !== void 0) {
|
|
30
|
-
if (character === quote) quote = void 0;
|
|
31
|
-
} else if (character === "'" || character === "\"") quote = character;
|
|
32
|
-
else if (character === ",") {
|
|
33
|
-
families.push(value.slice(start, index).trim());
|
|
34
|
-
start = index + 1;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
families.push(value.slice(start).trim());
|
|
38
|
-
return families;
|
|
39
|
-
};
|
|
40
|
-
const safeFontStack = (value) => {
|
|
41
|
-
return splitFontStack(value).every((family) => FONT_FAMILY_NAME.test(family) || SINGLE_QUOTED_FONT_FAMILY.test(family) || DOUBLE_QUOTED_FONT_FAMILY.test(family)) ? value : `'${escapeCssString(value)}'`;
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Flatten persisted font tokens into the compiler's two font fields, so the
|
|
45
|
-
* server (apps/api) and the in-browser canvas (apps/web) produce byte-identical
|
|
46
|
-
* output from ONE transform rather than two hand-synced copies:
|
|
47
|
-
* - `fontFamilies` = the inline stack the `font-{name}` utility emits — the
|
|
48
|
-
* family quoted (multi-word-safe) then the fallback (which the picker
|
|
49
|
-
* guarantees ends in a generic, so no client is ever fontless).
|
|
50
|
-
* - `fontFaces` = the @font-face set for tokens that self-host a webfont.
|
|
51
|
-
* Tokens without `faces` (system stacks) contribute a family but no face set.
|
|
52
|
-
*/
|
|
53
|
-
const flattenFontTokens = (tokens) => {
|
|
54
|
-
const fontFamilies = {};
|
|
55
|
-
const fontFaces = {};
|
|
56
|
-
for (const [name, token] of Object.entries(tokens)) {
|
|
57
|
-
fontFamilies[name] = `'${escapeCssString(token.family)}', ${safeFontStack(token.fallback)}`;
|
|
58
|
-
if (token.faces != null) fontFaces[name] = {
|
|
59
|
-
family: token.family,
|
|
60
|
-
faces: token.faces
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
return {
|
|
64
|
-
fontFamilies,
|
|
65
|
-
fontFaces
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
const mergeLayer = (table, overrides) => {
|
|
69
|
-
if (overrides === void 0) return table;
|
|
70
|
-
return {
|
|
71
|
-
colors: {
|
|
72
|
-
...table.colors,
|
|
73
|
-
...overrides.colors
|
|
74
|
-
},
|
|
75
|
-
colorsDark: {
|
|
76
|
-
...table.colorsDark,
|
|
77
|
-
...overrides.colorsDark
|
|
78
|
-
},
|
|
79
|
-
spacingPx: overrides.spacingPx ?? table.spacingPx,
|
|
80
|
-
text: {
|
|
81
|
-
...table.text,
|
|
82
|
-
...overrides.text
|
|
83
|
-
},
|
|
84
|
-
leading: {
|
|
85
|
-
...table.leading,
|
|
86
|
-
...overrides.leading
|
|
87
|
-
},
|
|
88
|
-
trackingEm: {
|
|
89
|
-
...table.trackingEm,
|
|
90
|
-
...overrides.trackingEm
|
|
91
|
-
},
|
|
92
|
-
radiusPx: {
|
|
93
|
-
...table.radiusPx,
|
|
94
|
-
...overrides.radiusPx
|
|
95
|
-
},
|
|
96
|
-
fontWeights: {
|
|
97
|
-
...table.fontWeights,
|
|
98
|
-
...overrides.fontWeights
|
|
99
|
-
},
|
|
100
|
-
fontFamilies: {
|
|
101
|
-
...table.fontFamilies,
|
|
102
|
-
...overrides.fontFamilies
|
|
103
|
-
},
|
|
104
|
-
fontFaces: {
|
|
105
|
-
...table.fontFaces,
|
|
106
|
-
...overrides.fontFaces
|
|
107
|
-
},
|
|
108
|
-
containerPx: {
|
|
109
|
-
...table.containerPx,
|
|
110
|
-
...overrides.containerPx
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
};
|
|
114
|
-
const resolveTokenTable = (layers) => (layers.overrides ?? []).reduce(mergeLayer, layers.base);
|
|
115
|
-
//#endregion
|
|
116
|
-
export { escapeCssString, flattenFontTokens, resolveTokenTable };
|
|
117
|
-
|
|
118
|
-
//# sourceMappingURL=theme.js.map
|