@ogxjs/core 0.1.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 +102 -0
- package/dist/builder.d.ts +75 -0
- package/dist/builder.d.ts.map +1 -0
- package/dist/builder.js +243 -0
- package/dist/cache.d.ts +32 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +71 -0
- package/dist/css.d.ts +83 -0
- package/dist/css.d.ts.map +1 -0
- package/dist/css.js +1 -0
- package/dist/font-registry.d.ts +34 -0
- package/dist/font-registry.d.ts.map +1 -0
- package/dist/font-registry.js +59 -0
- package/dist/fonts/inter/inter-300.ttf +0 -0
- package/dist/fonts/inter/inter-400.ttf +0 -0
- package/dist/fonts/inter/inter-500.ttf +0 -0
- package/dist/fonts/inter/inter-600.ttf +0 -0
- package/dist/fonts/inter/inter-700.ttf +0 -0
- package/dist/fonts.d.ts +29 -0
- package/dist/fonts.d.ts.map +1 -0
- package/dist/fonts.js +90 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/ogx.d.ts +16 -0
- package/dist/ogx.d.ts.map +1 -0
- package/dist/ogx.js +104 -0
- package/dist/presets/blog.d.ts +31 -0
- package/dist/presets/blog.d.ts.map +1 -0
- package/dist/presets/blog.js +98 -0
- package/dist/presets/docs.d.ts +23 -0
- package/dist/presets/docs.d.ts.map +1 -0
- package/dist/presets/docs.js +87 -0
- package/dist/presets/index.d.ts +20 -0
- package/dist/presets/index.d.ts.map +1 -0
- package/dist/presets/index.js +11 -0
- package/dist/presets/minimal.d.ts +20 -0
- package/dist/presets/minimal.d.ts.map +1 -0
- package/dist/presets/minimal.js +53 -0
- package/dist/presets/social.d.ts +29 -0
- package/dist/presets/social.d.ts.map +1 -0
- package/dist/presets/social.js +66 -0
- package/dist/render-png.d.ts +7 -0
- package/dist/render-png.d.ts.map +1 -0
- package/dist/render-png.js +19 -0
- package/dist/render-svg.d.ts +7 -0
- package/dist/render-svg.d.ts.map +1 -0
- package/dist/render-svg.js +123 -0
- package/dist/render.d.ts +10 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +180 -0
- package/dist/tailwind/colors.d.ts +6 -0
- package/dist/tailwind/colors.d.ts.map +1 -0
- package/dist/tailwind/colors.js +281 -0
- package/dist/tailwind/index.d.ts +2 -0
- package/dist/tailwind/index.d.ts.map +1 -0
- package/dist/tailwind/index.js +1 -0
- package/dist/tailwind/parser.d.ts +15 -0
- package/dist/tailwind/parser.d.ts.map +1 -0
- package/dist/tailwind/parser.js +1037 -0
- package/dist/tailwind/scales.d.ts +26 -0
- package/dist/tailwind/scales.d.ts.map +1 -0
- package/dist/tailwind/scales.js +126 -0
- package/dist/tailwind/test-parser.d.ts +2 -0
- package/dist/tailwind/test-parser.d.ts.map +1 -0
- package/dist/tailwind/test-parser.js +10 -0
- package/dist/targets.d.ts +67 -0
- package/dist/targets.d.ts.map +1 -0
- package/dist/targets.js +25 -0
- package/dist/types.d.ts +173 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +10 -0
- package/dist/utils/assets.d.ts +11 -0
- package/dist/utils/assets.d.ts.map +1 -0
- package/dist/utils/assets.js +35 -0
- package/dist/utils/color.d.ts +14 -0
- package/dist/utils/color.d.ts.map +1 -0
- package/dist/utils/color.js +68 -0
- package/dist/utils/text.d.ts +14 -0
- package/dist/utils/text.d.ts.map +1 -0
- package/dist/utils/text.js +50 -0
- package/package.json +71 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tailwind spacing scale
|
|
3
|
+
* https://tailwindcss.com/docs/customizing-spacing
|
|
4
|
+
*/
|
|
5
|
+
export declare const spacing: Record<string, number>;
|
|
6
|
+
/**
|
|
7
|
+
* Font size scale
|
|
8
|
+
*/
|
|
9
|
+
export declare const fontSize: Record<string, [number, number]>;
|
|
10
|
+
/**
|
|
11
|
+
* Font weight scale
|
|
12
|
+
*/
|
|
13
|
+
export declare const fontWeight: Record<string, number>;
|
|
14
|
+
/**
|
|
15
|
+
* Border radius scale
|
|
16
|
+
*/
|
|
17
|
+
export declare const borderRadius: Record<string, number | string>;
|
|
18
|
+
/**
|
|
19
|
+
* Opacity scale
|
|
20
|
+
*/
|
|
21
|
+
export declare const opacity: Record<string, number>;
|
|
22
|
+
/**
|
|
23
|
+
* Box shadow scale
|
|
24
|
+
*/
|
|
25
|
+
export declare const boxShadow: Record<string, string>;
|
|
26
|
+
//# sourceMappingURL=scales.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scales.d.ts","sourceRoot":"","sources":["../../src/tailwind/scales.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAoC1C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAcrD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAU7C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAUxD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAsB1C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAS5C,CAAC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tailwind spacing scale
|
|
3
|
+
* https://tailwindcss.com/docs/customizing-spacing
|
|
4
|
+
*/
|
|
5
|
+
export const spacing = {
|
|
6
|
+
"0": 0,
|
|
7
|
+
px: 1,
|
|
8
|
+
"0.5": 2,
|
|
9
|
+
"1": 4,
|
|
10
|
+
"1.5": 6,
|
|
11
|
+
"2": 8,
|
|
12
|
+
"2.5": 10,
|
|
13
|
+
"3": 12,
|
|
14
|
+
"3.5": 14,
|
|
15
|
+
"4": 16,
|
|
16
|
+
"5": 20,
|
|
17
|
+
"6": 24,
|
|
18
|
+
"7": 28,
|
|
19
|
+
"8": 32,
|
|
20
|
+
"9": 36,
|
|
21
|
+
"10": 40,
|
|
22
|
+
"11": 44,
|
|
23
|
+
"12": 48,
|
|
24
|
+
"14": 56,
|
|
25
|
+
"16": 64,
|
|
26
|
+
"20": 80,
|
|
27
|
+
"24": 96,
|
|
28
|
+
"28": 112,
|
|
29
|
+
"32": 128,
|
|
30
|
+
"36": 144,
|
|
31
|
+
"40": 160,
|
|
32
|
+
"44": 176,
|
|
33
|
+
"48": 192,
|
|
34
|
+
"52": 208,
|
|
35
|
+
"56": 224,
|
|
36
|
+
"60": 240,
|
|
37
|
+
"64": 256,
|
|
38
|
+
"72": 288,
|
|
39
|
+
"80": 320,
|
|
40
|
+
"96": 384,
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Font size scale
|
|
44
|
+
*/
|
|
45
|
+
export const fontSize = {
|
|
46
|
+
xs: [12, 16],
|
|
47
|
+
sm: [14, 20],
|
|
48
|
+
base: [16, 24],
|
|
49
|
+
lg: [18, 28],
|
|
50
|
+
xl: [20, 28],
|
|
51
|
+
"2xl": [24, 32],
|
|
52
|
+
"3xl": [30, 36],
|
|
53
|
+
"4xl": [36, 40],
|
|
54
|
+
"5xl": [48, 48],
|
|
55
|
+
"6xl": [60, 60],
|
|
56
|
+
"7xl": [72, 72],
|
|
57
|
+
"8xl": [96, 96],
|
|
58
|
+
"9xl": [128, 128],
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Font weight scale
|
|
62
|
+
*/
|
|
63
|
+
export const fontWeight = {
|
|
64
|
+
thin: 100,
|
|
65
|
+
extralight: 200,
|
|
66
|
+
light: 300,
|
|
67
|
+
normal: 400,
|
|
68
|
+
medium: 500,
|
|
69
|
+
semibold: 600,
|
|
70
|
+
bold: 700,
|
|
71
|
+
extrabold: 800,
|
|
72
|
+
black: 900,
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Border radius scale
|
|
76
|
+
*/
|
|
77
|
+
export const borderRadius = {
|
|
78
|
+
none: 0,
|
|
79
|
+
sm: 2,
|
|
80
|
+
"": 4,
|
|
81
|
+
md: 6,
|
|
82
|
+
lg: 8,
|
|
83
|
+
xl: 12,
|
|
84
|
+
"2xl": 16,
|
|
85
|
+
"3xl": 24,
|
|
86
|
+
full: 9999,
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Opacity scale
|
|
90
|
+
*/
|
|
91
|
+
export const opacity = {
|
|
92
|
+
"0": 0,
|
|
93
|
+
"5": 0.05,
|
|
94
|
+
"10": 0.1,
|
|
95
|
+
"15": 0.15,
|
|
96
|
+
"20": 0.2,
|
|
97
|
+
"25": 0.25,
|
|
98
|
+
"30": 0.3,
|
|
99
|
+
"35": 0.35,
|
|
100
|
+
"40": 0.4,
|
|
101
|
+
"45": 0.45,
|
|
102
|
+
"50": 0.5,
|
|
103
|
+
"55": 0.55,
|
|
104
|
+
"60": 0.6,
|
|
105
|
+
"65": 0.65,
|
|
106
|
+
"70": 0.7,
|
|
107
|
+
"75": 0.75,
|
|
108
|
+
"80": 0.8,
|
|
109
|
+
"85": 0.85,
|
|
110
|
+
"90": 0.9,
|
|
111
|
+
"95": 0.95,
|
|
112
|
+
"100": 1,
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Box shadow scale
|
|
116
|
+
*/
|
|
117
|
+
export const boxShadow = {
|
|
118
|
+
sm: "0 1px 2px 0 rgb(0 0 0 / 0.05)",
|
|
119
|
+
"": "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)",
|
|
120
|
+
md: "0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)",
|
|
121
|
+
lg: "0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)",
|
|
122
|
+
xl: "0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)",
|
|
123
|
+
"2xl": "0 25px 50px -12px rgb(0 0 0 / 0.25)",
|
|
124
|
+
inner: "inset 0 2px 4px 0 rgb(0 0 0 / 0.05)",
|
|
125
|
+
none: "0 0 #0000",
|
|
126
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-parser.d.ts","sourceRoot":"","sources":["../../src/tailwind/test-parser.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { parseTailwind } from "./index";
|
|
2
|
+
const tw = "mt-10 gap-6 justify-center items-center flex-row flex-wrap";
|
|
3
|
+
const theme = {};
|
|
4
|
+
const styles = parseTailwind(tw, theme);
|
|
5
|
+
console.log("Input TW:", tw);
|
|
6
|
+
console.log("Resulting Styles:", JSON.stringify(styles, null, 2));
|
|
7
|
+
const gapX = parseTailwind("gap-x-4", theme);
|
|
8
|
+
console.log("gap-x-4:", JSON.stringify(gapX, null, 2));
|
|
9
|
+
const gapY = parseTailwind("gap-y-4", theme);
|
|
10
|
+
console.log("gap-y-4:", JSON.stringify(gapY, null, 2));
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported platforms and their standard OG image dimensions
|
|
3
|
+
*/
|
|
4
|
+
export declare const TARGET_DIMENSIONS: {
|
|
5
|
+
/** Standard Open Graph (Facebook, LinkedIn, Slack) */
|
|
6
|
+
readonly meta: {
|
|
7
|
+
readonly width: 1200;
|
|
8
|
+
readonly height: 630;
|
|
9
|
+
};
|
|
10
|
+
/** Twitter/X Large Card */
|
|
11
|
+
readonly twitter: {
|
|
12
|
+
readonly width: 1200;
|
|
13
|
+
readonly height: 600;
|
|
14
|
+
};
|
|
15
|
+
/** Instagram Post / Square target */
|
|
16
|
+
readonly instagram: {
|
|
17
|
+
readonly width: 1080;
|
|
18
|
+
readonly height: 1080;
|
|
19
|
+
};
|
|
20
|
+
/** WhatsApp/Telegram (preferred 1.91:1 but often square-cropped) */
|
|
21
|
+
readonly whatsapp: {
|
|
22
|
+
readonly width: 1200;
|
|
23
|
+
readonly height: 630;
|
|
24
|
+
};
|
|
25
|
+
/** Pinterest (2:3 aspect ratio) */
|
|
26
|
+
readonly pinterest: {
|
|
27
|
+
readonly width: 1000;
|
|
28
|
+
readonly height: 1500;
|
|
29
|
+
};
|
|
30
|
+
/** E-commerce / Marketplaces */
|
|
31
|
+
readonly marketplace: {
|
|
32
|
+
readonly width: 1000;
|
|
33
|
+
readonly height: 1000;
|
|
34
|
+
};
|
|
35
|
+
/** YouTube Thumbnail */
|
|
36
|
+
readonly youtube: {
|
|
37
|
+
readonly width: 1280;
|
|
38
|
+
readonly height: 720;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export type Platform = keyof typeof TARGET_DIMENSIONS;
|
|
42
|
+
/**
|
|
43
|
+
* Get dimensions for a platform
|
|
44
|
+
*/
|
|
45
|
+
export declare function getPlatformDimensions(platform: Platform): {
|
|
46
|
+
readonly width: 1200;
|
|
47
|
+
readonly height: 630;
|
|
48
|
+
} | {
|
|
49
|
+
readonly width: 1200;
|
|
50
|
+
readonly height: 600;
|
|
51
|
+
} | {
|
|
52
|
+
readonly width: 1080;
|
|
53
|
+
readonly height: 1080;
|
|
54
|
+
} | {
|
|
55
|
+
readonly width: 1200;
|
|
56
|
+
readonly height: 630;
|
|
57
|
+
} | {
|
|
58
|
+
readonly width: 1000;
|
|
59
|
+
readonly height: 1500;
|
|
60
|
+
} | {
|
|
61
|
+
readonly width: 1000;
|
|
62
|
+
readonly height: 1000;
|
|
63
|
+
} | {
|
|
64
|
+
readonly width: 1280;
|
|
65
|
+
readonly height: 720;
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=targets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"targets.d.ts","sourceRoot":"","sources":["../src/targets.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,iBAAiB;IAC5B,sDAAsD;;;;;IAEtD,2BAA2B;;;;;IAE3B,qCAAqC;;;;;IAErC,oEAAoE;;;;;IAEpE,mCAAmC;;;;;IAEnC,gCAAgC;;;;;IAEhC,wBAAwB;;;;;CAEhB,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,MAAM,OAAO,iBAAiB,CAAC;AAEtD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,QAAQ;;;;;;;;;;;;;;;;;;;;;EAEvD"}
|
package/dist/targets.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported platforms and their standard OG image dimensions
|
|
3
|
+
*/
|
|
4
|
+
export const TARGET_DIMENSIONS = {
|
|
5
|
+
/** Standard Open Graph (Facebook, LinkedIn, Slack) */
|
|
6
|
+
meta: { width: 1200, height: 630 },
|
|
7
|
+
/** Twitter/X Large Card */
|
|
8
|
+
twitter: { width: 1200, height: 600 },
|
|
9
|
+
/** Instagram Post / Square target */
|
|
10
|
+
instagram: { width: 1080, height: 1080 },
|
|
11
|
+
/** WhatsApp/Telegram (preferred 1.91:1 but often square-cropped) */
|
|
12
|
+
whatsapp: { width: 1200, height: 630 },
|
|
13
|
+
/** Pinterest (2:3 aspect ratio) */
|
|
14
|
+
pinterest: { width: 1000, height: 1500 },
|
|
15
|
+
/** E-commerce / Marketplaces */
|
|
16
|
+
marketplace: { width: 1000, height: 1000 },
|
|
17
|
+
/** YouTube Thumbnail */
|
|
18
|
+
youtube: { width: 1280, height: 720 },
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Get dimensions for a platform
|
|
22
|
+
*/
|
|
23
|
+
export function getPlatformDimensions(platform) {
|
|
24
|
+
return TARGET_DIMENSIONS[platform] || TARGET_DIMENSIONS.meta;
|
|
25
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import type { CSSProperties } from "./css";
|
|
2
|
+
import type { Platform } from "./targets";
|
|
3
|
+
export type { Platform };
|
|
4
|
+
/**
|
|
5
|
+
* Known Tailwind color names
|
|
6
|
+
*/
|
|
7
|
+
export type TailwindBaseColor = "inherit" | "current" | "transparent" | "black" | "white" | "slate" | "gray" | "zinc" | "neutral" | "stone" | "red" | "orange" | "amber" | "yellow" | "lime" | "green" | "emerald" | "teal" | "cyan" | "sky" | "blue" | "indigo" | "violet" | "purple" | "fuchsia" | "pink" | "rose";
|
|
8
|
+
/**
|
|
9
|
+
* Standard Tailwind color weights
|
|
10
|
+
*/
|
|
11
|
+
export type TailwindColorWeight = "50" | "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900" | "950";
|
|
12
|
+
/**
|
|
13
|
+
* Standard Tailwind spacing scale
|
|
14
|
+
*/
|
|
15
|
+
export type TailwindSpacing = "0" | "px" | "0.5" | "1" | "1.5" | "2" | "2.5" | "3" | "3.5" | "4" | "5" | "6" | "7" | "8" | "9" | "10" | "11" | "12" | "14" | "16" | "20" | "24" | "28" | "32" | "36" | "40" | "44" | "48" | "52" | "56" | "60" | "64" | "72" | "80" | "96";
|
|
16
|
+
/**
|
|
17
|
+
* Standard Tailwind opacity scale
|
|
18
|
+
*/
|
|
19
|
+
export type TailwindOpacity = "0" | "5" | "10" | "20" | "25" | "30" | "40" | "50" | "60" | "70" | "75" | "80" | "90" | "95" | "100";
|
|
20
|
+
/**
|
|
21
|
+
* Semantic theme color names from ThemeConfig
|
|
22
|
+
*/
|
|
23
|
+
export type ThemeColorName = "background" | "foreground" | "primary" | "primary-foreground" | "secondary" | "secondary-foreground" | "muted" | "muted-foreground" | "accent" | "accent-foreground" | "destructive" | "destructive-foreground" | "border" | "input" | "ring";
|
|
24
|
+
/**
|
|
25
|
+
* Combined color type for suggestions
|
|
26
|
+
*/
|
|
27
|
+
export type TailwindColor = TailwindBaseColor | ThemeColorName | `${Exclude<TailwindBaseColor, "inherit" | "current" | "transparent" | "black" | "white">}-${TailwindColorWeight}`;
|
|
28
|
+
/**
|
|
29
|
+
* Common Tailwind utility classes for autocompletion
|
|
30
|
+
* The (string & {}) trick allows autocompletion while still accepting any string
|
|
31
|
+
*/
|
|
32
|
+
export type TailwindUtility = "flex" | "flex-col" | "flex-row" | "flex-1" | "flex-none" | "flex-wrap" | "items-start" | "items-center" | "items-end" | "items-baseline" | "items-stretch" | "justify-start" | "justify-center" | "justify-end" | "justify-between" | "justify-around" | "justify-evenly" | "w-full" | "w-screen" | "h-full" | "h-screen" | "relative" | "absolute" | "fixed" | "top-0" | "right-0" | "bottom-0" | "left-0" | "inset-0" | "rounded" | "rounded-sm" | "rounded-md" | "rounded-lg" | "rounded-xl" | "rounded-2xl" | "rounded-3xl" | "rounded-full" | "font-thin" | "font-extralight" | "font-light" | "font-normal" | "font-medium" | "font-semibold" | "font-bold" | "font-extrabold" | "font-black" | "text-xs" | "text-sm" | "text-base" | "text-lg" | "text-xl" | "text-2xl" | "text-3xl" | "text-4xl" | "text-5xl" | "text-6xl" | "text-7xl" | "text-8xl" | "text-9xl" | "text-left" | "text-center" | "text-right" | "text-justify" | "leading-none" | "leading-tight" | "leading-snug" | "leading-normal" | "leading-relaxed" | "leading-loose" | `bg-${TailwindColor}` | `text-${TailwindColor}` | `border-${TailwindColor}` | `p-${TailwindSpacing}` | `px-${TailwindSpacing}` | `py-${TailwindSpacing}` | `pt-${TailwindSpacing}` | `pr-${TailwindSpacing}` | `pb-${TailwindSpacing}` | `pl-${TailwindSpacing}` | `m-${TailwindSpacing}` | `mx-${TailwindSpacing}` | `my-${TailwindSpacing}` | `mt-${TailwindSpacing}` | `mr-${TailwindSpacing}` | `mb-${TailwindSpacing}` | `ml-${TailwindSpacing}` | `gap-${TailwindSpacing}` | `opacity-${TailwindOpacity}` | "rounded-none" | "rounded-sm" | "rounded-md" | "rounded-lg" | "rounded-xl" | "rounded-2xl" | "rounded-3xl" | "rounded-full" | "shadow" | "shadow-sm" | "shadow-md" | "shadow-lg" | "shadow-xl" | "shadow-2xl" | "shadow-inner" | "shadow-none" | "bg-grid" | "bg-dots" | "bg-lines" | (string & {});
|
|
33
|
+
/**
|
|
34
|
+
* JSX-like element for OGX rendering
|
|
35
|
+
*/
|
|
36
|
+
export interface OGXElement {
|
|
37
|
+
type: string;
|
|
38
|
+
props: OGXElementProps;
|
|
39
|
+
}
|
|
40
|
+
export interface OGXElementProps {
|
|
41
|
+
/** Tailwind-like utility classes */
|
|
42
|
+
tw?: TailwindUtility | TailwindUtility[];
|
|
43
|
+
/** Inline styles (takes precedence over tw) */
|
|
44
|
+
style?: CSSProperties;
|
|
45
|
+
/** Child elements */
|
|
46
|
+
children?: OGXChildren;
|
|
47
|
+
/** Image source */
|
|
48
|
+
src?: string;
|
|
49
|
+
/** Image alt text */
|
|
50
|
+
alt?: string;
|
|
51
|
+
/** Any other props */
|
|
52
|
+
[key: string]: unknown;
|
|
53
|
+
}
|
|
54
|
+
export type OGXChildren = OGXElement | (OGXElement | null)[] | string | number | null | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Font configuration for Satori
|
|
57
|
+
*/
|
|
58
|
+
export interface FontConfig {
|
|
59
|
+
name: string;
|
|
60
|
+
data: ArrayBuffer;
|
|
61
|
+
weight?: 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
|
|
62
|
+
style?: "normal" | "italic";
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Custom theme colors for design system integration
|
|
66
|
+
* Allows using semantic color names like bg-background, text-primary, etc.
|
|
67
|
+
*/
|
|
68
|
+
export interface ThemeConfig {
|
|
69
|
+
/** Background color */
|
|
70
|
+
background?: string;
|
|
71
|
+
/** Foreground/text color */
|
|
72
|
+
foreground?: string;
|
|
73
|
+
/** Primary brand color */
|
|
74
|
+
primary?: string;
|
|
75
|
+
/** Primary foreground (text on primary) */
|
|
76
|
+
"primary-foreground"?: string;
|
|
77
|
+
/** Secondary color */
|
|
78
|
+
secondary?: string;
|
|
79
|
+
/** Secondary foreground */
|
|
80
|
+
"secondary-foreground"?: string;
|
|
81
|
+
/** Muted background */
|
|
82
|
+
muted?: string;
|
|
83
|
+
/** Muted foreground */
|
|
84
|
+
"muted-foreground"?: string;
|
|
85
|
+
/** Accent color */
|
|
86
|
+
accent?: string;
|
|
87
|
+
/** Accent foreground */
|
|
88
|
+
"accent-foreground"?: string;
|
|
89
|
+
/** Destructive/error color */
|
|
90
|
+
destructive?: string;
|
|
91
|
+
/** Destructive foreground */
|
|
92
|
+
"destructive-foreground"?: string;
|
|
93
|
+
/** Border color */
|
|
94
|
+
border?: string;
|
|
95
|
+
/** Input border color */
|
|
96
|
+
input?: string;
|
|
97
|
+
/** Ring/focus color */
|
|
98
|
+
ring?: string;
|
|
99
|
+
/** Any other custom colors */
|
|
100
|
+
[key: string]: string | undefined;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Render options
|
|
104
|
+
*/
|
|
105
|
+
export interface RenderOptions {
|
|
106
|
+
/** Target platform for automatic dimensions */
|
|
107
|
+
platform?: Platform;
|
|
108
|
+
/** Image width in pixels (default: platform default or 1200) */
|
|
109
|
+
width?: number;
|
|
110
|
+
/** Image height in pixels (default: platform default or 630) */
|
|
111
|
+
height?: number;
|
|
112
|
+
/** Custom fonts */
|
|
113
|
+
fonts?: FontConfig[];
|
|
114
|
+
/** Debug mode - shows layout boxes */
|
|
115
|
+
debug?: boolean;
|
|
116
|
+
/** Custom theme colors */
|
|
117
|
+
theme?: ThemeConfig;
|
|
118
|
+
/** Color scheme for dark mode (light or dark) */
|
|
119
|
+
colorScheme?: "light" | "dark";
|
|
120
|
+
/** Custom response headers */
|
|
121
|
+
headers?: Record<string, string>;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Preset configuration base
|
|
125
|
+
*/
|
|
126
|
+
export interface OGXBaseConfig {
|
|
127
|
+
/** Target platform(s) for automatic dimensions */
|
|
128
|
+
platform?: Platform | Platform[];
|
|
129
|
+
/** Custom slot overrides */
|
|
130
|
+
slots?: Record<string, OGXElement>;
|
|
131
|
+
/** Render options (merged with top-level options) */
|
|
132
|
+
options?: RenderOptions;
|
|
133
|
+
/** Quick debug toggle */
|
|
134
|
+
debug?: boolean;
|
|
135
|
+
/** Custom fonts (if not provided, Inter will be loaded) */
|
|
136
|
+
fonts?: FontConfig[];
|
|
137
|
+
/** Custom theme colors */
|
|
138
|
+
theme?: ThemeConfig;
|
|
139
|
+
/** Color scheme for dark mode (light or dark) */
|
|
140
|
+
colorScheme?: "light" | "dark";
|
|
141
|
+
/** Enable snapshot caching (default: true) */
|
|
142
|
+
cache?: boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Declarative font registration for Inter.
|
|
145
|
+
* Automatically handles registration of requested weights.
|
|
146
|
+
*/
|
|
147
|
+
inter?: (300 | 400 | 500 | 600 | 700)[];
|
|
148
|
+
}
|
|
149
|
+
export type OGXConfig<T extends PresetName = PresetName> = OGXBaseConfig & {
|
|
150
|
+
preset: T;
|
|
151
|
+
} & PresetProps[T];
|
|
152
|
+
/**
|
|
153
|
+
* Preset function type
|
|
154
|
+
*/
|
|
155
|
+
export type Preset<TProps> = (props: TProps) => OGXElement;
|
|
156
|
+
import { blogPreset } from "./presets/blog";
|
|
157
|
+
import { docsPreset } from "./presets/docs";
|
|
158
|
+
import { minimalPreset } from "./presets/minimal";
|
|
159
|
+
import { socialPreset } from "./presets/social";
|
|
160
|
+
export declare const presets: {
|
|
161
|
+
readonly docs: Preset<import("./presets").DocsPresetProps>;
|
|
162
|
+
readonly blog: Preset<import("./presets").BlogPresetProps>;
|
|
163
|
+
readonly minimal: Preset<import("./presets").MinimalPresetProps>;
|
|
164
|
+
readonly social: Preset<import("./presets").SocialPresetProps>;
|
|
165
|
+
};
|
|
166
|
+
export type PresetName = keyof typeof presets;
|
|
167
|
+
export type PresetProps = {
|
|
168
|
+
docs: Parameters<typeof docsPreset>[0];
|
|
169
|
+
blog: Parameters<typeof blogPreset>[0];
|
|
170
|
+
minimal: Parameters<typeof minimalPreset>[0];
|
|
171
|
+
social: Parameters<typeof socialPreset>[0];
|
|
172
|
+
};
|
|
173
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC1C,YAAY,EAAE,QAAQ,EAAE,CAAC;AAEzB;;GAEG;AACH,MAAM,MAAM,iBAAiB,GACzB,SAAS,GACT,SAAS,GACT,aAAa,GACb,OAAO,GACP,OAAO,GACP,OAAO,GACP,MAAM,GACN,MAAM,GACN,SAAS,GACT,OAAO,GACP,KAAK,GACL,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,MAAM,GACN,OAAO,GACP,SAAS,GACT,MAAM,GACN,MAAM,GACN,KAAK,GACL,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,MAAM,GACN,MAAM,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAC3B,IAAI,GACJ,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,CAAC;AAEV;;GAEG;AACH,MAAM,MAAM,eAAe,GACvB,GAAG,GACH,IAAI,GACJ,KAAK,GACL,GAAG,GACH,KAAK,GACL,GAAG,GACH,KAAK,GACL,GAAG,GACH,KAAK,GACL,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI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C"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { blogPreset } from "./presets/blog";
|
|
2
|
+
import { docsPreset } from "./presets/docs";
|
|
3
|
+
import { minimalPreset } from "./presets/minimal";
|
|
4
|
+
import { socialPreset } from "./presets/social";
|
|
5
|
+
export const presets = {
|
|
6
|
+
docs: docsPreset,
|
|
7
|
+
blog: blogPreset,
|
|
8
|
+
minimal: minimalPreset,
|
|
9
|
+
social: socialPreset,
|
|
10
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a local file to a base64 Data URI
|
|
3
|
+
* Useful for images and fonts in Node/Bun environments
|
|
4
|
+
* In browser environments, this will throw as Node FS is unavailable.
|
|
5
|
+
*/
|
|
6
|
+
export declare function toDataUri(filePath: string): Promise<string>;
|
|
7
|
+
/**
|
|
8
|
+
* Alias for toDataUri, conceptually loading an asset
|
|
9
|
+
*/
|
|
10
|
+
export declare const loadAsset: typeof toDataUri;
|
|
11
|
+
//# sourceMappingURL=assets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../src/utils/assets.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA6BjE;AAED;;GAEG;AACH,eAAO,MAAM,SAAS,kBAAY,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a local file to a base64 Data URI
|
|
3
|
+
* Useful for images and fonts in Node/Bun environments
|
|
4
|
+
* In browser environments, this will throw as Node FS is unavailable.
|
|
5
|
+
*/
|
|
6
|
+
export async function toDataUri(filePath) {
|
|
7
|
+
// If filePath is already a data URI or URL, return it
|
|
8
|
+
if (filePath.startsWith("data:") || filePath.startsWith("http")) {
|
|
9
|
+
return filePath;
|
|
10
|
+
}
|
|
11
|
+
try {
|
|
12
|
+
const { readFile } = await import("node:fs/promises");
|
|
13
|
+
const { extname } = await import("node:path");
|
|
14
|
+
const buffer = await readFile(filePath);
|
|
15
|
+
const ext = extname(filePath).toLowerCase();
|
|
16
|
+
let mimeType = "image/png";
|
|
17
|
+
if (ext === ".svg")
|
|
18
|
+
mimeType = "image/svg+xml";
|
|
19
|
+
else if (ext === ".jpg" || ext === ".jpeg")
|
|
20
|
+
mimeType = "image/jpeg";
|
|
21
|
+
else if (ext === ".webp")
|
|
22
|
+
mimeType = "image/webp";
|
|
23
|
+
else if (ext === ".gif")
|
|
24
|
+
mimeType = "image/gif";
|
|
25
|
+
return `data:${mimeType};base64,${buffer.toString("base64")}`;
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
console.error("OGX: toDataUri is only supported in Node/Bun environments:", err);
|
|
29
|
+
throw new Error("OGX: Local asset loading is not supported in the browser.");
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Alias for toDataUri, conceptually loading an asset
|
|
34
|
+
*/
|
|
35
|
+
export const loadAsset = toDataUri;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Color utility functions
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Convert OKLCH color to HEX string
|
|
6
|
+
* Supports format: oklch(L C H) or oklch(L C H / A)
|
|
7
|
+
*/
|
|
8
|
+
export declare function normalizeColor(color: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* OKLCH to HEX conversion
|
|
11
|
+
* Formula from https://bottosson.github.io/posts/oklab/
|
|
12
|
+
*/
|
|
13
|
+
export declare function oklchToHex(l: number, c: number, h: number): string;
|
|
14
|
+
//# sourceMappingURL=color.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../src/utils/color.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAgBpD;AAoBD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAiClE"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Color utility functions
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Convert OKLCH color to HEX string
|
|
6
|
+
* Supports format: oklch(L C H) or oklch(L C H / A)
|
|
7
|
+
*/
|
|
8
|
+
export function normalizeColor(color) {
|
|
9
|
+
if (!color || typeof color !== "string")
|
|
10
|
+
return color;
|
|
11
|
+
const oklchMatch = color.match(/oklch\(\s*([\d.]+%?)\s+([\d.]+%?)\s+([\d.]+(?:deg|grad|rad|turn)?)\s*(?:\/\s*([\d.]+%?))?\s*\)/i);
|
|
12
|
+
if (oklchMatch?.[1] && oklchMatch[2] && oklchMatch[3]) {
|
|
13
|
+
const l = parseNormalized(oklchMatch[1], 1);
|
|
14
|
+
const c = parseNormalized(oklchMatch[2], 0.4);
|
|
15
|
+
const h = parseAngle(oklchMatch[3]);
|
|
16
|
+
return oklchToHex(l, c, h);
|
|
17
|
+
}
|
|
18
|
+
return color;
|
|
19
|
+
}
|
|
20
|
+
function parseNormalized(val, _max) {
|
|
21
|
+
if (val.endsWith("%")) {
|
|
22
|
+
return parseFloat(val) / 100;
|
|
23
|
+
}
|
|
24
|
+
const n = parseFloat(val);
|
|
25
|
+
// If L is e.g. 0.7, it's normalized. If it's e.g. 70, it might be a percentage without %
|
|
26
|
+
// But CSS oklch strictly expects 0-1 for L/C or %
|
|
27
|
+
return n;
|
|
28
|
+
}
|
|
29
|
+
function parseAngle(val) {
|
|
30
|
+
const v = parseFloat(val);
|
|
31
|
+
if (val.endsWith("rad"))
|
|
32
|
+
return (v * 180) / Math.PI;
|
|
33
|
+
if (val.endsWith("grad"))
|
|
34
|
+
return (v * 360) / 400;
|
|
35
|
+
if (val.endsWith("turn"))
|
|
36
|
+
return v * 360;
|
|
37
|
+
return v;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* OKLCH to HEX conversion
|
|
41
|
+
* Formula from https://bottosson.github.io/posts/oklab/
|
|
42
|
+
*/
|
|
43
|
+
export function oklchToHex(l, c, h) {
|
|
44
|
+
const hueRad = (h * Math.PI) / 180;
|
|
45
|
+
const a = c * Math.cos(hueRad);
|
|
46
|
+
const b = c * Math.sin(hueRad);
|
|
47
|
+
// OKLab to Linear sRGB
|
|
48
|
+
const l_ = l + 0.3963377774 * a + 0.2158037573 * b;
|
|
49
|
+
const m_ = l - 0.1055613458 * a - 0.0638541728 * b;
|
|
50
|
+
const s_ = l - 0.0894841775 * a - 1.291485548 * b;
|
|
51
|
+
const l_3 = l_ * l_ * l_;
|
|
52
|
+
const m_3 = m_ * m_ * m_;
|
|
53
|
+
const s_3 = s_ * s_ * s_;
|
|
54
|
+
let r = +4.0767416621 * l_3 - 3.3077115913 * m_3 + 0.2309699292 * s_3;
|
|
55
|
+
let g = -1.2684380046 * l_3 + 2.6097574011 * m_3 - 0.3413193965 * s_3;
|
|
56
|
+
let b_ = -0.0041960863 * l_3 - 0.7034186147 * m_3 + 1.707614701 * s_3;
|
|
57
|
+
// Linear to sRGB (gamma correction)
|
|
58
|
+
const f = (x) => x <= 0.0031308 ? 12.92 * x : 1.055 * x ** (1 / 2.4) - 0.055;
|
|
59
|
+
// Clamp values
|
|
60
|
+
r = Math.max(0, Math.min(1, r));
|
|
61
|
+
g = Math.max(0, Math.min(1, g));
|
|
62
|
+
b_ = Math.max(0, Math.min(1, b_));
|
|
63
|
+
const ri = Math.round(f(r) * 255);
|
|
64
|
+
const gi = Math.round(f(g) * 255);
|
|
65
|
+
const bi = Math.round(f(b_) * 255);
|
|
66
|
+
const toHex = (n) => n.toString(16).padStart(2, "0");
|
|
67
|
+
return `#${toHex(ri)}${toHex(gi)}${toHex(bi)}`.toUpperCase();
|
|
68
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FontConfig } from "../types";
|
|
2
|
+
export interface FitTextOptions {
|
|
3
|
+
maxWidth: number;
|
|
4
|
+
maxHeight?: number;
|
|
5
|
+
minFontSize?: number;
|
|
6
|
+
maxFontSize?: number;
|
|
7
|
+
fonts: FontConfig[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Estimate the best font size to fit text within a container
|
|
11
|
+
* Uses binary search with Satori's layout engine for accuracy
|
|
12
|
+
*/
|
|
13
|
+
export declare function calculateFittingFontSize(text: string, options: FitTextOptions): Promise<number>;
|
|
14
|
+
//# sourceMappingURL=text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/utils/text.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,UAAU,EAAE,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,MAAM,CAAC,CA2DjB"}
|