@kuma-ui/sheet
Advanced tools
Comparing version
/** | ||
* The generateHash function is a utility function that generates a hash value for a given input string using the MurmurHash algorithm. | ||
*/ | ||
export declare function generateHash(str: string): string; | ||
declare function generateHash(str: string): string; | ||
export { generateHash }; |
@@ -1,3 +0,5 @@ | ||
export { sheet } from "./sheet"; | ||
export { theme } from "./theme"; | ||
export * from "./regex"; | ||
export { sheet } from './sheet.js'; | ||
export { theme } from './theme.js'; | ||
export { styleCache } from './cache.js'; | ||
export { styleMap } from './styleMap.js'; | ||
export { cssPropertyRegex, removeSpacesExceptInPropertiesRegex } from './regex.js'; |
@@ -31,2 +31,4 @@ "use strict"; | ||
sheet: () => sheet, | ||
styleCache: () => styleCache, | ||
styleMap: () => styleMap, | ||
theme: () => theme | ||
@@ -122,8 +124,2 @@ }); | ||
} | ||
getFromCache(key) { | ||
return this.cache.get(key); | ||
} | ||
addToCache(key, styles) { | ||
this.cache.set(key, styles); | ||
} | ||
reset() { | ||
@@ -170,2 +166,61 @@ this.rules = []; | ||
var theme = Theme.getInstance(); | ||
// src/cache.ts | ||
var _StyleCache = class { | ||
cache; | ||
constructor() { | ||
this.cache = /* @__PURE__ */ new Map(); | ||
} | ||
static getInstance() { | ||
if (!_StyleCache.instance) { | ||
_StyleCache.instance = new _StyleCache(); | ||
} | ||
return _StyleCache.instance; | ||
} | ||
get(key) { | ||
return this.cache.get(key); | ||
} | ||
set(key, styles) { | ||
this.cache.set(key, styles); | ||
} | ||
reset() { | ||
this.cache.clear(); | ||
} | ||
}; | ||
var StyleCache = _StyleCache; | ||
__publicField(StyleCache, "instance"); | ||
var styleCache = StyleCache.getInstance(); | ||
// src/styleMap.ts | ||
var _StyleMap = class { | ||
map; | ||
constructor() { | ||
this.map = /* @__PURE__ */ new Map(); | ||
} | ||
static getInstance() { | ||
if (!_StyleMap.instance) { | ||
_StyleMap.instance = new _StyleMap(); | ||
} | ||
return _StyleMap.instance; | ||
} | ||
// Add the given CSS for the specified file to the map. | ||
// In the future, we might use an id to associate the HTML tag | ||
// with the corresponding CSS (by using the data-kuma-ui attribute) | ||
// and improve performance by removing duplicate CSS across different files. | ||
set(fileName, css) { | ||
this.map.set(fileName, css); | ||
} | ||
get(fileName) { | ||
return this.map.get(fileName); | ||
} | ||
delete(fileName) { | ||
this.map.delete(fileName); | ||
} | ||
reset() { | ||
this.map.clear(); | ||
} | ||
}; | ||
var StyleMap = _StyleMap; | ||
__publicField(StyleMap, "instance"); | ||
var styleMap = StyleMap.getInstance(); | ||
// Annotate the CommonJS export names for ESM import in node: | ||
@@ -176,3 +231,5 @@ 0 && (module.exports = { | ||
sheet, | ||
styleCache, | ||
styleMap, | ||
theme | ||
}); |
@@ -1,2 +0,4 @@ | ||
export declare const cssPropertyRegex: RegExp; | ||
export declare const removeSpacesExceptInPropertiesRegex: RegExp; | ||
declare const cssPropertyRegex: RegExp; | ||
declare const removeSpacesExceptInPropertiesRegex: RegExp; | ||
export { cssPropertyRegex, removeSpacesExceptInPropertiesRegex }; |
@@ -1,12 +0,6 @@ | ||
type ResponsiveStyle = { | ||
base: string; | ||
media: { | ||
[breakpoint: string]: string; | ||
}; | ||
}; | ||
export interface Rule { | ||
interface Rule { | ||
id: string; | ||
css: string; | ||
} | ||
export declare class Sheet { | ||
declare class Sheet { | ||
private static instance; | ||
@@ -24,7 +18,11 @@ private rules; | ||
getCSS(): string; | ||
getFromCache(key: string): ResponsiveStyle | undefined; | ||
addToCache(key: string, styles: ResponsiveStyle): void; | ||
reset(): void; | ||
} | ||
export declare const sheet: Sheet; | ||
export {}; | ||
/** | ||
* The Sheet singleton class is responsible for managing the CSS rules, responsive | ||
* styles, and pseudo-classes used by Kuma-UI. It provides methods to add and retrieve | ||
* rules, and generates the final CSS output. | ||
*/ | ||
declare const sheet: Sheet; | ||
export { Rule, Sheet, sheet }; |
@@ -119,8 +119,2 @@ "use strict"; | ||
} | ||
getFromCache(key) { | ||
return this.cache.get(key); | ||
} | ||
addToCache(key, styles) { | ||
this.cache.set(key, styles); | ||
} | ||
reset() { | ||
@@ -127,0 +121,0 @@ this.rules = []; |
@@ -1,2 +0,2 @@ | ||
export declare const defaultBreakpoints: Readonly<{ | ||
declare const defaultBreakpoints: Readonly<{ | ||
sm: "576px"; | ||
@@ -7,3 +7,3 @@ md: "768px"; | ||
}>; | ||
export declare class Theme { | ||
declare class Theme { | ||
private static instance; | ||
@@ -17,2 +17,4 @@ private _breakpoints; | ||
} | ||
export declare const theme: Theme; | ||
declare const theme: Theme; | ||
export { Theme, defaultBreakpoints, theme }; |
{ | ||
"name": "@kuma-ui/sheet", | ||
"version": "0.0.3", | ||
"version": "0.1.0", | ||
"description": "🐻 Kuma UI is a utility-first, zero-runtime CSS-in-JS library that offers an outstanding developer experience and optimized performance.", | ||
@@ -26,6 +26,11 @@ "repository": { | ||
}, | ||
"devDependencies": { | ||
"@jest/globals": "^29.5.0", | ||
"@jest/types": "^29.1.0", | ||
"jest": "^29.1.0", | ||
"@kuma-ui/jest-preset": "0.0.0" | ||
}, | ||
"scripts": { | ||
"build": "yarn build:dist && yarn build:declarations", | ||
"build:declarations": "tsc --emitDeclarationOnly --outDir dist", | ||
"build:dist": "tsup src --format cjs,esm --config ../../rollup.config.js", | ||
"build": "tsup --config ../../tsup.config.ts", | ||
"test": "jest", | ||
"typecheck": "tsc --noEmit --composite false", | ||
@@ -32,0 +37,0 @@ "lint": "eslint './src/**/*.{js,ts,jsx,tsx}'", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
32771
-29.25%4
Infinity%31
-11.43%1029
-29.81%1
Infinity%