init
This commit is contained in:
1
mc_test/node_modules/@emotion/utils/src/conditions/false.ts
generated
vendored
Executable file
1
mc_test/node_modules/@emotion/utils/src/conditions/false.ts
generated
vendored
Executable file
@ -0,0 +1 @@
|
||||
export default false as boolean
|
||||
1
mc_test/node_modules/@emotion/utils/src/conditions/is-browser.ts
generated
vendored
Executable file
1
mc_test/node_modules/@emotion/utils/src/conditions/is-browser.ts
generated
vendored
Executable file
@ -0,0 +1 @@
|
||||
export default typeof document !== 'undefined'
|
||||
1
mc_test/node_modules/@emotion/utils/src/conditions/true.ts
generated
vendored
Executable file
1
mc_test/node_modules/@emotion/utils/src/conditions/true.ts
generated
vendored
Executable file
@ -0,0 +1 @@
|
||||
export default true as boolean
|
||||
75
mc_test/node_modules/@emotion/utils/src/index.ts
generated
vendored
Executable file
75
mc_test/node_modules/@emotion/utils/src/index.ts
generated
vendored
Executable file
@ -0,0 +1,75 @@
|
||||
import isBrowser from '#is-browser'
|
||||
import { RegisteredCache, EmotionCache, SerializedStyles } from './types'
|
||||
|
||||
export function getRegisteredStyles(
|
||||
registered: RegisteredCache,
|
||||
registeredStyles: string[],
|
||||
classNames: string
|
||||
): string {
|
||||
let rawClassName = ''
|
||||
|
||||
classNames.split(' ').forEach(className => {
|
||||
if (registered[className] !== undefined) {
|
||||
registeredStyles.push(`${registered[className]};`)
|
||||
} else if (className) {
|
||||
rawClassName += `${className} `
|
||||
}
|
||||
})
|
||||
return rawClassName
|
||||
}
|
||||
|
||||
export const registerStyles = (
|
||||
cache: EmotionCache,
|
||||
serialized: SerializedStyles,
|
||||
isStringTag: boolean
|
||||
): void => {
|
||||
let 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
|
||||
}
|
||||
}
|
||||
|
||||
export const insertStyles = (
|
||||
cache: EmotionCache,
|
||||
serialized: SerializedStyles,
|
||||
isStringTag: boolean
|
||||
) => {
|
||||
registerStyles(cache, serialized, isStringTag)
|
||||
|
||||
let className = `${cache.key}-${serialized.name}`
|
||||
|
||||
if (cache.inserted[serialized.name] === undefined) {
|
||||
let stylesForSSR = ''
|
||||
let current: SerializedStyles | undefined = serialized
|
||||
do {
|
||||
let 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export * from './types'
|
||||
26
mc_test/node_modules/@emotion/utils/src/types.ts
generated
vendored
Executable file
26
mc_test/node_modules/@emotion/utils/src/types.ts
generated
vendored
Executable file
@ -0,0 +1,26 @@
|
||||
import type { StyleSheet } from '@emotion/sheet'
|
||||
|
||||
export type { StyleSheet }
|
||||
|
||||
export type RegisteredCache = Record<string, string | undefined>
|
||||
|
||||
export type SerializedStyles = {
|
||||
name: string
|
||||
styles: string
|
||||
next?: SerializedStyles
|
||||
}
|
||||
|
||||
export type EmotionCache = {
|
||||
inserted: Record<string, string | true | undefined>
|
||||
registered: RegisteredCache
|
||||
sheet: StyleSheet
|
||||
key: string
|
||||
compat?: true
|
||||
nonce?: string
|
||||
insert: (
|
||||
selector: string,
|
||||
serialized: SerializedStyles,
|
||||
sheet: StyleSheet,
|
||||
shouldCache: boolean
|
||||
) => string | void
|
||||
}
|
||||
Reference in New Issue
Block a user