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

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 (210) 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 +118 -0
  8. package/dist/StyleContext.js +64 -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 +74 -0
  29. package/dist/hooks/useCacheToken.d.ts +60 -0
  30. package/dist/hooks/useCacheToken.js +120 -0
  31. package/dist/hooks/useGlobalCache.d.ts +9 -0
  32. package/dist/hooks/useGlobalCache.js +70 -0
  33. package/dist/hooks/useStyleRegister.d.ts +47 -0
  34. package/dist/hooks/useStyleRegister.js +237 -0
  35. package/dist/index.d.ts +34 -0
  36. package/dist/index.js +29 -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/theme/Theme.d.ts +16 -0
  52. package/dist/theme/Theme.js +24 -0
  53. package/dist/theme/ThemeCache.js +79 -0
  54. package/dist/theme/calc/CSSCalculator.d.ts +19 -0
  55. package/dist/theme/calc/CSSCalculator.js +63 -0
  56. package/dist/theme/calc/NumCalculator.d.ts +14 -0
  57. package/dist/theme/calc/NumCalculator.js +37 -0
  58. package/dist/theme/calc/calculator.d.ts +32 -0
  59. package/dist/theme/calc/calculator.js +6 -0
  60. package/dist/theme/calc/index.d.ts +8 -0
  61. package/dist/theme/calc/index.js +12 -0
  62. package/dist/theme/createTheme.d.ts +11 -0
  63. package/dist/theme/createTheme.js +16 -0
  64. package/dist/theme/index.js +6 -0
  65. package/dist/theme/interface.d.ts +5 -0
  66. package/dist/transformers/autoPrefix.d.ts +6 -0
  67. package/dist/transformers/autoPrefix.js +7 -0
  68. package/dist/transformers/interface.d.ts +9 -0
  69. package/{es → dist}/transformers/legacyLogicalProperties.d.ts +6 -2
  70. package/dist/transformers/legacyLogicalProperties.js +123 -0
  71. package/dist/transformers/px2rem.d.ts +23 -0
  72. package/dist/transformers/px2rem.js +37 -0
  73. package/dist/util/cacheMapUtil.js +60 -0
  74. package/dist/util/css-variables.d.ts +7 -0
  75. package/dist/util/css-variables.js +35 -0
  76. package/dist/util/index.d.ts +8 -0
  77. package/dist/util/index.js +108 -0
  78. package/package.json +33 -64
  79. package/dist/cssinjs.umd.js +0 -3
  80. package/es/Cache.d.ts +0 -20
  81. package/es/Cache.js +0 -33
  82. package/es/Keyframes.d.ts +0 -9
  83. package/es/Keyframes.js +0 -14
  84. package/es/StyleContext.d.ts +0 -40
  85. package/es/StyleContext.js +0 -100
  86. package/es/extractStyle.d.ts +0 -12
  87. package/es/extractStyle.js +0 -43
  88. package/es/hooks/useCSSVarRegister.d.ts +0 -21
  89. package/es/hooks/useCSSVarRegister.js +0 -59
  90. package/es/hooks/useCacheToken.d.ts +0 -69
  91. package/es/hooks/useCacheToken.js +0 -106
  92. package/es/hooks/useEffectCleanupRegister.d.ts +0 -2
  93. package/es/hooks/useEffectCleanupRegister.js +0 -8
  94. package/es/hooks/useGlobalCache.d.ts +0 -7
  95. package/es/hooks/useGlobalCache.js +0 -41
  96. package/es/hooks/useHMR.d.ts +0 -3
  97. package/es/hooks/useHMR.js +0 -20
  98. package/es/hooks/useStyleRegister.d.ts +0 -81
  99. package/es/hooks/useStyleRegister.js +0 -216
  100. package/es/index.d.ts +0 -18
  101. package/es/index.js +0 -44
  102. package/es/interface.d.ts +0 -2
  103. package/es/linters/NaNLinter.d.ts +0 -3
  104. package/es/linters/NaNLinter.js +0 -7
  105. package/es/linters/contentQuotesLinter.d.ts +0 -3
  106. package/es/linters/contentQuotesLinter.js +0 -13
  107. package/es/linters/hashedAnimationLinter.d.ts +0 -3
  108. package/es/linters/hashedAnimationLinter.js +0 -10
  109. package/es/linters/index.d.ts +0 -7
  110. package/es/linters/interface.d.ts +0 -8
  111. package/es/linters/legacyNotSelectorLinter.d.ts +0 -3
  112. package/es/linters/legacyNotSelectorLinter.js +0 -14
  113. package/es/linters/logicalPropertiesLinter.d.ts +0 -3
  114. package/es/linters/logicalPropertiesLinter.js +0 -61
  115. package/es/linters/parentSelectorLinter.d.ts +0 -3
  116. package/es/linters/parentSelectorLinter.js +0 -7
  117. package/es/linters/utils.d.ts +0 -2
  118. package/es/linters/utils.js +0 -11
  119. package/es/theme/Theme.d.ts +0 -11
  120. package/es/theme/Theme.js +0 -21
  121. package/es/theme/ThemeCache.d.ts +0 -20
  122. package/es/theme/ThemeCache.js +0 -74
  123. package/es/theme/calc/CSSCalculator.d.ts +0 -15
  124. package/es/theme/calc/CSSCalculator.js +0 -40
  125. package/es/theme/calc/NumCalculator.d.ts +0 -10
  126. package/es/theme/calc/NumCalculator.js +0 -25
  127. package/es/theme/calc/calculator.d.ts +0 -30
  128. package/es/theme/calc/calculator.js +0 -5
  129. package/es/theme/calc/index.d.ts +0 -5
  130. package/es/theme/calc/index.js +0 -9
  131. package/es/theme/createTheme.d.ts +0 -6
  132. package/es/theme/createTheme.js +0 -10
  133. package/es/theme/index.d.ts +0 -6
  134. package/es/theme/interface.d.ts +0 -2
  135. package/es/transformers/interface.d.ts +0 -4
  136. package/es/transformers/legacyLogicalProperties.js +0 -108
  137. package/es/transformers/px2rem.d.ts +0 -20
  138. package/es/transformers/px2rem.js +0 -32
  139. package/es/util/cacheMapUtil.d.ts +0 -14
  140. package/es/util/cacheMapUtil.js +0 -48
  141. package/es/util/css-variables.d.ts +0 -20
  142. package/es/util/css-variables.js +0 -22
  143. package/es/util/index.d.ts +0 -15
  144. package/es/util/index.js +0 -85
  145. package/lib/Cache.d.ts +0 -20
  146. package/lib/Cache.js +0 -1
  147. package/lib/Keyframes.d.ts +0 -9
  148. package/lib/Keyframes.js +0 -1
  149. package/lib/StyleContext.d.ts +0 -40
  150. package/lib/StyleContext.js +0 -1
  151. package/lib/extractStyle.d.ts +0 -12
  152. package/lib/extractStyle.js +0 -1
  153. package/lib/hooks/useCSSVarRegister.d.ts +0 -21
  154. package/lib/hooks/useCSSVarRegister.js +0 -1
  155. package/lib/hooks/useCacheToken.d.ts +0 -69
  156. package/lib/hooks/useCacheToken.js +0 -1
  157. package/lib/hooks/useEffectCleanupRegister.d.ts +0 -2
  158. package/lib/hooks/useEffectCleanupRegister.js +0 -1
  159. package/lib/hooks/useGlobalCache.d.ts +0 -7
  160. package/lib/hooks/useGlobalCache.js +0 -1
  161. package/lib/hooks/useHMR.d.ts +0 -3
  162. package/lib/hooks/useHMR.js +0 -1
  163. package/lib/hooks/useStyleRegister.d.ts +0 -81
  164. package/lib/hooks/useStyleRegister.js +0 -3
  165. package/lib/index.d.ts +0 -18
  166. package/lib/index.js +0 -1
  167. package/lib/interface.d.ts +0 -2
  168. package/lib/linters/NaNLinter.d.ts +0 -3
  169. package/lib/linters/NaNLinter.js +0 -1
  170. package/lib/linters/contentQuotesLinter.d.ts +0 -3
  171. package/lib/linters/contentQuotesLinter.js +0 -1
  172. package/lib/linters/hashedAnimationLinter.d.ts +0 -3
  173. package/lib/linters/hashedAnimationLinter.js +0 -1
  174. package/lib/linters/index.d.ts +0 -7
  175. package/lib/linters/interface.d.ts +0 -8
  176. package/lib/linters/legacyNotSelectorLinter.d.ts +0 -3
  177. package/lib/linters/legacyNotSelectorLinter.js +0 -1
  178. package/lib/linters/logicalPropertiesLinter.d.ts +0 -3
  179. package/lib/linters/logicalPropertiesLinter.js +0 -1
  180. package/lib/linters/parentSelectorLinter.d.ts +0 -3
  181. package/lib/linters/parentSelectorLinter.js +0 -1
  182. package/lib/linters/utils.d.ts +0 -2
  183. package/lib/linters/utils.js +0 -1
  184. package/lib/theme/Theme.d.ts +0 -11
  185. package/lib/theme/Theme.js +0 -1
  186. package/lib/theme/ThemeCache.d.ts +0 -20
  187. package/lib/theme/ThemeCache.js +0 -1
  188. package/lib/theme/calc/CSSCalculator.d.ts +0 -15
  189. package/lib/theme/calc/CSSCalculator.js +0 -1
  190. package/lib/theme/calc/NumCalculator.d.ts +0 -10
  191. package/lib/theme/calc/NumCalculator.js +0 -1
  192. package/lib/theme/calc/calculator.d.ts +0 -30
  193. package/lib/theme/calc/calculator.js +0 -1
  194. package/lib/theme/calc/index.d.ts +0 -5
  195. package/lib/theme/calc/index.js +0 -1
  196. package/lib/theme/createTheme.d.ts +0 -6
  197. package/lib/theme/createTheme.js +0 -1
  198. package/lib/theme/index.d.ts +0 -6
  199. package/lib/theme/interface.d.ts +0 -2
  200. package/lib/transformers/interface.d.ts +0 -4
  201. package/lib/transformers/legacyLogicalProperties.d.ts +0 -12
  202. package/lib/transformers/legacyLogicalProperties.js +0 -1
  203. package/lib/transformers/px2rem.d.ts +0 -20
  204. package/lib/transformers/px2rem.js +0 -1
  205. package/lib/util/cacheMapUtil.d.ts +0 -14
  206. package/lib/util/cacheMapUtil.js +0 -1
  207. package/lib/util/css-variables.d.ts +0 -20
  208. package/lib/util/css-variables.js +0 -1
  209. package/lib/util/index.d.ts +0 -15
  210. package/lib/util/index.js +0 -1
@@ -1,100 +0,0 @@
1
- import { defineComponent as y, computed as i, provide as m, inject as p } from "vue";
2
- import C from "./Cache.js";
3
- const v = "data-token-hash", u = "data-css-hash", x = "data-cache-path", r = "__cssinjs_instance__";
4
- function s() {
5
- const n = Math.random().toString(12).slice(2);
6
- if (typeof document < "u" && document.head && document.body) {
7
- const d = document.body.querySelectorAll(`style[${u}]`) || [], {
8
- firstChild: o
9
- } = document.head;
10
- Array.from(d).forEach((e) => {
11
- e[r] = e[r] || n, e[r] === n && document.head.insertBefore(e, o);
12
- });
13
- const a = {};
14
- Array.from(document.querySelectorAll(`style[${u}]`)).forEach((e) => {
15
- const t = e.getAttribute(u);
16
- a[t] ? e[r] === n && e.parentNode?.removeChild(e) : a[t] = !0;
17
- });
18
- }
19
- return new C(n);
20
- }
21
- const f = Symbol("StyleContext"), S = {
22
- hashPriority: "low",
23
- cache: s(),
24
- defaultCache: !0
25
- }, b = /* @__PURE__ */ y((n, {
26
- slots: d
27
- }) => {
28
- const o = A(), a = i(() => {
29
- const e = n, t = {
30
- ...o.value
31
- };
32
- Object.keys(e).forEach((c) => {
33
- const h = e[c];
34
- e[c] !== void 0 && (t[c] = h);
35
- });
36
- const {
37
- cache: l
38
- } = e;
39
- return t.cache = t.cache || s(), t.defaultCache = !l && o.value.defaultCache, t;
40
- });
41
- return m(f, a), () => d.default?.();
42
- }, {
43
- name: "StyleProvider",
44
- name: "StyleProvider",
45
- inheritAttrs: !1,
46
- props: {
47
- autoClear: {
48
- type: Boolean,
49
- default: void 0
50
- },
51
- mock: {
52
- type: String,
53
- default: void 0
54
- },
55
- cache: {
56
- type: Object,
57
- default: void 0
58
- },
59
- defaultCache: {
60
- type: Boolean,
61
- default: void 0
62
- },
63
- hashPriority: {
64
- type: String,
65
- default: void 0
66
- },
67
- container: {
68
- type: Object,
69
- default: void 0
70
- },
71
- ssrInline: {
72
- type: Boolean,
73
- default: void 0
74
- },
75
- transformers: {
76
- type: Array,
77
- default: void 0
78
- },
79
- linters: {
80
- type: Array,
81
- default: void 0
82
- },
83
- layer: {
84
- type: Boolean,
85
- default: void 0
86
- }
87
- }
88
- });
89
- function A() {
90
- return p(f, i(() => S));
91
- }
92
- export {
93
- x as ATTR_CACHE_PATH,
94
- u as ATTR_MARK,
95
- v as ATTR_TOKEN,
96
- r as CSS_IN_JS_INSTANCE,
97
- b as StyleProvider,
98
- s as createCache,
99
- A as useStyleContext
100
- };
@@ -1,12 +0,0 @@
1
- import { default as Cache } from './Cache';
2
- declare const ExtractStyleFns: {
3
- style: import('./hooks/useGlobalCache').ExtractStyle<[styleStr: string, tokenKey: string, styleId: string, effectStyle: Record<string, string>, clientOnly: boolean | undefined, order: number]>;
4
- token: import('./hooks/useGlobalCache').ExtractStyle<[token: any, hashId: string, realToken: any, cssVarStr: string, cssVarKey: string]>;
5
- cssVar: import('./hooks/useGlobalCache').ExtractStyle<[cssVarToken: import('./util/css-variables').TokenWithCSSVar<any, Record<string, any>>, cssVarStr: string, styleId: string, cssVarKey: string]>;
6
- };
7
- type ExtractStyleType = keyof typeof ExtractStyleFns;
8
- export default function extractStyle(cache: Cache, options?: boolean | {
9
- plain?: boolean;
10
- types?: ExtractStyleType | ExtractStyleType[];
11
- }): string;
12
- export {};
@@ -1,43 +0,0 @@
1
- import { extract as h, TOKEN_PREFIX as P } from "./hooks/useCacheToken.js";
2
- import { extract as R, CSS_VAR_PREFIX as d } from "./hooks/useCSSVarRegister.js";
3
- import { extract as _, STYLE_PREFIX as g } from "./hooks/useStyleRegister.js";
4
- import { toStyleStr as A } from "./util/index.js";
5
- import { ATTR_CACHE_MAP as a, serialize as F } from "./util/cacheMapUtil.js";
6
- const T = {
7
- [g]: _,
8
- [P]: h,
9
- [d]: R
10
- };
11
- function $(e) {
12
- return e !== null;
13
- }
14
- function K(e, r) {
15
- const { plain: n = !1, types: c = ["style", "token", "cssVar"] } = typeof r == "boolean" ? { plain: r } : r || {}, l = new RegExp(
16
- `^(${(typeof c == "string" ? [c] : c).join("|")})%`
17
- ), p = Array.from(e.cache.keys()).filter(
18
- (t) => l.test(t)
19
- ), x = {}, i = {};
20
- let o = "";
21
- return p.map((t) => {
22
- const s = t.replace(l, "").replace(/%/g, "|"), [y] = t.split("%"), m = T[y], f = m(e.cache.get(t)[1], x, {
23
- plain: n
24
- });
25
- if (!f)
26
- return null;
27
- const [u, S, E] = f;
28
- return t.startsWith("style") && (i[s] = S), [u, E];
29
- }).filter($).sort(([t], [s]) => t - s).forEach(([, t]) => {
30
- o += t;
31
- }), o += A(
32
- `.${a}{content:"${F(i)}";}`,
33
- void 0,
34
- void 0,
35
- {
36
- [a]: a
37
- },
38
- n
39
- ), o;
40
- }
41
- export {
42
- K as default
43
- };
@@ -1,21 +0,0 @@
1
- import { MaybeRef } from 'vue';
2
- import { TokenWithCSSVar } from '../util/css-variables';
3
- import { ExtractStyle } from './useGlobalCache';
4
- export declare const CSS_VAR_PREFIX = "cssVar";
5
- type CSSVarCacheValue<V, T extends Record<string, V> = Record<string, V>> = [
6
- cssVarToken: TokenWithCSSVar<V, T>,
7
- cssVarStr: string,
8
- styleId: string,
9
- cssVarKey: string
10
- ];
11
- declare function useCSSVarRegister<V, T extends Record<string, V>>(config: MaybeRef<{
12
- path: string[];
13
- key: string;
14
- prefix?: string;
15
- unitless?: Record<string, boolean>;
16
- ignore?: Record<string, boolean>;
17
- scope?: string;
18
- token: any;
19
- }>, fn: MaybeRef<() => T>): import('vue').ComputedRef<CSSVarCacheValue<V, T>>;
20
- export declare const extract: ExtractStyle<CSSVarCacheValue<any>>;
21
- export default useCSSVarRegister;
@@ -1,59 +0,0 @@
1
- import { updateCSS as h, removeCSS as C } from "@v-c/util/dist/Dom/dynamicCSS";
2
- import { computed as t, unref as r } from "vue";
3
- import { useStyleContext as _, ATTR_MARK as k, CSS_IN_JS_INSTANCE as x, ATTR_TOKEN as A } from "../StyleContext.js";
4
- import { toStyleStr as I, isClientSide as R } from "../util/index.js";
5
- import { transformToken as K } from "../util/css-variables.js";
6
- import N from "./useGlobalCache.js";
7
- import { uniqueHash as V } from "./useStyleRegister.js";
8
- const E = "cssVar";
9
- function O(e, y) {
10
- const l = _(), n = t(() => r(e).path), o = t(() => r(e).key), i = t(() => r(e).prefix), p = t(() => r(e).unitless), a = t(() => r(e).ignore), c = t(() => r(e).scope), m = t(() => r(e).token), T = t(() => m.value._tokenKey), d = t(() => [...n.value, o.value, c.value, T.value]);
11
- return N(
12
- E,
13
- d,
14
- () => {
15
- const s = r(y)(), [S, u] = K(s, o.value, {
16
- prefix: i.value,
17
- unitless: p.value,
18
- ignore: a.value,
19
- scope: c.value
20
- }), v = V(d.value, u);
21
- return [S, u, v, o.value];
22
- },
23
- ([, , s]) => {
24
- R && C(s, { mark: k });
25
- },
26
- ([, s, S]) => {
27
- if (!s)
28
- return;
29
- const { container: u, cache: { instanceId: v } } = l.value, f = h(s, S, {
30
- mark: k,
31
- prepend: "queue",
32
- attachTo: u,
33
- priority: -999
34
- });
35
- f[x] = v, f.setAttribute(A, o);
36
- }
37
- );
38
- }
39
- const Q = (e, y, l) => {
40
- const [, n, o, i] = e, { plain: p } = l || {};
41
- if (!n)
42
- return null;
43
- const a = -999, c = {
44
- "data-vc-order": "prependQueue",
45
- "data-vc-priority": `${a}`
46
- }, m = I(
47
- n,
48
- i,
49
- o,
50
- c,
51
- p
52
- );
53
- return [a, o, m];
54
- };
55
- export {
56
- E as CSS_VAR_PREFIX,
57
- O as default,
58
- Q as extract
59
- };
@@ -1,69 +0,0 @@
1
- import { ComputedRef, MaybeRef } from 'vue';
2
- import { default as Theme } from '../theme/Theme';
3
- import { ExtractStyle } from './useGlobalCache';
4
- export interface Option<DerivativeToken, DesignToken> {
5
- /**
6
- * Generate token with salt.
7
- * This is used to generate different hashId even same derivative token for different version.
8
- */
9
- salt?: string;
10
- override?: object;
11
- /**
12
- * Format token as you need. Such as:
13
- *
14
- * - rename token
15
- * - merge token
16
- * - delete token
17
- *
18
- * This should always be the same since it's one time process.
19
- * It's ok to useMemo outside but this has better cache strategy.
20
- */
21
- formatToken?: (mergedToken: any) => DerivativeToken;
22
- /**
23
- * Get final token with origin token, override token and theme.
24
- * The parameters do not contain formatToken since it's passed by user.
25
- * @param origin The original token.
26
- * @param override Extra tokens to override.
27
- * @param theme Theme instance. Could get derivative token by `theme.getDerivativeToken`
28
- */
29
- getComputedToken?: (origin: DesignToken, override: object, theme: Theme<any, any>) => DerivativeToken;
30
- /**
31
- * Transform token to css variables.
32
- */
33
- cssVar?: {
34
- /** Prefix for css variables */
35
- prefix?: string;
36
- /** Tokens that should not be appended with unit */
37
- unitless?: Record<string, boolean>;
38
- /** Tokens that should not be transformed to css variables */
39
- ignore?: Record<string, boolean>;
40
- /** Tokens that preserves origin value */
41
- preserve?: Record<string, boolean>;
42
- /** Key for current theme. Useful for customizing and should be unique */
43
- key?: string;
44
- };
45
- }
46
- export declare function getComputedToken<DerivativeToken = object, DesignToken = DerivativeToken>(originToken: DesignToken, overrideToken: object, theme: Theme<any, any>, format?: (token: DesignToken) => DerivativeToken): any;
47
- export declare const TOKEN_PREFIX = "token";
48
- type TokenCacheValue<DerivativeToken> = [
49
- token: DerivativeToken & {
50
- _tokenKey: string;
51
- _themeKey: string;
52
- },
53
- hashId: string,
54
- realToken: DerivativeToken & {
55
- _tokenKey: string;
56
- },
57
- cssVarStr: string,
58
- cssVarKey: string
59
- ];
60
- /**
61
- * Cache theme derivative token as global shared one
62
- * @param theme Theme entity
63
- * @param tokens List of tokens, used for cache. Please do not dynamic generate object directly
64
- * @param option Additional config
65
- * @returns Call Theme.getDerivativeToken(tokenObject) to get token
66
- */
67
- export default function useCacheToken<DerivativeToken = object, DesignToken = DerivativeToken>(theme: MaybeRef<Theme<any, any>>, tokens: MaybeRef<Partial<DesignToken>[]>, option?: MaybeRef<Option<DerivativeToken, DesignToken>>): ComputedRef<TokenCacheValue<DerivativeToken>>;
68
- export declare const extract: ExtractStyle<TokenCacheValue<any>>;
69
- export {};
@@ -1,106 +0,0 @@
1
- import _ from "@emotion/hash";
2
- import { updateCSS as N } from "@v-c/util/dist/Dom/dynamicCSS";
3
- import { ref as x, computed as u, unref as c } from "vue";
4
- import { useStyleContext as A, ATTR_MARK as R, CSS_IN_JS_INSTANCE as K, ATTR_TOKEN as E } from "../StyleContext.js";
5
- import { memoResult as O, flattenToken as p, token2key as g, toStyleStr as D } from "../util/index.js";
6
- import { transformToken as V } from "../util/css-variables.js";
7
- import $ from "./useGlobalCache.js";
8
- const b = {}, L = process.env.NODE_ENV !== "production" ? "css-dev-only-do-not-override" : "css", i = /* @__PURE__ */ new Map();
9
- function M(e) {
10
- i.set(e, (i.get(e) || 0) + 1);
11
- }
12
- function P(e, l) {
13
- typeof document < "u" && document.querySelectorAll(`style[${E}="${e}"]`).forEach((t) => {
14
- t[K] === l && t.parentNode?.removeChild(t);
15
- });
16
- }
17
- const q = 0;
18
- function H(e, l) {
19
- i.set(e, (i.get(e) || 0) - 1);
20
- const n = Array.from(i.keys()), t = n.filter((s) => (i.get(s) || 0) <= 0);
21
- n.length - t.length > q && t.forEach((s) => {
22
- P(s, l), i.delete(s);
23
- });
24
- }
25
- function j(e, l, n, t) {
26
- let a = {
27
- ...n.getDerivativeToken(e),
28
- ...l
29
- };
30
- return t && (a = t(a)), a;
31
- }
32
- const w = "token";
33
- function B(e, l, n = x({})) {
34
- const t = A(), s = u(() => c(n).salt ?? ""), a = u(() => c(n).override ?? b), y = c(n).formatToken, d = c(n).getComputedToken, o = u(() => c(n).cssVar), f = u(() => O(() => Object.assign({}, ...c(l)), c(l))), T = u(() => p(f.value)), C = u(() => p(a.value)), I = u(() => o.value ? p(o.value) : "");
35
- return $(
36
- w,
37
- u(() => [s.value, c(e).id, T.value, C.value, I.value]),
38
- () => {
39
- let r = d ? d(f.value, a.value, c(e)) : j(f.value, a.value, c(e), y);
40
- const v = { ...r };
41
- let m = "";
42
- o.value && ([r, m] = V(
43
- r,
44
- o.value.key,
45
- {
46
- prefix: o.value.prefix,
47
- ignore: o.value.ignore,
48
- unitless: o.value.unitless,
49
- preserve: o.value.preserve
50
- }
51
- ));
52
- const k = g(r, s.value);
53
- r._tokenKey = k, v._tokenKey = g(v, s.value);
54
- const h = o.value?.key ?? k;
55
- r._themeKey = h, M(h);
56
- const S = `${L}-${_(k)}`;
57
- return r._hashId = S, [
58
- r,
59
- S,
60
- v,
61
- m,
62
- o.value?.key || ""
63
- ];
64
- },
65
- (r) => {
66
- H(r[0]._themeKey, t.value.cache.instanceId);
67
- },
68
- ([r, , , v]) => {
69
- if (o.value && v) {
70
- const m = N(
71
- v,
72
- _(`css-variables-${r._themeKey}`),
73
- {
74
- mark: R,
75
- prepend: "queue",
76
- attachTo: t.value.container,
77
- priority: -999
78
- }
79
- );
80
- m[K] = t.value.cache.instanceId, m.setAttribute(E, r._themeKey);
81
- }
82
- }
83
- );
84
- }
85
- const U = (e, l, n) => {
86
- const [, , t, s, a] = e, { plain: y } = n || {};
87
- if (!s)
88
- return null;
89
- const d = t._tokenKey, o = -999, f = {
90
- "data-vc-order": "prependQueue",
91
- "data-vc-priority": `${o}`
92
- }, T = D(
93
- s,
94
- a,
95
- d,
96
- f,
97
- y
98
- );
99
- return [o, d, T];
100
- };
101
- export {
102
- w as TOKEN_PREFIX,
103
- B as default,
104
- U as extract,
105
- j as getComputedToken
106
- };
@@ -1,2 +0,0 @@
1
- declare function useRun(): (fn: () => void) => void;
2
- export default useRun;
@@ -1,8 +0,0 @@
1
- function u() {
2
- return function(n) {
3
- n();
4
- };
5
- }
6
- export {
7
- u as default
8
- };
@@ -1,7 +0,0 @@
1
- import { ComputedRef } from 'vue';
2
- import { MaybeRef } from '../interface.ts';
3
- import { KeyType } from '../Cache';
4
- export type ExtractStyle<CacheValue> = (cache: CacheValue, effectStyles: Record<string, boolean>, options?: {
5
- plain?: boolean;
6
- }) => [order: number, styleId: string, style: string] | null;
7
- export default function useGlobalCache<CacheType>(prefix: MaybeRef<string>, keyPath: MaybeRef<KeyType[]>, cacheFn: () => CacheType, onCacheRemove?: (cache: CacheType, fromHMR: boolean) => void, onCacheEffect?: (cachedValue: CacheType) => void): ComputedRef<CacheType>;
@@ -1,41 +0,0 @@
1
- import { computed as i, unref as x, shallowRef as U, watch as y, onBeforeUnmount as _ } from "vue";
2
- import { pathKey as w } from "../Cache.js";
3
- import { useStyleContext as D } from "../StyleContext.js";
4
- import H from "./useEffectCleanupRegister.js";
5
- import M from "./useHMR.js";
6
- function K(b, g, E, s, f) {
7
- const l = D(), G = i(() => [x(b), ...x(g)]), c = i(() => w(G.value)), N = H(), v = [], h = M(), m = (u) => {
8
- l.value.cache.opUpdate(c.value, (n) => {
9
- const [o = 0, e] = n || [void 0, void 0];
10
- let a = e;
11
- process.env.NODE_ENV !== "production" && e && h && (s?.(a, h), a = null);
12
- const d = a || E(), C = [o, d];
13
- return u ? u(C) : C;
14
- });
15
- }, t = U();
16
- t.value = l.value.cache.opGet(c.value), process.env.NODE_ENV !== "production" && !t.value && (m(), t.value = l.value.cache.opGet(c.value));
17
- const r = i(() => t.value[1]);
18
- return y(
19
- c,
20
- (u, p) => {
21
- const n = l.value.cache;
22
- f?.(r.value), m(([o, e]) => (o === 0 && f?.(r.value), [o + 1, e])), p && n.opUpdate(p, (o) => {
23
- const [e = 0, a] = o || [];
24
- return e - 1 === 0 ? (N(() => {
25
- s?.(a, !1);
26
- }), null) : [e - 1, a];
27
- }), t.value = n.opGet(c.value), v.push(() => {
28
- s?.(t.value[1], !1);
29
- });
30
- },
31
- {
32
- immediate: !0,
33
- flush: "post"
34
- }
35
- ), _(() => {
36
- v.map((u) => u());
37
- }), r;
38
- }
39
- export {
40
- K as default
41
- };
@@ -1,3 +0,0 @@
1
- declare function useProdHMR(): boolean;
2
- declare const _default: typeof useProdHMR;
3
- export default _default;
@@ -1,20 +0,0 @@
1
- function u() {
2
- return !1;
3
- }
4
- let o = !1;
5
- function d() {
6
- return o;
7
- }
8
- const p = process.env.NODE_ENV === "production" ? u : d;
9
- if (process.env.NODE_ENV !== "production" && typeof module < "u" && module && module.hot && typeof window < "u") {
10
- const e = window;
11
- if (typeof e.webpackHotUpdate == "function") {
12
- const t = e.webpackHotUpdate;
13
- e.webpackHotUpdate = (...n) => (o = !0, setTimeout(() => {
14
- o = !1;
15
- }, 0), t(...n));
16
- }
17
- }
18
- export {
19
- p as default
20
- };
@@ -1,81 +0,0 @@
1
- import { VueNode } from '@v-c/util/dist/type';
2
- import { MaybeRef } from 'vue';
3
- import { Theme, Transformer } from '..';
4
- import { default as Keyframes } from '../Keyframes';
5
- import { Linter } from '../linters';
6
- import { HashPriority } from '../StyleContext';
7
- import { ExtractStyle } from './useGlobalCache';
8
- import type * as CSS from 'csstype';
9
- declare const SKIP_CHECK = "_skip_check_";
10
- declare const MULTI_VALUE = "_multi_value_";
11
- export interface LayerConfig {
12
- name: string;
13
- dependencies?: string[];
14
- }
15
- export type CSSProperties = Omit<CSS.PropertiesFallback<number | string>, 'animationName'> & {
16
- animationName?: CSS.PropertiesFallback<number | string>['animationName'] | Keyframes;
17
- };
18
- export type CSSPropertiesWithMultiValues = {
19
- [K in keyof CSSProperties]: CSSProperties[K] | readonly Extract<CSSProperties[K], string>[] | {
20
- [SKIP_CHECK]?: boolean;
21
- [MULTI_VALUE]?: boolean;
22
- value: CSSProperties[K] | CSSProperties[K][];
23
- };
24
- };
25
- export type CSSPseudos = {
26
- [K in CSS.Pseudos]?: CSSObject;
27
- };
28
- type ArrayCSSInterpolation = readonly CSSInterpolation[];
29
- export type InterpolationPrimitive = null | undefined | boolean | number | string | CSSObject;
30
- export type CSSInterpolation = InterpolationPrimitive | ArrayCSSInterpolation | Keyframes;
31
- export type CSSOthersObject = Record<string, CSSInterpolation>;
32
- export interface CSSObject extends CSSPropertiesWithMultiValues, CSSPseudos, CSSOthersObject {
33
- }
34
- export declare function normalizeStyle(styleStr: string): string;
35
- export interface ParseConfig {
36
- hashId?: string;
37
- hashPriority?: HashPriority;
38
- layer?: LayerConfig;
39
- path?: string;
40
- transformers?: Transformer[];
41
- linters?: Linter[];
42
- }
43
- export interface ParseInfo {
44
- root?: boolean;
45
- injectHash?: boolean;
46
- parentSelectors: string[];
47
- }
48
- export declare function parseStyle(interpolation: CSSInterpolation, config?: ParseConfig, { root, injectHash, parentSelectors }?: ParseInfo): [
49
- parsedStr: string,
50
- effectStyle: Record<string, string>
51
- ];
52
- export declare function uniqueHash(path: (string | number)[], styleStr: string): string;
53
- export declare const STYLE_PREFIX = "style";
54
- type StyleCacheValue = [
55
- styleStr: string,
56
- tokenKey: string,
57
- styleId: string,
58
- effectStyle: Record<string, string>,
59
- clientOnly: boolean | undefined,
60
- order: number
61
- ];
62
- /**
63
- * Register a style to the global style sheet.
64
- */
65
- export default function useStyleRegister(info: MaybeRef<{
66
- theme: Theme<any, any>;
67
- token: any;
68
- path: string[];
69
- hashId?: string;
70
- layer?: LayerConfig;
71
- nonce?: string | (() => string);
72
- clientOnly?: boolean;
73
- /**
74
- * Tell cssinjs the insert order of style.
75
- * It's useful when you need to insert style
76
- * before other style to overwrite for the same selector priority.
77
- */
78
- order?: number;
79
- }>, styleFn: MaybeRef<() => CSSInterpolation>): (node: VueNode) => any;
80
- export declare const extract: ExtractStyle<StyleCacheValue>;
81
- export {};