@kithinji/arcane 1.0.7 → 1.0.9
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/dist/browser/index.mjs +15 -28
- package/dist/browser/index.mjs.map +2 -2
- package/dist/node/index.cjs +218 -37
- package/dist/node/index.cjs.map +3 -3
- package/dist/node/index.mjs +214 -37
- package/dist/node/index.mjs.map +3 -3
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.node.d.ts +1 -1
- package/dist/types/index.node.d.ts.map +1 -1
- package/dist/types/inline/index.d.ts +2 -0
- package/dist/types/inline/index.d.ts.map +1 -0
- package/dist/types/inline/inline.d.ts +17 -0
- package/dist/types/inline/inline.d.ts.map +1 -0
- package/dist/types/inline-file/inline.d.ts +1 -0
- package/dist/types/inline-file/inline.d.ts.map +1 -1
- package/dist/types/style/style.d.ts +2 -2
- package/dist/types/style/style.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/index.node.ts +1 -1
- package/src/index.ts +1 -1
- package/src/inline/inline.ts +320 -0
- package/src/style/style.ts +42 -58
- package/src/inline-file/inline.ts +0 -38
- /package/src/{inline-file → inline}/index.ts +0 -0
package/dist/node/index.cjs
CHANGED
|
@@ -31,7 +31,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_node_exports = {};
|
|
32
32
|
__export(index_node_exports, {
|
|
33
33
|
apply$: () => apply$,
|
|
34
|
+
inlineDataURL$: () => inlineDataURL$,
|
|
35
|
+
inlineDataURLs$: () => inlineDataURLs$,
|
|
34
36
|
inlineFile$: () => inlineFile$,
|
|
37
|
+
inlineFileBase64$: () => inlineFileBase64$,
|
|
38
|
+
inlineFiles$: () => inlineFiles$,
|
|
35
39
|
style$: () => style$
|
|
36
40
|
});
|
|
37
41
|
module.exports = __toCommonJS(index_node_exports);
|
|
@@ -225,14 +229,9 @@ function processStyleObject(styleObj, cssRules) {
|
|
|
225
229
|
}
|
|
226
230
|
return result;
|
|
227
231
|
}
|
|
228
|
-
function style$(style
|
|
229
|
-
if (!context) {
|
|
230
|
-
throw new Error(
|
|
231
|
-
"style$ macro requires MacroContext. Ensure you're using this as a build-time macro."
|
|
232
|
-
);
|
|
233
|
-
}
|
|
232
|
+
function style$(style) {
|
|
234
233
|
const rStyle = style;
|
|
235
|
-
const value =
|
|
234
|
+
const value = this.resolveNodeValue(rStyle);
|
|
236
235
|
if (value == void 0) {
|
|
237
236
|
throw new Error(
|
|
238
237
|
`Could not resolve style object at build time. Ensure all values are statically analyzable (no runtime expressions, dynamic imports should be inlined).`
|
|
@@ -245,38 +244,30 @@ function style$(style, context) {
|
|
|
245
244
|
}
|
|
246
245
|
const cssRules = /* @__PURE__ */ new Map();
|
|
247
246
|
const classNameMap = processStyleObject(value, cssRules);
|
|
248
|
-
|
|
247
|
+
this.store.set("style_rules", Array.from(cssRules.values()));
|
|
249
248
|
const properties = Object.entries(classNameMap).map(
|
|
250
|
-
([key, className]) =>
|
|
251
|
-
|
|
252
|
-
|
|
249
|
+
([key, className]) => this.factory.createPropertyAssignment(
|
|
250
|
+
this.factory.createStringLiteral(key),
|
|
251
|
+
this.factory.createStringLiteral(className)
|
|
253
252
|
)
|
|
254
253
|
);
|
|
255
|
-
return
|
|
254
|
+
return this.factory.createObjectLiteralExpression(properties, true);
|
|
256
255
|
}
|
|
257
256
|
function apply$(...c) {
|
|
258
|
-
if (c.length < 1) {
|
|
259
|
-
throw new Error("apply$ requires at least one argument plus MacroContext");
|
|
260
|
-
}
|
|
261
|
-
const context = c.pop();
|
|
262
|
-
if (!context || !context.factory) {
|
|
263
|
-
throw new Error(
|
|
264
|
-
"apply$ macro requires MacroContext as the last argument. Ensure you're using this as a build-time macro."
|
|
265
|
-
);
|
|
266
|
-
}
|
|
267
257
|
const args = c;
|
|
258
|
+
const self = this;
|
|
268
259
|
if (args.length === 0) {
|
|
269
|
-
return
|
|
260
|
+
return self.factory.createObjectLiteralExpression(
|
|
270
261
|
[
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
262
|
+
self.factory.createPropertyAssignment(
|
|
263
|
+
self.factory.createIdentifier("className"),
|
|
264
|
+
self.factory.createStringLiteral("")
|
|
274
265
|
)
|
|
275
266
|
],
|
|
276
267
|
false
|
|
277
268
|
);
|
|
278
269
|
}
|
|
279
|
-
const f =
|
|
270
|
+
const f = self.factory;
|
|
280
271
|
function isTrue(e) {
|
|
281
272
|
return e.kind === import_typescript.default.SyntaxKind.TrueKeyword;
|
|
282
273
|
}
|
|
@@ -299,8 +290,8 @@ function apply$(...c) {
|
|
|
299
290
|
}
|
|
300
291
|
if (!import_typescript.default.isIdentifier(cur)) return null;
|
|
301
292
|
chain.unshift(cur.text);
|
|
302
|
-
const root =
|
|
303
|
-
let value =
|
|
293
|
+
const root = self.resolveIdentifier(f.createIdentifier(chain[0]));
|
|
294
|
+
let value = self.resolveNodeValue(root);
|
|
304
295
|
if (value == null) return null;
|
|
305
296
|
for (let i = 1; i < chain.length; i++) {
|
|
306
297
|
if (typeof value !== "object" || !(chain[i] in value)) {
|
|
@@ -414,39 +405,229 @@ function apply$(...c) {
|
|
|
414
405
|
);
|
|
415
406
|
}
|
|
416
407
|
|
|
417
|
-
// src/inline
|
|
408
|
+
// src/inline/inline.ts
|
|
418
409
|
var import_fs = __toESM(require("fs"), 1);
|
|
419
410
|
var import_path = __toESM(require("path"), 1);
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
411
|
+
var MIME_TYPES = {
|
|
412
|
+
".png": "image/png",
|
|
413
|
+
".jpg": "image/jpeg",
|
|
414
|
+
".jpeg": "image/jpeg",
|
|
415
|
+
".gif": "image/gif",
|
|
416
|
+
".svg": "image/svg+xml",
|
|
417
|
+
".webp": "image/webp",
|
|
418
|
+
".ico": "image/x-icon",
|
|
419
|
+
".bmp": "image/bmp",
|
|
420
|
+
".woff": "font/woff",
|
|
421
|
+
".woff2": "font/woff2",
|
|
422
|
+
".ttf": "font/ttf",
|
|
423
|
+
".otf": "font/otf",
|
|
424
|
+
".eot": "application/vnd.ms-fontobject",
|
|
425
|
+
".mp3": "audio/mpeg",
|
|
426
|
+
".wav": "audio/wav",
|
|
427
|
+
".ogg": "audio/ogg",
|
|
428
|
+
".mp4": "video/mp4",
|
|
429
|
+
".webm": "video/webm",
|
|
430
|
+
".pdf": "application/pdf",
|
|
431
|
+
".zip": "application/zip",
|
|
432
|
+
".txt": "text/plain",
|
|
433
|
+
".html": "text/html",
|
|
434
|
+
".css": "text/css",
|
|
435
|
+
".js": "text/javascript",
|
|
436
|
+
".json": "application/json",
|
|
437
|
+
".xml": "application/xml"
|
|
438
|
+
};
|
|
439
|
+
function getMimeType(filePath) {
|
|
440
|
+
const ext = import_path.default.extname(filePath).toLowerCase();
|
|
441
|
+
return MIME_TYPES[ext] || "application/octet-stream";
|
|
442
|
+
}
|
|
443
|
+
function resolveFilePath(filePath, context, macroName) {
|
|
426
444
|
const pathNode = filePath;
|
|
427
445
|
const resolvedPath = context.resolveNodeValue(pathNode);
|
|
428
446
|
if (typeof resolvedPath !== "string") {
|
|
429
447
|
throw new Error(
|
|
430
|
-
|
|
448
|
+
`${macroName} requires a string literal path, got: ${typeof resolvedPath}`
|
|
431
449
|
);
|
|
432
450
|
}
|
|
433
451
|
const sourceFile = context.sourceFile;
|
|
434
452
|
const sourceDir = import_path.default.dirname(sourceFile.fileName);
|
|
435
453
|
const absolutePath = import_path.default.resolve(sourceDir, resolvedPath);
|
|
454
|
+
return absolutePath;
|
|
455
|
+
}
|
|
456
|
+
function inlineFile$(filePath, options) {
|
|
457
|
+
const absolutePath = resolveFilePath(filePath, this, "inlineFile$");
|
|
458
|
+
const maxSize = options?.maxSize || 1024 * 1024;
|
|
436
459
|
let content;
|
|
437
460
|
try {
|
|
461
|
+
const stats = import_fs.default.statSync(absolutePath);
|
|
462
|
+
if (stats.size > maxSize) {
|
|
463
|
+
throw new Error(
|
|
464
|
+
`File "${absolutePath}" is too large (${stats.size} bytes). Maximum allowed: ${maxSize} bytes. Consider using uploadFile$ instead.`
|
|
465
|
+
);
|
|
466
|
+
}
|
|
438
467
|
content = import_fs.default.readFileSync(absolutePath, "utf-8");
|
|
439
468
|
} catch (error) {
|
|
469
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
470
|
+
throw new Error(
|
|
471
|
+
`File not found: "${absolutePath}" (referenced in ${this.sourceFile.fileName})`
|
|
472
|
+
);
|
|
473
|
+
}
|
|
474
|
+
throw new Error(
|
|
475
|
+
`Failed to read file "${absolutePath}": ${error instanceof Error ? error.message : String(error)}`
|
|
476
|
+
);
|
|
477
|
+
}
|
|
478
|
+
return this.factory.createStringLiteral(content);
|
|
479
|
+
}
|
|
480
|
+
function inlineFiles$(filePaths, options) {
|
|
481
|
+
const pathsNode = filePaths;
|
|
482
|
+
const resolvedPaths = this.resolveNodeValue(pathsNode);
|
|
483
|
+
if (!Array.isArray(resolvedPaths)) {
|
|
484
|
+
throw new Error(
|
|
485
|
+
`inlineFiles$ requires an array of string literals, got: ${typeof resolvedPaths}`
|
|
486
|
+
);
|
|
487
|
+
}
|
|
488
|
+
const sourceFile = this.sourceFile;
|
|
489
|
+
const sourceDir = import_path.default.dirname(sourceFile.fileName);
|
|
490
|
+
const maxSize = options?.maxSize || 1024 * 1024;
|
|
491
|
+
const fileContents = [];
|
|
492
|
+
for (const filePath of resolvedPaths) {
|
|
493
|
+
if (typeof filePath !== "string") {
|
|
494
|
+
throw new Error(
|
|
495
|
+
`inlineFiles$ requires all paths to be string literals, got: ${typeof filePath}`
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
const absolutePath = import_path.default.resolve(sourceDir, filePath);
|
|
499
|
+
try {
|
|
500
|
+
const stats = import_fs.default.statSync(absolutePath);
|
|
501
|
+
if (stats.size > maxSize) {
|
|
502
|
+
throw new Error(
|
|
503
|
+
`File "${absolutePath}" is too large (${stats.size} bytes). Maximum allowed: ${maxSize} bytes.`
|
|
504
|
+
);
|
|
505
|
+
}
|
|
506
|
+
const content = import_fs.default.readFileSync(absolutePath, "utf-8");
|
|
507
|
+
fileContents.push(content);
|
|
508
|
+
} catch (error) {
|
|
509
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
510
|
+
throw new Error(
|
|
511
|
+
`File not found: "${absolutePath}" (referenced in ${sourceFile.fileName})`
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
throw new Error(
|
|
515
|
+
`Failed to read file "${absolutePath}": ${error instanceof Error ? error.message : String(error)}`
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
const elements = fileContents.map(
|
|
520
|
+
(content) => this.factory.createStringLiteral(content)
|
|
521
|
+
);
|
|
522
|
+
return this.factory.createArrayLiteralExpression(elements, true);
|
|
523
|
+
}
|
|
524
|
+
function inlineFileBase64$(filePath, options) {
|
|
525
|
+
const absolutePath = resolveFilePath(filePath, this, "inlineFileBase64$");
|
|
526
|
+
const maxSize = options?.maxSize || 100 * 1024;
|
|
527
|
+
let content;
|
|
528
|
+
try {
|
|
529
|
+
const stats = import_fs.default.statSync(absolutePath);
|
|
530
|
+
if (stats.size > maxSize) {
|
|
531
|
+
throw new Error(
|
|
532
|
+
`File "${absolutePath}" is too large (${stats.size} bytes). Maximum allowed: ${maxSize} bytes. Consider using uploadFile$ instead.`
|
|
533
|
+
);
|
|
534
|
+
}
|
|
535
|
+
const buffer = import_fs.default.readFileSync(absolutePath);
|
|
536
|
+
content = buffer.toString("base64");
|
|
537
|
+
} catch (error) {
|
|
538
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
539
|
+
throw new Error(
|
|
540
|
+
`File not found: "${absolutePath}" (referenced in ${this.sourceFile.fileName})`
|
|
541
|
+
);
|
|
542
|
+
}
|
|
543
|
+
throw new Error(
|
|
544
|
+
`Failed to read file "${absolutePath}": ${error instanceof Error ? error.message : String(error)}`
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
return this.factory.createStringLiteral(content);
|
|
548
|
+
}
|
|
549
|
+
function inlineDataURL$(filePath, options) {
|
|
550
|
+
const absolutePath = resolveFilePath(filePath, this, "inlineDataURL$");
|
|
551
|
+
const maxSize = options?.maxSize || 100 * 1024;
|
|
552
|
+
let dataURL;
|
|
553
|
+
try {
|
|
554
|
+
const stats = import_fs.default.statSync(absolutePath);
|
|
555
|
+
if (stats.size > maxSize) {
|
|
556
|
+
throw new Error(
|
|
557
|
+
`File "${absolutePath}" is too large (${stats.size} bytes). Maximum allowed: ${maxSize} bytes. Consider using uploadFile$ instead.`
|
|
558
|
+
);
|
|
559
|
+
}
|
|
560
|
+
const mimeType = options?.mimeType || getMimeType(absolutePath);
|
|
561
|
+
const buffer = import_fs.default.readFileSync(absolutePath);
|
|
562
|
+
const base64 = buffer.toString("base64");
|
|
563
|
+
dataURL = `data:${mimeType};base64,${base64}`;
|
|
564
|
+
} catch (error) {
|
|
565
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
566
|
+
throw new Error(
|
|
567
|
+
`File not found: "${absolutePath}" (referenced in ${this.sourceFile.fileName})`
|
|
568
|
+
);
|
|
569
|
+
}
|
|
440
570
|
throw new Error(
|
|
441
571
|
`Failed to read file "${absolutePath}": ${error instanceof Error ? error.message : String(error)}`
|
|
442
572
|
);
|
|
443
573
|
}
|
|
444
|
-
return
|
|
574
|
+
return this.factory.createStringLiteral(dataURL);
|
|
575
|
+
}
|
|
576
|
+
function inlineDataURLs$(filePaths, options) {
|
|
577
|
+
const pathsNode = filePaths;
|
|
578
|
+
const resolvedPaths = this.resolveNodeValue(pathsNode);
|
|
579
|
+
if (!Array.isArray(resolvedPaths)) {
|
|
580
|
+
throw new Error(
|
|
581
|
+
`inlineDataURLs$ requires an array of string literals, got: ${typeof resolvedPaths}`
|
|
582
|
+
);
|
|
583
|
+
}
|
|
584
|
+
const sourceFile = this.sourceFile;
|
|
585
|
+
const sourceDir = import_path.default.dirname(sourceFile.fileName);
|
|
586
|
+
const maxSize = options?.maxSize || 100 * 1024;
|
|
587
|
+
const dataURLs = [];
|
|
588
|
+
for (const filePath of resolvedPaths) {
|
|
589
|
+
if (typeof filePath !== "string") {
|
|
590
|
+
throw new Error(
|
|
591
|
+
`inlineDataURLs$ requires all paths to be string literals, got: ${typeof filePath}`
|
|
592
|
+
);
|
|
593
|
+
}
|
|
594
|
+
const absolutePath = import_path.default.resolve(sourceDir, filePath);
|
|
595
|
+
try {
|
|
596
|
+
const stats = import_fs.default.statSync(absolutePath);
|
|
597
|
+
if (stats.size > maxSize) {
|
|
598
|
+
throw new Error(
|
|
599
|
+
`File "${absolutePath}" is too large (${stats.size} bytes). Maximum allowed: ${maxSize} bytes.`
|
|
600
|
+
);
|
|
601
|
+
}
|
|
602
|
+
const mimeType = options?.mimeType || getMimeType(absolutePath);
|
|
603
|
+
const buffer = import_fs.default.readFileSync(absolutePath);
|
|
604
|
+
const base64 = buffer.toString("base64");
|
|
605
|
+
const dataURL = `data:${mimeType};base64,${base64}`;
|
|
606
|
+
dataURLs.push(dataURL);
|
|
607
|
+
} catch (error) {
|
|
608
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
609
|
+
throw new Error(
|
|
610
|
+
`File not found: "${absolutePath}" (referenced in ${sourceFile.fileName})`
|
|
611
|
+
);
|
|
612
|
+
}
|
|
613
|
+
throw new Error(
|
|
614
|
+
`Failed to read file "${absolutePath}": ${error instanceof Error ? error.message : String(error)}`
|
|
615
|
+
);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
const elements = dataURLs.map(
|
|
619
|
+
(dataURL) => this.factory.createStringLiteral(dataURL)
|
|
620
|
+
);
|
|
621
|
+
return this.factory.createArrayLiteralExpression(elements, true);
|
|
445
622
|
}
|
|
446
623
|
// Annotate the CommonJS export names for ESM import in node:
|
|
447
624
|
0 && (module.exports = {
|
|
448
625
|
apply$,
|
|
626
|
+
inlineDataURL$,
|
|
627
|
+
inlineDataURLs$,
|
|
449
628
|
inlineFile$,
|
|
629
|
+
inlineFileBase64$,
|
|
630
|
+
inlineFiles$,
|
|
450
631
|
style$
|
|
451
632
|
});
|
|
452
633
|
//# sourceMappingURL=index.cjs.map
|
package/dist/node/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/index.node.ts", "../../src/style/style.ts", "../../src/inline
|
|
4
|
-
"sourcesContent": ["export * from \"./style\";\nexport * from \"./inline-file\";\n", "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", "import { MacroContext } from \"@kithinji/pod\";\nimport ts from \"typescript\";\nimport fs from \"fs\";\nimport path from \"path\";\n\nexport function inlineFile$(filePath: string, context?: MacroContext): string {\n if (!context) {\n throw new Error(\n \"inlineFile$ macro requires MacroContext. Ensure you're using this as a build-time macro.\"\n );\n }\n\n const pathNode = filePath as unknown as ts.Node;\n const resolvedPath = context.resolveNodeValue(pathNode);\n\n if (typeof resolvedPath !== \"string\") {\n throw new Error(\n `inlineFile$ macro requires a string literal path, got: ${typeof resolvedPath}`\n );\n }\n\n const sourceFile = context.sourceFile;\n const sourceDir = path.dirname(sourceFile.fileName);\n const absolutePath = path.resolve(sourceDir, resolvedPath);\n\n let content: string;\n try {\n content = fs.readFileSync(absolutePath, \"utf-8\");\n } catch (error) {\n throw new Error(\n `Failed to read file \"${absolutePath}\": ${\n error instanceof Error ? error.message : String(error)\n }`\n );\n }\n\n return context.factory.createStringLiteral(content) as any;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,wBAAe;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,E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ACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,WAAW;AACjB,QAAM,eAAe,QAAQ,iBAAiB,QAAQ;AAEtD,MAAI,OAAO,iBAAiB,UAAU;AACpC,UAAM,IAAI;AAAA,MACR,0DAA0D,OAAO,YAAY;AAAA,IAC/E;AAAA,EACF;AAEA,QAAM,aAAa,QAAQ;AAC3B,QAAM,YAAY,YAAAC,QAAK,QAAQ,WAAW,QAAQ;AAClD,QAAM,eAAe,YAAAA,QAAK,QAAQ,WAAW,YAAY;AAEzD,MAAI;AACJ,MAAI;AACF,cAAU,UAAAC,QAAG,aAAa,cAAc,OAAO;AAAA,EACjD,SAAS,OAAO;AACd,UAAM,IAAI;AAAA,MACR,wBAAwB,YAAY,MAClC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CACvD;AAAA,IACF;AAAA,EACF;AAEA,SAAO,QAAQ,QAAQ,oBAAoB,OAAO;AACpD;",
|
|
3
|
+
"sources": ["../../src/index.node.ts", "../../src/style/style.ts", "../../src/inline/inline.ts"],
|
|
4
|
+
"sourcesContent": ["export * from \"./style\";\nexport * from \"./inline\";\n", "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 this: MacroContext,\n style: T,\n): MapNamespaces<T> {\n const rStyle = style as unknown as ts.Node;\n const value = this.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 this.store.set(\"style_rules\", Array.from(cssRules.values()));\n\n const properties = Object.entries(classNameMap).map(([key, className]) =>\n this.factory.createPropertyAssignment(\n this.factory.createStringLiteral(key),\n this.factory.createStringLiteral(className),\n ),\n );\n\n return this.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$(this: MacroContext, ...c: any[]) {\n const args = c as ts.Expression[];\n\n const self = this;\n\n if (args.length === 0) {\n return self.factory.createObjectLiteralExpression(\n [\n self.factory.createPropertyAssignment(\n self.factory.createIdentifier(\"className\"),\n self.factory.createStringLiteral(\"\"),\n ),\n ],\n false,\n );\n }\n\n const f = self.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 = self.resolveIdentifier(f.createIdentifier(chain[0]));\n let value = self.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", "import { MacroContext } from \"@kithinji/pod\";\nimport ts from \"typescript\";\nimport fs from \"fs\";\nimport path from \"path\";\n\nconst MIME_TYPES: Record<string, string> = {\n \".png\": \"image/png\",\n \".jpg\": \"image/jpeg\",\n \".jpeg\": \"image/jpeg\",\n \".gif\": \"image/gif\",\n \".svg\": \"image/svg+xml\",\n \".webp\": \"image/webp\",\n \".ico\": \"image/x-icon\",\n \".bmp\": \"image/bmp\",\n\n \".woff\": \"font/woff\",\n \".woff2\": \"font/woff2\",\n \".ttf\": \"font/ttf\",\n \".otf\": \"font/otf\",\n \".eot\": \"application/vnd.ms-fontobject\",\n\n \".mp3\": \"audio/mpeg\",\n \".wav\": \"audio/wav\",\n \".ogg\": \"audio/ogg\",\n \".mp4\": \"video/mp4\",\n \".webm\": \"video/webm\",\n\n \".pdf\": \"application/pdf\",\n \".zip\": \"application/zip\",\n\n \".txt\": \"text/plain\",\n \".html\": \"text/html\",\n \".css\": \"text/css\",\n \".js\": \"text/javascript\",\n \".json\": \"application/json\",\n \".xml\": \"application/xml\",\n};\n\nfunction getMimeType(filePath: string): string {\n const ext = path.extname(filePath).toLowerCase();\n return MIME_TYPES[ext] || \"application/octet-stream\";\n}\n\nfunction resolveFilePath(\n filePath: string,\n context: MacroContext,\n macroName: string,\n): string {\n const pathNode = filePath as unknown as ts.Node;\n const resolvedPath = context.resolveNodeValue(pathNode);\n\n if (typeof resolvedPath !== \"string\") {\n throw new Error(\n `${macroName} requires a string literal path, got: ${typeof resolvedPath}`,\n );\n }\n\n const sourceFile = context.sourceFile;\n const sourceDir = path.dirname(sourceFile.fileName);\n const absolutePath = path.resolve(sourceDir, resolvedPath);\n\n return absolutePath;\n}\n\nexport interface InlineFileOptions {\n maxSize?: number;\n}\n\nexport interface InlineDataURLOptions {\n maxSize?: number;\n mimeType?: string;\n}\n\nexport interface InlineBase64Options {\n maxSize?: number;\n}\n\nexport function inlineFile$(\n this: MacroContext,\n filePath: string,\n options?: InlineFileOptions,\n): string {\n const absolutePath = resolveFilePath(filePath, this, \"inlineFile$\");\n const maxSize = options?.maxSize || 1024 * 1024;\n\n let content: string;\n try {\n const stats = fs.statSync(absolutePath);\n\n if (stats.size > maxSize) {\n throw new Error(\n `File \"${absolutePath}\" is too large (${stats.size} bytes). Maximum allowed: ${maxSize} bytes. Consider using uploadFile$ instead.`,\n );\n }\n\n content = fs.readFileSync(absolutePath, \"utf-8\");\n } catch (error) {\n if (error instanceof Error && \"code\" in error && error.code === \"ENOENT\") {\n throw new Error(\n `File not found: \"${absolutePath}\" (referenced in ${this.sourceFile.fileName})`,\n );\n }\n throw new Error(\n `Failed to read file \"${absolutePath}\": ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n }\n\n return this.factory.createStringLiteral(content) as any;\n}\n\nexport function inlineFiles$(\n this: MacroContext,\n filePaths: string[],\n options?: InlineFileOptions,\n): string[] {\n const pathsNode = filePaths as unknown as ts.Node;\n const resolvedPaths = this.resolveNodeValue(pathsNode);\n\n if (!Array.isArray(resolvedPaths)) {\n throw new Error(\n `inlineFiles$ requires an array of string literals, got: ${typeof resolvedPaths}`,\n );\n }\n\n const sourceFile = this.sourceFile;\n const sourceDir = path.dirname(sourceFile.fileName);\n const maxSize = options?.maxSize || 1024 * 1024;\n\n const fileContents: string[] = [];\n\n for (const filePath of resolvedPaths) {\n if (typeof filePath !== \"string\") {\n throw new Error(\n `inlineFiles$ requires all paths to be string literals, got: ${typeof filePath}`,\n );\n }\n\n const absolutePath = path.resolve(sourceDir, filePath);\n\n try {\n const stats = fs.statSync(absolutePath);\n\n if (stats.size > maxSize) {\n throw new Error(\n `File \"${absolutePath}\" is too large (${stats.size} bytes). Maximum allowed: ${maxSize} bytes.`,\n );\n }\n\n const content = fs.readFileSync(absolutePath, \"utf-8\");\n fileContents.push(content);\n } catch (error) {\n if (\n error instanceof Error &&\n \"code\" in error &&\n error.code === \"ENOENT\"\n ) {\n throw new Error(\n `File not found: \"${absolutePath}\" (referenced in ${sourceFile.fileName})`,\n );\n }\n throw new Error(\n `Failed to read file \"${absolutePath}\": ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n }\n }\n\n const elements = fileContents.map((content) =>\n this.factory.createStringLiteral(content),\n );\n\n return this.factory.createArrayLiteralExpression(elements, true) as any;\n}\n\nexport function inlineFileBase64$(\n this: MacroContext,\n filePath: string,\n options?: InlineBase64Options,\n): string {\n const absolutePath = resolveFilePath(filePath, this, \"inlineFileBase64$\");\n const maxSize = options?.maxSize || 100 * 1024;\n\n let content: string;\n try {\n const stats = fs.statSync(absolutePath);\n\n if (stats.size > maxSize) {\n throw new Error(\n `File \"${absolutePath}\" is too large (${stats.size} bytes). Maximum allowed: ${maxSize} bytes. Consider using uploadFile$ instead.`,\n );\n }\n\n const buffer = fs.readFileSync(absolutePath);\n content = buffer.toString(\"base64\");\n } catch (error) {\n if (error instanceof Error && \"code\" in error && error.code === \"ENOENT\") {\n throw new Error(\n `File not found: \"${absolutePath}\" (referenced in ${this.sourceFile.fileName})`,\n );\n }\n throw new Error(\n `Failed to read file \"${absolutePath}\": ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n }\n\n return this.factory.createStringLiteral(content) as any;\n}\n\nexport function inlineDataURL$(\n this: MacroContext,\n filePath: string,\n options?: InlineDataURLOptions,\n): string {\n const absolutePath = resolveFilePath(filePath, this, \"inlineDataURL$\");\n const maxSize = options?.maxSize || 100 * 1024;\n\n let dataURL: string;\n try {\n const stats = fs.statSync(absolutePath);\n\n if (stats.size > maxSize) {\n throw new Error(\n `File \"${absolutePath}\" is too large (${stats.size} bytes). Maximum allowed: ${maxSize} bytes. Consider using uploadFile$ instead.`,\n );\n }\n\n const mimeType = options?.mimeType || getMimeType(absolutePath);\n const buffer = fs.readFileSync(absolutePath);\n const base64 = buffer.toString(\"base64\");\n\n dataURL = `data:${mimeType};base64,${base64}`;\n } catch (error) {\n if (error instanceof Error && \"code\" in error && error.code === \"ENOENT\") {\n throw new Error(\n `File not found: \"${absolutePath}\" (referenced in ${this.sourceFile.fileName})`,\n );\n }\n throw new Error(\n `Failed to read file \"${absolutePath}\": ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n }\n\n return this.factory.createStringLiteral(dataURL) as any;\n}\n\nexport function inlineDataURLs$(\n this: MacroContext,\n filePaths: string[],\n options?: InlineDataURLOptions,\n): string[] {\n const pathsNode = filePaths as unknown as ts.Node;\n const resolvedPaths = this.resolveNodeValue(pathsNode);\n\n if (!Array.isArray(resolvedPaths)) {\n throw new Error(\n `inlineDataURLs$ requires an array of string literals, got: ${typeof resolvedPaths}`,\n );\n }\n\n const sourceFile = this.sourceFile;\n const sourceDir = path.dirname(sourceFile.fileName);\n const maxSize = options?.maxSize || 100 * 1024;\n\n const dataURLs: string[] = [];\n\n for (const filePath of resolvedPaths) {\n if (typeof filePath !== \"string\") {\n throw new Error(\n `inlineDataURLs$ requires all paths to be string literals, got: ${typeof filePath}`,\n );\n }\n\n const absolutePath = path.resolve(sourceDir, filePath);\n\n try {\n const stats = fs.statSync(absolutePath);\n\n if (stats.size > maxSize) {\n throw new Error(\n `File \"${absolutePath}\" is too large (${stats.size} bytes). Maximum allowed: ${maxSize} bytes.`,\n );\n }\n\n const mimeType = options?.mimeType || getMimeType(absolutePath);\n const buffer = fs.readFileSync(absolutePath);\n const base64 = buffer.toString(\"base64\");\n\n const dataURL = `data:${mimeType};base64,${base64}`;\n dataURLs.push(dataURL);\n } catch (error) {\n if (\n error instanceof Error &&\n \"code\" in error &&\n error.code === \"ENOENT\"\n ) {\n throw new Error(\n `File not found: \"${absolutePath}\" (referenced in ${sourceFile.fileName})`,\n );\n }\n throw new Error(\n `Failed to read file \"${absolutePath}\": ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n }\n }\n\n const elements = dataURLs.map((dataURL) =>\n this.factory.createStringLiteral(dataURL),\n );\n\n return this.factory.createArrayLiteralExpression(elements, true) as any;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,wBAAe;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;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