@kithinji/arcane 1.0.0 → 1.0.2

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.
@@ -0,0 +1,382 @@
1
+ // src/style/style.ts
2
+ import ts from "typescript";
3
+ var UNITLESS_PROPS = /* @__PURE__ */ new Set([
4
+ "z-index",
5
+ "opacity",
6
+ "flex-grow",
7
+ "flex-shrink",
8
+ "flex",
9
+ "order",
10
+ "font-weight",
11
+ "line-height",
12
+ "zoom",
13
+ "column-count",
14
+ "animation-iteration-count",
15
+ "grid-column",
16
+ "grid-row",
17
+ "grid-column-start",
18
+ "grid-column-end",
19
+ "grid-row-start",
20
+ "grid-row-end",
21
+ "tab-size",
22
+ "counter-increment",
23
+ "counter-reset",
24
+ "orphans",
25
+ "widows"
26
+ ]);
27
+ var DEV_MODE = process.env.NODE_ENV === "development";
28
+ function simpleHash(str) {
29
+ let hash = 0;
30
+ for (let i = 0; i < str.length; i++) {
31
+ const char = str.charCodeAt(i);
32
+ hash = (hash << 5) - hash + char;
33
+ hash = hash & hash;
34
+ }
35
+ return Math.abs(hash).toString(36).padStart(8, "0").slice(0, 8);
36
+ }
37
+ function hashProperty(prop, value, cssRules) {
38
+ const input = `${prop}:${value}`;
39
+ let hash = simpleHash(input);
40
+ let className;
41
+ if (DEV_MODE) {
42
+ const hint = prop.replace(/[^a-z]/gi, "").slice(0, 3).toLowerCase();
43
+ className = `a-${hint}-${hash}`;
44
+ } else {
45
+ className = `a-${hash}`;
46
+ }
47
+ let attempt = 0;
48
+ while (cssRules.has(className)) {
49
+ const existing = cssRules.get(className);
50
+ const kebabProp = toKebabCase(prop);
51
+ const normalizedValue = normalizeValue(prop, value);
52
+ const expectedRule = `.${className} { ${kebabProp}: ${normalizedValue}; }`;
53
+ if (existing.includes(`${kebabProp}: ${normalizedValue}`)) {
54
+ break;
55
+ }
56
+ hash = simpleHash(`${input}-${++attempt}`);
57
+ className = DEV_MODE ? `a-${prop.slice(0, 3)}-${hash}` : `a-${hash}`;
58
+ if (attempt > 100) {
59
+ throw new Error(
60
+ `Hash collision limit exceeded for property ${prop}:${value}`
61
+ );
62
+ }
63
+ }
64
+ return className;
65
+ }
66
+ function toKebabCase(str) {
67
+ if (str.match(/^(webkit|moz|ms)[A-Z]/)) {
68
+ return "-" + str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
69
+ }
70
+ if (str.startsWith("--")) {
71
+ return str;
72
+ }
73
+ return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
74
+ }
75
+ function normalizeValue(prop, value) {
76
+ if (typeof value === "number") {
77
+ const kebabProp = toKebabCase(prop);
78
+ if (UNITLESS_PROPS.has(kebabProp)) {
79
+ return String(value);
80
+ }
81
+ return `${value}px`;
82
+ }
83
+ return String(value);
84
+ }
85
+ function isPseudoOrMediaKey(key) {
86
+ return key.startsWith(":") || key.startsWith("@") || key.startsWith("&");
87
+ }
88
+ function validateStyleValue(value, path) {
89
+ if (value === null) {
90
+ throw new Error(
91
+ `Invalid style value at ${path}: null is not allowed. Use undefined or omit the property.`
92
+ );
93
+ }
94
+ if (typeof value === "function") {
95
+ throw new Error(
96
+ `Invalid style value at ${path}: functions must be resolved at build time.`
97
+ );
98
+ }
99
+ }
100
+ function processStyleValue(prop, value, cssRules, path = prop) {
101
+ validateStyleValue(value, path);
102
+ if (prop.startsWith("--")) {
103
+ const className2 = hashProperty(prop, value, cssRules);
104
+ if (!cssRules.has(className2)) {
105
+ const cssRule = `.${className2} { ${prop}: ${value}; }`;
106
+ cssRules.set(className2, cssRule);
107
+ }
108
+ return className2;
109
+ }
110
+ const kebabProp = toKebabCase(prop);
111
+ if (typeof value === "object" && !Array.isArray(value)) {
112
+ const classes = [];
113
+ for (const [nestedKey, nestedValue] of Object.entries(value)) {
114
+ validateStyleValue(nestedValue, `${path}.${nestedKey}`);
115
+ if (nestedKey === "default") {
116
+ const normalizedValue2 = normalizeValue(
117
+ prop,
118
+ nestedValue
119
+ );
120
+ const className2 = hashProperty(prop, normalizedValue2, cssRules);
121
+ if (!cssRules.has(className2)) {
122
+ const cssRule = `.${className2} { ${kebabProp}: ${normalizedValue2}; }`;
123
+ cssRules.set(className2, cssRule);
124
+ }
125
+ classes.push(className2);
126
+ } else if (isPseudoOrMediaKey(nestedKey)) {
127
+ const normalizedValue2 = normalizeValue(
128
+ prop,
129
+ nestedValue
130
+ );
131
+ const className2 = hashProperty(
132
+ `${prop}${nestedKey}`,
133
+ normalizedValue2,
134
+ cssRules
135
+ );
136
+ if (!cssRules.has(className2)) {
137
+ let cssRule;
138
+ if (nestedKey.startsWith("@")) {
139
+ cssRule = `${nestedKey} { .${className2} { ${kebabProp}: ${normalizedValue2}; } }`;
140
+ } else if (nestedKey.startsWith("&")) {
141
+ const selector = nestedKey.slice(1);
142
+ cssRule = `.${className2}${selector} { ${kebabProp}: ${normalizedValue2}; }`;
143
+ } else {
144
+ cssRule = `.${className2}${nestedKey} { ${kebabProp}: ${normalizedValue2}; }`;
145
+ }
146
+ cssRules.set(className2, cssRule);
147
+ }
148
+ classes.push(className2);
149
+ } else {
150
+ throw new Error(
151
+ `Invalid nested key "${nestedKey}" at ${path}. Expected "default", a pseudo-class (":hover"), media query ("@media"), or nesting selector ("&").`
152
+ );
153
+ }
154
+ }
155
+ return classes.join(" ");
156
+ }
157
+ const normalizedValue = normalizeValue(prop, value);
158
+ const className = hashProperty(prop, normalizedValue, cssRules);
159
+ if (!cssRules.has(className)) {
160
+ const cssRule = `.${className} { ${kebabProp}: ${normalizedValue}; }`;
161
+ cssRules.set(className, cssRule);
162
+ }
163
+ return className;
164
+ }
165
+ function processStyleObject(styleObj, cssRules) {
166
+ const result = {};
167
+ for (const [namespace, styles] of Object.entries(styleObj)) {
168
+ if (typeof styles !== "object" || Array.isArray(styles)) {
169
+ throw new Error(
170
+ `Invalid style namespace "${namespace}": expected an object, got ${typeof styles}`
171
+ );
172
+ }
173
+ const classes = [];
174
+ for (const [prop, value] of Object.entries(styles)) {
175
+ if (value === void 0) continue;
176
+ const className = processStyleValue(
177
+ prop,
178
+ value,
179
+ cssRules,
180
+ `${namespace}.${prop}`
181
+ );
182
+ if (className) {
183
+ classes.push(className);
184
+ }
185
+ }
186
+ result[namespace] = classes.filter(Boolean).join(" ");
187
+ }
188
+ return result;
189
+ }
190
+ function style$(style, context) {
191
+ if (!context) {
192
+ throw new Error(
193
+ "style$ macro requires MacroContext. Ensure you're using this as a build-time macro."
194
+ );
195
+ }
196
+ const rStyle = style;
197
+ const value = context.resolveNodeValue(rStyle);
198
+ if (value == void 0) {
199
+ throw new Error(
200
+ `Could not resolve style object at build time. Ensure all values are statically analyzable (no runtime expressions, dynamic imports should be inlined).`
201
+ );
202
+ }
203
+ if (typeof value !== "object" || Array.isArray(value)) {
204
+ throw new Error(
205
+ `style$ expects an object with style namespaces, got ${typeof value}`
206
+ );
207
+ }
208
+ const cssRules = /* @__PURE__ */ new Map();
209
+ const classNameMap = processStyleObject(value, cssRules);
210
+ context.store.set("style_rules", Array.from(cssRules.values()));
211
+ const properties = Object.entries(classNameMap).map(
212
+ ([key, className]) => context.factory.createPropertyAssignment(
213
+ context.factory.createStringLiteral(key),
214
+ context.factory.createStringLiteral(className)
215
+ )
216
+ );
217
+ return context.factory.createObjectLiteralExpression(properties, true);
218
+ }
219
+ function apply$(...c) {
220
+ if (c.length < 1) {
221
+ throw new Error("apply$ requires at least one argument plus MacroContext");
222
+ }
223
+ const context = c.pop();
224
+ if (!context || !context.factory) {
225
+ throw new Error(
226
+ "apply$ macro requires MacroContext as the last argument. Ensure you're using this as a build-time macro."
227
+ );
228
+ }
229
+ const args = c;
230
+ if (args.length === 0) {
231
+ return context.factory.createObjectLiteralExpression(
232
+ [
233
+ context.factory.createPropertyAssignment(
234
+ context.factory.createIdentifier("className"),
235
+ context.factory.createStringLiteral("")
236
+ )
237
+ ],
238
+ false
239
+ );
240
+ }
241
+ const f = context.factory;
242
+ function isTrue(e) {
243
+ return e.kind === ts.SyntaxKind.TrueKeyword;
244
+ }
245
+ function isFalse(e) {
246
+ return e.kind === ts.SyntaxKind.FalseKeyword;
247
+ }
248
+ function isEmptyString(e) {
249
+ return ts.isStringLiteral(e) && e.text === "";
250
+ }
251
+ function tryResolveStatic(expr) {
252
+ if (ts.isStringLiteral(expr)) {
253
+ return expr.text;
254
+ }
255
+ if (!ts.isPropertyAccessExpression(expr)) return null;
256
+ const chain = [];
257
+ let cur = expr;
258
+ while (ts.isPropertyAccessExpression(cur)) {
259
+ chain.unshift(cur.name.text);
260
+ cur = cur.expression;
261
+ }
262
+ if (!ts.isIdentifier(cur)) return null;
263
+ chain.unshift(cur.text);
264
+ const root = context.resolveIdentifier(f.createIdentifier(chain[0]));
265
+ let value = context.resolveNodeValue(root);
266
+ if (value == null) return null;
267
+ for (let i = 1; i < chain.length; i++) {
268
+ if (typeof value !== "object" || !(chain[i] in value)) {
269
+ return null;
270
+ }
271
+ value = value[chain[i]];
272
+ }
273
+ return typeof value === "string" ? value : null;
274
+ }
275
+ function build(expr) {
276
+ if (isEmptyString(expr)) {
277
+ return { kind: "static", value: "" };
278
+ }
279
+ const s = tryResolveStatic(expr);
280
+ if (s != null) {
281
+ return { kind: "static", value: s };
282
+ }
283
+ if (ts.isBinaryExpression(expr) && expr.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken) {
284
+ if (isTrue(expr.left)) return build(expr.right);
285
+ if (isFalse(expr.left)) return { kind: "static", value: "" };
286
+ const rs = tryResolveStatic(expr.right);
287
+ if (rs != null) {
288
+ return {
289
+ kind: "dynamic",
290
+ stringSafe: true,
291
+ expr: f.createElementAccessExpression(
292
+ f.createArrayLiteralExpression([
293
+ f.createStringLiteral(""),
294
+ f.createStringLiteral(rs)
295
+ ]),
296
+ f.createPrefixUnaryExpression(ts.SyntaxKind.PlusToken, expr.left)
297
+ )
298
+ };
299
+ }
300
+ return { kind: "dynamic", expr, stringSafe: false };
301
+ }
302
+ if (ts.isConditionalExpression(expr)) {
303
+ if (isTrue(expr.condition)) return build(expr.whenTrue);
304
+ if (isFalse(expr.condition)) return build(expr.whenFalse);
305
+ const t = tryResolveStatic(expr.whenTrue);
306
+ const fv = tryResolveStatic(expr.whenFalse);
307
+ if (t != null && fv != null) {
308
+ return {
309
+ kind: "dynamic",
310
+ stringSafe: true,
311
+ expr: f.createElementAccessExpression(
312
+ f.createArrayLiteralExpression([
313
+ f.createStringLiteral(fv),
314
+ f.createStringLiteral(t)
315
+ ]),
316
+ f.createPrefixUnaryExpression(
317
+ ts.SyntaxKind.PlusToken,
318
+ expr.condition
319
+ )
320
+ )
321
+ };
322
+ }
323
+ return { kind: "dynamic", expr, stringSafe: false };
324
+ }
325
+ return { kind: "dynamic", expr, stringSafe: false };
326
+ }
327
+ const frags = [];
328
+ for (const arg of args) {
329
+ const frag = build(arg);
330
+ if (frag.kind === "static" && frag.value === "") {
331
+ continue;
332
+ }
333
+ const last = frags[frags.length - 1];
334
+ if (frag.kind === "static" && last?.kind === "static") {
335
+ last.value += " " + frag.value;
336
+ } else {
337
+ frags.push(frag);
338
+ }
339
+ }
340
+ let classExpr;
341
+ if (frags.length === 0) {
342
+ classExpr = f.createStringLiteral("");
343
+ } else if (frags.every((f2) => f2.kind === "static")) {
344
+ classExpr = f.createStringLiteral(
345
+ frags.map((f2) => f2.value).join(" ").trim()
346
+ );
347
+ } else {
348
+ classExpr = f.createCallExpression(
349
+ f.createPropertyAccessExpression(
350
+ f.createArrayLiteralExpression(
351
+ frags.map((frag) => {
352
+ if (frag.kind === "static") {
353
+ return f.createStringLiteral(frag.value);
354
+ }
355
+ if (frag.stringSafe) {
356
+ return frag.expr;
357
+ }
358
+ return f.createConditionalExpression(
359
+ frag.expr,
360
+ void 0,
361
+ frag.expr,
362
+ void 0,
363
+ f.createStringLiteral("")
364
+ );
365
+ })
366
+ ),
367
+ "join"
368
+ ),
369
+ void 0,
370
+ [f.createStringLiteral(" ")]
371
+ );
372
+ }
373
+ return f.createObjectLiteralExpression(
374
+ [f.createPropertyAssignment(f.createIdentifier("className"), classExpr)],
375
+ false
376
+ );
377
+ }
378
+ export {
379
+ apply$,
380
+ style$
381
+ };
382
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/style/style.ts"],
4
+ "sourcesContent": ["import { MacroContext } from \"@kithinji/pod\";\nimport ts from \"typescript\";\nimport { MapNamespaces } from \"./style_types\";\n\nconst UNITLESS_PROPS = new Set([\n \"z-index\",\n \"opacity\",\n \"flex-grow\",\n \"flex-shrink\",\n \"flex\",\n \"order\",\n \"font-weight\",\n \"line-height\",\n \"zoom\",\n \"column-count\",\n \"animation-iteration-count\",\n \"grid-column\",\n \"grid-row\",\n \"grid-column-start\",\n \"grid-column-end\",\n \"grid-row-start\",\n \"grid-row-end\",\n \"tab-size\",\n \"counter-increment\",\n \"counter-reset\",\n \"orphans\",\n \"widows\",\n]);\n\nconst DEV_MODE = process.env.NODE_ENV === \"development\";\n\nfunction simpleHash(str: string): string {\n let hash = 0;\n for (let i = 0; i < str.length; i++) {\n const char = str.charCodeAt(i);\n hash = (hash << 5) - hash + char;\n hash = hash & hash;\n }\n\n return Math.abs(hash).toString(36).padStart(8, \"0\").slice(0, 8);\n}\n\nfunction hashProperty(\n prop: string,\n value: string | number,\n cssRules: Map<string, string>\n): string {\n const input = `${prop}:${value}`;\n let hash = simpleHash(input);\n let className: string;\n\n if (DEV_MODE) {\n // Add readable hint in development\n const hint = prop\n .replace(/[^a-z]/gi, \"\")\n .slice(0, 3)\n .toLowerCase();\n className = `a-${hint}-${hash}`;\n } else {\n className = `a-${hash}`;\n }\n\n let attempt = 0;\n\n // Handle hash collisions\n while (cssRules.has(className)) {\n const existing = cssRules.get(className)!;\n const kebabProp = toKebabCase(prop);\n const normalizedValue = normalizeValue(prop, value);\n const expectedRule = `.${className} { ${kebabProp}: ${normalizedValue}; }`;\n\n // If the existing rule matches, it's the same style (deduplication)\n if (existing.includes(`${kebabProp}: ${normalizedValue}`)) {\n break;\n }\n\n // Collision detected, rehash\n hash = simpleHash(`${input}-${++attempt}`);\n className = DEV_MODE ? `a-${prop.slice(0, 3)}-${hash}` : `a-${hash}`;\n\n if (attempt > 100) {\n throw new Error(\n `Hash collision limit exceeded for property ${prop}:${value}`\n );\n }\n }\n\n return className;\n}\n\nfunction toKebabCase(str: string): string {\n // Handle vendor prefixes (webkit, moz, ms)\n if (str.match(/^(webkit|moz|ms)[A-Z]/)) {\n return \"-\" + str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n }\n\n // Handle CSS custom properties\n if (str.startsWith(\"--\")) {\n return str;\n }\n\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\nfunction normalizeValue(prop: string, value: string | number): string {\n if (typeof value === \"number\") {\n const kebabProp = toKebabCase(prop);\n\n if (UNITLESS_PROPS.has(kebabProp)) {\n return String(value);\n }\n\n return `${value}px`;\n }\n\n return String(value);\n}\n\nfunction isPseudoOrMediaKey(key: string): boolean {\n return key.startsWith(\":\") || key.startsWith(\"@\") || key.startsWith(\"&\");\n}\n\nfunction validateStyleValue(value: any, path: string): void {\n if (value === null) {\n throw new Error(\n `Invalid style value at ${path}: null is not allowed. Use undefined or omit the property.`\n );\n }\n\n if (typeof value === \"function\") {\n throw new Error(\n `Invalid style value at ${path}: functions must be resolved at build time.`\n );\n }\n}\n\nfunction processStyleValue(\n prop: string,\n value: any,\n cssRules: Map<string, string>,\n path: string = prop\n): string {\n validateStyleValue(value, path);\n\n if (prop.startsWith(\"--\")) {\n const className = hashProperty(prop, value, cssRules);\n if (!cssRules.has(className)) {\n const cssRule = `.${className} { ${prop}: ${value}; }`;\n cssRules.set(className, cssRule);\n }\n return className;\n }\n\n const kebabProp = toKebabCase(prop);\n\n // Handle nested objects for pseudo-classes, media queries, etc.\n if (typeof value === \"object\" && !Array.isArray(value)) {\n const classes: string[] = [];\n\n for (const [nestedKey, nestedValue] of Object.entries(value)) {\n validateStyleValue(nestedValue, `${path}.${nestedKey}`);\n\n if (nestedKey === \"default\") {\n const normalizedValue = normalizeValue(\n prop,\n nestedValue as string | number\n );\n const className = hashProperty(prop, normalizedValue, cssRules);\n\n if (!cssRules.has(className)) {\n const cssRule = `.${className} { ${kebabProp}: ${normalizedValue}; }`;\n cssRules.set(className, cssRule);\n }\n\n classes.push(className);\n } else if (isPseudoOrMediaKey(nestedKey)) {\n const normalizedValue = normalizeValue(\n prop,\n nestedValue as string | number\n );\n const className = hashProperty(\n `${prop}${nestedKey}`,\n normalizedValue,\n cssRules\n );\n\n if (!cssRules.has(className)) {\n let cssRule: string;\n\n if (nestedKey.startsWith(\"@\")) {\n // Media query\n cssRule = `${nestedKey} { .${className} { ${kebabProp}: ${normalizedValue}; } }`;\n } else if (nestedKey.startsWith(\"&\")) {\n // Nesting selector (e.g., &:hover, & > div)\n const selector = nestedKey.slice(1);\n cssRule = `.${className}${selector} { ${kebabProp}: ${normalizedValue}; }`;\n } else {\n // Pseudo-class/element (e.g., :hover, ::before)\n cssRule = `.${className}${nestedKey} { ${kebabProp}: ${normalizedValue}; }`;\n }\n\n cssRules.set(className, cssRule);\n }\n\n classes.push(className);\n } else {\n throw new Error(\n `Invalid nested key \"${nestedKey}\" at ${path}. Expected \"default\", a pseudo-class (\":hover\"), media query (\"@media\"), or nesting selector (\"&\").`\n );\n }\n }\n\n return classes.join(\" \");\n }\n\n const normalizedValue = normalizeValue(prop, value);\n const className = hashProperty(prop, normalizedValue, cssRules);\n\n if (!cssRules.has(className)) {\n const cssRule = `.${className} { ${kebabProp}: ${normalizedValue}; }`;\n cssRules.set(className, cssRule);\n }\n\n return className;\n}\n\nfunction processStyleObject(\n styleObj: Record<string, any>,\n cssRules: Map<string, string>\n): Record<string, string> {\n const result: Record<string, string> = {};\n\n for (const [namespace, styles] of Object.entries(styleObj)) {\n if (typeof styles !== \"object\" || Array.isArray(styles)) {\n throw new Error(\n `Invalid style namespace \"${namespace}\": expected an object, got ${typeof styles}`\n );\n }\n\n const classes: string[] = [];\n\n for (const [prop, value] of Object.entries(styles)) {\n if (value === undefined) continue;\n\n const className = processStyleValue(\n prop,\n value,\n cssRules,\n `${namespace}.${prop}`\n );\n\n if (className) {\n classes.push(className);\n }\n }\n\n result[namespace] = classes.filter(Boolean).join(\" \");\n }\n\n return result;\n}\n\nexport function style$<const T extends Record<string, any>>(\n style: T,\n context?: MacroContext\n): MapNamespaces<T> {\n if (!context) {\n throw new Error(\n \"style$ macro requires MacroContext. Ensure you're using this as a build-time macro.\"\n );\n }\n\n const rStyle = style as unknown as ts.Node;\n const value = context.resolveNodeValue(rStyle);\n\n if (value == undefined) {\n throw new Error(\n `Could not resolve style object at build time. ` +\n `Ensure all values are statically analyzable (no runtime expressions, dynamic imports should be inlined).`\n );\n }\n\n if (typeof value !== \"object\" || Array.isArray(value)) {\n throw new Error(\n `style$ expects an object with style namespaces, got ${typeof value}`\n );\n }\n\n const cssRules = new Map<string, string>();\n const classNameMap = processStyleObject(value, cssRules);\n\n context.store.set(\"style_rules\", Array.from(cssRules.values()));\n\n const properties = Object.entries(classNameMap).map(([key, className]) =>\n context.factory.createPropertyAssignment(\n context.factory.createStringLiteral(key),\n context.factory.createStringLiteral(className)\n )\n );\n\n return context.factory.createObjectLiteralExpression(properties, true) as any;\n}\n\ntype Fragment =\n | { kind: \"static\"; value: string }\n | { kind: \"dynamic\"; expr: ts.Expression; stringSafe: boolean };\n\nexport function apply$(...c: any[]) {\n if (c.length < 1) {\n throw new Error(\"apply$ requires at least one argument plus MacroContext\");\n }\n\n const context = c.pop() as MacroContext;\n\n if (!context || !context.factory) {\n throw new Error(\n \"apply$ macro requires MacroContext as the last argument. Ensure you're using this as a build-time macro.\"\n );\n }\n\n const args = c as ts.Expression[];\n\n if (args.length === 0) {\n return context.factory.createObjectLiteralExpression(\n [\n context.factory.createPropertyAssignment(\n context.factory.createIdentifier(\"className\"),\n context.factory.createStringLiteral(\"\")\n ),\n ],\n false\n );\n }\n\n const f = context.factory;\n\n function isTrue(e: ts.Expression): boolean {\n return e.kind === ts.SyntaxKind.TrueKeyword;\n }\n\n function isFalse(e: ts.Expression): boolean {\n return e.kind === ts.SyntaxKind.FalseKeyword;\n }\n\n function isEmptyString(e: ts.Expression): boolean {\n return ts.isStringLiteral(e) && e.text === \"\";\n }\n\n function tryResolveStatic(expr: ts.Expression): string | null {\n // Try to resolve string literals directly\n if (ts.isStringLiteral(expr)) {\n return expr.text;\n }\n\n // Try to resolve property access chains (e.g., classes.button)\n if (!ts.isPropertyAccessExpression(expr)) return null;\n\n const chain: string[] = [];\n let cur: ts.Expression = expr;\n\n while (ts.isPropertyAccessExpression(cur)) {\n chain.unshift(cur.name.text);\n cur = cur.expression;\n }\n\n if (!ts.isIdentifier(cur)) return null;\n chain.unshift(cur.text);\n\n const root = context.resolveIdentifier(f.createIdentifier(chain[0]));\n let value = context.resolveNodeValue(root);\n\n if (value == null) return null;\n\n for (let i = 1; i < chain.length; i++) {\n if (typeof value !== \"object\" || !(chain[i] in value)) {\n return null;\n }\n value = value[chain[i]];\n }\n\n return typeof value === \"string\" ? value : null;\n }\n\n function build(expr: ts.Expression): Fragment {\n // Handle empty strings\n if (isEmptyString(expr)) {\n return { kind: \"static\", value: \"\" };\n }\n\n // Try static resolution first\n const s = tryResolveStatic(expr);\n if (s != null) {\n return { kind: \"static\", value: s };\n }\n\n // Handle: condition && \"class\"\n if (\n ts.isBinaryExpression(expr) &&\n expr.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken\n ) {\n if (isTrue(expr.left)) return build(expr.right);\n if (isFalse(expr.left)) return { kind: \"static\", value: \"\" };\n\n const rs = tryResolveStatic(expr.right);\n if (rs != null) {\n // Optimize to: [\"\", \"class\"][+condition]\n return {\n kind: \"dynamic\",\n stringSafe: true,\n expr: f.createElementAccessExpression(\n f.createArrayLiteralExpression([\n f.createStringLiteral(\"\"),\n f.createStringLiteral(rs),\n ]),\n f.createPrefixUnaryExpression(ts.SyntaxKind.PlusToken, expr.left)\n ),\n };\n }\n\n return { kind: \"dynamic\", expr, stringSafe: false };\n }\n\n // Handle: condition ? \"a\" : \"b\"\n if (ts.isConditionalExpression(expr)) {\n if (isTrue(expr.condition)) return build(expr.whenTrue);\n if (isFalse(expr.condition)) return build(expr.whenFalse);\n\n const t = tryResolveStatic(expr.whenTrue);\n const fv = tryResolveStatic(expr.whenFalse);\n\n if (t != null && fv != null) {\n // Optimize to: [\"b\", \"a\"][+condition]\n return {\n kind: \"dynamic\",\n stringSafe: true,\n expr: f.createElementAccessExpression(\n f.createArrayLiteralExpression([\n f.createStringLiteral(fv),\n f.createStringLiteral(t),\n ]),\n f.createPrefixUnaryExpression(\n ts.SyntaxKind.PlusToken,\n expr.condition\n )\n ),\n };\n }\n\n return { kind: \"dynamic\", expr, stringSafe: false };\n }\n\n return { kind: \"dynamic\", expr, stringSafe: false };\n }\n\n // Build and merge fragments\n const frags: Fragment[] = [];\n\n for (const arg of args) {\n const frag = build(arg);\n\n // Skip empty static values\n if (frag.kind === \"static\" && frag.value === \"\") {\n continue;\n }\n\n const last = frags[frags.length - 1];\n\n // Merge consecutive static fragments\n if (frag.kind === \"static\" && last?.kind === \"static\") {\n last.value += \" \" + frag.value;\n } else {\n frags.push(frag);\n }\n }\n\n // Generate final className expression\n let classExpr: ts.Expression;\n\n if (frags.length === 0) {\n // All classes were empty\n classExpr = f.createStringLiteral(\"\");\n } else if (frags.every((f) => f.kind === \"static\")) {\n // All static - compile to single string\n classExpr = f.createStringLiteral(\n frags\n .map((f) => f.value)\n .join(\" \")\n .trim()\n );\n } else {\n // Mixed static/dynamic - generate array.join(\" \")\n classExpr = f.createCallExpression(\n f.createPropertyAccessExpression(\n f.createArrayLiteralExpression(\n frags.map((frag) => {\n if (frag.kind === \"static\") {\n return f.createStringLiteral(frag.value);\n }\n if (frag.stringSafe) {\n return frag.expr;\n }\n // Wrap unsafe expressions in conditional: expr ? expr : \"\"\n return f.createConditionalExpression(\n frag.expr,\n undefined,\n frag.expr,\n undefined,\n f.createStringLiteral(\"\")\n );\n })\n ),\n \"join\"\n ),\n undefined,\n [f.createStringLiteral(\" \")]\n );\n }\n\n return f.createObjectLiteralExpression(\n [f.createPropertyAssignment(f.createIdentifier(\"className\"), classExpr)],\n false\n );\n}\n"],
5
+ "mappings": ";AACA,OAAO,QAAQ;AAGf,IAAM,iBAAiB,oBAAI,IAAI;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,IAAM,WAAW,QAAQ,IAAI,aAAa;AAE1C,SAAS,WAAW,KAAqB;AACvC,MAAI,OAAO;AACX,WAAS,IAAI,GAAG,IAAI,IAAI,QAAQ,KAAK;AACnC,UAAM,OAAO,IAAI,WAAW,CAAC;AAC7B,YAAQ,QAAQ,KAAK,OAAO;AAC5B,WAAO,OAAO;AAAA,EAChB;AAEA,SAAO,KAAK,IAAI,IAAI,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,EAAE,MAAM,GAAG,CAAC;AAChE;AAEA,SAAS,aACP,MACA,OACA,UACQ;AACR,QAAM,QAAQ,GAAG,IAAI,IAAI,KAAK;AAC9B,MAAI,OAAO,WAAW,KAAK;AAC3B,MAAI;AAEJ,MAAI,UAAU;AAEZ,UAAM,OAAO,KACV,QAAQ,YAAY,EAAE,EACtB,MAAM,GAAG,CAAC,EACV,YAAY;AACf,gBAAY,KAAK,IAAI,IAAI,IAAI;AAAA,EAC/B,OAAO;AACL,gBAAY,KAAK,IAAI;AAAA,EACvB;AAEA,MAAI,UAAU;AAGd,SAAO,SAAS,IAAI,SAAS,GAAG;AAC9B,UAAM,WAAW,SAAS,IAAI,SAAS;AACvC,UAAM,YAAY,YAAY,IAAI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AAC,EAAE,oBAAoB,GAAG,CAAC;AAAA,IAC7B;AAAA,EACF;AAEA,SAAO,EAAE;AAAA,IACP,CAAC,EAAE,yBAAyB,EAAE,iBAAiB,WAAW,GAAG,SAAS,CAAC;AAAA,IACvE;AAAA,EACF;AACF;",
6
+ "names": ["className", "normalizedValue", "f"]
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/assert/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export * from "./style";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./style";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/style/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { MacroContext } from "@kithinji/pod";
2
+ import ts from "typescript";
3
+ import { MapNamespaces } from "./style_types";
4
+ export declare function style$<const T extends Record<string, any>>(style: T, context?: MacroContext): MapNamespaces<T>;
5
+ export declare function apply$(...c: any[]): ts.ObjectLiteralExpression;
6
+ //# sourceMappingURL=style.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../src/style/style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAoQ9C,wBAAgB,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACxD,KAAK,EAAE,CAAC,EACR,OAAO,CAAC,EAAE,YAAY,GACrB,aAAa,CAAC,CAAC,CAAC,CAoClB;AAMD,wBAAgB,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,8BAuNjC"}
@@ -0,0 +1,70 @@
1
+ import { CSSProperties } from "./types";
2
+ import { CSSType } from "./var_types";
3
+ declare const StyleClassNameTag: unique symbol;
4
+ export type StyleClassNameFor<K, V> = string & {
5
+ _opaque: typeof StyleClassNameTag;
6
+ _key: K;
7
+ _value: V;
8
+ };
9
+ declare class _StyleVar<out Val> {
10
+ private _opaque;
11
+ private _value;
12
+ }
13
+ export type StyleVar<Val> = _StyleVar<Val> & string;
14
+ type PseudoClassStr = `:${string}`;
15
+ type AtRuleStr = `@${string}`;
16
+ type CondStr = PseudoClassStr | AtRuleStr;
17
+ type CSSPropertiesWithExtras = Partial<Readonly<CSSProperties & {
18
+ "::after": CSSProperties;
19
+ "::backdrop": CSSProperties;
20
+ "::before": CSSProperties;
21
+ "::cue": CSSProperties;
22
+ "::cue-region": CSSProperties;
23
+ "::first-letter": CSSProperties;
24
+ "::first-line": CSSProperties;
25
+ "::file-selector-button": CSSProperties;
26
+ "::grammar-error": CSSProperties;
27
+ "::marker": CSSProperties;
28
+ "::placeholder": CSSProperties;
29
+ "::selection": CSSProperties;
30
+ "::spelling-error": CSSProperties;
31
+ "::target-text": CSSProperties;
32
+ "::-webkit-scrollbar"?: CSSProperties;
33
+ "::-webkit-scrollbar-button"?: CSSProperties;
34
+ "::-webkit-scrollbar-thumb"?: CSSProperties;
35
+ "::-webkit-scrollbar-track"?: CSSProperties;
36
+ "::-webkit-scrollbar-track-piece"?: CSSProperties;
37
+ "::-webkit-scrollbar-corner"?: CSSProperties;
38
+ "::-webkit-resizer"?: CSSProperties;
39
+ "::-webkit-search-decoration"?: CSSProperties;
40
+ "::-webkit-search-cancel-button"?: CSSProperties;
41
+ "::-webkit-search-results-button"?: CSSProperties;
42
+ "::-webkit-search-results-decoration"?: CSSProperties;
43
+ "::-webkit-slider-thumb"?: CSSProperties;
44
+ "::-webkit-slider-runnable-track"?: CSSProperties;
45
+ "::-moz-range-thumb"?: CSSProperties;
46
+ "::-moz-range-track"?: CSSProperties;
47
+ "::-moz-range-progress"?: CSSProperties;
48
+ }>>;
49
+ type NotUndefined = {} | null;
50
+ type UserAuthoredStyles = CSSPropertiesWithExtras | {
51
+ [key: string]: NotUndefined;
52
+ };
53
+ type ComplexStyleValueType<T> = T extends StyleVar<infer U> ? U extends CSSType<infer V> ? V : U : T extends string | number | null | symbol ? T : T extends ReadonlyArray<infer U> ? ComplexStyleValueType<U> : T extends Readonly<{
54
+ default: infer A;
55
+ [cond: CondStr]: infer B;
56
+ }> ? ComplexStyleValueType<A> | ComplexStyleValueType<B> : T;
57
+ declare const StyleInlineStylesTag: unique symbol;
58
+ export type InlineStyles = {
59
+ _opaque: typeof StyleInlineStylesTag;
60
+ };
61
+ export type MapNamespace<CSS> = Readonly<{
62
+ [Key in keyof CSS]: StyleClassNameFor<Key, ComplexStyleValueType<CSS[Key]>>;
63
+ }>;
64
+ export type MapNamespaces<S extends {
65
+ [key: string]: UserAuthoredStyles | ((...args: any) => UserAuthoredStyles);
66
+ }> = Readonly<{
67
+ [Key in keyof S]: S[Key] extends (...args: infer Args) => infer Obj ? (...args: Args) => Readonly<[MapNamespace<Obj>, InlineStyles]> : MapNamespace<S[Key]>;
68
+ }>;
69
+ export {};
70
+ //# sourceMappingURL=style_types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style_types.d.ts","sourceRoot":"","sources":["../../../src/style/style_types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,CAAC,MAAM,iBAAiB,EAAE,OAAO,MAAM,CAAC;AAC/C,MAAM,MAAM,iBAAiB,CAAC,CAAC,EAAE,CAAC,IAAI,MAAM,GA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