@ogxjs/core 0.1.1 → 0.2.0-alpha.1

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.
Files changed (62) hide show
  1. package/dist/builder.d.ts +5 -0
  2. package/dist/builder.d.ts.map +1 -1
  3. package/dist/builder.js +11 -1
  4. package/dist/cache/hash.d.ts +66 -0
  5. package/dist/cache/hash.d.ts.map +1 -0
  6. package/dist/cache/hash.js +161 -0
  7. package/dist/cache/index.d.ts +10 -0
  8. package/dist/cache/index.d.ts.map +1 -0
  9. package/dist/cache/index.js +12 -0
  10. package/dist/cache/lru.d.ts +122 -0
  11. package/dist/cache/lru.d.ts.map +1 -0
  12. package/dist/cache/lru.js +269 -0
  13. package/dist/cache/snapshot.d.ts +116 -0
  14. package/dist/cache/snapshot.d.ts.map +1 -0
  15. package/dist/cache/snapshot.js +204 -0
  16. package/dist/cache.d.ts +2 -2
  17. package/dist/cache.js +2 -2
  18. package/dist/css.d.ts +19 -6
  19. package/dist/css.d.ts.map +1 -1
  20. package/dist/index.d.ts +18 -4
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +41 -10
  23. package/dist/ogx.js +2 -2
  24. package/dist/perf/index.d.ts +8 -0
  25. package/dist/perf/index.d.ts.map +1 -0
  26. package/dist/perf/index.js +7 -0
  27. package/dist/perf/timing.d.ts +160 -0
  28. package/dist/perf/timing.d.ts.map +1 -0
  29. package/dist/perf/timing.js +305 -0
  30. package/dist/presets/blog.js +1 -1
  31. package/dist/presets/docs.d.ts +2 -0
  32. package/dist/presets/docs.d.ts.map +1 -1
  33. package/dist/presets/docs.js +26 -23
  34. package/dist/presets/minimal.d.ts +2 -0
  35. package/dist/presets/minimal.d.ts.map +1 -1
  36. package/dist/presets/minimal.js +8 -16
  37. package/dist/presets/social.d.ts +2 -0
  38. package/dist/presets/social.d.ts.map +1 -1
  39. package/dist/presets/social.js +28 -18
  40. package/dist/render-png.d.ts.map +1 -1
  41. package/dist/render-png.js +9 -1
  42. package/dist/render-svg.d.ts.map +1 -1
  43. package/dist/render-svg.js +11 -1
  44. package/dist/tailwind/class-cache.d.ts +141 -0
  45. package/dist/tailwind/class-cache.d.ts.map +1 -0
  46. package/dist/tailwind/class-cache.js +212 -0
  47. package/dist/tailwind/index.d.ts +14 -1
  48. package/dist/tailwind/index.d.ts.map +1 -1
  49. package/dist/tailwind/index.js +15 -1
  50. package/dist/tailwind/lookup-tables.d.ts +30 -0
  51. package/dist/tailwind/lookup-tables.d.ts.map +1 -0
  52. package/dist/tailwind/lookup-tables.js +427 -0
  53. package/dist/tailwind/parser-v2.d.ts +54 -0
  54. package/dist/tailwind/parser-v2.d.ts.map +1 -0
  55. package/dist/tailwind/parser-v2.js +250 -0
  56. package/dist/tailwind/parser.d.ts +1 -0
  57. package/dist/tailwind/parser.d.ts.map +1 -1
  58. package/dist/tailwind/parser.js +1 -0
  59. package/dist/tailwind/prefix-handlers.d.ts +68 -0
  60. package/dist/tailwind/prefix-handlers.d.ts.map +1 -0
  61. package/dist/tailwind/prefix-handlers.js +931 -0
  62. package/package.json +17 -2
@@ -0,0 +1,269 @@
1
+ /**
2
+ * @ogxjs/core - LRU Cache Implementation
3
+ * Least Recently Used cache with O(1) operations
4
+ *
5
+ * @description
6
+ * High-performance LRU cache using Map + doubly-linked list.
7
+ * - O(1) get, set, delete
8
+ * - Automatic eviction when max size reached
9
+ * - Optional TTL (time-to-live) support
10
+ * - Memory-bounded
11
+ *
12
+ * @version 0.2.0 "Turbo"
13
+ */
14
+ // LRU CACHE CLASS
15
+ /**
16
+ * LRU Cache with O(1) operations
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * const cache = new LRUCache<string, Buffer>({ maxSize: 100, ttl: 60000 });
21
+ *
22
+ * cache.set("image-1", buffer);
23
+ * const result = cache.get("image-1"); // → buffer
24
+ *
25
+ * console.log(cache.stats); // { size: 1, hits: 1, ... }
26
+ * ```
27
+ */
28
+ export class LRUCache {
29
+ cache = new Map();
30
+ head = null;
31
+ tail = null;
32
+ maxSize;
33
+ ttl;
34
+ onEvict;
35
+ // Stats
36
+ _hits = 0;
37
+ _misses = 0;
38
+ _evictions = 0;
39
+ constructor(options = {}) {
40
+ this.maxSize = options.maxSize ?? 1000;
41
+ this.ttl = options.ttl ?? 0;
42
+ this.onEvict = options.onEvict;
43
+ }
44
+ /**
45
+ * Get a value from the cache
46
+ * Moves the item to the front (most recently used)
47
+ */
48
+ get(key) {
49
+ const node = this.cache.get(key);
50
+ if (!node) {
51
+ this._misses++;
52
+ return undefined;
53
+ }
54
+ // Check TTL
55
+ if (this.ttl > 0 && Date.now() - node.timestamp > this.ttl) {
56
+ this.delete(key);
57
+ this._misses++;
58
+ return undefined;
59
+ }
60
+ // Move to front
61
+ this.moveToFront(node);
62
+ this._hits++;
63
+ return node.value;
64
+ }
65
+ /**
66
+ * Set a value in the cache
67
+ * Evicts least recently used item if at capacity
68
+ */
69
+ set(key, value) {
70
+ const existing = this.cache.get(key);
71
+ if (existing) {
72
+ // Update existing
73
+ existing.value = value;
74
+ existing.timestamp = Date.now();
75
+ this.moveToFront(existing);
76
+ return;
77
+ }
78
+ // Evict if at capacity
79
+ if (this.cache.size >= this.maxSize) {
80
+ this.evictLRU();
81
+ }
82
+ // Create new node
83
+ const node = {
84
+ key,
85
+ value,
86
+ timestamp: Date.now(),
87
+ prev: null,
88
+ next: this.head,
89
+ };
90
+ // Update links
91
+ if (this.head) {
92
+ this.head.prev = node;
93
+ }
94
+ this.head = node;
95
+ if (!this.tail) {
96
+ this.tail = node;
97
+ }
98
+ this.cache.set(key, node);
99
+ }
100
+ /**
101
+ * Check if a key exists (without updating LRU order)
102
+ */
103
+ has(key) {
104
+ const node = this.cache.get(key);
105
+ if (!node)
106
+ return false;
107
+ // Check TTL
108
+ if (this.ttl > 0 && Date.now() - node.timestamp > this.ttl) {
109
+ this.delete(key);
110
+ return false;
111
+ }
112
+ return true;
113
+ }
114
+ /**
115
+ * Delete a key from the cache
116
+ */
117
+ delete(key) {
118
+ const node = this.cache.get(key);
119
+ if (!node)
120
+ return false;
121
+ this.removeNode(node);
122
+ this.cache.delete(key);
123
+ return true;
124
+ }
125
+ /**
126
+ * Clear the entire cache
127
+ */
128
+ clear() {
129
+ this.cache.clear();
130
+ this.head = null;
131
+ this.tail = null;
132
+ this._hits = 0;
133
+ this._misses = 0;
134
+ this._evictions = 0;
135
+ }
136
+ /**
137
+ * Get cache size
138
+ */
139
+ get size() {
140
+ return this.cache.size;
141
+ }
142
+ /**
143
+ * Get cache statistics
144
+ */
145
+ get stats() {
146
+ const total = this._hits + this._misses;
147
+ return {
148
+ size: this.cache.size,
149
+ maxSize: this.maxSize,
150
+ hits: this._hits,
151
+ misses: this._misses,
152
+ hitRate: total > 0 ? this._hits / total : 0,
153
+ evictions: this._evictions,
154
+ };
155
+ }
156
+ /**
157
+ * Get all keys (in LRU order, most recent first)
158
+ */
159
+ keys() {
160
+ const result = [];
161
+ let node = this.head;
162
+ while (node) {
163
+ result.push(node.key);
164
+ node = node.next;
165
+ }
166
+ return result;
167
+ }
168
+ /**
169
+ * Iterate over entries (in LRU order)
170
+ */
171
+ *entries() {
172
+ let node = this.head;
173
+ while (node) {
174
+ yield [node.key, node.value];
175
+ node = node.next;
176
+ }
177
+ }
178
+ /**
179
+ * Prune expired entries (if TTL is set)
180
+ * Call periodically for long-running processes
181
+ */
182
+ prune() {
183
+ if (this.ttl === 0)
184
+ return 0;
185
+ const now = Date.now();
186
+ let pruned = 0;
187
+ for (const [key, node] of this.cache) {
188
+ if (now - node.timestamp > this.ttl) {
189
+ this.delete(key);
190
+ pruned++;
191
+ }
192
+ }
193
+ return pruned;
194
+ }
195
+ // ═══════════════════════════════════════════════════════════════════════
196
+ // PRIVATE METHODS
197
+ // ═══════════════════════════════════════════════════════════════════════
198
+ /**
199
+ * Move a node to the front (most recently used)
200
+ */
201
+ moveToFront(node) {
202
+ if (node === this.head)
203
+ return;
204
+ // Remove from current position
205
+ this.removeNode(node);
206
+ // Add to front
207
+ node.prev = null;
208
+ node.next = this.head;
209
+ if (this.head) {
210
+ this.head.prev = node;
211
+ }
212
+ this.head = node;
213
+ if (!this.tail) {
214
+ this.tail = node;
215
+ }
216
+ }
217
+ /**
218
+ * Remove a node from the linked list (but not from Map)
219
+ */
220
+ removeNode(node) {
221
+ if (node.prev) {
222
+ node.prev.next = node.next;
223
+ }
224
+ else {
225
+ this.head = node.next;
226
+ }
227
+ if (node.next) {
228
+ node.next.prev = node.prev;
229
+ }
230
+ else {
231
+ this.tail = node.prev;
232
+ }
233
+ }
234
+ /**
235
+ * Evict the least recently used item
236
+ */
237
+ evictLRU() {
238
+ if (!this.tail)
239
+ return;
240
+ const evicted = this.tail;
241
+ // Call eviction callback
242
+ if (this.onEvict) {
243
+ this.onEvict(evicted.key, evicted.value);
244
+ }
245
+ // Remove from list
246
+ this.removeNode(evicted);
247
+ this.cache.delete(evicted.key);
248
+ this._evictions++;
249
+ }
250
+ }
251
+ // CONVENIENCE FACTORIES
252
+ /**
253
+ * Create a small LRU cache (100 items)
254
+ */
255
+ export function createSmallCache(ttl = 0) {
256
+ return new LRUCache({ maxSize: 100, ttl });
257
+ }
258
+ /**
259
+ * Create a medium LRU cache (1000 items)
260
+ */
261
+ export function createMediumCache(ttl = 0) {
262
+ return new LRUCache({ maxSize: 1000, ttl });
263
+ }
264
+ /**
265
+ * Create a large LRU cache (10000 items)
266
+ */
267
+ export function createLargeCache(ttl = 0) {
268
+ return new LRUCache({ maxSize: 10000, ttl });
269
+ }
@@ -0,0 +1,116 @@
1
+ /**
2
+ * @ogxjs/core - Snapshot Cache v2
3
+ * High-performance image cache with LRU eviction
4
+ *
5
+ * @description
6
+ * Refactored cache system for v0.2.0 "Turbo":
7
+ * - Uses fast sync hash (FNV-1a/xxHash) instead of SHA-256
8
+ * - LRU eviction instead of simple Map
9
+ * - Optional TTL support
10
+ * - Memory bounded
11
+ *
12
+ * @version 0.2.0 "Turbo"
13
+ */
14
+ import { type LRUCacheStats } from "./lru";
15
+ export interface SnapshotCacheOptions {
16
+ /** Maximum number of cached images (default: 500) */
17
+ maxSize?: number;
18
+ /** Time-to-live in milliseconds (default: 0 = no expiration) */
19
+ ttl?: number;
20
+ }
21
+ export interface SnapshotCacheStats extends LRUCacheStats {
22
+ /** Memory estimate in bytes */
23
+ memoryEstimate: number;
24
+ }
25
+ /**
26
+ * Cache for generated OG images
27
+ *
28
+ * Uses LRU eviction to bound memory usage.
29
+ * Keys are generated from config objects using fast hash.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * const cache = new SnapshotCacheV2({ maxSize: 100, ttl: 60000 });
34
+ *
35
+ * const hash = cache.getHash(config);
36
+ * if (!cache.has(hash)) {
37
+ * const image = await render(element);
38
+ * cache.set(hash, image);
39
+ * }
40
+ * return cache.get(hash);
41
+ * ```
42
+ */
43
+ export declare class SnapshotCacheV2 {
44
+ private cache;
45
+ private memoryEstimate;
46
+ constructor(options?: SnapshotCacheOptions);
47
+ /**
48
+ * Generate a hash key for a configuration object
49
+ * Uses fast sync hash (no await needed)
50
+ */
51
+ getHash(config: unknown): string;
52
+ /**
53
+ * Get a cached image by hash
54
+ */
55
+ get(hash: string): Uint8Array | string | undefined;
56
+ /**
57
+ * Check if a hash exists in cache
58
+ */
59
+ has(hash: string): boolean;
60
+ /**
61
+ * Store an image in cache
62
+ */
63
+ set(hash: string, data: Uint8Array | string): void;
64
+ /**
65
+ * Delete a cached image
66
+ */
67
+ delete(hash: string): boolean;
68
+ /**
69
+ * Clear the entire cache
70
+ */
71
+ clear(): void;
72
+ /**
73
+ * Get cache size
74
+ */
75
+ get size(): number;
76
+ /**
77
+ * Get cache statistics
78
+ */
79
+ get stats(): SnapshotCacheStats;
80
+ /**
81
+ * Prune expired entries
82
+ */
83
+ prune(): number;
84
+ /**
85
+ * @deprecated Use getHash() instead (sync, no await needed)
86
+ */
87
+ getHashAsync(config: unknown): Promise<string>;
88
+ /**
89
+ * Set cache TTL
90
+ * Note: Only affects new entries, not existing ones
91
+ */
92
+ setTTL(_milliseconds: number): void;
93
+ }
94
+ export declare function getSnapshotCache(): SnapshotCacheV2;
95
+ /**
96
+ * Configure the global cache instance
97
+ * Must be called before any cache operations
98
+ */
99
+ export declare function configureSnapshotCache(options: SnapshotCacheOptions): void;
100
+ /**
101
+ * Legacy export for backward compatibility
102
+ */
103
+ export declare const snapshotCache: {
104
+ readonly instance: SnapshotCacheV2;
105
+ getHash(config: unknown): string;
106
+ getHashAsync(config: unknown): Promise<string>;
107
+ get(hash: string): Uint8Array | string | undefined;
108
+ has(hash: string): boolean;
109
+ set(hash: string, data: Uint8Array | string): void;
110
+ delete(hash: string): boolean;
111
+ clear(): void;
112
+ readonly size: number;
113
+ readonly stats: SnapshotCacheStats;
114
+ setTTL(ms: number): void;
115
+ };
116
+ //# sourceMappingURL=snapshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../src/cache/snapshot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAIrD,MAAM,WAAW,oBAAoB;IACpC,qDAAqD;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,GAAG,CAAC,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,kBAAmB,SAAQ,aAAa;IACxD,+BAA+B;IAC/B,cAAc,EAAE,MAAM,CAAC;CACvB;AAID;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,eAAe;IAC3B,OAAO,CAAC,KAAK,CAAwC;IACrD,OAAO,CAAC,cAAc,CAAK;gBAEf,OAAO,GAAE,oBAAyB;IAe9C;;;OAGG;IACH,OAAO,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM;IAIhC;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,SAAS;IAIlD;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI;IAWlD;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAY7B;;OAEG;IACH,KAAK,IAAI,IAAI;IAKb;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,IAAI,KAAK,IAAI,kBAAkB,CAK9B;IAED;;OAEG;IACH,KAAK,IAAI,MAAM;IAQf;;OAEG;IACG,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAIpD;;;OAGG;IACH,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;CAKnC;AAUD,wBAAgB,gBAAgB,IAAI,eAAe,CAQlD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI,CAE1E;AAED;;GAEG;AACH,eAAO,MAAM,aAAa;;oBAKT,OAAO,GAAG,MAAM;yBAIL,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;cAI1C,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,SAAS;cAIxC,MAAM,GAAG,OAAO;cAIhB,MAAM,QAAQ,UAAU,GAAG,MAAM,GAAG,IAAI;iBAIrC,MAAM,GAAG,OAAO;aAIpB,IAAI;mBAID,MAAM;oBAIL,kBAAkB;eAIpB,MAAM,GAAG,IAAI;CAGxB,CAAC"}
@@ -0,0 +1,204 @@
1
+ /**
2
+ * @ogxjs/core - Snapshot Cache v2
3
+ * High-performance image cache with LRU eviction
4
+ *
5
+ * @description
6
+ * Refactored cache system for v0.2.0 "Turbo":
7
+ * - Uses fast sync hash (FNV-1a/xxHash) instead of SHA-256
8
+ * - LRU eviction instead of simple Map
9
+ * - Optional TTL support
10
+ * - Memory bounded
11
+ *
12
+ * @version 0.2.0 "Turbo"
13
+ */
14
+ import { hashObject } from "./hash";
15
+ import { LRUCache } from "./lru";
16
+ // SNAPSHOT CACHE CLASS
17
+ /**
18
+ * Cache for generated OG images
19
+ *
20
+ * Uses LRU eviction to bound memory usage.
21
+ * Keys are generated from config objects using fast hash.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const cache = new SnapshotCacheV2({ maxSize: 100, ttl: 60000 });
26
+ *
27
+ * const hash = cache.getHash(config);
28
+ * if (!cache.has(hash)) {
29
+ * const image = await render(element);
30
+ * cache.set(hash, image);
31
+ * }
32
+ * return cache.get(hash);
33
+ * ```
34
+ */
35
+ export class SnapshotCacheV2 {
36
+ cache;
37
+ memoryEstimate = 0;
38
+ constructor(options = {}) {
39
+ this.cache = new LRUCache({
40
+ maxSize: options.maxSize ?? 500,
41
+ ttl: options.ttl ?? 0,
42
+ onEvict: (_key, value) => {
43
+ // Update memory estimate on eviction
44
+ if (value instanceof Uint8Array) {
45
+ this.memoryEstimate -= value.byteLength;
46
+ }
47
+ else if (typeof value === "string") {
48
+ this.memoryEstimate -= value.length * 2; // UTF-16
49
+ }
50
+ },
51
+ });
52
+ }
53
+ /**
54
+ * Generate a hash key for a configuration object
55
+ * Uses fast sync hash (no await needed)
56
+ */
57
+ getHash(config) {
58
+ return hashObject(config);
59
+ }
60
+ /**
61
+ * Get a cached image by hash
62
+ */
63
+ get(hash) {
64
+ return this.cache.get(hash);
65
+ }
66
+ /**
67
+ * Check if a hash exists in cache
68
+ */
69
+ has(hash) {
70
+ return this.cache.has(hash);
71
+ }
72
+ /**
73
+ * Store an image in cache
74
+ */
75
+ set(hash, data) {
76
+ // Update memory estimate
77
+ if (data instanceof Uint8Array) {
78
+ this.memoryEstimate += data.byteLength;
79
+ }
80
+ else if (typeof data === "string") {
81
+ this.memoryEstimate += data.length * 2;
82
+ }
83
+ this.cache.set(hash, data);
84
+ }
85
+ /**
86
+ * Delete a cached image
87
+ */
88
+ delete(hash) {
89
+ const existing = this.cache.get(hash);
90
+ if (existing) {
91
+ if (existing instanceof Uint8Array) {
92
+ this.memoryEstimate -= existing.byteLength;
93
+ }
94
+ else if (typeof existing === "string") {
95
+ this.memoryEstimate -= existing.length * 2;
96
+ }
97
+ }
98
+ return this.cache.delete(hash);
99
+ }
100
+ /**
101
+ * Clear the entire cache
102
+ */
103
+ clear() {
104
+ this.cache.clear();
105
+ this.memoryEstimate = 0;
106
+ }
107
+ /**
108
+ * Get cache size
109
+ */
110
+ get size() {
111
+ return this.cache.size;
112
+ }
113
+ /**
114
+ * Get cache statistics
115
+ */
116
+ get stats() {
117
+ return {
118
+ ...this.cache.stats,
119
+ memoryEstimate: this.memoryEstimate,
120
+ };
121
+ }
122
+ /**
123
+ * Prune expired entries
124
+ */
125
+ prune() {
126
+ return this.cache.prune();
127
+ }
128
+ // ═══════════════════════════════════════════════════════════════════════
129
+ // LEGACY COMPATIBILITY
130
+ // ═══════════════════════════════════════════════════════════════════════
131
+ /**
132
+ * @deprecated Use getHash() instead (sync, no await needed)
133
+ */
134
+ async getHashAsync(config) {
135
+ return this.getHash(config);
136
+ }
137
+ /**
138
+ * Set cache TTL
139
+ * Note: Only affects new entries, not existing ones
140
+ */
141
+ setTTL(_milliseconds) {
142
+ console.warn("SnapshotCacheV2.setTTL() is deprecated. Pass ttl in constructor options.");
143
+ }
144
+ }
145
+ // SINGLETON INSTANCE
146
+ /**
147
+ * Global singleton cache instance
148
+ * Configured with sensible defaults
149
+ */
150
+ let _instance = null;
151
+ export function getSnapshotCache() {
152
+ if (!_instance) {
153
+ _instance = new SnapshotCacheV2({
154
+ maxSize: 500,
155
+ ttl: 0, // No expiration by default
156
+ });
157
+ }
158
+ return _instance;
159
+ }
160
+ /**
161
+ * Configure the global cache instance
162
+ * Must be called before any cache operations
163
+ */
164
+ export function configureSnapshotCache(options) {
165
+ _instance = new SnapshotCacheV2(options);
166
+ }
167
+ /**
168
+ * Legacy export for backward compatibility
169
+ */
170
+ export const snapshotCache = {
171
+ get instance() {
172
+ return getSnapshotCache();
173
+ },
174
+ getHash(config) {
175
+ return getSnapshotCache().getHash(config);
176
+ },
177
+ async getHashAsync(config) {
178
+ return getSnapshotCache().getHash(config);
179
+ },
180
+ get(hash) {
181
+ return getSnapshotCache().get(hash);
182
+ },
183
+ has(hash) {
184
+ return getSnapshotCache().has(hash);
185
+ },
186
+ set(hash, data) {
187
+ getSnapshotCache().set(hash, data);
188
+ },
189
+ delete(hash) {
190
+ return getSnapshotCache().delete(hash);
191
+ },
192
+ clear() {
193
+ getSnapshotCache().clear();
194
+ },
195
+ get size() {
196
+ return getSnapshotCache().size;
197
+ },
198
+ get stats() {
199
+ return getSnapshotCache().stats;
200
+ },
201
+ setTTL(ms) {
202
+ getSnapshotCache().setTTL(ms);
203
+ },
204
+ };
package/dist/cache.d.ts CHANGED
@@ -21,9 +21,9 @@ export declare class SnapshotCache {
21
21
  */
22
22
  getHashAsync(config: any): Promise<string>;
23
23
  /**
24
- * Calculate a hash for a configuration object (sync fallback)
24
+ * Calculate a hash for a configuration object (sync)
25
25
  * Uses djb2 algorithm - fast but has higher collision probability
26
- * @deprecated Use getHashAsync for better collision resistance
26
+ * Note: Cache v2 uses FNV-1a (fnv1a/fastHash) for better performance
27
27
  */
28
28
  getHash(config: any): string;
29
29
  /**
package/dist/cache.js CHANGED
@@ -50,9 +50,9 @@ export class SnapshotCache {
50
50
  }
51
51
  }
52
52
  /**
53
- * Calculate a hash for a configuration object (sync fallback)
53
+ * Calculate a hash for a configuration object (sync)
54
54
  * Uses djb2 algorithm - fast but has higher collision probability
55
- * @deprecated Use getHashAsync for better collision resistance
55
+ * Note: Cache v2 uses FNV-1a (fnv1a/fastHash) for better performance
56
56
  */
57
57
  getHash(config) {
58
58
  const str = this.serializeConfig(config);
package/dist/css.d.ts CHANGED
@@ -3,15 +3,15 @@
3
3
  * This is a subset of React.CSSProperties optimized for OG image generation
4
4
  */
5
5
  export interface CSSProperties {
6
- display?: "flex" | "none";
7
- position?: "relative" | "absolute";
6
+ display?: "flex" | "none" | "block" | "inline" | "inline-flex" | "inline-block";
7
+ position?: "relative" | "absolute" | "fixed" | "static" | "sticky";
8
8
  flexDirection?: "row" | "row-reverse" | "column" | "column-reverse";
9
9
  flexWrap?: "nowrap" | "wrap" | "wrap-reverse";
10
10
  flexGrow?: number;
11
11
  flexShrink?: number;
12
12
  flexBasis?: number | string;
13
13
  alignItems?: "flex-start" | "flex-end" | "center" | "baseline" | "stretch";
14
- alignContent?: "flex-start" | "flex-end" | "center" | "space-between" | "space-around" | "stretch";
14
+ alignContent?: "flex-start" | "flex-end" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch";
15
15
  alignSelf?: "auto" | "flex-start" | "flex-end" | "center" | "baseline" | "stretch";
16
16
  justifyContent?: "flex-start" | "flex-end" | "center" | "space-between" | "space-around" | "space-evenly";
17
17
  gap?: number | string;
@@ -39,7 +39,7 @@ export interface CSSProperties {
39
39
  left?: number | string;
40
40
  border?: string;
41
41
  borderWidth?: number | string;
42
- borderStyle?: "solid" | "dashed";
42
+ borderStyle?: "solid" | "dashed" | "dotted" | "double" | "none";
43
43
  borderColor?: string;
44
44
  borderTop?: string;
45
45
  borderRight?: string;
@@ -71,13 +71,26 @@ export interface CSSProperties {
71
71
  whiteSpace?: "normal" | "pre" | "pre-wrap" | "pre-line" | "nowrap";
72
72
  wordBreak?: "normal" | "break-all" | "break-word" | "keep-all";
73
73
  opacity?: number;
74
- overflow?: "visible" | "hidden";
74
+ overflow?: "visible" | "hidden" | "auto" | "scroll";
75
+ overflowX?: "visible" | "hidden" | "auto" | "scroll";
76
+ overflowY?: "visible" | "hidden" | "auto" | "scroll";
75
77
  boxShadow?: string;
76
78
  transform?: string;
77
79
  transformOrigin?: string;
78
- objectFit?: "contain" | "cover" | "none";
80
+ objectFit?: "contain" | "cover" | "none" | "fill" | "scale-down";
79
81
  objectPosition?: string;
80
82
  filter?: string;
81
83
  clipPath?: string;
84
+ zIndex?: number | string;
85
+ aspectRatio?: string;
86
+ justifyItems?: "start" | "end" | "center" | "stretch";
87
+ justifySelf?: "auto" | "start" | "end" | "center" | "stretch";
88
+ pointerEvents?: "none" | "auto";
89
+ userSelect?: "none" | "text" | "all" | "auto";
90
+ borderTopWidth?: number | string;
91
+ borderRightWidth?: number | string;
92
+ borderBottomWidth?: number | string;
93
+ borderLeftWidth?: number | string;
94
+ overflowWrap?: "normal" | "break-word";
82
95
  }
83
96
  //# sourceMappingURL=css.d.ts.map
package/dist/css.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"css.d.ts","sourceRoot":"","sources":["../src/css.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,aAAa;IAE7B,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IACnC,aAAa,CAAC,EAAE,KAAK,GAAG,aAAa,GAAG,QAAQ,GAAG,gBAAgB,CAAC;IACpE,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,cAAc,CAAC;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;IAC3E,YAAY,CAAC,EACV,YAAY,GACZ,UAAU,GACV,QAAQ,GACR,eAAe,GACf,cAAc,GACd,SAAS,CAAC;IACb,SAAS,CAAC,EACP,MAAM,GACN,YAAY,GACZ,UAAU,GACV,QAAQ,GACR,UAAU,GACV,SAAS,CAAC;IACb,cAAc,CAAC,EACZ,YAAY,GACZ,UAAU,GACV,QAAQ,GACR,eAAe,GACf,cAAc,GACd,cAAc,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,MAAM,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