diff --git a/src/extractStyle.ts b/src/extractStyle.ts new file mode 100644 index 0000000..dd2b0fe --- /dev/null +++ b/src/extractStyle.ts @@ -0,0 +1,81 @@ +import type Cache from './Cache'; +import { + extract as tokenExtractStyle, + TOKEN_PREFIX, +} from './hooks/useCacheToken'; +import { + CSS_VAR_PREFIX, + extract as cssVarExtractStyle, +} from './hooks/useCSSVarRegister'; +import { + extract as styleExtractStyle, + STYLE_PREFIX, +} from './hooks/useStyleRegister'; +import { toStyleStr } from './util'; +import { + ATTR_CACHE_MAP, + serialize as serializeCacheMap, +} from './util/cacheMapUtil'; + +const ExtractStyleFns = { + [STYLE_PREFIX]: styleExtractStyle, + [TOKEN_PREFIX]: tokenExtractStyle, + [CSS_VAR_PREFIX]: cssVarExtractStyle, +}; + +function isNotNull(value: T | null): value is T { + return value !== null; +} + +export default function extractStyle(cache: Cache, plain = false) { + const matchPrefixRegexp = new RegExp( + `^(${Object.keys(ExtractStyleFns).join('|')})%`, + ); + + // prefix with `style` is used for `useStyleRegister` to cache style context + const styleKeys = Array.from(cache.cache.keys()).filter((key) => + matchPrefixRegexp.test(key), + ); + + // Common effect styles like animation + const effectStyles: Record = {}; + + // Mapping of cachePath to style hash + const cachePathMap: Record = {}; + + let styleText = ''; + + styleKeys + .map<[number, string] | null>((key) => { + const cachePath = key.replace(matchPrefixRegexp, '').replace(/%/g, '|'); + const [prefix] = key.split('%'); + const extractFn = ExtractStyleFns[prefix as keyof typeof ExtractStyleFns]; + const extractedStyle = extractFn(cache.cache.get(key)![1], effectStyles, { + plain, + }); + if (!extractedStyle) { + return null; + } + const [order, styleId, styleStr] = extractedStyle; + cachePathMap[cachePath] = styleId; + return [order, styleStr]; + }) + .filter(isNotNull) + .sort(([o1], [o2]) => o1 - o2) + .forEach(([, style]) => { + styleText += style; + }); + + // ==================== Fill Cache Path ==================== + styleText += toStyleStr( + `.${ATTR_CACHE_MAP}{content:"${serializeCacheMap(cachePathMap)}";}`, + undefined, + undefined, + { + [ATTR_CACHE_MAP]: ATTR_CACHE_MAP, + }, + plain, + ); + + return styleText; +} diff --git a/src/hooks/useCSSVarRegister.ts b/src/hooks/useCSSVarRegister.ts index bc58448..74d4f32 100644 --- a/src/hooks/useCSSVarRegister.ts +++ b/src/hooks/useCSSVarRegister.ts @@ -1,4 +1,3 @@ -import hash from '@emotion/hash'; import { removeCSS, updateCSS } from 'rc-util/lib/Dom/dynamicCSS'; import { useContext } from 'react'; import StyleContext, { @@ -6,10 +5,21 @@ import StyleContext, { ATTR_TOKEN, CSS_IN_JS_INSTANCE, } from '../StyleContext'; -import { isClientSide } from '../util'; +import { isClientSide, toStyleStr } from '../util'; import type { TokenWithCSSVar } from '../util/css-variables'; import { transformToken } from '../util/css-variables'; +import type { ExtractStyle } from './useGlobalCache'; import useGlobalCache from './useGlobalCache'; +import { uniqueHash } from './useStyleRegister'; + +export const CSS_VAR_PREFIX = 'cssVar'; + +type CSSVarCacheValue = [ + cssVarToken: TokenWithCSSVar, + cssVarStr: string, + styleId: string, + cssVarKey: string, +]; const useCSSVarRegister = >( config: { @@ -29,24 +39,24 @@ const useCSSVarRegister = >( } = useContext(StyleContext); const { _tokenKey: tokenKey } = token; - const cache = useGlobalCache<[TokenWithCSSVar, string, T, string]>( - 'variables', + const cache = useGlobalCache>( + CSS_VAR_PREFIX, [...config.path, key, tokenKey], () => { - const styleId = hash([...config.path, key].join('%')); const originToken = fn(); const [mergedToken, cssVarsStr] = transformToken(originToken, key, { prefix, unitless, }); - return [mergedToken, cssVarsStr, originToken, styleId]; + const styleId = uniqueHash([...config.path, key], cssVarsStr); + return [mergedToken, cssVarsStr, styleId, key]; }, - ([, , , styleId], fromHMR) => { + ([, , styleId], fromHMR) => { if ((fromHMR || autoClear) && isClientSide) { removeCSS(styleId, { mark: ATTR_MARK }); } }, - ([, cssVarsStr, , styleId]) => { + ([, cssVarsStr, styleId]) => { if (!cssVarsStr) { return; } @@ -67,4 +77,36 @@ const useCSSVarRegister = >( return cache; }; +export const extract: ExtractStyle> = ( + cache, + effectStyles, + options, +) => { + const [, styleStr, styleId, cssVarKey] = cache; + const { plain } = options || {}; + + if (!styleStr) { + return null; + } + + const order = -999; + + // ====================== Style ====================== + // Used for rc-util + const sharedAttrs = { + 'data-rc-order': 'prependQueue', + 'data-rc-priority': `${order}`, + }; + + const styleText = toStyleStr( + styleStr, + cssVarKey, + styleId, + sharedAttrs, + plain, + ); + + return [order, styleId, styleText]; +}; + export default useCSSVarRegister; diff --git a/src/hooks/useCacheToken.tsx b/src/hooks/useCacheToken.tsx index 27fb2ba..058019f 100644 --- a/src/hooks/useCacheToken.tsx +++ b/src/hooks/useCacheToken.tsx @@ -7,8 +7,9 @@ import StyleContext, { CSS_IN_JS_INSTANCE, } from '../StyleContext'; import type Theme from '../theme/Theme'; -import { flattenToken, memoResult, token2key } from '../util'; +import { flattenToken, memoResult, token2key, toStyleStr } from '../util'; import { transformToken } from '../util/css-variables'; +import type { ExtractStyle } from './useGlobalCache'; import useGlobalCache from './useGlobalCache'; const EMPTY_OVERRIDE = {}; @@ -130,6 +131,16 @@ export const getComputedToken = < return mergedDerivativeToken; }; +export const TOKEN_PREFIX = 'token'; + +type TokenCacheValue = [ + token: DerivativeToken & { _tokenKey: string; _themeKey: string }, + hashId: string, + realToken: DerivativeToken & { _tokenKey: string }, + cssVarStr: string, + cssVarKey: string, +]; + /** * Cache theme derivative token as global shared one * @param theme Theme entity @@ -144,12 +155,7 @@ export default function useCacheToken< theme: Theme, tokens: Partial[], option: Option = {}, -): [ - DerivativeToken & { _tokenKey: string; _themeKey: string }, - string, - DerivativeToken, - string, -] { +): TokenCacheValue { const { cache: { instanceId }, container, @@ -170,15 +176,8 @@ export default function useCacheToken< const cssVarStr = cssVar ? flattenToken(cssVar) : ''; - const cachedToken = useGlobalCache< - [ - DerivativeToken & { _tokenKey: string; _themeKey: string }, - string, - DerivativeToken, - string, - ] - >( - 'token', + const cachedToken = useGlobalCache>( + TOKEN_PREFIX, [salt, theme.id, tokenStr, overrideTokenStr, cssVarStr], () => { let mergedDerivativeToken = compute @@ -214,7 +213,13 @@ export default function useCacheToken< : `${hashPrefix}-${hash(tokenKey)}`; mergedDerivativeToken._hashId = hashId; // Not used - return [mergedDerivativeToken, hashId, actualToken, cssVarsStr]; + return [ + mergedDerivativeToken, + hashId, + actualToken, + cssVarsStr, + cssVar?.key || '', + ]; }, (cache) => { // Remove token will remove all related style @@ -243,3 +248,36 @@ export default function useCacheToken< return cachedToken; } + +export const extract: ExtractStyle> = ( + cache, + effectStyles, + options, +) => { + const [, , realToken, styleStr, cssVarKey] = cache; + const { plain } = options || {}; + + if (!styleStr) { + return null; + } + + const styleId = realToken._tokenKey; + const order = -999; + + // ====================== Style ====================== + // Used for rc-util + const sharedAttrs = { + 'data-rc-order': 'prependQueue', + 'data-rc-priority': `${order}`, + }; + + const styleText = toStyleStr( + styleStr, + cssVarKey, + styleId, + sharedAttrs, + plain, + ); + + return [order, styleId, styleText]; +}; diff --git a/src/hooks/useGlobalCache.tsx b/src/hooks/useGlobalCache.tsx index 1207fd9..ef27ecb 100644 --- a/src/hooks/useGlobalCache.tsx +++ b/src/hooks/useGlobalCache.tsx @@ -5,6 +5,14 @@ import useCompatibleInsertionEffect from './useCompatibleInsertionEffect'; import useEffectCleanupRegister from './useEffectCleanupRegister'; import useHMR from './useHMR'; +export type ExtractStyle = ( + cache: CacheValue, + effectStyles: Record, + options?: { + plain?: boolean; + }, +) => [order: number, styleId: string, style: string] | null; + export default function useGlobalCache( prefix: string, keyPath: KeyType[], @@ -25,7 +33,7 @@ export default function useGlobalCache( const buildCache = (updater?: (data: UpdaterArgs) => UpdaterArgs) => { globalCache.update(fullPath, (prevCache) => { - const [times = 0, cache] = prevCache || []; + const [times = 0, cache] = prevCache || [undefined, undefined]; // HMR should always ignore cache since developer may change it let tmpCache = cache; diff --git a/src/hooks/useStyleRegister/index.tsx b/src/hooks/useStyleRegister.tsx similarity index 64% rename from src/hooks/useStyleRegister/index.tsx rename to src/hooks/useStyleRegister.tsx index 3cf2843..cfae0de 100644 --- a/src/hooks/useStyleRegister/index.tsx +++ b/src/hooks/useStyleRegister.tsx @@ -5,27 +5,25 @@ import * as React from 'react'; // @ts-ignore import unitless from '@emotion/unitless'; import { compile, serialize, stringify } from 'stylis'; -import type { Theme, Transformer } from '../..'; -import type Cache from '../../Cache'; -import type Keyframes from '../../Keyframes'; -import type { Linter } from '../../linters'; -import { contentQuotesLinter, hashedAnimationLinter } from '../../linters'; -import type { HashPriority } from '../../StyleContext'; +import type { Theme, Transformer } from '..'; +import type Keyframes from '../Keyframes'; +import type { Linter } from '../linters'; +import { contentQuotesLinter, hashedAnimationLinter } from '../linters'; +import type { HashPriority } from '../StyleContext'; import StyleContext, { ATTR_CACHE_PATH, ATTR_MARK, ATTR_TOKEN, CSS_IN_JS_INSTANCE, -} from '../../StyleContext'; -import { isClientSide, supportLayer } from '../../util'; -import useGlobalCache from '../useGlobalCache'; +} from '../StyleContext'; +import { isClientSide, supportLayer, toStyleStr } from '../util'; import { - ATTR_CACHE_MAP, CSS_FILE_STYLE, existPath, getStyleAndHash, - serialize as serializeCacheMap, -} from './cacheMapUtil'; +} from '../util/cacheMapUtil'; +import type { ExtractStyle } from './useGlobalCache'; +import useGlobalCache from './useGlobalCache'; const SKIP_CHECK = '_skip_check_'; const MULTI_VALUE = '_multi_value_'; @@ -344,7 +342,7 @@ export const parseStyle = ( // ============================================================================ // == Register == // ============================================================================ -function uniqueHash(path: (string | number)[], styleStr: string) { +export function uniqueHash(path: (string | number)[], styleStr: string) { return hash(`${path.join('%')}${styleStr}`); } @@ -352,6 +350,17 @@ function Empty() { return null; } +export const STYLE_PREFIX = 'style'; + +type StyleCacheValue = [ + styleStr: string, + tokenKey: string, + styleId: string, + effectStyle: Record, + clientOnly: boolean | undefined, + order: number, +]; + /** * Register a style to the global style sheet. */ @@ -395,100 +404,92 @@ export default function useStyleRegister( isMergedClientSide = mock === 'client'; } - const [cachedStyleStr, cachedTokenKey, cachedStyleId] = useGlobalCache< - [ - styleStr: string, - tokenKey: string, - styleId: string, - effectStyle: Record, - clientOnly: boolean | undefined, - order: number, - ] - >( - 'style', - fullPath, - // Create cache if needed - () => { - const cachePath = fullPath.join('|'); - - // Get style from SSR inline style directly - if (existPath(cachePath)) { - const [inlineCacheStyleStr, styleHash] = getStyleAndHash(cachePath); - if (inlineCacheStyleStr) { - return [ - inlineCacheStyleStr, - tokenKey, - styleHash, - {}, - clientOnly, - order, - ]; + const [cachedStyleStr, cachedTokenKey, cachedStyleId] = + useGlobalCache( + STYLE_PREFIX, + fullPath, + // Create cache if needed + () => { + const cachePath = fullPath.join('|'); + + // Get style from SSR inline style directly + if (existPath(cachePath)) { + const [inlineCacheStyleStr, styleHash] = getStyleAndHash(cachePath); + if (inlineCacheStyleStr) { + return [ + inlineCacheStyleStr, + tokenKey, + styleHash, + {}, + clientOnly, + order, + ]; + } } - } - // Generate style - const styleObj = styleFn(); - const [parsedStyle, effectStyle] = parseStyle(styleObj, { - hashId, - hashPriority, - layer, - path: path.join('-'), - transformers, - linters, - }); + // Generate style + const styleObj = styleFn(); + const [parsedStyle, effectStyle] = parseStyle(styleObj, { + hashId, + hashPriority, + layer, + path: path.join('-'), + transformers, + linters, + }); - const styleStr = normalizeStyle(parsedStyle); - const styleId = uniqueHash(fullPath, styleStr); + const styleStr = normalizeStyle(parsedStyle); + const styleId = uniqueHash(fullPath, styleStr); - return [styleStr, tokenKey, styleId, effectStyle, clientOnly, order]; - }, + return [styleStr, tokenKey, styleId, effectStyle, clientOnly, order]; + }, - // Remove cache if no need - ([, , styleId], fromHMR) => { - if ((fromHMR || autoClear) && isClientSide) { - removeCSS(styleId, { mark: ATTR_MARK }); - } - }, - - // Effect: Inject style here - ([styleStr, _, styleId, effectStyle]) => { - if (isMergedClientSide && styleStr !== CSS_FILE_STYLE) { - const mergedCSSConfig: Parameters[2] = { - mark: ATTR_MARK, - prepend: 'queue', - attachTo: container, - priority: order, - }; - - const nonceStr = typeof nonce === 'function' ? nonce() : nonce; - - if (nonceStr) { - mergedCSSConfig.csp = { nonce: nonceStr }; + // Remove cache if no need + ([, , styleId], fromHMR) => { + if ((fromHMR || autoClear) && isClientSide) { + removeCSS(styleId, { mark: ATTR_MARK }); } + }, + + // Effect: Inject style here + ([styleStr, _, styleId, effectStyle]) => { + if (isMergedClientSide && styleStr !== CSS_FILE_STYLE) { + const mergedCSSConfig: Parameters[2] = { + mark: ATTR_MARK, + prepend: 'queue', + attachTo: container, + priority: order, + }; - const style = updateCSS(styleStr, styleId, mergedCSSConfig); + const nonceStr = typeof nonce === 'function' ? nonce() : nonce; - (style as any)[CSS_IN_JS_INSTANCE] = cache.instanceId; + if (nonceStr) { + mergedCSSConfig.csp = { nonce: nonceStr }; + } - // Used for `useCacheToken` to remove on batch when token removed - style.setAttribute(ATTR_TOKEN, tokenKey); + const style = updateCSS(styleStr, styleId, mergedCSSConfig); - // Debug usage. Dev only - if (process.env.NODE_ENV !== 'production') { - style.setAttribute(ATTR_CACHE_PATH, fullPath.join('|')); - } + (style as any)[CSS_IN_JS_INSTANCE] = cache.instanceId; - // Inject client side effect style - Object.keys(effectStyle).forEach((effectKey) => { - updateCSS( - normalizeStyle(effectStyle[effectKey]), - `_effect-${effectKey}`, - mergedCSSConfig, - ); - }); - } - }, - ); + // Used for `useCacheToken` to remove on batch when token removed + style.setAttribute(ATTR_TOKEN, tokenKey); + + // Debug usage. Dev only + if (process.env.NODE_ENV !== 'production') { + style.setAttribute(ATTR_CACHE_PATH, fullPath.join('|')); + } + + // Inject client side effect style + Object.keys(effectStyle).forEach((effectKey) => { + updateCSS( + normalizeStyle(effectStyle[effectKey]), + `_effect-${effectKey}`, + mergedCSSConfig, + ); + }); + } + }, + ); return (node: React.ReactElement) => { let styleNode: React.ReactElement; @@ -516,118 +517,54 @@ export default function useStyleRegister( }; } -// ============================================================================ -// == SSR == -// ============================================================================ -export function extractStyle(cache: Cache, plain = false) { - const matchPrefixRegexp = /^style%/; - - // prefix with `style` is used for `useStyleRegister` to cache style context - const styleKeys = Array.from(cache.cache.keys()).filter((key) => - matchPrefixRegexp.test(key), - ); - - // Common effect styles like animation - const effectStyles: Record = {}; - - // Mapping of cachePath to style hash - const cachePathMap: Record = {}; - - let styleText = ''; - - function toStyleStr( - style: string, - tokenKey?: string, - styleId?: string, - customizeAttrs: Record = {}, - ) { - const attrs: Record = { - ...customizeAttrs, - [ATTR_TOKEN]: tokenKey, - [ATTR_MARK]: styleId, - }; - - const attrStr = Object.keys(attrs) - .map((attr) => { - const val = attrs[attr]; - return val ? `${attr}="${val}"` : null; - }) - .filter((v) => v) - .join(' '); - - return plain ? style : ``; +export const extract: ExtractStyle = ( + cache, + effectStyles, + options, +) => { + const [ + styleStr, + tokenKey, + styleId, + effectStyle, + clientOnly, + order, + ]: StyleCacheValue = cache; + const { plain } = options || {}; + + // Skip client only style + if (clientOnly) { + return null; } - // ====================== Fill Style ====================== - type OrderStyle = [order: number, style: string]; - - const orderStyles: OrderStyle[] = styleKeys - .map((key) => { - const cachePath = key.replace(matchPrefixRegexp, '').replace(/%/g, '|'); - - const [styleStr, tokenKey, styleId, effectStyle, clientOnly, order]: [ - string, - string, - string, - Record, - boolean, - number, - ] = cache.cache.get(key)![1]; - - // Skip client only style - if (clientOnly) { - return null! as OrderStyle; - } - - // ====================== Style ====================== - // Used for rc-util - const sharedAttrs = { - 'data-rc-order': 'prependQueue', - 'data-rc-priority': `${order}`, - }; + let keyStyleText = styleStr; - let keyStyleText = toStyleStr(styleStr, tokenKey, styleId, sharedAttrs); - - // Save cache path with hash mapping - cachePathMap[cachePath] = styleId; + // ====================== Style ====================== + // Used for rc-util + const sharedAttrs = { + 'data-rc-order': 'prependQueue', + 'data-rc-priority': `${order}`, + }; - // =============== Create effect style =============== - if (effectStyle) { - Object.keys(effectStyle).forEach((effectKey) => { - // Effect style can be reused - if (!effectStyles[effectKey]) { - effectStyles[effectKey] = true; - keyStyleText += toStyleStr( - normalizeStyle(effectStyle[effectKey]), - tokenKey, - `_effect-${effectKey}`, - sharedAttrs, - ); - } - }); + keyStyleText = toStyleStr(styleStr, tokenKey, styleId, sharedAttrs, plain); + + // =============== Create effect style =============== + if (effectStyle) { + Object.keys(effectStyle).forEach((effectKey) => { + // Effect style can be reused + if (!effectStyles[effectKey]) { + effectStyles[effectKey] = true; + const effectStyleStr = normalizeStyle(effectStyle[effectKey]); + keyStyleText += toStyleStr( + effectStyleStr, + tokenKey, + `_effect-${effectKey}`, + sharedAttrs, + plain, + ); } - - const ret: OrderStyle = [order, keyStyleText]; - - return ret; - }) - .filter((o) => o); - - orderStyles - .sort((o1, o2) => o1[0] - o2[0]) - .forEach(([, style]) => { - styleText += style; }); + } - // ==================== Fill Cache Path ==================== - styleText += toStyleStr( - `.${ATTR_CACHE_MAP}{content:"${serializeCacheMap(cachePathMap)}";}`, - undefined, - undefined, - { - [ATTR_CACHE_MAP]: ATTR_CACHE_MAP, - }, - ); - - return styleText; -} + return [order, styleId, keyStyleText]; +}; diff --git a/src/index.ts b/src/index.ts index 3e063fb..3452183 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,8 @@ +import extractStyle from './extractStyle'; import useCacheToken, { getComputedToken } from './hooks/useCacheToken'; import useCSSVarRegister from './hooks/useCSSVarRegister'; import type { CSSInterpolation, CSSObject } from './hooks/useStyleRegister'; -import useStyleRegister, { extractStyle } from './hooks/useStyleRegister'; +import useStyleRegister from './hooks/useStyleRegister'; import Keyframes from './Keyframes'; import type { Linter } from './linters'; import { diff --git a/src/hooks/useStyleRegister/cacheMapUtil.ts b/src/util/cacheMapUtil.ts similarity index 97% rename from src/hooks/useStyleRegister/cacheMapUtil.ts rename to src/util/cacheMapUtil.ts index 5376003..2500dd1 100644 --- a/src/hooks/useStyleRegister/cacheMapUtil.ts +++ b/src/util/cacheMapUtil.ts @@ -1,5 +1,5 @@ import canUseDom from 'rc-util/lib/Dom/canUseDom'; -import { ATTR_MARK } from '../../StyleContext'; +import { ATTR_MARK } from '../StyleContext'; export const ATTR_CACHE_MAP = 'data-ant-cssinjs-cache-path'; diff --git a/src/util/index.ts b/src/util/index.ts index b3afd7b..57932b8 100644 --- a/src/util/index.ts +++ b/src/util/index.ts @@ -1,6 +1,7 @@ import hash from '@emotion/hash'; import canUseDom from 'rc-util/lib/Dom/canUseDom'; import { removeCSS, updateCSS } from 'rc-util/lib/Dom/dynamicCSS'; +import { ATTR_MARK, ATTR_TOKEN } from '../StyleContext'; import { Theme } from '../theme'; // Create a cache for memo concat @@ -155,3 +156,30 @@ export function unit(num: string | number) { } return num; } + +export function toStyleStr( + style: string, + tokenKey?: string, + styleId?: string, + customizeAttrs: Record = {}, + plain = false, +) { + if (plain) { + return style; + } + const attrs: Record = { + ...customizeAttrs, + [ATTR_TOKEN]: tokenKey, + [ATTR_MARK]: styleId, + }; + + const attrStr = Object.keys(attrs) + .map((attr) => { + const val = attrs[attr]; + return val ? `${attr}="${val}"` : null; + }) + .filter((v) => v) + .join(' '); + + return ``; +} diff --git a/tests/__snapshots__/css-variables.spec.tsx.snap b/tests/__snapshots__/css-variables.spec.tsx.snap new file mode 100644 index 0000000..55a0075 --- /dev/null +++ b/tests/__snapshots__/css-variables.spec.tsx.snap @@ -0,0 +1,3 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`CSS Variables > support ssr 1`] = `""`; diff --git a/tests/css-variables.spec.tsx b/tests/css-variables.spec.tsx index 5a1e085..13acac2 100644 --- a/tests/css-variables.spec.tsx +++ b/tests/css-variables.spec.tsx @@ -5,7 +5,9 @@ import type { PropsWithChildren } from 'react'; import React from 'react'; import { expect } from 'vitest'; import { + createCache, createTheme, + extractStyle, StyleProvider, unit, useCacheToken, @@ -376,4 +378,23 @@ describe('CSS Variables', () => { styles = Array.from(document.head.querySelectorAll('style')); expect(styles.length).toBe(1); }); + + it('support ssr', () => { + const cache = createCache(); + render( + + + + + , + ); + + expect(extractStyle(cache)).toMatchSnapshot(); + }); }); diff --git a/tests/server.spec.tsx b/tests/server.spec.tsx index e5cded8..d96e454 100644 --- a/tests/server.spec.tsx +++ b/tests/server.spec.tsx @@ -12,9 +12,9 @@ import { useCacheToken, useStyleRegister, } from '../src'; -import * as cacheMapUtil from '../src/hooks/useStyleRegister/cacheMapUtil'; -import { reset } from '../src/hooks/useStyleRegister/cacheMapUtil'; import { ATTR_MARK, CSS_IN_JS_INSTANCE } from '../src/StyleContext'; +import * as cacheMapUtil from '../src/util/cacheMapUtil'; +import { reset } from '../src/util/cacheMapUtil'; interface DesignToken { primaryColor: string;