@pandacss/shared
Advanced tools
Comparing version 0.0.0-dev-20240413152357 to 0.0.0-dev-20240419031424
@@ -9,2 +9,24 @@ import { W as WalkObjectStopFn, M as MappedObject, C as CreateCssContext } from './shared-5yRolXii.js'; | ||
declare class CacheMap<K, V> implements Map<K, V> { | ||
private cache; | ||
private keysInUse; | ||
private maxCacheSize; | ||
constructor(maxCacheSize?: number); | ||
get(key: K): V | undefined; | ||
set(key: K, value: V): this; | ||
delete(key: K): boolean; | ||
private updateKeyUsage; | ||
private evictLeastRecentlyUsed; | ||
clear(): void; | ||
has(key: K): boolean; | ||
get size(): number; | ||
forEach(callback: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void; | ||
keys(): IterableIterator<K>; | ||
values(): IterableIterator<V>; | ||
entries(): IterableIterator<[K, V]>; | ||
[Symbol.iterator](): IterableIterator<[K, V]>; | ||
[Symbol.toStringTag]: string; | ||
toJSON: () => Map<K, V>; | ||
} | ||
type Operand = string | number | { | ||
@@ -138,2 +160,2 @@ ref: string; | ||
export { CreateCssContext, type CssVar, type CssVarOptions, type MapToRecord, MappedObject, PandaError, type PandaErrorCode, WalkObjectStopFn, assign, calc, camelCaseProperty, capitalize, createRegex, cssVar, dashCase, deepSet, entries, esc, flatten, fromEntries, getArbitraryValue, getDotPath, getNegativePath, getOrCreateSet, getPropertyPriority, getUnit, isCssFunction, isCssUnit, isCssVar, isObjectOrArray, mapEntries, mapToJson, mergeWith, normalizeStyleObject, omit, parseJson, splitBy, splitDotPath, stringifyJson, toEm, toPx, toRem, toResponsiveObject, traverse, uncapitalize, unionType }; | ||
export { CacheMap, CreateCssContext, type CssVar, type CssVarOptions, type MapToRecord, MappedObject, PandaError, type PandaErrorCode, WalkObjectStopFn, assign, calc, camelCaseProperty, capitalize, createRegex, cssVar, dashCase, deepSet, entries, esc, flatten, fromEntries, getArbitraryValue, getDotPath, getNegativePath, getOrCreateSet, getPropertyPriority, getUnit, isCssFunction, isCssUnit, isCssVar, isObjectOrArray, mapEntries, mapToJson, mergeWith, normalizeStyleObject, omit, parseJson, splitBy, splitDotPath, stringifyJson, toEm, toPx, toRem, toResponsiveObject, traverse, uncapitalize, unionType }; |
@@ -23,2 +23,3 @@ "use strict"; | ||
__export(src_exports, { | ||
CacheMap: () => CacheMap, | ||
PandaError: () => PandaError, | ||
@@ -158,2 +159,81 @@ assign: () => assign, | ||
// src/cache-map.ts | ||
var CacheMap = class { | ||
cache; | ||
keysInUse; | ||
maxCacheSize; | ||
constructor(maxCacheSize = 1e3) { | ||
this.maxCacheSize = maxCacheSize; | ||
this.cache = /* @__PURE__ */ new Map(); | ||
this.keysInUse = []; | ||
} | ||
get(key) { | ||
if (!this.cache.has(key)) { | ||
return void 0; | ||
} | ||
this.updateKeyUsage(key); | ||
return this.cache.get(key); | ||
} | ||
set(key, value) { | ||
if (!this.cache.has(key) && this.cache.size === this.maxCacheSize) { | ||
this.evictLeastRecentlyUsed(); | ||
} | ||
this.cache.set(key, value); | ||
this.updateKeyUsage(key); | ||
return this; | ||
} | ||
delete(key) { | ||
const result = this.cache.delete(key); | ||
if (result) { | ||
const index = this.keysInUse.indexOf(key); | ||
if (index !== -1) { | ||
this.keysInUse.splice(index, 1); | ||
} | ||
} | ||
return result; | ||
} | ||
updateKeyUsage(key) { | ||
const index = this.keysInUse.indexOf(key); | ||
if (index !== -1) { | ||
this.keysInUse.splice(index, 1); | ||
} | ||
this.keysInUse.push(key); | ||
} | ||
evictLeastRecentlyUsed() { | ||
const keyToEvict = this.keysInUse.shift(); | ||
if (keyToEvict !== void 0) { | ||
this.cache.delete(keyToEvict); | ||
} | ||
} | ||
clear() { | ||
this.cache.clear(); | ||
this.keysInUse = []; | ||
} | ||
has(key) { | ||
return this.cache.has(key); | ||
} | ||
get size() { | ||
return this.cache.size; | ||
} | ||
forEach(callback2, thisArg) { | ||
this.cache.forEach(callback2, thisArg); | ||
} | ||
keys() { | ||
return this.cache.keys(); | ||
} | ||
values() { | ||
return this.cache.values(); | ||
} | ||
entries() { | ||
return this.cache.entries(); | ||
} | ||
[Symbol.iterator]() { | ||
return this.cache[Symbol.iterator](); | ||
} | ||
[Symbol.toStringTag] = "CacheMap"; | ||
toJSON = () => { | ||
return this.cache; | ||
}; | ||
}; | ||
// src/calc.ts | ||
@@ -948,2 +1028,3 @@ function isCssVar(value) { | ||
0 && (module.exports = { | ||
CacheMap, | ||
PandaError, | ||
@@ -950,0 +1031,0 @@ assign, |
{ | ||
"name": "@pandacss/shared", | ||
"version": "0.0.0-dev-20240413152357", | ||
"version": "0.0.0-dev-20240419031424", | ||
"description": "Shared utilities for css panda", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
109972
2965