@styleflow.app/astro 0.3.0-beta.5 → 1.0.0-beta.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/README.md +8 -3
- package/dist/S.astro.d.ts +9 -22
- package/dist/html.d.ts +5 -0
- package/dist/html.d.ts.map +1 -0
- package/dist/html.js +22 -0
- package/dist/html.js.map +1 -0
- package/dist/index.d.ts +39 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -6
- package/dist/index.js.map +1 -1
- package/dist/integration.d.ts +0 -1
- package/dist/integration.d.ts.map +1 -1
- package/dist/integration.js +67 -12
- package/dist/integration.js.map +1 -1
- package/dist/runtime.d.ts +9 -2
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +109 -140
- package/dist/runtime.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -7
package/dist/runtime.js
CHANGED
|
@@ -1,190 +1,159 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OVERRIDE_FLAG_ALIASES, STYLEFLOW_RESERVED_DATA_ATTRIBUTES, STYLEFLOW_SUPPORTED_HTML_TAGS } from "./html.js";
|
|
2
2
|
const STYLEFLOW_PROP_NAMES = new Set([
|
|
3
|
-
"as",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"surface",
|
|
7
|
-
"foreground",
|
|
8
|
-
"layoutRole",
|
|
9
|
-
"density",
|
|
10
|
-
"ty",
|
|
11
|
-
"v",
|
|
12
|
-
"w",
|
|
13
|
-
"interactivePriority",
|
|
14
|
-
"noBackground",
|
|
15
|
-
"noBg",
|
|
16
|
-
"noBorder",
|
|
17
|
-
"noB",
|
|
18
|
-
"noPadding",
|
|
19
|
-
"noP",
|
|
20
|
-
"noGap",
|
|
21
|
-
"noG",
|
|
22
|
-
"noRadius",
|
|
23
|
-
"noR",
|
|
24
|
-
"noForeground",
|
|
25
|
-
"noFg"
|
|
3
|
+
"as", "theme", "tone", "intensity", "surface", "foreground", "layoutRole", "density",
|
|
4
|
+
"ty", "v", "w", "interactivePriority", "noBackground", "noBg", "noBorder", "noB",
|
|
5
|
+
"noPadding", "noP", "noGap", "noG", "noRadius", "noR", "noForeground", "noFg"
|
|
26
6
|
]);
|
|
27
|
-
export function resolveStyleFlowAstroPrimitive(props) {
|
|
7
|
+
export function resolveStyleFlowAstroPrimitive(props, suppliedContract) {
|
|
8
|
+
const contract = suppliedContract ?? readRuntimeContract();
|
|
28
9
|
const tag = normalizeHtmlTag(props.as);
|
|
29
10
|
const attributes = collectPassthroughAttributes(props);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
11
|
+
assignTheme(attributes, props, contract);
|
|
12
|
+
assignColor(attributes, props, contract);
|
|
13
|
+
assignLayout(attributes, props, contract);
|
|
14
|
+
assignTypography(attributes, tag, props, contract);
|
|
15
|
+
assignInteraction(attributes, props, contract);
|
|
16
|
+
assignOverrides(attributes, props);
|
|
35
17
|
recordStyleFlowUsage(tag, attributes);
|
|
36
18
|
return { tag, attributes };
|
|
37
19
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
20
|
+
function readRuntimeContract() {
|
|
21
|
+
const compiled = typeof __STYLEFLOW_PROJECT_CONTRACT__ === "undefined"
|
|
22
|
+
? undefined : __STYLEFLOW_PROJECT_CONTRACT__;
|
|
23
|
+
const contract = compiled ?? globalThis.__STYLEFLOW_PROJECT_CONTRACT__;
|
|
24
|
+
if (!contract)
|
|
25
|
+
throw new Error("Styleflow runtime contract is unavailable. Add styleflowAstro() and run styleflow build before Astro.");
|
|
26
|
+
return contract;
|
|
27
|
+
}
|
|
28
|
+
function requireString(prop, value) {
|
|
29
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
30
|
+
throw new Error(`Invalid Styleflow ${prop} "${String(value)}". Semantic coordinates must be string IDs.`);
|
|
47
31
|
}
|
|
48
32
|
return value;
|
|
49
33
|
}
|
|
34
|
+
function requireOne(prop, value, allowed) {
|
|
35
|
+
const normalized = requireString(prop, value);
|
|
36
|
+
if (!allowed.includes(normalized))
|
|
37
|
+
throw new Error(`Invalid Styleflow ${prop} "${normalized}". Use one of: ${allowed.join(", ")}.`);
|
|
38
|
+
return normalized;
|
|
39
|
+
}
|
|
50
40
|
export function normalizeHtmlTag(value) {
|
|
51
|
-
if (!STYLEFLOW_SUPPORTED_HTML_TAGS.includes(value))
|
|
52
|
-
throw new Error(`Unsupported
|
|
53
|
-
}
|
|
41
|
+
if (!STYLEFLOW_SUPPORTED_HTML_TAGS.includes(value))
|
|
42
|
+
throw new Error(`Unsupported Styleflow HTML tag: ${value}`);
|
|
54
43
|
return value;
|
|
55
44
|
}
|
|
56
45
|
function collectPassthroughAttributes(props) {
|
|
57
46
|
const attributes = {};
|
|
58
47
|
for (const [key, value] of Object.entries(props)) {
|
|
59
|
-
if (STYLEFLOW_PROP_NAMES.has(key) || value === undefined || value === false)
|
|
48
|
+
if (STYLEFLOW_PROP_NAMES.has(key) || value === undefined || value === false)
|
|
60
49
|
continue;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
if (isSafeAttributeValue(value)) {
|
|
50
|
+
if (key.startsWith("data-") && STYLEFLOW_RESERVED_DATA_ATTRIBUTES.includes(key))
|
|
51
|
+
throw new Error(`Reserved Styleflow runtime attribute cannot be authored: ${key}`);
|
|
52
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean")
|
|
66
53
|
attributes[key] = value;
|
|
67
|
-
}
|
|
68
54
|
}
|
|
69
55
|
return attributes;
|
|
70
56
|
}
|
|
71
|
-
function
|
|
72
|
-
if (props.
|
|
73
|
-
attributes["data-
|
|
74
|
-
|
|
57
|
+
function assignTheme(attributes, props, contract) {
|
|
58
|
+
if (props.theme !== undefined)
|
|
59
|
+
attributes["data-styleflow-theme"] = requireOne("theme", props.theme, contract.semantic.themes);
|
|
60
|
+
}
|
|
61
|
+
function assignColor(attributes, props, contract) {
|
|
62
|
+
const axes = contract.semantic.axes.color;
|
|
63
|
+
const tone = props.tone !== undefined ? requireOne("tone", props.tone, axes.tones) : undefined;
|
|
64
|
+
if (tone)
|
|
65
|
+
attributes["data-color-tone"] = tone;
|
|
75
66
|
if (props.intensity !== undefined) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
attributes["data-
|
|
80
|
-
}
|
|
81
|
-
if (props.
|
|
82
|
-
attributes["data-
|
|
83
|
-
|
|
67
|
+
if (typeof props.intensity === "number")
|
|
68
|
+
throw new Error(`Invalid Styleflow intensity "${props.intensity}". Numeric v0.x intensities are unsupported.`);
|
|
69
|
+
const allowed = tone ? axes.intensitiesByTone[tone] ?? [] : [...new Set(Object.values(axes.intensitiesByTone).flat())];
|
|
70
|
+
attributes["data-color-intensity"] = requireOne("intensity", props.intensity, allowed);
|
|
71
|
+
}
|
|
72
|
+
if (props.surface !== undefined)
|
|
73
|
+
attributes["data-surface-type"] = requireOne("surface", props.surface, axes.surfaces);
|
|
74
|
+
if (props.foreground !== undefined)
|
|
75
|
+
attributes["data-foreground"] = requireOne("foreground", props.foreground, axes.foregrounds);
|
|
84
76
|
}
|
|
85
|
-
function
|
|
86
|
-
if (props.layoutRole !== undefined)
|
|
87
|
-
attributes["data-layout-role"] =
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
attributes["data-layout-density"] = requireEnumValue("density", String(props.density), LAYOUT_DENSITIES);
|
|
91
|
-
}
|
|
77
|
+
function assignLayout(attributes, props, contract) {
|
|
78
|
+
if (props.layoutRole !== undefined)
|
|
79
|
+
attributes["data-layout-role"] = requireOne("layoutRole", props.layoutRole, contract.semantic.axes.layout.roles);
|
|
80
|
+
if (props.density !== undefined)
|
|
81
|
+
attributes["data-layout-density"] = requireOne("density", props.density, contract.semantic.axes.layout.densities);
|
|
92
82
|
}
|
|
93
|
-
function
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
83
|
+
function typographyDefaults(tag, contract) {
|
|
84
|
+
const candidates = tag === "p" || tag === "span" || tag === "li" ? ["body", "md"]
|
|
85
|
+
: tag === "small" ? ["body", "sm"] : /^h[1-6]$/.test(tag) ? ["heading", tag.slice(1)] : [];
|
|
86
|
+
if (candidates.length === 2 && contract.semantic.axes.typography.variantsByType[candidates[0]]?.includes(candidates[1]))
|
|
87
|
+
return { ty: candidates[0], v: candidates[1], w: contract.semantic.agentPolicy.defaults.typography.w };
|
|
88
|
+
if (candidates.length === 2)
|
|
89
|
+
return contract.semantic.agentPolicy.defaults.typography;
|
|
90
|
+
if (tag === "strong")
|
|
91
|
+
return {
|
|
92
|
+
w: contract.semantic.axes.typography.weights.includes("strong")
|
|
93
|
+
? "strong"
|
|
94
|
+
: contract.semantic.agentPolicy.defaults.typography.w
|
|
95
|
+
};
|
|
96
|
+
return {};
|
|
97
|
+
}
|
|
98
|
+
function assignTypography(attributes, tag, props, contract) {
|
|
99
|
+
const defaults = typographyDefaults(tag, contract);
|
|
100
|
+
const ty = props.ty !== undefined ? requireOne("ty", props.ty, contract.semantic.axes.typography.types) : defaults.ty;
|
|
101
|
+
const variants = ty ? contract.semantic.axes.typography.variantsByType[ty] ?? [] : [];
|
|
102
|
+
const v = props.v !== undefined ? requireOne("v", props.v, variants) : defaults.v;
|
|
103
|
+
const w = props.w !== undefined ? requireOne("w", props.w, contract.semantic.axes.typography.weights) : defaults.w;
|
|
104
|
+
if (ty)
|
|
108
105
|
attributes["data-text-type"] = ty;
|
|
109
|
-
|
|
110
|
-
if (v) {
|
|
106
|
+
if (v)
|
|
111
107
|
attributes["data-text-variant"] = v;
|
|
112
|
-
|
|
113
|
-
if (w) {
|
|
108
|
+
if (w)
|
|
114
109
|
attributes["data-text-weight"] = w;
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
110
|
+
if (ty && v && w) {
|
|
111
|
+
const tokens = contract.resolved[contract.defaultTheme]?.resolved.typography ?? [];
|
|
112
|
+
const token = tokens.find((item) => item.ty === ty && item.v === v && item.w === w);
|
|
113
|
+
if (!token)
|
|
114
|
+
throw new Error(`Invalid Styleflow typography coordinate ty="${ty}" v="${v}" w="${w}".`);
|
|
115
|
+
attributes["data-text-style"] = token.id;
|
|
118
116
|
}
|
|
119
117
|
}
|
|
120
|
-
function
|
|
121
|
-
if (props.interactivePriority !== undefined)
|
|
122
|
-
attributes["data-interactive-priority"] =
|
|
123
|
-
}
|
|
118
|
+
function assignInteraction(attributes, props, contract) {
|
|
119
|
+
if (props.interactivePriority !== undefined)
|
|
120
|
+
attributes["data-interactive-priority"] = requireOne("interactivePriority", props.interactivePriority, contract.semantic.axes.interaction.priorities);
|
|
124
121
|
}
|
|
125
|
-
function
|
|
122
|
+
function assignOverrides(attributes, props) {
|
|
126
123
|
for (const [long, short] of OVERRIDE_FLAG_ALIASES) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if (longValue !== undefined &&
|
|
130
|
-
shortValue !== undefined &&
|
|
131
|
-
Boolean(longValue) !== Boolean(shortValue)) {
|
|
132
|
-
throw new Error(`Contradictory StyleFlow override aliases: ${long}={${String(longValue)}} and ${short}={${String(shortValue)}}. Keep exactly one.`);
|
|
133
|
-
}
|
|
124
|
+
if (props[long] !== undefined && props[short] !== undefined)
|
|
125
|
+
throw new Error(`Ambiguous Styleflow override aliases: keep exactly one of ${long} / ${short}.`);
|
|
134
126
|
}
|
|
135
|
-
if (props.noBackground || props.noBg)
|
|
127
|
+
if (props.noBackground || props.noBg)
|
|
136
128
|
attributes["data-sf-no-background"] = true;
|
|
137
|
-
|
|
138
|
-
if (props.noBorder || props.noB) {
|
|
129
|
+
if (props.noBorder || props.noB)
|
|
139
130
|
attributes["data-sf-no-border"] = true;
|
|
140
|
-
|
|
141
|
-
if (props.noPadding || props.noP) {
|
|
131
|
+
if (props.noPadding || props.noP)
|
|
142
132
|
attributes["data-sf-no-padding"] = true;
|
|
143
|
-
|
|
144
|
-
if (props.noGap || props.noG) {
|
|
133
|
+
if (props.noGap || props.noG)
|
|
145
134
|
attributes["data-sf-no-gap"] = true;
|
|
146
|
-
|
|
147
|
-
if (props.noRadius || props.noR) {
|
|
135
|
+
if (props.noRadius || props.noR)
|
|
148
136
|
attributes["data-sf-no-radius"] = true;
|
|
149
|
-
|
|
150
|
-
if (props.noForeground || props.noFg) {
|
|
137
|
+
if (props.noForeground || props.noFg)
|
|
151
138
|
attributes["data-sf-no-foreground"] = true;
|
|
152
|
-
}
|
|
153
139
|
}
|
|
154
|
-
/*
|
|
155
|
-
* Opt-in runtime usage collection (spec §13.1): enabled by the integration
|
|
156
|
-
* via STYLEFLOW_ASTRO_USAGE=1 and flushed to .styleflow/astro-usage.json at
|
|
157
|
-
* astro:build:done. Collected on globalThis because Vite SSR can instantiate
|
|
158
|
-
* this module more than once in the same process.
|
|
159
|
-
*/
|
|
160
140
|
const STYLEFLOW_USAGE_GLOBAL = "__STYLEFLOW_ASTRO_USAGE__";
|
|
161
141
|
export function readStyleFlowUsageEntries() {
|
|
162
142
|
const store = globalThis[STYLEFLOW_USAGE_GLOBAL];
|
|
163
143
|
return store ? [...store.values()] : [];
|
|
164
144
|
}
|
|
165
|
-
export function clearStyleFlowUsageEntries() {
|
|
166
|
-
globalThis[STYLEFLOW_USAGE_GLOBAL] = new Map();
|
|
167
|
-
}
|
|
145
|
+
export function clearStyleFlowUsageEntries() { globalThis[STYLEFLOW_USAGE_GLOBAL] = new Map(); }
|
|
168
146
|
function recordStyleFlowUsage(tag, attributes) {
|
|
169
|
-
if (process.env.STYLEFLOW_ASTRO_USAGE !== "1")
|
|
147
|
+
if (process.env.STYLEFLOW_ASTRO_USAGE !== "1")
|
|
170
148
|
return;
|
|
171
|
-
|
|
172
|
-
const
|
|
149
|
+
const global = globalThis;
|
|
150
|
+
const store = global[STYLEFLOW_USAGE_GLOBAL] ?? new Map();
|
|
151
|
+
const record = { tag };
|
|
173
152
|
for (const [key, value] of Object.entries(attributes)) {
|
|
174
|
-
if (
|
|
175
|
-
|
|
176
|
-
}
|
|
153
|
+
if (value !== undefined)
|
|
154
|
+
record[key] = value;
|
|
177
155
|
}
|
|
178
|
-
|
|
179
|
-
store
|
|
180
|
-
}
|
|
181
|
-
function isReservedDataAttribute(value) {
|
|
182
|
-
return (STYLEFLOW_RESERVED_DATA_ATTRIBUTES.includes(value) || value.startsWith("data-sf-"));
|
|
183
|
-
}
|
|
184
|
-
function isSafeAttributeValue(value) {
|
|
185
|
-
return (typeof value === "string" ||
|
|
186
|
-
typeof value === "number" ||
|
|
187
|
-
typeof value === "boolean" ||
|
|
188
|
-
value === undefined);
|
|
156
|
+
store.set(JSON.stringify(record), record);
|
|
157
|
+
global[STYLEFLOW_USAGE_GLOBAL] = store;
|
|
189
158
|
}
|
|
190
159
|
//# sourceMappingURL=runtime.js.map
|
package/dist/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,YAAY,EACZ,qBAAqB,EACrB,kCAAkC,EAClC,6BAA6B,EAC7B,gBAAgB,EAChB,kBAAkB,EAClB,uBAAuB,EACvB,2BAA2B,EAC3B,0BAA0B,EAW3B,MAAM,qBAAqB,CAAC;AAkB7B,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC;IACnC,IAAI;IACJ,MAAM;IACN,WAAW;IACX,SAAS;IACT,YAAY;IACZ,YAAY;IACZ,SAAS;IACT,IAAI;IACJ,GAAG;IACH,GAAG;IACH,qBAAqB;IACrB,cA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AACJ,CAAC;AAED,SAAS,oBAAoB,CAC3B,KAAc;IAEd,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,SAAS;QAC1B,KAAK,KAAK,SAAS,CACpB,CAAC;AACJ,CAAC","sourcesContent":["import {\n COLOR_INTENSITIES,\n COLOR_SURFACES,\n COLOR_TONES,\n FOREGROUND_ROLES,\n INTERACTIVE_PRIORITIES,\n LAYOUT_DENSITIES,\n LAYOUT_ROLES,\n OVERRIDE_FLAG_ALIASES,\n STYLEFLOW_RESERVED_DATA_ATTRIBUTES,\n STYLEFLOW_SUPPORTED_HTML_TAGS,\n TYPOGRAPHY_TYPES,\n TYPOGRAPHY_WEIGHTS,\n createTypographyStyleId,\n getTypographyDefaultsForTag,\n isTypographyVariantForType,\n type ColorIntensity,\n type ColorSurface,\n type ColorTone,\n type ForegroundRole,\n type InteractivePriority,\n type LayoutDensity,\n type LayoutRole,\n type StyleFlowSupportedHtmlTag,\n type TypographyType,\n type TypographyWeight\n} from \"@styleflow.app/core\";\n\nexport type StyleFlowAstroAttributeValue =\n | string\n | number\n | boolean\n | undefined;\n\nexport interface StyleFlowAstroPrimitiveInput {\n as: string;\n [key: string]: unknown;\n}\n\nexport interface StyleFlowAstroResolvedPrimitive {\n tag: StyleFlowSupportedHtmlTag;\n attributes: Record<string, StyleFlowAstroAttributeValue>;\n}\n\nconst STYLEFLOW_PROP_NAMES = new Set([\n \"as\",\n \"tone\",\n \"intensity\",\n \"surface\",\n \"foreground\",\n \"layoutRole\",\n \"density\",\n \"ty\",\n \"v\",\n \"w\",\n \"interactivePriority\",\n \"noBackground\",\n \"noBg\",\n \"noBorder\",\n \"noB\",\n \"noPadding\",\n \"noP\",\n \"noGap\",\n \"noG\",\n \"noRadius\",\n \"noR\",\n \"noForeground\",\n \"noFg\"\n]);\n\nexport function resolveStyleFlowAstroPrimitive(\n props: StyleFlowAstroPrimitiveInput\n): StyleFlowAstroResolvedPrimitive {\n const tag = normalizeHtmlTag(props.as);\n const attributes = collectPassthroughAttributes(props);\n\n assignColorAttributes(attributes, props);\n assignLayoutAttributes(attributes, props);\n assignTypographyAttributes(attributes, tag, props);\n assignInteractionAttributes(attributes, props);\n assignOverrideAttributes(attributes, props);\n\n recordStyleFlowUsage(tag, attributes);\n\n return { tag, attributes };\n}\n\n/*\n * S.astro renders server-side, so throwing here fails `astro dev`/`astro\n * build` loudly instead of shipping out-of-contract markup (spec §13.3).\n * Narrowing to the project's ACTIVE axes stays with the CLI lint, which has\n * the full contract context.\n */\nfunction requireEnumValue<T extends string | number>(\n prop: string,\n value: T,\n allowed: readonly T[]\n): T {\n if (!allowed.includes(value)) {\n throw new Error(\n `Invalid StyleFlow ${prop} \"${String(value)}\". Use one of: ${allowed.join(\", \")}.`\n );\n }\n\n return value;\n}\n\nexport function normalizeHtmlTag(value: string): StyleFlowSupportedHtmlTag {\n if (!STYLEFLOW_SUPPORTED_HTML_TAGS.includes(value as StyleFlowSupportedHtmlTag)) {\n throw new Error(`Unsupported StyleFlow HTML tag: ${value}`);\n }\n\n return value as StyleFlowSupportedHtmlTag;\n}\n\nfunction collectPassthroughAttributes(\n props: StyleFlowAstroPrimitiveInput\n): Record<string, StyleFlowAstroAttributeValue> {\n const attributes: Record<string, StyleFlowAstroAttributeValue> = {};\n\n for (const [key, value] of Object.entries(props)) {\n if (STYLEFLOW_PROP_NAMES.has(key) || value === undefined || value === false) {\n continue;\n }\n\n if (key.startsWith(\"data-\") && isReservedDataAttribute(key)) {\n throw new Error(`Reserved StyleFlow runtime attribute cannot be authored: ${key}`);\n }\n\n if (isSafeAttributeValue(value)) {\n attributes[key] = value;\n }\n }\n\n return attributes;\n}\n\nfunction assignColorAttributes(\n attributes: Record<string, StyleFlowAstroAttributeValue>,\n props: StyleFlowAstroPrimitiveInput\n): void {\n if (props.tone !== undefined) {\n attributes[\"data-color-tone\"] = requireEnumValue(\n \"tone\",\n String(props.tone) as ColorTone,\n COLOR_TONES\n );\n }\n\n if (props.intensity !== undefined) {\n attributes[\"data-color-intensity\"] = requireEnumValue(\n \"intensity\",\n Number(props.intensity) as ColorIntensity,\n COLOR_INTENSITIES\n );\n }\n\n if (props.surface !== undefined) {\n attributes[\"data-surface-type\"] = requireEnumValue(\n \"surface\",\n String(props.surface) as ColorSurface,\n COLOR_SURFACES\n );\n }\n\n if (props.foreground !== undefined) {\n attributes[\"data-foreground\"] = requireEnumValue(\n \"foreground\",\n String(props.foreground) as ForegroundRole,\n FOREGROUND_ROLES\n );\n }\n}\n\nfunction assignLayoutAttributes(\n attributes: Record<string, StyleFlowAstroAttributeValue>,\n props: StyleFlowAstroPrimitiveInput\n): void {\n if (props.layoutRole !== undefined) {\n attributes[\"data-layout-role\"] = requireEnumValue(\n \"layoutRole\",\n String(props.layoutRole) as LayoutRole,\n LAYOUT_ROLES\n );\n }\n\n if (props.density !== undefined) {\n attributes[\"data-layout-density\"] = requireEnumValue(\n \"density\",\n String(props.density) as LayoutDensity,\n LAYOUT_DENSITIES\n );\n }\n}\n\nfunction assignTypographyAttributes(\n attributes: Record<string, StyleFlowAstroAttributeValue>,\n tag: StyleFlowSupportedHtmlTag,\n props: StyleFlowAstroPrimitiveInput\n): void {\n const defaults = getTypographyDefaultsForTag(tag);\n\n if (props.ty !== undefined) {\n requireEnumValue(\"ty\", String(props.ty) as TypographyType, TYPOGRAPHY_TYPES);\n }\n\n if (props.w !== undefined) {\n requireEnumValue(\"w\", String(props.w) as TypographyWeight, TYPOGRAPHY_WEIGHTS);\n }\n\n const ty = (props.ty as TypographyType | undefined) ?? defaults.ty;\n const v = props.v !== undefined ? String(props.v) : defaults.v;\n const w = (props.w as TypographyWeight | undefined) ?? defaults.w;\n\n if (props.v !== undefined && ty && !isTypographyVariantForType(ty, String(props.v))) {\n throw new Error(\n `Invalid StyleFlow typography coordinate ty=\"${ty}\" v=\"${String(props.v)}\".`\n );\n }\n\n if (ty) {\n attributes[\"data-text-type\"] = ty;\n }\n\n if (v) {\n attributes[\"data-text-variant\"] = v;\n }\n\n if (w) {\n attributes[\"data-text-weight\"] = w;\n }\n\n if (ty && v && w && isTypographyVariantForType(ty, v)) {\n attributes[\"data-text-style\"] = createTypographyStyleId({ ty, v, w });\n }\n}\n\nfunction assignInteractionAttributes(\n attributes: Record<string, StyleFlowAstroAttributeValue>,\n props: StyleFlowAstroPrimitiveInput\n): void {\n if (props.interactivePriority !== undefined) {\n attributes[\"data-interactive-priority\"] = requireEnumValue(\n \"interactivePriority\",\n String(props.interactivePriority) as InteractivePriority,\n INTERACTIVE_PRIORITIES\n );\n }\n}\n\nfunction assignOverrideAttributes(\n attributes: Record<string, StyleFlowAstroAttributeValue>,\n props: StyleFlowAstroPrimitiveInput\n): void {\n for (const [long, short] of OVERRIDE_FLAG_ALIASES) {\n const longValue = props[long];\n const shortValue = props[short];\n\n if (\n longValue !== undefined &&\n shortValue !== undefined &&\n Boolean(longValue) !== Boolean(shortValue)\n ) {\n throw new Error(\n `Contradictory StyleFlow override aliases: ${long}={${String(longValue)}} and ${short}={${String(shortValue)}}. Keep exactly one.`\n );\n }\n }\n\n if (props.noBackground || props.noBg) {\n attributes[\"data-sf-no-background\"] = true;\n }\n\n if (props.noBorder || props.noB) {\n attributes[\"data-sf-no-border\"] = true;\n }\n\n if (props.noPadding || props.noP) {\n attributes[\"data-sf-no-padding\"] = true;\n }\n\n if (props.noGap || props.noG) {\n attributes[\"data-sf-no-gap\"] = true;\n }\n\n if (props.noRadius || props.noR) {\n attributes[\"data-sf-no-radius\"] = true;\n }\n\n if (props.noForeground || props.noFg) {\n attributes[\"data-sf-no-foreground\"] = true;\n }\n}\n\n/*\n * Opt-in runtime usage collection (spec §13.1): enabled by the integration\n * via STYLEFLOW_ASTRO_USAGE=1 and flushed to .styleflow/astro-usage.json at\n * astro:build:done. Collected on globalThis because Vite SSR can instantiate\n * this module more than once in the same process.\n */\nconst STYLEFLOW_USAGE_GLOBAL = \"__STYLEFLOW_ASTRO_USAGE__\";\n\ntype UsageGlobal = typeof globalThis & {\n [STYLEFLOW_USAGE_GLOBAL]?: Map<string, Record<string, string | number | boolean>>;\n};\n\nexport function readStyleFlowUsageEntries(): Record<string, string | number | boolean>[] {\n const store = (globalThis as UsageGlobal)[STYLEFLOW_USAGE_GLOBAL];\n return store ? [...store.values()] : [];\n}\n\nexport function clearStyleFlowUsageEntries(): void {\n (globalThis as UsageGlobal)[STYLEFLOW_USAGE_GLOBAL] = new Map();\n}\n\nfunction recordStyleFlowUsage(\n tag: string,\n attributes: Record<string, StyleFlowAstroAttributeValue>\n): void {\n if (process.env.STYLEFLOW_ASTRO_USAGE !== \"1\") {\n return;\n }\n\n const entry: Record<string, string | number | boolean> = { tag };\n for (const [key, value] of Object.entries(attributes)) {\n if (key.startsWith(\"data-\") && value !== undefined && isReservedDataAttribute(key)) {\n entry[key] = value;\n }\n }\n\n const store = ((globalThis as UsageGlobal)[STYLEFLOW_USAGE_GLOBAL] ??= new Map());\n store.set(JSON.stringify(entry), entry);\n}\n\nfunction isReservedDataAttribute(value: string): boolean {\n return (\n STYLEFLOW_RESERVED_DATA_ATTRIBUTES.includes(\n value as (typeof STYLEFLOW_RESERVED_DATA_ATTRIBUTES)[number]\n ) || value.startsWith(\"data-sf-\")\n );\n}\n\nfunction isSafeAttributeValue(\n value: unknown\n): value is StyleFlowAstroAttributeValue {\n return (\n typeof value === \"string\" ||\n typeof value === \"number\" ||\n typeof value === \"boolean\" ||\n value === undefined\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,qBAAqB,EACrB,kCAAkC,EAClC,6BAA6B,EAE9B,MAAM,WAAW,CAAC;AAmBnB,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC;IACnC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS;IACpF,IAAI,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IDE_FLAG_ALIASES,\n STYLEFLOW_RESERVED_DATA_ATTRIBUTES,\n STYLEFLOW_SUPPORTED_HTML_TAGS,\n type StyleFlowSupportedHtmlTag\n} from \"./html.js\";\n\nexport interface StyleflowRuntimeProjectContract {\n version: \"1.0.0\";\n defaultTheme: string;\n semantic: StyleflowSemanticContract;\n resolved: Record<string, StyleflowResolvedThemeContract>;\n}\n\ndeclare const __STYLEFLOW_PROJECT_CONTRACT__: StyleflowRuntimeProjectContract | undefined;\ntype RuntimeGlobal = typeof globalThis & { __STYLEFLOW_PROJECT_CONTRACT__?: StyleflowRuntimeProjectContract };\n\nexport type StyleFlowAstroAttributeValue = string | number | boolean | undefined;\nexport interface StyleFlowAstroPrimitiveInput { as: string; [key: string]: unknown }\nexport interface StyleFlowAstroResolvedPrimitive {\n tag: StyleFlowSupportedHtmlTag;\n attributes: Record<string, StyleFlowAstroAttributeValue>;\n}\n\nconst STYLEFLOW_PROP_NAMES = new Set([\n \"as\", \"theme\", \"tone\", \"intensity\", \"surface\", \"foreground\", \"layoutRole\", \"density\",\n \"ty\", \"v\", \"w\", \"interactivePriority\", \"noBackground\", \"noBg\", \"noBorder\", \"noB\",\n \"noPadding\", \"noP\", \"noGap\", \"noG\", \"noRadius\", \"noR\", \"noForeground\", \"noFg\"\n]);\n\nexport function resolveStyleFlowAstroPrimitive(\n props: StyleFlowAstroPrimitiveInput,\n suppliedContract?: StyleflowRuntimeProjectContract\n): StyleFlowAstroResolvedPrimitive {\n const contract = suppliedContract ?? readRuntimeContract();\n const tag = normalizeHtmlTag(props.as);\n const attributes = collectPassthroughAttributes(props);\n assignTheme(attributes, props, contract);\n assignColor(attributes, props, contract);\n assignLayout(attributes, props, contract);\n assignTypography(attributes, tag, props, contract);\n assignInteraction(attributes, props, contract);\n assignOverrides(attributes, props);\n recordStyleFlowUsage(tag, attributes);\n return { tag, attributes };\n}\n\nfunction readRuntimeContract(): StyleflowRuntimeProjectContract {\n const compiled = typeof __STYLEFLOW_PROJECT_CONTRACT__ === \"undefined\"\n ? undefined : __STYLEFLOW_PROJECT_CONTRACT__;\n const contract = compiled ?? (globalThis as RuntimeGlobal).__STYLEFLOW_PROJECT_CONTRACT__;\n if (!contract) throw new Error(\"Styleflow runtime contract is unavailable. Add styleflowAstro() and run styleflow build before Astro.\");\n return contract;\n}\n\nfunction requireString(prop: string, value: unknown): string {\n if (typeof value !== \"string\" || value.length === 0) {\n throw new Error(`Invalid Styleflow ${prop} \"${String(value)}\". Semantic coordinates must be string IDs.`);\n }\n return value;\n}\nfunction requireOne(prop: string, value: unknown, allowed: readonly string[]): string {\n const normalized = requireString(prop, value);\n if (!allowed.includes(normalized)) throw new Error(`Invalid Styleflow ${prop} \"${normalized}\". Use one of: ${allowed.join(\", \")}.`);\n return normalized;\n}\n\nexport function normalizeHtmlTag(value: string): StyleFlowSupportedHtmlTag {\n if (!STYLEFLOW_SUPPORTED_HTML_TAGS.includes(value as StyleFlowSupportedHtmlTag)) throw new Error(`Unsupported Styleflow HTML tag: ${value}`);\n return value as StyleFlowSupportedHtmlTag;\n}\n\nfunction collectPassthroughAttributes(props: StyleFlowAstroPrimitiveInput): Record<string, StyleFlowAstroAttributeValue> {\n const attributes: Record<string, StyleFlowAstroAttributeValue> = {};\n for (const [key, value] of Object.entries(props)) {\n if (STYLEFLOW_PROP_NAMES.has(key) || value === undefined || value === false) continue;\n if (key.startsWith(\"data-\") && STYLEFLOW_RESERVED_DATA_ATTRIBUTES.includes(key as never)) throw new Error(`Reserved Styleflow runtime attribute cannot be authored: ${key}`);\n if (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") attributes[key] = value;\n }\n return attributes;\n}\n\nfunction assignTheme(attributes: Record<string, StyleFlowAstroAttributeValue>, props: StyleFlowAstroPrimitiveInput, contract: StyleflowRuntimeProjectContract): void {\n if (props.theme !== undefined) attributes[\"data-styleflow-theme\"] = requireOne(\"theme\", props.theme, contract.semantic.themes);\n}\nfunction assignColor(attributes: Record<string, StyleFlowAstroAttributeValue>, props: StyleFlowAstroPrimitiveInput, contract: StyleflowRuntimeProjectContract): void {\n const axes = contract.semantic.axes.color;\n const tone = props.tone !== undefined ? requireOne(\"tone\", props.tone, axes.tones) : undefined;\n if (tone) attributes[\"data-color-tone\"] = tone;\n if (props.intensity !== undefined) {\n if (typeof props.intensity === \"number\") throw new Error(`Invalid Styleflow intensity \"${props.intensity}\". Numeric v0.x intensities are unsupported.`);\n const allowed = tone ? axes.intensitiesByTone[tone] ?? [] : [...new Set(Object.values(axes.intensitiesByTone).flat())];\n attributes[\"data-color-intensity\"] = requireOne(\"intensity\", props.intensity, allowed);\n }\n if (props.surface !== undefined) attributes[\"data-surface-type\"] = requireOne(\"surface\", props.surface, axes.surfaces);\n if (props.foreground !== undefined) attributes[\"data-foreground\"] = requireOne(\"foreground\", props.foreground, axes.foregrounds);\n}\nfunction assignLayout(attributes: Record<string, StyleFlowAstroAttributeValue>, props: StyleFlowAstroPrimitiveInput, contract: StyleflowRuntimeProjectContract): void {\n if (props.layoutRole !== undefined) attributes[\"data-layout-role\"] = requireOne(\"layoutRole\", props.layoutRole, contract.semantic.axes.layout.roles);\n if (props.density !== undefined) attributes[\"data-layout-density\"] = requireOne(\"density\", props.density, contract.semantic.axes.layout.densities);\n}\n\nfunction typographyDefaults(tag: string, contract: StyleflowRuntimeProjectContract): { ty?: string; v?: string; w?: string } {\n const candidates = tag === \"p\" || tag === \"span\" || tag === \"li\" ? [\"body\", \"md\"]\n : tag === \"small\" ? [\"body\", \"sm\"] : /^h[1-6]$/.test(tag) ? [\"heading\", tag.slice(1)] : [];\n if (candidates.length === 2 && contract.semantic.axes.typography.variantsByType[candidates[0]!]?.includes(candidates[1]!)) return { ty: candidates[0], v: candidates[1], w: contract.semantic.agentPolicy.defaults.typography.w };\n if (candidates.length === 2) return contract.semantic.agentPolicy.defaults.typography;\n if (tag === \"strong\") return {\n w: contract.semantic.axes.typography.weights.includes(\"strong\")\n ? \"strong\"\n : contract.semantic.agentPolicy.defaults.typography.w\n };\n return {};\n}\nfunction assignTypography(attributes: Record<string, StyleFlowAstroAttributeValue>, tag: string, props: StyleFlowAstroPrimitiveInput, contract: StyleflowRuntimeProjectContract): void {\n const defaults = typographyDefaults(tag, contract);\n const ty = props.ty !== undefined ? requireOne(\"ty\", props.ty, contract.semantic.axes.typography.types) : defaults.ty;\n const variants = ty ? contract.semantic.axes.typography.variantsByType[ty] ?? [] : [];\n const v = props.v !== undefined ? requireOne(\"v\", props.v, variants) : defaults.v;\n const w = props.w !== undefined ? requireOne(\"w\", props.w, contract.semantic.axes.typography.weights) : defaults.w;\n if (ty) attributes[\"data-text-type\"] = ty;\n if (v) attributes[\"data-text-variant\"] = v;\n if (w) attributes[\"data-text-weight\"] = w;\n if (ty && v && w) {\n const tokens = contract.resolved[contract.defaultTheme]?.resolved.typography ?? [];\n const token = tokens.find((item) => item.ty === ty && item.v === v && item.w === w);\n if (!token) throw new Error(`Invalid Styleflow typography coordinate ty=\"${ty}\" v=\"${v}\" w=\"${w}\".`);\n attributes[\"data-text-style\"] = token.id;\n }\n}\nfunction assignInteraction(attributes: Record<string, StyleFlowAstroAttributeValue>, props: StyleFlowAstroPrimitiveInput, contract: StyleflowRuntimeProjectContract): void {\n if (props.interactivePriority !== undefined) attributes[\"data-interactive-priority\"] = requireOne(\"interactivePriority\", props.interactivePriority, contract.semantic.axes.interaction.priorities);\n}\nfunction assignOverrides(attributes: Record<string, StyleFlowAstroAttributeValue>, props: StyleFlowAstroPrimitiveInput): void {\n for (const [long, short] of OVERRIDE_FLAG_ALIASES) {\n if (props[long] !== undefined && props[short] !== undefined) throw new Error(`Ambiguous Styleflow override aliases: keep exactly one of ${long} / ${short}.`);\n }\n if (props.noBackground || props.noBg) attributes[\"data-sf-no-background\"] = true;\n if (props.noBorder || props.noB) attributes[\"data-sf-no-border\"] = true;\n if (props.noPadding || props.noP) attributes[\"data-sf-no-padding\"] = true;\n if (props.noGap || props.noG) attributes[\"data-sf-no-gap\"] = true;\n if (props.noRadius || props.noR) attributes[\"data-sf-no-radius\"] = true;\n if (props.noForeground || props.noFg) attributes[\"data-sf-no-foreground\"] = true;\n}\n\nconst STYLEFLOW_USAGE_GLOBAL = \"__STYLEFLOW_ASTRO_USAGE__\";\ntype UsageGlobal = typeof globalThis & { [STYLEFLOW_USAGE_GLOBAL]?: Map<string, Record<string, string | number | boolean>> };\nexport function readStyleFlowUsageEntries(): Record<string, string | number | boolean>[] {\n const store = (globalThis as UsageGlobal)[STYLEFLOW_USAGE_GLOBAL]; return store ? [...store.values()] : [];\n}\nexport function clearStyleFlowUsageEntries(): void { (globalThis as UsageGlobal)[STYLEFLOW_USAGE_GLOBAL] = new Map(); }\nfunction recordStyleFlowUsage(tag: string, attributes: Record<string, StyleFlowAstroAttributeValue>): void {\n if (process.env.STYLEFLOW_ASTRO_USAGE !== \"1\") return;\n const global = globalThis as UsageGlobal; const store = global[STYLEFLOW_USAGE_GLOBAL] ?? new Map();\n const record: Record<string, string | number | boolean> = { tag };\n for (const [key, value] of Object.entries(attributes)) {\n if (value !== undefined) record[key] = value;\n }\n store.set(JSON.stringify(record), record); global[STYLEFLOW_USAGE_GLOBAL] = store;\n}\n"]}
|