@antdv-next/cssinjs 1.0.0-alpha.1 → 1.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/StyleContext.d.ts +3 -2
- package/dist/StyleContext.js +4 -1
- package/dist/cssinjs-utils/util/genStyleUtils.js +11 -11
- package/dist/hooks/useCSSVarRegister.js +30 -18
- package/dist/hooks/useCacheToken.js +32 -19
- package/dist/hooks/useGlobalCache.js +9 -11
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/ssr/styleCollector.d.ts +8 -0
- package/dist/ssr/styleCollector.js +11 -0
- package/dist/util/index.js +1 -1
- package/package.json +2 -2
package/dist/StyleContext.d.ts
CHANGED
|
@@ -2,12 +2,13 @@ import { Linter } from "./linters/interface.js";
|
|
|
2
2
|
import "./linters/index.js";
|
|
3
3
|
import { Entity, KeyType } from "./Cache.js";
|
|
4
4
|
import * as vue7 from "vue";
|
|
5
|
-
import { Ref } from "vue";
|
|
5
|
+
import { App, Ref } from "vue";
|
|
6
6
|
|
|
7
7
|
//#region src/StyleContext.d.ts
|
|
8
8
|
|
|
9
9
|
declare function createCache(): vue7.Raw<Entity>;
|
|
10
10
|
declare function useStyleContextProvide(props: Ref<StyleContextProps>): void;
|
|
11
|
+
declare function provideStyleContext(app: App, props: Ref<StyleContextProps>): void;
|
|
11
12
|
declare function useStyleContext(): Ref<{
|
|
12
13
|
autoClear?: boolean
|
|
13
14
|
/** @private Test only. Not work in production. */ | undefined;
|
|
@@ -115,4 +116,4 @@ interface StyleContextProps {
|
|
|
115
116
|
type StyleProviderProps = StyleContextProps;
|
|
116
117
|
declare const StyleProvider: vue7.DefineSetupFnComponent<Partial<StyleContextProps>, {}, {}, Partial<StyleContextProps> & {}, vue7.PublicProps>;
|
|
117
118
|
//#endregion
|
|
118
|
-
export { StyleProvider, StyleProviderProps, createCache, useStyleContext, useStyleContextProvide };
|
|
119
|
+
export { StyleProvider, StyleProviderProps, createCache, provideStyleContext, useStyleContext, useStyleContextProvide };
|
package/dist/StyleContext.js
CHANGED
|
@@ -36,6 +36,9 @@ const StyleContextKey = Symbol("StyleContext");
|
|
|
36
36
|
function useStyleContextProvide(props) {
|
|
37
37
|
provide(StyleContextKey, props);
|
|
38
38
|
}
|
|
39
|
+
function provideStyleContext(app, props) {
|
|
40
|
+
app.provide(StyleContextKey, props);
|
|
41
|
+
}
|
|
39
42
|
function useStyleContext() {
|
|
40
43
|
return inject(StyleContextKey, ref(defaultStyleContext));
|
|
41
44
|
}
|
|
@@ -61,4 +64,4 @@ const StyleProvider = defineComponent((props, { slots }) => {
|
|
|
61
64
|
] });
|
|
62
65
|
|
|
63
66
|
//#endregion
|
|
64
|
-
export { ATTR_CACHE_PATH, ATTR_MARK, ATTR_TOKEN, CSS_IN_JS_INSTANCE, StyleProvider, createCache, useStyleContext, useStyleContextProvide };
|
|
67
|
+
export { ATTR_CACHE_PATH, ATTR_MARK, ATTR_TOKEN, CSS_IN_JS_INSTANCE, StyleProvider, createCache, provideStyleContext, useStyleContext, useStyleContextProvide };
|
|
@@ -78,22 +78,22 @@ function genStyleUtils(config) {
|
|
|
78
78
|
}).value) return hashId;
|
|
79
79
|
const prefix = usePrefix();
|
|
80
80
|
const csp = useCSP();
|
|
81
|
-
const type =
|
|
81
|
+
const type = "css";
|
|
82
82
|
const calc = computed(() => {
|
|
83
83
|
return useUniqueMemo_default(() => {
|
|
84
84
|
const unitlessCssVar = /* @__PURE__ */ new Set();
|
|
85
|
-
|
|
86
|
-
unitlessCssVar.add(token2CSSVar(key, cssVar
|
|
87
|
-
unitlessCssVar.add(token2CSSVar(key, getCompVarPrefix_default(component, cssVar
|
|
85
|
+
Object.keys(options.unitless || {}).forEach((key) => {
|
|
86
|
+
unitlessCssVar.add(token2CSSVar(key, cssVar?.value?.prefix));
|
|
87
|
+
unitlessCssVar.add(token2CSSVar(key, getCompVarPrefix_default(component, cssVar?.value?.prefix)));
|
|
88
88
|
});
|
|
89
|
-
return calc_default(type
|
|
89
|
+
return calc_default(type, unitlessCssVar);
|
|
90
90
|
}, [
|
|
91
91
|
type,
|
|
92
92
|
component,
|
|
93
93
|
cssVar?.value?.prefix
|
|
94
94
|
]);
|
|
95
95
|
});
|
|
96
|
-
const
|
|
96
|
+
const { max, min } = maxmin_default(type);
|
|
97
97
|
const sharedConfig = computed(() => {
|
|
98
98
|
return {
|
|
99
99
|
theme: theme?.value,
|
|
@@ -131,8 +131,8 @@ function genStyleUtils(config) {
|
|
|
131
131
|
const defaultComponentToken = getDefaultComponentToken_default(component, realToken.value, getDefaultToken);
|
|
132
132
|
const componentCls = `.${prefixCls.value}`;
|
|
133
133
|
const componentToken = getComponentToken_default(component, realToken.value, defaultComponentToken, { deprecatedTokens: options.deprecatedTokens });
|
|
134
|
-
if (
|
|
135
|
-
defaultComponentToken[key] = `var(${token2CSSVar(key, getCompVarPrefix_default(component, cssVar
|
|
134
|
+
if (defaultComponentToken && typeof defaultComponentToken === "object") Object.keys(defaultComponentToken).forEach((key) => {
|
|
135
|
+
defaultComponentToken[key] = `var(${token2CSSVar(key, getCompVarPrefix_default(component, cssVar?.value?.prefix))})`;
|
|
136
136
|
});
|
|
137
137
|
const mergedToken = merge(proxyToken.value, {
|
|
138
138
|
componentCls,
|
|
@@ -140,9 +140,9 @@ function genStyleUtils(config) {
|
|
|
140
140
|
iconCls: `.${prefix.value.iconPrefixCls}`,
|
|
141
141
|
antCls: `.${prefix.value.rootPrefixCls}`,
|
|
142
142
|
calc: calc.value,
|
|
143
|
-
max
|
|
144
|
-
min
|
|
145
|
-
},
|
|
143
|
+
max,
|
|
144
|
+
min
|
|
145
|
+
}, defaultComponentToken);
|
|
146
146
|
const styleInterpolation = styleFn(mergedToken, {
|
|
147
147
|
hashId: hashId.value,
|
|
148
148
|
prefixCls: prefixCls.value,
|
|
@@ -1,22 +1,39 @@
|
|
|
1
|
+
import { collectStyleText } from "../ssr/styleCollector.js";
|
|
1
2
|
import { ATTR_MARK, ATTR_TOKEN, CSS_IN_JS_INSTANCE, useStyleContext } from "../StyleContext.js";
|
|
2
3
|
import { transformToken } from "../util/css-variables.js";
|
|
3
4
|
import { isClientSide, toStyleStr } from "../util/index.js";
|
|
4
5
|
import { useGlobalCache } from "./useGlobalCache.js";
|
|
5
6
|
import { uniqueHash } from "./useStyleRegister.js";
|
|
7
|
+
import canUseDom from "@v-c/util/dist/Dom/canUseDom";
|
|
6
8
|
import { removeCSS, updateCSS } from "@v-c/util/dist/Dom/dynamicCSS";
|
|
7
9
|
import { computed } from "vue";
|
|
8
10
|
|
|
9
11
|
//#region src/hooks/useCSSVarRegister.ts
|
|
10
12
|
const CSS_VAR_PREFIX = "cssVar";
|
|
13
|
+
const extract = (cache, _effectStyles, options) => {
|
|
14
|
+
const [, styleStr, styleId, cssVarKey] = cache;
|
|
15
|
+
const { plain } = options || {};
|
|
16
|
+
if (!styleStr) return null;
|
|
17
|
+
const order = -999;
|
|
18
|
+
return [
|
|
19
|
+
order,
|
|
20
|
+
styleId,
|
|
21
|
+
toStyleStr(styleStr, cssVarKey, styleId, {
|
|
22
|
+
"data-rc-order": "prependQueue",
|
|
23
|
+
"data-rc-priority": `${order}`
|
|
24
|
+
}, plain)
|
|
25
|
+
];
|
|
26
|
+
};
|
|
11
27
|
function useCSSVarRegister(config, fn) {
|
|
12
28
|
const styleContext = useStyleContext();
|
|
13
29
|
const stylePath = computed(() => {
|
|
14
|
-
const { key,
|
|
30
|
+
const { key, scope = "", token } = config.value;
|
|
31
|
+
const tokenKey = token?._tokenKey;
|
|
15
32
|
return [
|
|
16
33
|
...config.value.path,
|
|
17
34
|
key,
|
|
18
|
-
|
|
19
|
-
|
|
35
|
+
scope,
|
|
36
|
+
tokenKey
|
|
20
37
|
];
|
|
21
38
|
});
|
|
22
39
|
return useGlobalCache(computed(() => CSS_VAR_PREFIX), stylePath, () => {
|
|
@@ -42,7 +59,16 @@ function useCSSVarRegister(config, fn) {
|
|
|
42
59
|
mark: ATTR_MARK,
|
|
43
60
|
attachTo: styleContext.value.container
|
|
44
61
|
});
|
|
45
|
-
}, (
|
|
62
|
+
}, (cacheValue) => {
|
|
63
|
+
const [, cssVarsStr, styleId] = cacheValue;
|
|
64
|
+
if (!canUseDom()) {
|
|
65
|
+
const extracted = extract(cacheValue, {}, { plain: false });
|
|
66
|
+
if (extracted) {
|
|
67
|
+
const [, , styleText] = extracted;
|
|
68
|
+
collectStyleText(styleText);
|
|
69
|
+
}
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
46
72
|
if (!cssVarsStr) return;
|
|
47
73
|
const context = styleContext.value;
|
|
48
74
|
const style = updateCSS(cssVarsStr, styleId, {
|
|
@@ -55,20 +81,6 @@ function useCSSVarRegister(config, fn) {
|
|
|
55
81
|
style.setAttribute(ATTR_TOKEN, config.value.key);
|
|
56
82
|
});
|
|
57
83
|
}
|
|
58
|
-
const extract = (cache, _effectStyles, options) => {
|
|
59
|
-
const [, styleStr, styleId, cssVarKey] = cache;
|
|
60
|
-
const { plain } = options || {};
|
|
61
|
-
if (!styleStr) return null;
|
|
62
|
-
const order = -999;
|
|
63
|
-
return [
|
|
64
|
-
order,
|
|
65
|
-
styleId,
|
|
66
|
-
toStyleStr(styleStr, cssVarKey, styleId, {
|
|
67
|
-
"data-rc-order": "prependQueue",
|
|
68
|
-
"data-rc-priority": `${order}`
|
|
69
|
-
}, plain)
|
|
70
|
-
];
|
|
71
|
-
};
|
|
72
84
|
|
|
73
85
|
//#endregion
|
|
74
86
|
export { CSS_VAR_PREFIX, useCSSVarRegister as default, extract };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { collectStyleText } from "../ssr/styleCollector.js";
|
|
1
2
|
import { ATTR_MARK, ATTR_TOKEN, CSS_IN_JS_INSTANCE, useStyleContext } from "../StyleContext.js";
|
|
2
3
|
import { transformToken } from "../util/css-variables.js";
|
|
3
4
|
import { flattenToken, memoResult, toStyleStr, token2key } from "../util/index.js";
|
|
4
5
|
import { useGlobalCache } from "./useGlobalCache.js";
|
|
5
6
|
import hash from "@emotion/hash";
|
|
7
|
+
import canUseDom from "@v-c/util/dist/Dom/canUseDom";
|
|
6
8
|
import { updateCSS } from "@v-c/util/dist/Dom/dynamicCSS";
|
|
7
9
|
import { computed } from "vue";
|
|
8
10
|
|
|
@@ -39,6 +41,21 @@ function getComputedToken(originToken, overrideToken, theme, format) {
|
|
|
39
41
|
return mergedDerivativeToken;
|
|
40
42
|
}
|
|
41
43
|
const TOKEN_PREFIX = "token";
|
|
44
|
+
const extract = (cache, _effectStyles, options) => {
|
|
45
|
+
const [, , realToken, styleStr, cssVarKey] = cache;
|
|
46
|
+
const { plain } = options || {};
|
|
47
|
+
if (!styleStr) return null;
|
|
48
|
+
const styleId = realToken._tokenKey;
|
|
49
|
+
const order = -999;
|
|
50
|
+
return [
|
|
51
|
+
order,
|
|
52
|
+
styleId,
|
|
53
|
+
toStyleStr(styleStr, cssVarKey, styleId, {
|
|
54
|
+
"data-rc-order": "prependQueue",
|
|
55
|
+
"data-rc-priority": `${order}`
|
|
56
|
+
}, plain)
|
|
57
|
+
];
|
|
58
|
+
};
|
|
42
59
|
/**
|
|
43
60
|
* Cache theme derivative token as global shared one
|
|
44
61
|
* @param theme Theme entity
|
|
@@ -57,7 +74,7 @@ function useCacheToken(theme, tokens, option) {
|
|
|
57
74
|
const mergedToken = computed(() => memoResult(() => Object.assign({}, ...resolvedTokens.value), resolvedTokens.value));
|
|
58
75
|
const tokenStr = computed(() => flattenToken(mergedToken.value));
|
|
59
76
|
const overrideTokenStr = computed(() => flattenToken(override.value));
|
|
60
|
-
const cssVarStr = computed(() =>
|
|
77
|
+
const cssVarStr = computed(() => flattenToken(cssVar.value));
|
|
61
78
|
return useGlobalCache(computed(() => TOKEN_PREFIX), computed(() => [
|
|
62
79
|
salt.value,
|
|
63
80
|
theme.value.id,
|
|
@@ -67,7 +84,7 @@ function useCacheToken(theme, tokens, option) {
|
|
|
67
84
|
]), () => {
|
|
68
85
|
const mergedDerivativeToken = compute.value ? compute.value(mergedToken.value, override.value, theme.value) : getComputedToken(mergedToken.value, override.value, theme.value, formatToken.value);
|
|
69
86
|
const actualToken = { ...mergedDerivativeToken };
|
|
70
|
-
const mergedSalt = `${salt.value}_${cssVar.value
|
|
87
|
+
const mergedSalt = `${salt.value}_${cssVar.value.prefix || ""}`;
|
|
71
88
|
const hashId = hash(mergedSalt);
|
|
72
89
|
const hashCls = `${hashPrefix}-${hash(mergedSalt)}`;
|
|
73
90
|
actualToken._tokenKey = token2key(actualToken, mergedSalt);
|
|
@@ -75,7 +92,9 @@ function useCacheToken(theme, tokens, option) {
|
|
|
75
92
|
prefix: cssVar.value.prefix,
|
|
76
93
|
ignore: cssVar.value.ignore,
|
|
77
94
|
unitless: cssVar.value.unitless,
|
|
78
|
-
preserve: cssVar.value.preserve
|
|
95
|
+
preserve: cssVar.value.preserve,
|
|
96
|
+
hashPriority: styleContext.value.hashPriority,
|
|
97
|
+
hashCls: cssVar.value.hashed ? hashCls : void 0
|
|
79
98
|
});
|
|
80
99
|
tokenWithCssVar._hashId = hashId;
|
|
81
100
|
recordCleanToken(cssVar.value.key);
|
|
@@ -88,7 +107,16 @@ function useCacheToken(theme, tokens, option) {
|
|
|
88
107
|
];
|
|
89
108
|
}, ([, , , , themeKey]) => {
|
|
90
109
|
cleanTokenStyle(themeKey, styleContext.value.cache.instanceId);
|
|
91
|
-
}, (
|
|
110
|
+
}, (cacheValue) => {
|
|
111
|
+
const [, , , cssVarsStr, themeKey] = cacheValue;
|
|
112
|
+
if (!canUseDom()) {
|
|
113
|
+
const extracted = extract(cacheValue, {}, { plain: false });
|
|
114
|
+
if (extracted) {
|
|
115
|
+
const [, , styleText] = extracted;
|
|
116
|
+
collectStyleText(styleText);
|
|
117
|
+
}
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
92
120
|
if (!cssVarsStr) return;
|
|
93
121
|
const style = updateCSS(cssVarsStr, hash(`css-var-${themeKey}`), {
|
|
94
122
|
mark: ATTR_MARK,
|
|
@@ -100,21 +128,6 @@ function useCacheToken(theme, tokens, option) {
|
|
|
100
128
|
style.setAttribute(ATTR_TOKEN, themeKey);
|
|
101
129
|
});
|
|
102
130
|
}
|
|
103
|
-
const extract = (cache, _effectStyles, options) => {
|
|
104
|
-
const [, , realToken, styleStr, cssVarKey] = cache;
|
|
105
|
-
const { plain } = options || {};
|
|
106
|
-
if (!styleStr) return null;
|
|
107
|
-
const styleId = realToken._tokenKey;
|
|
108
|
-
const order = -999;
|
|
109
|
-
return [
|
|
110
|
-
order,
|
|
111
|
-
styleId,
|
|
112
|
-
toStyleStr(styleStr, cssVarKey, styleId, {
|
|
113
|
-
"data-rc-order": "prependQueue",
|
|
114
|
-
"data-rc-priority": `${order}`
|
|
115
|
-
}, plain)
|
|
116
|
-
];
|
|
117
|
-
};
|
|
118
131
|
|
|
119
132
|
//#endregion
|
|
120
133
|
export { TOKEN_PREFIX, useCacheToken as default, extract, getComputedToken };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { pathKey } from "../Cache.js";
|
|
2
2
|
import { useStyleContext } from "../StyleContext.js";
|
|
3
|
-
import { computed,
|
|
3
|
+
import { computed, watch } from "vue";
|
|
4
4
|
|
|
5
5
|
//#region src/hooks/useGlobalCache.ts
|
|
6
6
|
const isDev = process.env.NODE_ENV !== "production";
|
|
@@ -29,6 +29,7 @@ function useGlobalCache(prefix, keyPath, cacheFn, onCacheRemove, onCacheEffect)
|
|
|
29
29
|
});
|
|
30
30
|
};
|
|
31
31
|
const getCacheEntity = () => styleContext.value.cache.opGet(fullPathStr.value);
|
|
32
|
+
buildCache();
|
|
32
33
|
const cacheContent = computed(() => {
|
|
33
34
|
let entity = styleContext.value.cache.opGet(fullPathStr.value);
|
|
34
35
|
if (isDev && !entity) {
|
|
@@ -37,32 +38,29 @@ function useGlobalCache(prefix, keyPath, cacheFn, onCacheRemove, onCacheEffect)
|
|
|
37
38
|
}
|
|
38
39
|
return entity[1];
|
|
39
40
|
});
|
|
40
|
-
watch(fullPathStr,
|
|
41
|
-
|
|
41
|
+
watch(fullPathStr, (_, _1, onCleanup) => {
|
|
42
|
+
const currentPath = fullPathStr.value;
|
|
42
43
|
buildCache(([times, cache]) => [times + 1, cache]);
|
|
43
|
-
if (!effectMap.has(
|
|
44
|
+
if (!effectMap.has(currentPath)) {
|
|
44
45
|
onCacheEffect?.(cacheContent.value);
|
|
45
|
-
effectMap.set(
|
|
46
|
+
effectMap.set(currentPath, true);
|
|
46
47
|
Promise.resolve().then(() => {
|
|
47
|
-
effectMap.delete(
|
|
48
|
+
effectMap.delete(currentPath);
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
51
|
const globalCache = styleContext.value.cache;
|
|
51
52
|
onCleanup(() => {
|
|
52
|
-
globalCache.opUpdate(
|
|
53
|
+
globalCache.opUpdate(currentPath, (prevCache) => {
|
|
53
54
|
const [times = 0, cache] = prevCache || [];
|
|
54
55
|
if (times - 1 === 0) {
|
|
55
56
|
onCacheRemove?.(cache, false);
|
|
56
|
-
effectMap.delete(
|
|
57
|
+
effectMap.delete(currentPath);
|
|
57
58
|
return null;
|
|
58
59
|
}
|
|
59
60
|
return [times - 1, cache];
|
|
60
61
|
});
|
|
61
62
|
});
|
|
62
63
|
}, { immediate: true });
|
|
63
|
-
if (onCacheEffect) watchEffect(() => {
|
|
64
|
-
onCacheEffect(cacheContent.value);
|
|
65
|
-
});
|
|
66
64
|
return cacheContent;
|
|
67
65
|
}
|
|
68
66
|
|
package/dist/index.d.ts
CHANGED
|
@@ -11,13 +11,14 @@ import { linter as linter$2 } from "./linters/logicalPropertiesLinter.js";
|
|
|
11
11
|
import { linter } from "./linters/NaNLinter.js";
|
|
12
12
|
import { linter as linter$3 } from "./linters/parentSelectorLinter.js";
|
|
13
13
|
import "./linters/index.js";
|
|
14
|
-
import { StyleProvider, StyleProviderProps, createCache, useStyleContext, useStyleContextProvide } from "./StyleContext.js";
|
|
14
|
+
import { StyleProvider, StyleProviderProps, createCache, provideStyleContext, useStyleContext, useStyleContextProvide } from "./StyleContext.js";
|
|
15
15
|
import { Transformer } from "./transformers/interface.js";
|
|
16
16
|
import { CSSInterpolation, CSSObject, useStyleRegister } from "./hooks/useStyleRegister.js";
|
|
17
17
|
import { token2CSSVar } from "./util/css-variables.js";
|
|
18
18
|
import { useCSSVarRegister } from "./hooks/useCSSVarRegister.js";
|
|
19
19
|
import { extractStyle } from "./extractStyle.js";
|
|
20
20
|
import { getComputedToken, useCacheToken } from "./hooks/useCacheToken.js";
|
|
21
|
+
import { collectStyleText, setStyleCollector } from "./ssr/styleCollector.js";
|
|
21
22
|
import { transform } from "./transformers/autoPrefix.js";
|
|
22
23
|
import { transform as transform$1 } from "./transformers/legacyLogicalProperties.js";
|
|
23
24
|
import { transform as transform$2 } from "./transformers/px2rem.js";
|
|
@@ -31,4 +32,4 @@ declare const _experimental: {
|
|
|
31
32
|
supportModernCSS: () => boolean;
|
|
32
33
|
};
|
|
33
34
|
//#endregion
|
|
34
|
-
export { type AbstractCalculator, type CSSInterpolation, type CSSObject, CSSUtil, CSSVarRegisterProps, ComponentToken, ComponentTokenKey, type DerivativeFunc, FullToken, GenStyleFn, GetCompUnitless, GetDefaultToken, GetDefaultTokenFn, GetResetStyles, GlobalToken, GlobalTokenWithComponent, Keyframe as Keyframes, type Linter, linter as NaNLinter, OverrideTokenMap, StyleInfo, StyleProvider, type StyleProviderProps, SubStyleComponentProps, Theme, TokenMap, TokenMapKey, type TokenType, TokenWithCommonCls, type Transformer, _experimental, transform as autoPrefixTransformer, createCache, createTheme, extractStyle, genCalc, genStyleUtils, getComputedToken, transform$1 as legacyLogicalPropertiesTransformer, linter$1 as legacyNotSelectorLinter, linter$2 as logicalPropertiesLinter, merge as mergeToken, linter$3 as parentSelectorLinter, transform$2 as px2remTransformer, statistic, statisticToken, token2CSSVar, unit, useCSSVarRegister, useCacheToken, useStyleContext, useStyleContextProvide, useStyleRegister };
|
|
35
|
+
export { type AbstractCalculator, type CSSInterpolation, type CSSObject, CSSUtil, CSSVarRegisterProps, ComponentToken, ComponentTokenKey, type DerivativeFunc, FullToken, GenStyleFn, GetCompUnitless, GetDefaultToken, GetDefaultTokenFn, GetResetStyles, GlobalToken, GlobalTokenWithComponent, Keyframe as Keyframes, type Linter, linter as NaNLinter, OverrideTokenMap, StyleInfo, StyleProvider, type StyleProviderProps, SubStyleComponentProps, Theme, TokenMap, TokenMapKey, type TokenType, TokenWithCommonCls, type Transformer, _experimental, transform as autoPrefixTransformer, collectStyleText, createCache, createTheme, extractStyle, genCalc, genStyleUtils, getComputedToken, transform$1 as legacyLogicalPropertiesTransformer, linter$1 as legacyNotSelectorLinter, linter$2 as logicalPropertiesLinter, merge as mergeToken, linter$3 as parentSelectorLinter, provideStyleContext, transform$2 as px2remTransformer, setStyleCollector, statistic, statisticToken, token2CSSVar, unit, useCSSVarRegister, useCacheToken, useStyleContext, useStyleContextProvide, useStyleRegister };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { collectStyleText, setStyleCollector } from "./ssr/styleCollector.js";
|
|
2
|
+
import { StyleProvider, createCache, provideStyleContext, useStyleContext, useStyleContextProvide } from "./StyleContext.js";
|
|
2
3
|
import calc_default from "./theme/calc/index.js";
|
|
3
4
|
import Theme from "./theme/Theme.js";
|
|
4
5
|
import createTheme from "./theme/createTheme.js";
|
|
@@ -26,4 +27,4 @@ import "./cssinjs-utils/index.js";
|
|
|
26
27
|
const _experimental = { supportModernCSS: () => supportWhere() && supportLogicProps() };
|
|
27
28
|
|
|
28
29
|
//#endregion
|
|
29
|
-
export { Keyframes_default as Keyframes, NaNLinter_default as NaNLinter, StyleProvider, Theme, _experimental, autoPrefix_default as autoPrefixTransformer, createCache, createTheme, extractStyle, calc_default as genCalc, genStyleUtils_default as genStyleUtils, getComputedToken, legacyLogicalProperties_default as legacyLogicalPropertiesTransformer, legacyNotSelectorLinter_default as legacyNotSelectorLinter, logicalPropertiesLinter_default as logicalPropertiesLinter, merge as mergeToken, parentSelectorLinter_default as parentSelectorLinter, px2rem_default as px2remTransformer, statistic, statistic_default as statisticToken, token2CSSVar, unit, useCSSVarRegister, useCacheToken, useStyleContext, useStyleContextProvide, useStyleRegister };
|
|
30
|
+
export { Keyframes_default as Keyframes, NaNLinter_default as NaNLinter, StyleProvider, Theme, _experimental, autoPrefix_default as autoPrefixTransformer, collectStyleText, createCache, createTheme, extractStyle, calc_default as genCalc, genStyleUtils_default as genStyleUtils, getComputedToken, legacyLogicalProperties_default as legacyLogicalPropertiesTransformer, legacyNotSelectorLinter_default as legacyNotSelectorLinter, logicalPropertiesLinter_default as logicalPropertiesLinter, merge as mergeToken, parentSelectorLinter_default as parentSelectorLinter, provideStyleContext, px2rem_default as px2remTransformer, setStyleCollector, statistic, statistic_default as statisticToken, token2CSSVar, unit, useCSSVarRegister, useCacheToken, useStyleContext, useStyleContextProvide, useStyleRegister };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/ssr/styleCollector.d.ts
|
|
2
|
+
type StyleCollector = {
|
|
3
|
+
push: (styleText: string) => void;
|
|
4
|
+
} | null;
|
|
5
|
+
declare function setStyleCollector(next: StyleCollector): void;
|
|
6
|
+
declare function collectStyleText(styleText: string): void;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { collectStyleText, setStyleCollector };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/ssr/styleCollector.ts
|
|
2
|
+
let collector = null;
|
|
3
|
+
function setStyleCollector(next) {
|
|
4
|
+
collector = next;
|
|
5
|
+
}
|
|
6
|
+
function collectStyleText(styleText) {
|
|
7
|
+
collector?.push(styleText);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { collectStyleText, setStyleCollector };
|
package/dist/util/index.js
CHANGED
|
@@ -3,8 +3,8 @@ import Theme from "../theme/Theme.js";
|
|
|
3
3
|
import "../theme/index.js";
|
|
4
4
|
import { token2CSSVar } from "./css-variables.js";
|
|
5
5
|
import hash from "@emotion/hash";
|
|
6
|
-
import { removeCSS, updateCSS } from "@v-c/util/dist/Dom/dynamicCSS";
|
|
7
6
|
import canUseDom from "@v-c/util/dist/Dom/canUseDom";
|
|
7
|
+
import { removeCSS, updateCSS } from "@v-c/util/dist/Dom/dynamicCSS";
|
|
8
8
|
|
|
9
9
|
//#region src/util/index.ts
|
|
10
10
|
const resultCache = /* @__PURE__ */ new WeakMap();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antdv-next/cssinjs",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-alpha.
|
|
4
|
+
"version": "1.0.0-alpha.3",
|
|
5
5
|
"description": "cssinjs solution for ant-design-vue",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@emotion/hash": "^0.8.0",
|
|
32
32
|
"@emotion/unitless": "^0.7.5",
|
|
33
|
-
"@v-c/util": "^1.0.
|
|
33
|
+
"@v-c/util": "^1.0.7",
|
|
34
34
|
"csstype": "^3.2.3",
|
|
35
35
|
"defu": "^6.1.4",
|
|
36
36
|
"stylis": "^4.3.6"
|