@antdv-next/cssinjs 0.0.3 → 1.0.0-alpha.2

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.
Files changed (212) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +0 -141
  3. package/dist/Cache.d.ts +22 -0
  4. package/dist/Cache.js +45 -0
  5. package/dist/Keyframes.d.ts +12 -0
  6. package/dist/Keyframes.js +17 -0
  7. package/dist/StyleContext.d.ts +119 -0
  8. package/dist/StyleContext.js +67 -0
  9. package/dist/cssinjs-utils/_util/hooks/useUniqueMemo.js +62 -0
  10. package/dist/cssinjs-utils/hooks/useCSP.d.ts +8 -0
  11. package/dist/cssinjs-utils/hooks/useCSP.js +8 -0
  12. package/dist/cssinjs-utils/hooks/usePrefix.d.ts +9 -0
  13. package/dist/cssinjs-utils/hooks/useToken.d.ts +25 -0
  14. package/dist/cssinjs-utils/index.d.ts +4 -0
  15. package/dist/cssinjs-utils/index.js +4 -0
  16. package/dist/cssinjs-utils/interface/components.d.ts +12 -0
  17. package/dist/cssinjs-utils/util/genStyleUtils.d.ts +127 -0
  18. package/dist/cssinjs-utils/util/genStyleUtils.js +188 -0
  19. package/dist/cssinjs-utils/util/getCompVarPrefix.js +8 -0
  20. package/dist/cssinjs-utils/util/getComponentToken.js +22 -0
  21. package/dist/cssinjs-utils/util/getDefaultComponentToken.js +11 -0
  22. package/dist/cssinjs-utils/util/maxmin.js +17 -0
  23. package/dist/cssinjs-utils/util/statistic.d.ts +15 -0
  24. package/dist/cssinjs-utils/util/statistic.js +52 -0
  25. package/dist/extractStyle.d.ts +18 -0
  26. package/dist/extractStyle.js +54 -0
  27. package/dist/hooks/useCSSVarRegister.d.ts +19 -0
  28. package/dist/hooks/useCSSVarRegister.js +86 -0
  29. package/dist/hooks/useCacheToken.d.ts +60 -0
  30. package/dist/hooks/useCacheToken.js +133 -0
  31. package/dist/hooks/useGlobalCache.d.ts +9 -0
  32. package/dist/hooks/useGlobalCache.js +68 -0
  33. package/dist/hooks/useStyleRegister.d.ts +47 -0
  34. package/dist/hooks/useStyleRegister.js +237 -0
  35. package/dist/index.d.ts +35 -0
  36. package/dist/index.js +30 -0
  37. package/dist/linters/NaNLinter.d.ts +6 -0
  38. package/dist/linters/NaNLinter.js +10 -0
  39. package/dist/linters/contentQuotesLinter.js +18 -0
  40. package/dist/linters/hashedAnimationLinter.js +12 -0
  41. package/dist/linters/index.d.ts +5 -0
  42. package/dist/linters/index.js +8 -0
  43. package/dist/linters/interface.d.ts +11 -0
  44. package/dist/linters/legacyNotSelectorLinter.d.ts +6 -0
  45. package/dist/linters/legacyNotSelectorLinter.js +20 -0
  46. package/dist/linters/logicalPropertiesLinter.d.ts +6 -0
  47. package/dist/linters/logicalPropertiesLinter.js +57 -0
  48. package/dist/linters/parentSelectorLinter.d.ts +7 -0
  49. package/dist/linters/parentSelectorLinter.js +12 -0
  50. package/dist/linters/utils.js +10 -0
  51. package/dist/ssr/styleCollector.d.ts +8 -0
  52. package/dist/ssr/styleCollector.js +11 -0
  53. package/dist/theme/Theme.d.ts +16 -0
  54. package/dist/theme/Theme.js +24 -0
  55. package/dist/theme/ThemeCache.js +79 -0
  56. package/dist/theme/calc/CSSCalculator.d.ts +19 -0
  57. package/dist/theme/calc/CSSCalculator.js +63 -0
  58. package/dist/theme/calc/NumCalculator.d.ts +14 -0
  59. package/dist/theme/calc/NumCalculator.js +37 -0
  60. package/dist/theme/calc/calculator.d.ts +32 -0
  61. package/dist/theme/calc/calculator.js +6 -0
  62. package/dist/theme/calc/index.d.ts +8 -0
  63. package/dist/theme/calc/index.js +12 -0
  64. package/dist/theme/createTheme.d.ts +11 -0
  65. package/dist/theme/createTheme.js +16 -0
  66. package/dist/theme/index.js +6 -0
  67. package/dist/theme/interface.d.ts +5 -0
  68. package/dist/transformers/autoPrefix.d.ts +6 -0
  69. package/dist/transformers/autoPrefix.js +7 -0
  70. package/dist/transformers/interface.d.ts +9 -0
  71. package/{es → dist}/transformers/legacyLogicalProperties.d.ts +6 -2
  72. package/dist/transformers/legacyLogicalProperties.js +123 -0
  73. package/dist/transformers/px2rem.d.ts +23 -0
  74. package/dist/transformers/px2rem.js +37 -0
  75. package/dist/util/cacheMapUtil.js +60 -0
  76. package/dist/util/css-variables.d.ts +7 -0
  77. package/dist/util/css-variables.js +35 -0
  78. package/dist/util/index.d.ts +8 -0
  79. package/dist/util/index.js +108 -0
  80. package/package.json +33 -64
  81. package/dist/cssinjs.umd.js +0 -3
  82. package/es/Cache.d.ts +0 -20
  83. package/es/Cache.js +0 -33
  84. package/es/Keyframes.d.ts +0 -9
  85. package/es/Keyframes.js +0 -14
  86. package/es/StyleContext.d.ts +0 -40
  87. package/es/StyleContext.js +0 -100
  88. package/es/extractStyle.d.ts +0 -12
  89. package/es/extractStyle.js +0 -43
  90. package/es/hooks/useCSSVarRegister.d.ts +0 -21
  91. package/es/hooks/useCSSVarRegister.js +0 -59
  92. package/es/hooks/useCacheToken.d.ts +0 -69
  93. package/es/hooks/useCacheToken.js +0 -106
  94. package/es/hooks/useEffectCleanupRegister.d.ts +0 -2
  95. package/es/hooks/useEffectCleanupRegister.js +0 -8
  96. package/es/hooks/useGlobalCache.d.ts +0 -7
  97. package/es/hooks/useGlobalCache.js +0 -41
  98. package/es/hooks/useHMR.d.ts +0 -3
  99. package/es/hooks/useHMR.js +0 -20
  100. package/es/hooks/useStyleRegister.d.ts +0 -81
  101. package/es/hooks/useStyleRegister.js +0 -216
  102. package/es/index.d.ts +0 -18
  103. package/es/index.js +0 -44
  104. package/es/interface.d.ts +0 -2
  105. package/es/linters/NaNLinter.d.ts +0 -3
  106. package/es/linters/NaNLinter.js +0 -7
  107. package/es/linters/contentQuotesLinter.d.ts +0 -3
  108. package/es/linters/contentQuotesLinter.js +0 -13
  109. package/es/linters/hashedAnimationLinter.d.ts +0 -3
  110. package/es/linters/hashedAnimationLinter.js +0 -10
  111. package/es/linters/index.d.ts +0 -7
  112. package/es/linters/interface.d.ts +0 -8
  113. package/es/linters/legacyNotSelectorLinter.d.ts +0 -3
  114. package/es/linters/legacyNotSelectorLinter.js +0 -14
  115. package/es/linters/logicalPropertiesLinter.d.ts +0 -3
  116. package/es/linters/logicalPropertiesLinter.js +0 -61
  117. package/es/linters/parentSelectorLinter.d.ts +0 -3
  118. package/es/linters/parentSelectorLinter.js +0 -7
  119. package/es/linters/utils.d.ts +0 -2
  120. package/es/linters/utils.js +0 -11
  121. package/es/theme/Theme.d.ts +0 -11
  122. package/es/theme/Theme.js +0 -21
  123. package/es/theme/ThemeCache.d.ts +0 -20
  124. package/es/theme/ThemeCache.js +0 -74
  125. package/es/theme/calc/CSSCalculator.d.ts +0 -15
  126. package/es/theme/calc/CSSCalculator.js +0 -40
  127. package/es/theme/calc/NumCalculator.d.ts +0 -10
  128. package/es/theme/calc/NumCalculator.js +0 -25
  129. package/es/theme/calc/calculator.d.ts +0 -30
  130. package/es/theme/calc/calculator.js +0 -5
  131. package/es/theme/calc/index.d.ts +0 -5
  132. package/es/theme/calc/index.js +0 -9
  133. package/es/theme/createTheme.d.ts +0 -6
  134. package/es/theme/createTheme.js +0 -10
  135. package/es/theme/index.d.ts +0 -6
  136. package/es/theme/interface.d.ts +0 -2
  137. package/es/transformers/interface.d.ts +0 -4
  138. package/es/transformers/legacyLogicalProperties.js +0 -108
  139. package/es/transformers/px2rem.d.ts +0 -20
  140. package/es/transformers/px2rem.js +0 -32
  141. package/es/util/cacheMapUtil.d.ts +0 -14
  142. package/es/util/cacheMapUtil.js +0 -48
  143. package/es/util/css-variables.d.ts +0 -20
  144. package/es/util/css-variables.js +0 -22
  145. package/es/util/index.d.ts +0 -15
  146. package/es/util/index.js +0 -85
  147. package/lib/Cache.d.ts +0 -20
  148. package/lib/Cache.js +0 -1
  149. package/lib/Keyframes.d.ts +0 -9
  150. package/lib/Keyframes.js +0 -1
  151. package/lib/StyleContext.d.ts +0 -40
  152. package/lib/StyleContext.js +0 -1
  153. package/lib/extractStyle.d.ts +0 -12
  154. package/lib/extractStyle.js +0 -1
  155. package/lib/hooks/useCSSVarRegister.d.ts +0 -21
  156. package/lib/hooks/useCSSVarRegister.js +0 -1
  157. package/lib/hooks/useCacheToken.d.ts +0 -69
  158. package/lib/hooks/useCacheToken.js +0 -1
  159. package/lib/hooks/useEffectCleanupRegister.d.ts +0 -2
  160. package/lib/hooks/useEffectCleanupRegister.js +0 -1
  161. package/lib/hooks/useGlobalCache.d.ts +0 -7
  162. package/lib/hooks/useGlobalCache.js +0 -1
  163. package/lib/hooks/useHMR.d.ts +0 -3
  164. package/lib/hooks/useHMR.js +0 -1
  165. package/lib/hooks/useStyleRegister.d.ts +0 -81
  166. package/lib/hooks/useStyleRegister.js +0 -3
  167. package/lib/index.d.ts +0 -18
  168. package/lib/index.js +0 -1
  169. package/lib/interface.d.ts +0 -2
  170. package/lib/linters/NaNLinter.d.ts +0 -3
  171. package/lib/linters/NaNLinter.js +0 -1
  172. package/lib/linters/contentQuotesLinter.d.ts +0 -3
  173. package/lib/linters/contentQuotesLinter.js +0 -1
  174. package/lib/linters/hashedAnimationLinter.d.ts +0 -3
  175. package/lib/linters/hashedAnimationLinter.js +0 -1
  176. package/lib/linters/index.d.ts +0 -7
  177. package/lib/linters/interface.d.ts +0 -8
  178. package/lib/linters/legacyNotSelectorLinter.d.ts +0 -3
  179. package/lib/linters/legacyNotSelectorLinter.js +0 -1
  180. package/lib/linters/logicalPropertiesLinter.d.ts +0 -3
  181. package/lib/linters/logicalPropertiesLinter.js +0 -1
  182. package/lib/linters/parentSelectorLinter.d.ts +0 -3
  183. package/lib/linters/parentSelectorLinter.js +0 -1
  184. package/lib/linters/utils.d.ts +0 -2
  185. package/lib/linters/utils.js +0 -1
  186. package/lib/theme/Theme.d.ts +0 -11
  187. package/lib/theme/Theme.js +0 -1
  188. package/lib/theme/ThemeCache.d.ts +0 -20
  189. package/lib/theme/ThemeCache.js +0 -1
  190. package/lib/theme/calc/CSSCalculator.d.ts +0 -15
  191. package/lib/theme/calc/CSSCalculator.js +0 -1
  192. package/lib/theme/calc/NumCalculator.d.ts +0 -10
  193. package/lib/theme/calc/NumCalculator.js +0 -1
  194. package/lib/theme/calc/calculator.d.ts +0 -30
  195. package/lib/theme/calc/calculator.js +0 -1
  196. package/lib/theme/calc/index.d.ts +0 -5
  197. package/lib/theme/calc/index.js +0 -1
  198. package/lib/theme/createTheme.d.ts +0 -6
  199. package/lib/theme/createTheme.js +0 -1
  200. package/lib/theme/index.d.ts +0 -6
  201. package/lib/theme/interface.d.ts +0 -2
  202. package/lib/transformers/interface.d.ts +0 -4
  203. package/lib/transformers/legacyLogicalProperties.d.ts +0 -12
  204. package/lib/transformers/legacyLogicalProperties.js +0 -1
  205. package/lib/transformers/px2rem.d.ts +0 -20
  206. package/lib/transformers/px2rem.js +0 -1
  207. package/lib/util/cacheMapUtil.d.ts +0 -14
  208. package/lib/util/cacheMapUtil.js +0 -1
  209. package/lib/util/css-variables.d.ts +0 -20
  210. package/lib/util/css-variables.js +0 -1
  211. package/lib/util/index.d.ts +0 -15
  212. package/lib/util/index.js +0 -1
@@ -0,0 +1,60 @@
1
+ import { Theme } from "../theme/Theme.js";
2
+ import "./useGlobalCache.js";
3
+ import { Ref } from "vue";
4
+
5
+ //#region src/hooks/useCacheToken.d.ts
6
+ interface Option<DerivativeToken, DesignToken> {
7
+ /**
8
+ * Generate token with salt.
9
+ * This is used to generate different hashId even same derivative token for different version.
10
+ */
11
+ salt?: string;
12
+ override?: object;
13
+ /**
14
+ * Format token as you need. Such as:
15
+ *
16
+ * - rename token
17
+ * - merge token
18
+ * - delete token
19
+ *
20
+ * This should always be the same since it's one time process.
21
+ * It's ok to useMemo outside but this has better cache strategy.
22
+ */
23
+ formatToken?: (mergedToken: any) => DerivativeToken;
24
+ /**
25
+ * Get final token with origin token, override token and theme.
26
+ * The parameters do not contain formatToken since it's passed by user.
27
+ * @param origin The original token.
28
+ * @param override Extra tokens to override.
29
+ * @param theme Theme instance. Could get derivative token by `theme.getDerivativeToken`
30
+ */
31
+ getComputedToken?: (origin: DesignToken, override: object, theme: Theme<any, any>) => DerivativeToken;
32
+ /**
33
+ * Transform token to css variables.
34
+ */
35
+ cssVar: {
36
+ hashed?: boolean;
37
+ /** Prefix for css variables */
38
+ prefix?: string;
39
+ /** Tokens that should not be appended with unit */
40
+ unitless?: Record<string, boolean>;
41
+ /** Tokens that should not be transformed to css variables */
42
+ ignore?: Record<string, boolean>;
43
+ /** Tokens that preserves origin value */
44
+ preserve?: Record<string, boolean>;
45
+ /** Key for current theme. Useful for customizing and should be unique */
46
+ key: string;
47
+ };
48
+ }
49
+ declare function getComputedToken<DerivativeToken = object, DesignToken = DerivativeToken>(originToken: DesignToken, overrideToken: object, theme: Theme<any, any>, format?: (token: DesignToken) => DerivativeToken): any;
50
+ type TokenCacheValue<DerivativeToken> = [token: DerivativeToken, hashId: string, realToken: DerivativeToken, cssVarStr: string, cssVarKey: string];
51
+ /**
52
+ * Cache theme derivative token as global shared one
53
+ * @param theme Theme entity
54
+ * @param tokens List of tokens, used for cache. Please do not dynamic generate object directly
55
+ * @param option Additional config
56
+ * @returns Call Theme.getDerivativeToken(tokenObject) to get token
57
+ */
58
+ declare function useCacheToken<DerivativeToken = Record<string, any>, DesignToken = DerivativeToken>(theme: Ref<Theme<any, any>>, tokens: Ref<(Partial<DesignToken> | (() => Partial<DesignToken>))[]>, option: Ref<Option<DerivativeToken, DesignToken>>): Ref<TokenCacheValue<DerivativeToken>, TokenCacheValue<DerivativeToken>>;
59
+ //#endregion
60
+ export { getComputedToken, useCacheToken };
@@ -0,0 +1,133 @@
1
+ import { collectStyleText } from "../ssr/styleCollector.js";
2
+ import { ATTR_MARK, ATTR_TOKEN, CSS_IN_JS_INSTANCE, useStyleContext } from "../StyleContext.js";
3
+ import { transformToken } from "../util/css-variables.js";
4
+ import { flattenToken, memoResult, toStyleStr, token2key } from "../util/index.js";
5
+ import { useGlobalCache } from "./useGlobalCache.js";
6
+ import hash from "@emotion/hash";
7
+ import canUseDom from "@v-c/util/dist/Dom/canUseDom";
8
+ import { updateCSS } from "@v-c/util/dist/Dom/dynamicCSS";
9
+ import { computed } from "vue";
10
+
11
+ //#region src/hooks/useCacheToken.ts
12
+ const EMPTY_OVERRIDE = {};
13
+ const hashPrefix = process.env.NODE_ENV !== "production" ? "css-dev-only-do-not-override" : "css";
14
+ const tokenKeys = /* @__PURE__ */ new Map();
15
+ function recordCleanToken(tokenKey) {
16
+ tokenKeys.set(tokenKey, (tokenKeys.get(tokenKey) || 0) + 1);
17
+ }
18
+ function removeStyleTags(key, instanceId) {
19
+ if (typeof document !== "undefined") document.querySelectorAll(`style[${ATTR_TOKEN}="${key}"]`).forEach((style) => {
20
+ if (style[CSS_IN_JS_INSTANCE] === instanceId) style.parentNode?.removeChild(style);
21
+ });
22
+ }
23
+ const TOKEN_THRESHOLD = -1;
24
+ function cleanTokenStyle(tokenKey, instanceId) {
25
+ tokenKeys.set(tokenKey, (tokenKeys.get(tokenKey) || 0) - 1);
26
+ const cleanableKeyList = /* @__PURE__ */ new Set();
27
+ tokenKeys.forEach((value, key) => {
28
+ if (value <= 0) cleanableKeyList.add(key);
29
+ });
30
+ if (tokenKeys.size - cleanableKeyList.size > TOKEN_THRESHOLD) cleanableKeyList.forEach((key) => {
31
+ removeStyleTags(key, instanceId);
32
+ tokenKeys.delete(key);
33
+ });
34
+ }
35
+ function getComputedToken(originToken, overrideToken, theme, format) {
36
+ let mergedDerivativeToken = {
37
+ ...theme.getDerivativeToken(originToken),
38
+ ...overrideToken
39
+ };
40
+ if (format) mergedDerivativeToken = format(mergedDerivativeToken);
41
+ return mergedDerivativeToken;
42
+ }
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
+ };
59
+ /**
60
+ * Cache theme derivative token as global shared one
61
+ * @param theme Theme entity
62
+ * @param tokens List of tokens, used for cache. Please do not dynamic generate object directly
63
+ * @param option Additional config
64
+ * @returns Call Theme.getDerivativeToken(tokenObject) to get token
65
+ */
66
+ function useCacheToken(theme, tokens, option) {
67
+ const styleContext = useStyleContext();
68
+ const salt = computed(() => option.value.salt ?? "");
69
+ const override = computed(() => option.value.override ? option.value.override : EMPTY_OVERRIDE);
70
+ const formatToken = computed(() => option.value.formatToken);
71
+ const compute = computed(() => option.value.getComputedToken);
72
+ const cssVar = computed(() => option.value.cssVar);
73
+ const resolvedTokens = computed(() => tokens.value.map((token) => typeof token === "function" ? token() : token));
74
+ const mergedToken = computed(() => memoResult(() => Object.assign({}, ...resolvedTokens.value), resolvedTokens.value));
75
+ const tokenStr = computed(() => flattenToken(mergedToken.value));
76
+ const overrideTokenStr = computed(() => flattenToken(override.value));
77
+ const cssVarStr = computed(() => flattenToken(cssVar.value));
78
+ return useGlobalCache(computed(() => TOKEN_PREFIX), computed(() => [
79
+ salt.value,
80
+ theme.value.id,
81
+ tokenStr.value,
82
+ overrideTokenStr.value,
83
+ cssVarStr.value
84
+ ]), () => {
85
+ const mergedDerivativeToken = compute.value ? compute.value(mergedToken.value, override.value, theme.value) : getComputedToken(mergedToken.value, override.value, theme.value, formatToken.value);
86
+ const actualToken = { ...mergedDerivativeToken };
87
+ const mergedSalt = `${salt.value}_${cssVar.value.prefix || ""}`;
88
+ const hashId = hash(mergedSalt);
89
+ const hashCls = `${hashPrefix}-${hash(mergedSalt)}`;
90
+ actualToken._tokenKey = token2key(actualToken, mergedSalt);
91
+ const [tokenWithCssVar, cssVarsStr] = transformToken(mergedDerivativeToken, cssVar.value.key, {
92
+ prefix: cssVar.value.prefix,
93
+ ignore: cssVar.value.ignore,
94
+ unitless: cssVar.value.unitless,
95
+ preserve: cssVar.value.preserve,
96
+ hashPriority: styleContext.value.hashPriority,
97
+ hashCls: cssVar.value.hashed ? hashCls : void 0
98
+ });
99
+ tokenWithCssVar._hashId = hashId;
100
+ recordCleanToken(cssVar.value.key);
101
+ return [
102
+ tokenWithCssVar,
103
+ hashCls,
104
+ actualToken,
105
+ cssVarsStr,
106
+ cssVar.value.key
107
+ ];
108
+ }, ([, , , , themeKey]) => {
109
+ cleanTokenStyle(themeKey, styleContext.value.cache.instanceId);
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
+ }
120
+ if (!cssVarsStr) return;
121
+ const style = updateCSS(cssVarsStr, hash(`css-var-${themeKey}`), {
122
+ mark: ATTR_MARK,
123
+ prepend: "queue",
124
+ attachTo: styleContext.value.container,
125
+ priority: -999
126
+ });
127
+ style[CSS_IN_JS_INSTANCE] = styleContext.value.cache.instanceId;
128
+ style.setAttribute(ATTR_TOKEN, themeKey);
129
+ });
130
+ }
131
+
132
+ //#endregion
133
+ export { TOKEN_PREFIX, useCacheToken as default, extract, getComputedToken };
@@ -0,0 +1,9 @@
1
+ import { Ref } from "vue";
2
+
3
+ //#region src/hooks/useGlobalCache.d.ts
4
+ type ExtractStyle<CacheValue> = (cache: CacheValue, effectStyles: Record<string, boolean>, options?: {
5
+ plain?: boolean;
6
+ autoPrefix?: boolean;
7
+ }) => [order: number, styleId: string, style: string] | null;
8
+ //#endregion
9
+ export { ExtractStyle };
@@ -0,0 +1,68 @@
1
+ import { pathKey } from "../Cache.js";
2
+ import { useStyleContext } from "../StyleContext.js";
3
+ import { computed, watch } from "vue";
4
+
5
+ //#region src/hooks/useGlobalCache.ts
6
+ const isDev = process.env.NODE_ENV !== "production";
7
+ const effectMap = /* @__PURE__ */ new Map();
8
+ /**
9
+ * Global cache for CSS-in-JS styles
10
+ *
11
+ * This hook manages a reference-counted cache to ensure styles are properly
12
+ * created, shared, and cleaned up across component instances.
13
+ *
14
+ * Key differences from React version:
15
+ * - No useInsertionEffect needed - Vue's watchEffect handles timing naturally
16
+ * - No StrictMode double-mounting issues - Vue doesn't double-mount
17
+ * - HMR handling is simpler - can rely on Vue's reactivity system
18
+ * - No need for cleanup register pattern - onBeforeUnmount is sufficient
19
+ */
20
+ function useGlobalCache(prefix, keyPath, cacheFn, onCacheRemove, onCacheEffect) {
21
+ const styleContext = useStyleContext();
22
+ const fullPath = computed(() => [prefix.value, ...keyPath.value]);
23
+ const fullPathStr = computed(() => pathKey(fullPath.value));
24
+ const buildCache = (updater) => {
25
+ styleContext.value.cache.opUpdate(fullPathStr.value, (prevCache) => {
26
+ const [times = 0, cache] = prevCache || [void 0, void 0];
27
+ const data = [times, cache || cacheFn()];
28
+ return updater ? updater(data) : data;
29
+ });
30
+ };
31
+ const getCacheEntity = () => styleContext.value.cache.opGet(fullPathStr.value);
32
+ buildCache();
33
+ const cacheContent = computed(() => {
34
+ let entity = styleContext.value.cache.opGet(fullPathStr.value);
35
+ if (isDev && !entity) {
36
+ buildCache();
37
+ entity = getCacheEntity();
38
+ }
39
+ return entity[1];
40
+ });
41
+ watch(fullPathStr, (_, _1, onCleanup) => {
42
+ const currentPath = fullPathStr.value;
43
+ buildCache(([times, cache]) => [times + 1, cache]);
44
+ if (!effectMap.has(currentPath)) {
45
+ onCacheEffect?.(cacheContent.value);
46
+ effectMap.set(currentPath, true);
47
+ Promise.resolve().then(() => {
48
+ effectMap.delete(currentPath);
49
+ });
50
+ }
51
+ const globalCache = styleContext.value.cache;
52
+ onCleanup(() => {
53
+ globalCache.opUpdate(currentPath, (prevCache) => {
54
+ const [times = 0, cache] = prevCache || [];
55
+ if (times - 1 === 0) {
56
+ onCacheRemove?.(cache, false);
57
+ effectMap.delete(currentPath);
58
+ return null;
59
+ }
60
+ return [times - 1, cache];
61
+ });
62
+ });
63
+ }, { immediate: true });
64
+ return cacheContent;
65
+ }
66
+
67
+ //#endregion
68
+ export { useGlobalCache };
@@ -0,0 +1,47 @@
1
+ import { Theme } from "../theme/Theme.js";
2
+ import { Keyframe } from "../Keyframes.js";
3
+ import "../linters/index.js";
4
+ import "../StyleContext.js";
5
+ import "../transformers/interface.js";
6
+ import "./useGlobalCache.js";
7
+ import { Ref } from "vue";
8
+ import * as CSS from "csstype";
9
+
10
+ //#region src/hooks/useStyleRegister.d.ts
11
+ declare const SKIP_CHECK = "_skip_check_";
12
+ declare const MULTI_VALUE = "_multi_value_";
13
+ interface LayerConfig {
14
+ name: string;
15
+ dependencies?: string[];
16
+ }
17
+ type CSSProperties = Omit<CSS.PropertiesFallback<number | string>, 'animationName'> & {
18
+ animationName?: CSS.PropertiesFallback<number | string>['animationName'] | Keyframe;
19
+ };
20
+ type CSSPropertiesWithMultiValues = { [K in keyof CSSProperties]: CSSProperties[K] | readonly Extract<CSSProperties[K], string>[] | {
21
+ [SKIP_CHECK]?: boolean;
22
+ [MULTI_VALUE]?: boolean;
23
+ value: CSSProperties[K] | CSSProperties[K][];
24
+ } };
25
+ type CSSPseudos = { [K in CSS.Pseudos]?: CSSObject };
26
+ type ArrayCSSInterpolation = readonly CSSInterpolation[];
27
+ type InterpolationPrimitive = null | undefined | boolean | number | string | CSSObject;
28
+ type CSSInterpolation = InterpolationPrimitive | ArrayCSSInterpolation | Keyframe;
29
+ type CSSOthersObject = Record<string, CSSInterpolation>;
30
+ interface CSSObject extends CSSPropertiesWithMultiValues, CSSPseudos, CSSOthersObject {}
31
+ declare function useStyleRegister(info: Ref<{
32
+ theme: Theme<any, any>;
33
+ token: any;
34
+ path: string[];
35
+ hashId?: string;
36
+ layer?: LayerConfig;
37
+ nonce?: string | (() => string);
38
+ clientOnly?: boolean;
39
+ /**
40
+ * Tell cssinjs the insert order of style.
41
+ * It's useful when you need to insert style
42
+ * before other style to overwrite for the same selector priority.
43
+ */
44
+ order?: number;
45
+ }>, styleFn: () => CSSInterpolation): void;
46
+ //#endregion
47
+ export { CSSInterpolation, CSSObject, useStyleRegister };
@@ -0,0 +1,237 @@
1
+ import { ATTR_CACHE_PATH, ATTR_MARK, CSS_IN_JS_INSTANCE, useStyleContext } from "../StyleContext.js";
2
+ import { isClientSide, toStyleStr } from "../util/index.js";
3
+ import { useGlobalCache } from "./useGlobalCache.js";
4
+ import contentQuotesLinter_default from "../linters/contentQuotesLinter.js";
5
+ import hashedAnimationLinter_default from "../linters/hashedAnimationLinter.js";
6
+ import "../linters/index.js";
7
+ import { CSS_FILE_STYLE, existPath, getStyleAndHash } from "../util/cacheMapUtil.js";
8
+ import hash from "@emotion/hash";
9
+ import { removeCSS, updateCSS } from "@v-c/util/dist/Dom/dynamicCSS";
10
+ import { computed } from "vue";
11
+ import unitless from "@emotion/unitless";
12
+ import { compile, middleware, prefixer, serialize, stringify } from "stylis";
13
+
14
+ //#region src/hooks/useStyleRegister.ts
15
+ const isDev = process.env.NODE_ENV !== "production";
16
+ const SKIP_CHECK = "_skip_check_";
17
+ const MULTI_VALUE = "_multi_value_";
18
+ function normalizeStyle(styleStr, autoPrefix) {
19
+ return (autoPrefix ? serialize(compile(styleStr), middleware([prefixer, stringify])) : serialize(compile(styleStr), stringify)).replace(/\{%%%:[^;];\}/g, ";");
20
+ }
21
+ function isCompoundCSSProperty(value) {
22
+ return typeof value === "object" && value && (SKIP_CHECK in value || MULTI_VALUE in value);
23
+ }
24
+ function injectSelectorHash(key, hashId, hashPriority) {
25
+ if (!hashId) return key;
26
+ const hashClassName = `.${hashId}`;
27
+ const hashSelector = hashPriority === "low" ? `:where(${hashClassName})` : hashClassName;
28
+ return key.split(",").map((k) => {
29
+ const fullPath = k.trim().split(/\s+/);
30
+ let firstPath = fullPath[0] || "";
31
+ const htmlElement = firstPath.match(/^\w+/)?.[0] || "";
32
+ firstPath = `${htmlElement}${hashSelector}${firstPath.slice(htmlElement.length)}`;
33
+ return [firstPath, ...fullPath.slice(1)].join(" ");
34
+ }).join(",");
35
+ }
36
+ function parseStyle(interpolation, config = {}, { root, injectHash, parentSelectors } = {
37
+ root: true,
38
+ parentSelectors: []
39
+ }) {
40
+ const { hashId, layer, path, hashPriority, transformers = [], linters = [] } = config;
41
+ let styleStr = "";
42
+ let effectStyle = {};
43
+ function parseKeyframes(keyframes) {
44
+ const animationName = keyframes.getName(hashId);
45
+ if (!effectStyle[animationName]) {
46
+ const [parsedStr] = parseStyle(keyframes.style, config, {
47
+ root: false,
48
+ parentSelectors
49
+ });
50
+ effectStyle[animationName] = `@keyframes ${keyframes.getName(hashId)}${parsedStr}`;
51
+ }
52
+ }
53
+ function flattenList(list, fullList = []) {
54
+ list.forEach((item) => {
55
+ if (Array.isArray(item)) flattenList(item, fullList);
56
+ else if (item) fullList.push(item);
57
+ });
58
+ return fullList;
59
+ }
60
+ flattenList(Array.isArray(interpolation) ? interpolation : [interpolation]).forEach((originStyle) => {
61
+ const style = typeof originStyle === "string" && !root ? {} : originStyle;
62
+ if (typeof style === "string") styleStr += `${style}\n`;
63
+ else if (style._keyframe) parseKeyframes(style);
64
+ else {
65
+ const mergedStyle = transformers.reduce((prev, trans) => trans?.visit?.(prev) || prev, style);
66
+ Object.keys(mergedStyle).forEach((key) => {
67
+ const value = mergedStyle[key];
68
+ if (typeof value === "object" && value && (key !== "animationName" || !value._keyframe) && !isCompoundCSSProperty(value)) {
69
+ let subInjectHash = false;
70
+ let mergedKey = key.trim();
71
+ let nextRoot = false;
72
+ if ((root || injectHash) && hashId) if (mergedKey.startsWith("@")) subInjectHash = true;
73
+ else if (mergedKey === "&") mergedKey = injectSelectorHash("", hashId, hashPriority);
74
+ else mergedKey = injectSelectorHash(key, hashId, hashPriority);
75
+ else if (root && !hashId && (mergedKey === "&" || mergedKey === "")) {
76
+ mergedKey = "";
77
+ nextRoot = true;
78
+ }
79
+ const [parsedStr, childEffectStyle] = parseStyle(value, config, {
80
+ root: nextRoot,
81
+ injectHash: subInjectHash,
82
+ parentSelectors: [...parentSelectors, mergedKey]
83
+ });
84
+ effectStyle = {
85
+ ...effectStyle,
86
+ ...childEffectStyle
87
+ };
88
+ styleStr += `${mergedKey}${parsedStr}`;
89
+ } else {
90
+ function appendStyle(cssKey, cssValue) {
91
+ if (process.env.NODE_ENV !== "production" && (typeof value !== "object" || !value?.[SKIP_CHECK])) [
92
+ contentQuotesLinter_default,
93
+ hashedAnimationLinter_default,
94
+ ...linters
95
+ ].forEach((linter) => linter(cssKey, cssValue, {
96
+ path,
97
+ hashId,
98
+ parentSelectors
99
+ }));
100
+ const styleName = cssKey.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
101
+ let formatValue = cssValue;
102
+ if (!unitless[cssKey] && typeof formatValue === "number" && formatValue !== 0) formatValue = `${formatValue}px`;
103
+ if (cssKey === "animationName" && cssValue?._keyframe) {
104
+ parseKeyframes(cssValue);
105
+ formatValue = cssValue.getName(hashId);
106
+ }
107
+ styleStr += `${styleName}:${formatValue};`;
108
+ }
109
+ const actualValue = value?.value ?? value;
110
+ if (typeof value === "object" && value?.[MULTI_VALUE] && Array.isArray(actualValue)) actualValue.forEach((item) => {
111
+ appendStyle(key, item);
112
+ });
113
+ else appendStyle(key, actualValue);
114
+ }
115
+ });
116
+ }
117
+ });
118
+ if (!root) styleStr = `{${styleStr}}`;
119
+ else if (layer) {
120
+ if (styleStr) styleStr = `@layer ${layer.name} {${styleStr}}`;
121
+ if (layer.dependencies) effectStyle[`@layer ${layer.name}`] = layer.dependencies.map((deps) => `@layer ${deps}, ${layer.name};`).join("\n");
122
+ }
123
+ return [styleStr, effectStyle];
124
+ }
125
+ function uniqueHash(path, styleStr) {
126
+ return hash(`${path.join("%")}${styleStr}`);
127
+ }
128
+ const STYLE_PREFIX = "style";
129
+ function useStyleRegister(info, styleFn) {
130
+ const styleContext = useStyleContext();
131
+ const enableLayer = computed(() => !!styleContext.value.layer);
132
+ const order = computed(() => info.value.order ?? 0);
133
+ const hashId = computed(() => info.value.hashId);
134
+ const fullPath = computed(() => {
135
+ const path = [hashId.value || ""];
136
+ if (enableLayer.value) path.push("layer");
137
+ path.push(...info.value.path);
138
+ return path;
139
+ });
140
+ const isMergedClientSide = computed(() => {
141
+ let merged = isClientSide;
142
+ if (isDev && styleContext.value.mock !== void 0) merged = styleContext.value.mock === "client";
143
+ return merged;
144
+ });
145
+ useGlobalCache(computed(() => STYLE_PREFIX), fullPath, () => {
146
+ const cachePath = fullPath.value.join("|");
147
+ const context = styleContext.value;
148
+ const infoValue = info.value;
149
+ if (existPath(cachePath)) {
150
+ const [inlineCacheStyleStr, styleHash] = getStyleAndHash(cachePath);
151
+ if (inlineCacheStyleStr) return [
152
+ inlineCacheStyleStr,
153
+ styleHash,
154
+ {},
155
+ infoValue.clientOnly,
156
+ order.value
157
+ ];
158
+ }
159
+ const [parsedStyle, effectStyle] = parseStyle(styleFn(), {
160
+ hashId: infoValue.hashId,
161
+ hashPriority: context.hashPriority,
162
+ layer: enableLayer.value ? infoValue.layer : void 0,
163
+ path: infoValue.path.join("-"),
164
+ transformers: context.transformers || [],
165
+ linters: context.linters || []
166
+ });
167
+ const styleStr = normalizeStyle(parsedStyle, styleContext.value.autoPrefix || false);
168
+ return [
169
+ styleStr,
170
+ uniqueHash(fullPath.value, styleStr),
171
+ effectStyle,
172
+ infoValue.clientOnly,
173
+ order.value
174
+ ];
175
+ }, (cacheValue, fromHMR) => {
176
+ const [, styleId] = cacheValue;
177
+ if (fromHMR && isClientSide) removeCSS(styleId, { mark: ATTR_MARK });
178
+ }, (cacheValue) => {
179
+ const [styleStr, styleId, effectStyle, , priority] = cacheValue;
180
+ if (!isMergedClientSide.value || styleStr === CSS_FILE_STYLE) return;
181
+ const { layer: enableLayer$1, container, autoPrefix, cache } = styleContext.value;
182
+ const { nonce } = info.value;
183
+ const mergedCSSConfig = {
184
+ mark: ATTR_MARK,
185
+ prepend: enableLayer$1 ? false : "queue",
186
+ attachTo: container,
187
+ priority
188
+ };
189
+ const nonceStr = typeof nonce === "function" ? nonce() : nonce;
190
+ if (nonceStr) mergedCSSConfig.csp = { nonce: nonceStr };
191
+ const effectLayerKeys = [];
192
+ const effectRestKeys = [];
193
+ Object.keys(effectStyle).forEach((key) => {
194
+ if (key.startsWith("@layer")) effectLayerKeys.push(key);
195
+ else effectRestKeys.push(key);
196
+ });
197
+ effectLayerKeys.forEach((effectKey) => {
198
+ updateCSS(normalizeStyle(effectStyle[effectKey], autoPrefix || false), `_layer-${effectKey}`, {
199
+ ...mergedCSSConfig,
200
+ prepend: true
201
+ });
202
+ });
203
+ const style = updateCSS(styleStr, styleId, mergedCSSConfig);
204
+ style[CSS_IN_JS_INSTANCE] = cache.instanceId;
205
+ if (isDev) style.setAttribute(ATTR_CACHE_PATH, fullPath.value.join("|"));
206
+ effectRestKeys.forEach((effectKey) => {
207
+ updateCSS(normalizeStyle(effectStyle[effectKey], autoPrefix || false), `_effect-${effectKey}`, mergedCSSConfig);
208
+ });
209
+ });
210
+ }
211
+ const extract = (cache, effectStyles, options) => {
212
+ const [styleStr, styleId, effectStyle, clientOnly, order] = cache;
213
+ const { plain, autoPrefix } = options || {};
214
+ if (clientOnly) return null;
215
+ let keyStyleText = styleStr;
216
+ const sharedAttrs = {
217
+ "data-rc-order": "prependQueue",
218
+ "data-rc-priority": `${order}`
219
+ };
220
+ keyStyleText = toStyleStr(styleStr, void 0, styleId, sharedAttrs, plain);
221
+ if (effectStyle) Object.keys(effectStyle).forEach((effectKey) => {
222
+ if (!effectStyles[effectKey]) {
223
+ effectStyles[effectKey] = true;
224
+ const effectStyleHTML = toStyleStr(normalizeStyle(effectStyle[effectKey], autoPrefix || false), void 0, `_effect-${effectKey}`, sharedAttrs, plain);
225
+ if (effectKey.startsWith("@layer")) keyStyleText = effectStyleHTML + keyStyleText;
226
+ else keyStyleText += effectStyleHTML;
227
+ }
228
+ });
229
+ return [
230
+ order,
231
+ styleId,
232
+ keyStyleText
233
+ ];
234
+ };
235
+
236
+ //#endregion
237
+ export { STYLE_PREFIX, useStyleRegister as default, extract, uniqueHash };
@@ -0,0 +1,35 @@
1
+ import { AbstractCalculator } from "./theme/calc/calculator.js";
2
+ import { genCalc } from "./theme/calc/index.js";
3
+ import { DerivativeFunc, TokenType } from "./theme/interface.js";
4
+ import { Theme } from "./theme/Theme.js";
5
+ import { createTheme } from "./theme/createTheme.js";
6
+ import { ComponentToken, ComponentTokenKey, GlobalToken, GlobalTokenWithComponent, OverrideTokenMap, TokenMap, TokenMapKey } from "./cssinjs-utils/interface/components.js";
7
+ import { Keyframe } from "./Keyframes.js";
8
+ import { Linter } from "./linters/interface.js";
9
+ import { linter as linter$1 } from "./linters/legacyNotSelectorLinter.js";
10
+ import { linter as linter$2 } from "./linters/logicalPropertiesLinter.js";
11
+ import { linter } from "./linters/NaNLinter.js";
12
+ import { linter as linter$3 } from "./linters/parentSelectorLinter.js";
13
+ import "./linters/index.js";
14
+ import { StyleProvider, StyleProviderProps, createCache, provideStyleContext, useStyleContext, useStyleContextProvide } from "./StyleContext.js";
15
+ import { Transformer } from "./transformers/interface.js";
16
+ import { CSSInterpolation, CSSObject, useStyleRegister } from "./hooks/useStyleRegister.js";
17
+ import { token2CSSVar } from "./util/css-variables.js";
18
+ import { useCSSVarRegister } from "./hooks/useCSSVarRegister.js";
19
+ import { extractStyle } from "./extractStyle.js";
20
+ import { getComputedToken, useCacheToken } from "./hooks/useCacheToken.js";
21
+ import { collectStyleText, setStyleCollector } from "./ssr/styleCollector.js";
22
+ import { transform } from "./transformers/autoPrefix.js";
23
+ import { transform as transform$1 } from "./transformers/legacyLogicalProperties.js";
24
+ import { transform as transform$2 } from "./transformers/px2rem.js";
25
+ import { unit } from "./util/index.js";
26
+ import { CSSUtil, CSSVarRegisterProps, FullToken, GenStyleFn, GetCompUnitless, GetDefaultToken, GetDefaultTokenFn, GetResetStyles, StyleInfo, SubStyleComponentProps, TokenWithCommonCls, genStyleUtils } from "./cssinjs-utils/util/genStyleUtils.js";
27
+ import { merge, statistic, statisticToken } from "./cssinjs-utils/util/statistic.js";
28
+ import "./cssinjs-utils/index.js";
29
+
30
+ //#region src/index.d.ts
31
+ declare const _experimental: {
32
+ supportModernCSS: () => boolean;
33
+ };
34
+ //#endregion
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 ADDED
@@ -0,0 +1,30 @@
1
+ import { collectStyleText, setStyleCollector } from "./ssr/styleCollector.js";
2
+ import { StyleProvider, createCache, provideStyleContext, useStyleContext, useStyleContextProvide } from "./StyleContext.js";
3
+ import calc_default from "./theme/calc/index.js";
4
+ import Theme from "./theme/Theme.js";
5
+ import createTheme from "./theme/createTheme.js";
6
+ import "./theme/index.js";
7
+ import { token2CSSVar } from "./util/css-variables.js";
8
+ import { supportLogicProps, supportWhere, unit } from "./util/index.js";
9
+ import useCacheToken, { getComputedToken } from "./hooks/useCacheToken.js";
10
+ import legacyNotSelectorLinter_default from "./linters/legacyNotSelectorLinter.js";
11
+ import logicalPropertiesLinter_default from "./linters/logicalPropertiesLinter.js";
12
+ import NaNLinter_default from "./linters/NaNLinter.js";
13
+ import parentSelectorLinter_default from "./linters/parentSelectorLinter.js";
14
+ import "./linters/index.js";
15
+ import useStyleRegister from "./hooks/useStyleRegister.js";
16
+ import useCSSVarRegister from "./hooks/useCSSVarRegister.js";
17
+ import extractStyle from "./extractStyle.js";
18
+ import Keyframes_default from "./Keyframes.js";
19
+ import autoPrefix_default from "./transformers/autoPrefix.js";
20
+ import legacyLogicalProperties_default from "./transformers/legacyLogicalProperties.js";
21
+ import px2rem_default from "./transformers/px2rem.js";
22
+ import statistic_default, { merge, statistic } from "./cssinjs-utils/util/statistic.js";
23
+ import genStyleUtils_default from "./cssinjs-utils/util/genStyleUtils.js";
24
+ import "./cssinjs-utils/index.js";
25
+
26
+ //#region src/index.ts
27
+ const _experimental = { supportModernCSS: () => supportWhere() && supportLogicProps() };
28
+
29
+ //#endregion
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,6 @@
1
+ import { Linter } from "./interface.js";
2
+
3
+ //#region src/linters/NaNLinter.d.ts
4
+ declare const linter: Linter;
5
+ //#endregion
6
+ export { linter };
@@ -0,0 +1,10 @@
1
+ import { lintWarning } from "./utils.js";
2
+
3
+ //#region src/linters/NaNLinter.ts
4
+ const linter = (key, value, info) => {
5
+ if (typeof value === "string" && /NaN/.test(value) || Number.isNaN(value)) lintWarning(`Unexpected 'NaN' in property '${key}: ${value}'.`, info);
6
+ };
7
+ var NaNLinter_default = linter;
8
+
9
+ //#endregion
10
+ export { NaNLinter_default as default };
@@ -0,0 +1,18 @@
1
+ import { lintWarning } from "./utils.js";
2
+
3
+ //#region src/linters/contentQuotesLinter.ts
4
+ const linter = (key, value, info) => {
5
+ if (key === "content") {
6
+ if (typeof value !== "string" || ![
7
+ "normal",
8
+ "none",
9
+ "initial",
10
+ "inherit",
11
+ "unset"
12
+ ].includes(value) && !/(attr|counters?|url|(((repeating-)?(linear|radial))|conic)-gradient)\(|(no-)?(open|close)-quote/.test(value) && !value.startsWith("var(") && (value.charAt(0) !== value.charAt(value.length - 1) || value.charAt(0) !== "\"" && value.charAt(0) !== "'")) lintWarning(`You seem to be using a value for 'content' without quotes, try replacing it with \`content: '"${value}"'\`.`, info);
13
+ }
14
+ };
15
+ var contentQuotesLinter_default = linter;
16
+
17
+ //#endregion
18
+ export { contentQuotesLinter_default as default };