@emotion/utils
Advanced tools
Comparing version 1.3.0 to 1.4.0
@@ -1,5 +0,5 @@ | ||
import { RegisteredCache, EmotionCache, SerializedStyles } from './types'; | ||
import { RegisteredCache, EmotionCache, SerializedStyles } from "./types.js"; | ||
export declare function getRegisteredStyles(registered: RegisteredCache, registeredStyles: string[], classNames: string): string; | ||
export declare const registerStyles: (cache: EmotionCache, serialized: SerializedStyles, isStringTag: boolean) => void; | ||
export declare const insertStyles: (cache: EmotionCache, serialized: SerializedStyles, isStringTag: boolean) => string | undefined; | ||
export * from './types'; | ||
export * from "./types.js"; |
@@ -1,2 +0,3 @@ | ||
var isBrowser = "object" !== 'undefined'; | ||
var isBrowser = true; | ||
function getRegisteredStyles(registered, registeredStyles, classNames) { | ||
@@ -3,0 +4,0 @@ var rawClassName = ''; |
export * from "./declarations/src/index"; | ||
//# sourceMappingURL=emotion-utils.cjs.d.ts.map | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW1vdGlvbi11dGlscy5janMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4vZGVjbGFyYXRpb25zL3NyYy9pbmRleC5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBIn0= |
'use strict'; | ||
if (process.env.NODE_ENV === "production") { | ||
module.exports = require("./emotion-utils.cjs.prod.js"); | ||
} else { | ||
module.exports = require("./emotion-utils.cjs.dev.js"); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var isBrowser = typeof document !== 'undefined'; | ||
function getRegisteredStyles(registered, registeredStyles, classNames) { | ||
var rawClassName = ''; | ||
classNames.split(' ').forEach(function (className) { | ||
if (registered[className] !== undefined) { | ||
registeredStyles.push(registered[className] + ";"); | ||
} else { | ||
rawClassName += className + " "; | ||
} | ||
}); | ||
return rawClassName; | ||
} | ||
var registerStyles = function registerStyles(cache, serialized, isStringTag) { | ||
var className = cache.key + "-" + serialized.name; | ||
if ( // we only need to add the styles to the registered cache if the | ||
// class name could be used further down | ||
// the tree but if it's a string tag, we know it won't | ||
// so we don't have to add it to registered cache. | ||
// this improves memory usage since we can avoid storing the whole style string | ||
(isStringTag === false || // we need to always store it if we're in compat mode and | ||
// in node since emotion-server relies on whether a style is in | ||
// the registered cache to know whether a style is global or not | ||
// also, note that this check will be dead code eliminated in the browser | ||
isBrowser === false && cache.compat !== undefined) && cache.registered[className] === undefined) { | ||
cache.registered[className] = serialized.styles; | ||
} | ||
}; | ||
var insertStyles = function insertStyles(cache, serialized, isStringTag) { | ||
registerStyles(cache, serialized, isStringTag); | ||
var className = cache.key + "-" + serialized.name; | ||
if (cache.inserted[serialized.name] === undefined) { | ||
var stylesForSSR = ''; | ||
var current = serialized; | ||
do { | ||
var maybeStyles = cache.insert(serialized === current ? "." + className : '', current, cache.sheet, true); | ||
if (!isBrowser && maybeStyles !== undefined) { | ||
stylesForSSR += maybeStyles; | ||
} | ||
current = current.next; | ||
} while (current !== undefined); | ||
if (!isBrowser && stylesForSSR.length !== 0) { | ||
return stylesForSSR; | ||
} | ||
} | ||
}; | ||
exports.getRegisteredStyles = getRegisteredStyles; | ||
exports.insertStyles = insertStyles; | ||
exports.registerStyles = registerStyles; |
var isBrowser = typeof document !== 'undefined'; | ||
function getRegisteredStyles(registered, registeredStyles, classNames) { | ||
@@ -3,0 +4,0 @@ var rawClassName = ''; |
{ | ||
"name": "@emotion/utils", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "internal utils for emotion", | ||
@@ -8,12 +8,29 @@ "main": "dist/emotion-utils.cjs.js", | ||
"types": "dist/emotion-utils.cjs.d.ts", | ||
"browser": { | ||
"./dist/emotion-utils.esm.js": "./dist/emotion-utils.browser.esm.js" | ||
}, | ||
"exports": { | ||
".": { | ||
"module": { | ||
"worker": "./dist/emotion-utils.worker.esm.js", | ||
"browser": "./dist/emotion-utils.browser.esm.js", | ||
"default": "./dist/emotion-utils.esm.js" | ||
"types": { | ||
"import": "./dist/emotion-utils.cjs.mjs", | ||
"default": "./dist/emotion-utils.cjs.js" | ||
}, | ||
"edge-light": { | ||
"module": "./dist/emotion-utils.edge-light.esm.js", | ||
"import": "./dist/emotion-utils.edge-light.cjs.mjs", | ||
"default": "./dist/emotion-utils.edge-light.cjs.js" | ||
}, | ||
"worker": { | ||
"module": "./dist/emotion-utils.edge-light.esm.js", | ||
"import": "./dist/emotion-utils.edge-light.cjs.mjs", | ||
"default": "./dist/emotion-utils.edge-light.cjs.js" | ||
}, | ||
"workerd": { | ||
"module": "./dist/emotion-utils.edge-light.esm.js", | ||
"import": "./dist/emotion-utils.edge-light.cjs.mjs", | ||
"default": "./dist/emotion-utils.edge-light.cjs.js" | ||
}, | ||
"browser": { | ||
"module": "./dist/emotion-utils.browser.esm.js", | ||
"import": "./dist/emotion-utils.browser.cjs.mjs", | ||
"default": "./dist/emotion-utils.browser.cjs.js" | ||
}, | ||
"module": "./dist/emotion-utils.esm.js", | ||
"import": "./dist/emotion-utils.cjs.mjs", | ||
@@ -24,2 +41,11 @@ "default": "./dist/emotion-utils.cjs.js" | ||
}, | ||
"imports": { | ||
"#is-browser": { | ||
"edge-light": "./src/conditions/false.ts", | ||
"workerd": "./src/conditions/false.ts", | ||
"worker": "./src/conditions/false.ts", | ||
"browser": "./src/conditions/true.ts", | ||
"default": "./src/conditions/is-browser.ts" | ||
} | ||
}, | ||
"license": "MIT", | ||
@@ -40,11 +66,3 @@ "scripts": { | ||
"typescript": "^5.4.5" | ||
}, | ||
"preconstruct": { | ||
"exports": { | ||
"envConditions": [ | ||
"browser", | ||
"worker" | ||
] | ||
} | ||
} | ||
} |
@@ -0,5 +1,4 @@ | ||
import isBrowser from '#is-browser' | ||
import { RegisteredCache, EmotionCache, SerializedStyles } from './types' | ||
const isBrowser = typeof document !== 'undefined' | ||
export function getRegisteredStyles( | ||
@@ -6,0 +5,0 @@ registered: RegisteredCache, |
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
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
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
19880
20
406
1
1