boss-css 0.0.1 → 0.0.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 (268) hide show
  1. package/README.md +1 -0
  2. package/dist/_virtual/rolldown_runtime.cjs +43 -0
  3. package/dist/_virtual/rolldown_runtime.mjs +20 -0
  4. package/dist/api/browser.cjs +54 -0
  5. package/dist/api/browser.mjs +48 -0
  6. package/dist/api/config.cjs +94 -0
  7. package/dist/api/config.mjs +91 -0
  8. package/dist/api/css.cjs +304 -0
  9. package/dist/api/css.mjs +303 -0
  10. package/dist/api/dictionary.cjs +218 -0
  11. package/dist/api/dictionary.mjs +215 -0
  12. package/dist/api/file/dts.cjs +21 -0
  13. package/dist/api/file/dts.mjs +21 -0
  14. package/dist/api/file/file.cjs +123 -0
  15. package/dist/api/file/file.mjs +120 -0
  16. package/dist/api/file/js.cjs +118 -0
  17. package/dist/api/file/js.mjs +116 -0
  18. package/dist/api/names.cjs +52 -0
  19. package/dist/api/names.mjs +46 -0
  20. package/dist/api/noopCss.cjs +37 -0
  21. package/dist/api/noopCss.mjs +36 -0
  22. package/dist/api/propTree.cjs +54 -0
  23. package/dist/api/propTree.mjs +48 -0
  24. package/dist/api/server.cjs +112 -0
  25. package/dist/api/server.mjs +106 -0
  26. package/dist/cli/build.cjs +1 -0
  27. package/dist/cli/build.mjs +3 -0
  28. package/dist/cli/index.cjs +30 -0
  29. package/dist/cli/index.mjs +29 -0
  30. package/dist/cli/tasks/build.cjs +24 -0
  31. package/dist/cli/tasks/build.mjs +23 -0
  32. package/dist/cli/tasks/choose.cjs +47 -0
  33. package/dist/cli/tasks/choose.mjs +46 -0
  34. package/dist/cli/tasks/compile.cjs +68 -0
  35. package/dist/cli/tasks/compile.mjs +67 -0
  36. package/dist/cli/tasks/dev.cjs +51 -0
  37. package/dist/cli/tasks/dev.mjs +48 -0
  38. package/dist/cli/tasks/init.cjs +1835 -0
  39. package/dist/cli/tasks/init.mjs +1831 -0
  40. package/dist/cli/tasks/watch.cjs +38 -0
  41. package/dist/cli/tasks/watch.mjs +37 -0
  42. package/dist/cli/templates/init.cjs +82 -0
  43. package/dist/cli/templates/init.mjs +78 -0
  44. package/dist/cli/types.cjs +13 -0
  45. package/dist/cli/types.mjs +13 -0
  46. package/dist/cli/utils.cjs +43 -0
  47. package/dist/cli/utils.mjs +41 -0
  48. package/dist/compile/classname-strategy.cjs +79 -0
  49. package/dist/compile/classname-strategy.mjs +77 -0
  50. package/dist/compile/classname.cjs +366 -0
  51. package/dist/compile/classname.mjs +360 -0
  52. package/dist/compile/index.cjs +238 -0
  53. package/dist/compile/index.mjs +235 -0
  54. package/dist/compile/jsx.cjs +803 -0
  55. package/dist/compile/jsx.mjs +800 -0
  56. package/dist/compile/prepared.cjs +88 -0
  57. package/dist/compile/prepared.mjs +87 -0
  58. package/dist/compile/runtime.cjs +33 -0
  59. package/dist/compile/runtime.mjs +32 -0
  60. package/dist/compile/transform.cjs +371 -0
  61. package/dist/compile/transform.mjs +369 -0
  62. package/dist/cx/index.cjs +93 -0
  63. package/dist/cx/index.mjs +85 -0
  64. package/dist/detect-fw/index.cjs +384 -0
  65. package/dist/detect-fw/index.mjs +379 -0
  66. package/dist/dev/client.cjs +39 -0
  67. package/dist/dev/client.mjs +38 -0
  68. package/dist/dev/plugin/browser.cjs +11 -0
  69. package/dist/dev/plugin/browser.mjs +9 -0
  70. package/dist/dev/plugin/server.cjs +86 -0
  71. package/dist/dev/plugin/server.mjs +78 -0
  72. package/dist/dev/port.cjs +46 -0
  73. package/dist/dev/port.mjs +43 -0
  74. package/dist/dev/runtime.cjs +28 -0
  75. package/dist/dev/runtime.mjs +29 -0
  76. package/dist/dev/server.cjs +808 -0
  77. package/dist/dev/server.mjs +805 -0
  78. package/dist/dev/shared.cjs +6 -0
  79. package/dist/dev/shared.mjs +5 -0
  80. package/dist/eslint-plugin/index.cjs +66 -0
  81. package/dist/eslint-plugin/index.mjs +66 -0
  82. package/dist/eslint-plugin/rules/classnames-only.cjs +68 -0
  83. package/dist/eslint-plugin/rules/classnames-only.mjs +68 -0
  84. package/dist/eslint-plugin/rules/format-classnames.cjs +137 -0
  85. package/dist/eslint-plugin/rules/format-classnames.mjs +136 -0
  86. package/dist/eslint-plugin/rules/no-unknown-classes.cjs +119 -0
  87. package/dist/eslint-plugin/rules/no-unknown-classes.mjs +119 -0
  88. package/dist/eslint-plugin/rules/prefer-classnames.cjs +69 -0
  89. package/dist/eslint-plugin/rules/prefer-classnames.mjs +69 -0
  90. package/dist/eslint-plugin/rules/prefer-token-values.cjs +197 -0
  91. package/dist/eslint-plugin/rules/prefer-token-values.mjs +197 -0
  92. package/dist/eslint-plugin/rules/props-only.cjs +115 -0
  93. package/dist/eslint-plugin/rules/props-only.mjs +115 -0
  94. package/dist/eslint-plugin/rules/redundant-cx.cjs +66 -0
  95. package/dist/eslint-plugin/rules/redundant-cx.mjs +66 -0
  96. package/dist/eslint-plugin/rules/require-prop-functions.cjs +130 -0
  97. package/dist/eslint-plugin/rules/require-prop-functions.mjs +130 -0
  98. package/dist/eslint-plugin/utils/api.cjs +30 -0
  99. package/dist/eslint-plugin/utils/api.mjs +29 -0
  100. package/dist/eslint-plugin/utils/ast.cjs +119 -0
  101. package/dist/eslint-plugin/utils/ast.mjs +112 -0
  102. package/dist/eslint-plugin/utils/boss-classes.cjs +185 -0
  103. package/dist/eslint-plugin/utils/boss-classes.mjs +175 -0
  104. package/dist/eslint-plugin/utils/defaults.cjs +99 -0
  105. package/dist/eslint-plugin/utils/defaults.mjs +93 -0
  106. package/dist/eslint-plugin/utils/format.cjs +20 -0
  107. package/dist/eslint-plugin/utils/format.mjs +19 -0
  108. package/dist/eslint-plugin/utils/order.cjs +76 -0
  109. package/dist/eslint-plugin/utils/order.mjs +76 -0
  110. package/dist/eslint-plugin/utils/property-order.cjs +449 -0
  111. package/dist/eslint-plugin/utils/property-order.mjs +448 -0
  112. package/dist/eslint-plugin/utils/static.cjs +36 -0
  113. package/dist/eslint-plugin/utils/static.mjs +35 -0
  114. package/dist/fontsource/directory.cjs +39588 -0
  115. package/dist/fontsource/directory.mjs +39587 -0
  116. package/dist/fontsource/server.cjs +291 -0
  117. package/dist/fontsource/server.mjs +282 -0
  118. package/dist/index.cjs +10 -0
  119. package/dist/index.mjs +6 -0
  120. package/dist/log/browser.cjs +28 -0
  121. package/dist/log/browser.mjs +28 -0
  122. package/dist/log/server.cjs +32 -0
  123. package/dist/log/server.mjs +30 -0
  124. package/dist/merge/index.cjs +590 -0
  125. package/dist/merge/index.mjs +586 -0
  126. package/dist/native/browser.cjs +78 -0
  127. package/dist/native/browser.mjs +77 -0
  128. package/dist/native/server.cjs +180 -0
  129. package/dist/native/server.mjs +176 -0
  130. package/dist/native/styleTypes.cjs +168 -0
  131. package/dist/native/styleTypes.mjs +164 -0
  132. package/dist/parser/classname/server.cjs +239 -0
  133. package/dist/parser/classname/server.mjs +232 -0
  134. package/dist/parser/jsx/browser.cjs +66 -0
  135. package/dist/parser/jsx/browser.mjs +63 -0
  136. package/dist/parser/jsx/extractCode.cjs +99 -0
  137. package/dist/parser/jsx/extractCode.mjs +98 -0
  138. package/dist/parser/jsx/extractPrepared.cjs +123 -0
  139. package/dist/parser/jsx/extractPrepared.mjs +122 -0
  140. package/dist/parser/jsx/extractProps.cjs +234 -0
  141. package/dist/parser/jsx/extractProps.mjs +232 -0
  142. package/dist/parser/jsx/isDOMProp.cjs +17 -0
  143. package/dist/parser/jsx/isDOMProp.mjs +15 -0
  144. package/dist/parser/jsx/native.cjs +110 -0
  145. package/dist/parser/jsx/native.mjs +108 -0
  146. package/dist/parser/jsx/runtime.cjs +4 -0
  147. package/dist/parser/jsx/runtime.mjs +3 -0
  148. package/dist/parser/jsx/server.cjs +278 -0
  149. package/dist/parser/jsx/server.mjs +268 -0
  150. package/dist/postcss/index.cjs +16 -0
  151. package/dist/postcss/index.mjs +16 -0
  152. package/dist/prop/at/runtime-only.cjs +90 -0
  153. package/dist/prop/at/runtime-only.mjs +88 -0
  154. package/dist/prop/at/server.cjs +282 -0
  155. package/dist/prop/at/server.mjs +268 -0
  156. package/dist/prop/at/shared.cjs +153 -0
  157. package/dist/prop/at/shared.mjs +144 -0
  158. package/dist/prop/bosswind/browser.cjs +18 -0
  159. package/dist/prop/bosswind/browser.mjs +16 -0
  160. package/dist/prop/bosswind/runtime-only.cjs +18 -0
  161. package/dist/prop/bosswind/runtime-only.mjs +16 -0
  162. package/dist/prop/bosswind/server.cjs +81 -0
  163. package/dist/prop/bosswind/server.mjs +72 -0
  164. package/dist/prop/bosswind/shared.cjs +861 -0
  165. package/dist/prop/bosswind/shared.mjs +855 -0
  166. package/dist/prop/bosswind/tailwind-theme.cjs +703 -0
  167. package/dist/prop/bosswind/tailwind-theme.mjs +702 -0
  168. package/dist/prop/child/runtime-only.cjs +18 -0
  169. package/dist/prop/child/runtime-only.mjs +15 -0
  170. package/dist/prop/child/server.cjs +81 -0
  171. package/dist/prop/child/server.mjs +72 -0
  172. package/dist/prop/css/getDtsTemplate.cjs +65 -0
  173. package/dist/prop/css/getDtsTemplate.mjs +63 -0
  174. package/dist/prop/css/runtime-only.cjs +14 -0
  175. package/dist/prop/css/runtime-only.mjs +13 -0
  176. package/dist/prop/css/server.cjs +99 -0
  177. package/dist/prop/css/server.mjs +90 -0
  178. package/dist/prop/pseudo/runtime-only.cjs +23 -0
  179. package/dist/prop/pseudo/runtime-only.mjs +21 -0
  180. package/dist/prop/pseudo/server.cjs +91 -0
  181. package/dist/prop/pseudo/server.mjs +82 -0
  182. package/dist/prop/pseudo/shared.cjs +61 -0
  183. package/dist/prop/pseudo/shared.mjs +60 -0
  184. package/dist/reset/server.cjs +34 -0
  185. package/dist/reset/server.mjs +26 -0
  186. package/dist/runtime/index.cjs +119 -0
  187. package/dist/runtime/index.mjs +118 -0
  188. package/dist/runtime/preact.cjs +4 -0
  189. package/dist/runtime/preact.mjs +3 -0
  190. package/dist/runtime/qwik.cjs +21 -0
  191. package/dist/runtime/qwik.mjs +18 -0
  192. package/dist/runtime/react.cjs +4 -0
  193. package/dist/runtime/react.mjs +3 -0
  194. package/dist/runtime/solid.cjs +15 -0
  195. package/dist/runtime/solid.mjs +14 -0
  196. package/dist/runtime/stencil.cjs +25 -0
  197. package/dist/runtime/stencil.mjs +21 -0
  198. package/dist/runtime/style.cjs +14 -0
  199. package/dist/runtime/style.mjs +13 -0
  200. package/dist/shared/boundaries.cjs +288 -0
  201. package/dist/shared/boundaries.mjs +285 -0
  202. package/dist/shared/customCss.cjs +212 -0
  203. package/dist/shared/customCss.mjs +211 -0
  204. package/dist/shared/debug.cjs +76 -0
  205. package/dist/shared/debug.mjs +74 -0
  206. package/dist/shared/file.cjs +21 -0
  207. package/dist/shared/file.mjs +19 -0
  208. package/dist/shared/framework.cjs +10 -0
  209. package/dist/shared/framework.mjs +9 -0
  210. package/dist/shared/json.cjs +58 -0
  211. package/dist/shared/json.mjs +57 -0
  212. package/dist/shared/types.cjs +11 -0
  213. package/dist/shared/types.mjs +10 -0
  214. package/dist/strategy/classic/runtime-only.cjs +190 -0
  215. package/dist/strategy/classic/runtime-only.mjs +186 -0
  216. package/dist/strategy/classname-first/runtime-only.cjs +138 -0
  217. package/dist/strategy/classname-first/runtime-only.mjs +134 -0
  218. package/dist/strategy/classname-first/server.cjs +139 -0
  219. package/dist/strategy/classname-first/server.mjs +133 -0
  220. package/dist/strategy/classname-only/server.cjs +43 -0
  221. package/dist/strategy/classname-only/server.mjs +35 -0
  222. package/dist/strategy/inline-first/browser.cjs +61 -0
  223. package/dist/strategy/inline-first/browser.mjs +58 -0
  224. package/dist/strategy/inline-first/runtime-only.cjs +159 -0
  225. package/dist/strategy/inline-first/runtime-only.mjs +155 -0
  226. package/dist/strategy/inline-first/server.cjs +92 -0
  227. package/dist/strategy/inline-first/server.mjs +83 -0
  228. package/dist/strategy/runtime/runtime-only.cjs +24 -0
  229. package/dist/strategy/runtime/runtime-only.mjs +22 -0
  230. package/dist/strategy/runtime/server.cjs +72 -0
  231. package/dist/strategy/runtime/server.mjs +63 -0
  232. package/dist/strategy/runtime-only/css.cjs +183 -0
  233. package/dist/strategy/runtime-only/css.mjs +181 -0
  234. package/dist/tasks/build.cjs +88 -0
  235. package/dist/tasks/build.mjs +84 -0
  236. package/dist/tasks/compile.cjs +12 -0
  237. package/dist/tasks/compile.mjs +12 -0
  238. package/dist/tasks/postcss.cjs +116 -0
  239. package/dist/tasks/postcss.mjs +113 -0
  240. package/dist/tasks/session.cjs +46 -0
  241. package/dist/tasks/session.mjs +42 -0
  242. package/dist/tasks/watch.cjs +102 -0
  243. package/dist/tasks/watch.mjs +99 -0
  244. package/dist/transform/cache.cjs +24 -0
  245. package/dist/transform/cache.mjs +21 -0
  246. package/dist/transform/processFile.cjs +26 -0
  247. package/dist/transform/processFile.mjs +24 -0
  248. package/dist/use/token/browser.cjs +65 -0
  249. package/dist/use/token/browser.mjs +61 -0
  250. package/dist/use/token/runtime-only.cjs +245 -0
  251. package/dist/use/token/runtime-only.mjs +239 -0
  252. package/dist/use/token/server.cjs +325 -0
  253. package/dist/use/token/server.mjs +313 -0
  254. package/dist/use/token/vars.cjs +47 -0
  255. package/dist/use/token/vars.mjs +46 -0
  256. package/package.json +300 -4
  257. package/src/api/config.d.ts +1 -0
  258. package/src/fontsource/types.d.ts +50 -0
  259. package/src/packages/document-create-element/createElement.browser.js +3 -0
  260. package/src/packages/document-create-element/createElement.js +7 -0
  261. package/src/packages/document-create-element/package.json +17 -0
  262. package/src/packages/is-css-prop/browser.js +13 -0
  263. package/src/packages/is-css-prop/index.js +13 -0
  264. package/src/packages/is-css-prop/package-lock.json +52 -0
  265. package/src/packages/is-css-prop/package.json +17 -0
  266. package/src/prop/css/csstype.json +4387 -0
  267. package/src/prop/css/package.json +3 -0
  268. package/src/reset/reset.css +259 -0
@@ -0,0 +1,134 @@
1
+ import { getClassNameProp } from "../../shared/framework.mjs";
2
+ import { cx } from "../../cx/index.mjs";
3
+ import { resolveRuntimeToken } from "../../use/token/runtime-only.mjs";
4
+ import { buildKeyframesRule, normalizeKeyframeStep, parseKeyframesContext } from "../../prop/at/shared.mjs";
5
+ import { resolveAtQuery } from "../../prop/at/runtime-only.mjs";
6
+ import { createChildContext } from "../../prop/child/runtime-only.mjs";
7
+ import { buildRuntimeSelector, resolvePropertyName } from "../../prop/css/runtime-only.mjs";
8
+ import hash from "@emotion/hash";
9
+ import isCSSProp from "@boss-css/is-css-prop";
10
+
11
+ //#region src/strategy/classname-first/runtime-only.ts
12
+ const name = "classname-first";
13
+ const resolveRuntimeValue = (value) => {
14
+ if (typeof value !== "function") return value;
15
+ return resolveRuntimeValue(value());
16
+ };
17
+ const buildAutoKeyframesName = (api, contexts) => {
18
+ return `kf-${hash(`${api.selectorPrefix ?? ""}|${contexts.join("|")}`)}`;
19
+ };
20
+ const handleKeyframes = (api, { output, tag, contexts, prop, value }) => {
21
+ const info = parseKeyframesContext(prop);
22
+ if (!info || !value || typeof value !== "object" || Array.isArray(value)) return false;
23
+ const classNameProp = getClassNameProp(api.framework);
24
+ const keyframesContexts = [...contexts, prop];
25
+ const keyframesName = info.name ?? buildAutoKeyframesName(api, keyframesContexts);
26
+ const query = resolveAtQuery(api, keyframesContexts);
27
+ const frames = /* @__PURE__ */ new Map();
28
+ const selectors = /* @__PURE__ */ new Set();
29
+ for (const [step, stepValue] of Object.entries(value)) {
30
+ if (!stepValue || typeof stepValue !== "object" || Array.isArray(stepValue)) continue;
31
+ const normalizedStep = normalizeKeyframeStep(step);
32
+ if (!normalizedStep) continue;
33
+ const stepContexts = [...keyframesContexts, step];
34
+ for (const [propName, rawValue] of Object.entries(stepValue)) {
35
+ if (!isCSSProp(tag, propName)) continue;
36
+ let resolved = resolveRuntimeValue(rawValue);
37
+ let selectorValue = resolved;
38
+ const token = resolveRuntimeToken(api, propName, resolved);
39
+ if (token) {
40
+ resolved = token.value;
41
+ selectorValue = token.selectorValue;
42
+ }
43
+ const className = api.contextToClassName(propName, selectorValue, stepContexts, false, api.selectorPrefix);
44
+ const cssClassName = api.contextToClassName(propName, selectorValue, stepContexts, true, api.selectorPrefix);
45
+ output[classNameProp] = cx(output[classNameProp], className);
46
+ const selector = buildRuntimeSelector(cssClassName, stepContexts);
47
+ selectors.add(selector);
48
+ const propertyName = resolvePropertyName(propName);
49
+ const valueText = String(api.dictionary.toValue(resolved, propertyName));
50
+ if (!frames.has(normalizedStep)) frames.set(normalizedStep, /* @__PURE__ */ new Map());
51
+ frames.get(normalizedStep)?.set(propertyName, valueText);
52
+ }
53
+ }
54
+ if (!frames.size) return true;
55
+ const css = api.css;
56
+ if (!css) return true;
57
+ css.addRule(buildKeyframesRule(keyframesName, frames), query);
58
+ for (const selector of selectors) {
59
+ css.selector({
60
+ selector,
61
+ query
62
+ });
63
+ css.rule("animation-name", keyframesName);
64
+ css.write();
65
+ }
66
+ return true;
67
+ };
68
+ const insertRuntimeRule = (api, className, contexts, prop, value) => {
69
+ const selector = buildRuntimeSelector(className, contexts);
70
+ const query = resolveAtQuery(api, contexts);
71
+ const property = resolvePropertyName(prop);
72
+ const css = api.css;
73
+ if (!css) return;
74
+ css.selector({
75
+ selector,
76
+ query
77
+ });
78
+ css.rule(property, value);
79
+ css.write();
80
+ };
81
+ const onBrowserObjectStart = (api, { input, output = {}, tag, contexts = [] }) => {
82
+ const classNameProp = getClassNameProp(api.framework);
83
+ const outputRecord = output;
84
+ const inputRecord = input;
85
+ for (const prop in inputRecord) {
86
+ const rawValue = inputRecord[prop];
87
+ if (prop === "child" && rawValue && typeof rawValue === "object" && !Array.isArray(rawValue)) {
88
+ for (const [selector, childValue] of Object.entries(rawValue)) {
89
+ const childContext = createChildContext(selector);
90
+ contexts.push(childContext);
91
+ api.trigger("onBrowserObjectStart", {
92
+ input: childValue,
93
+ output,
94
+ contexts,
95
+ tag
96
+ });
97
+ }
98
+ continue;
99
+ }
100
+ if (rawValue && typeof rawValue === "object" && !Array.isArray(rawValue)) {
101
+ if (handleKeyframes(api, {
102
+ output: outputRecord,
103
+ tag,
104
+ contexts,
105
+ prop,
106
+ value: rawValue
107
+ })) continue;
108
+ contexts.push(prop);
109
+ api.trigger("onBrowserObjectStart", {
110
+ input: rawValue,
111
+ output,
112
+ contexts,
113
+ tag
114
+ });
115
+ continue;
116
+ }
117
+ if (!isCSSProp(tag, prop)) continue;
118
+ let value = resolveRuntimeValue(rawValue);
119
+ let selectorValue = value;
120
+ const token = resolveRuntimeToken(api, prop, value);
121
+ if (token) {
122
+ value = token.value;
123
+ selectorValue = token.selectorValue;
124
+ }
125
+ const className = api.contextToClassName(prop, selectorValue, contexts, false, api.selectorPrefix);
126
+ const cssClassName = api.contextToClassName(prop, selectorValue, contexts, true, api.selectorPrefix);
127
+ outputRecord[classNameProp] = cx(outputRecord[classNameProp], className);
128
+ insertRuntimeRule(api, cssClassName, contexts, prop, value);
129
+ }
130
+ contexts.pop();
131
+ };
132
+
133
+ //#endregion
134
+ export { name, onBrowserObjectStart };
@@ -0,0 +1,139 @@
1
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
+
3
+ //#region src/strategy/classname-first/server.ts
4
+ var server_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
5
+ name: () => name,
6
+ onBoot: () => onBoot,
7
+ onPropTree: () => onPropTree,
8
+ settings: () => settings
9
+ });
10
+ const settings = new Map([["emitRuntime", false], ["emitAllTokens", false]]);
11
+ let needsRuntime = false;
12
+ const isFunctionProp = (prop) => typeof prop?.isFn === "boolean" && prop.isFn;
13
+ const resolveDescriptor = (api, name) => {
14
+ return api.dictionary.resolve(name);
15
+ };
16
+ const normalizeArrayValue = (value) => {
17
+ return value.map((entry) => {
18
+ if (entry && typeof entry === "object" && "value" in entry) {
19
+ const raw = entry.value;
20
+ return Array.isArray(raw) ? normalizeArrayValue(raw) : raw;
21
+ }
22
+ return entry;
23
+ });
24
+ };
25
+ const describeLocation = (file, code) => {
26
+ if (!file?.path && !code) return "";
27
+ const parts = [];
28
+ if (file?.path) parts.push(file.path);
29
+ if (code) parts.push(code.trim());
30
+ return parts.length ? ` (${parts.join(" | ")})` : "";
31
+ };
32
+ const onBoot = async (api) => {
33
+ const runtimeConfig = api.runtime;
34
+ const hasRuntimeConfig = Boolean(runtimeConfig && (runtimeConfig.only !== void 0 || runtimeConfig.strategy));
35
+ const runtimeStrategy = runtimeConfig?.strategy ?? name;
36
+ const runtimeModule = hasRuntimeConfig ? "boss-css/strategy/runtime/runtime-only" : "boss-css/strategy/classname-first/browser";
37
+ const shouldEmitRuntime = () => needsRuntime || settings.get("emitRuntime") === true;
38
+ const runtimePlugin = { onBrowserObjectStart: api.file.js.import({
39
+ name: "onBrowserObjectStart",
40
+ from: runtimeModule
41
+ }, shouldEmitRuntime) };
42
+ if (hasRuntimeConfig) runtimePlugin.onInit = api.file.js.import({
43
+ name: "onInit",
44
+ from: runtimeModule
45
+ }, shouldEmitRuntime);
46
+ api.file.js.config({
47
+ from: runtimeModule,
48
+ config: { plugin: runtimePlugin }
49
+ }, shouldEmitRuntime);
50
+ api.file.js.config({
51
+ from: "boss-css/strategy/classname-first",
52
+ config: {
53
+ selectorPrefix: api.selectorPrefix,
54
+ selectorScope: api.selectorScope,
55
+ strategy: runtimeStrategy,
56
+ ...hasRuntimeConfig ? { runtime: runtimeConfig } : {}
57
+ }
58
+ }, shouldEmitRuntime);
59
+ api.strategy = name;
60
+ if (settings.get("emitAllTokens") === true || process.env.NODE_ENV !== "production") api.emitAllTokens = true;
61
+ };
62
+ const onPropTree = async (api, { tree, parser, file, code }) => {
63
+ if (api.runtime?.only === true) return;
64
+ const invalidProps = [];
65
+ const pruneTree = (node) => {
66
+ const next = {};
67
+ for (const [name, prop] of Object.entries(node)) {
68
+ const value = prop?.value;
69
+ const resolved = resolveDescriptor(api, name);
70
+ const isCssProp = Boolean(resolved.descriptor?.isCSSProp);
71
+ if (value && typeof value === "object" && !Array.isArray(value)) {
72
+ const nested = pruneTree(value);
73
+ if (Object.keys(nested).length) next[name] = {
74
+ ...prop,
75
+ value: nested
76
+ };
77
+ continue;
78
+ }
79
+ if (!isCssProp) {
80
+ next[name] = prop;
81
+ continue;
82
+ }
83
+ needsRuntime ||= parser === "jsx";
84
+ if (prop.dynamic && !isFunctionProp(prop)) {
85
+ invalidProps.push(name);
86
+ continue;
87
+ }
88
+ if (prop.dynamic && isFunctionProp(prop)) {
89
+ next[name] = {
90
+ ...prop,
91
+ value: null,
92
+ selectorValue: null
93
+ };
94
+ continue;
95
+ }
96
+ const normalizedValue = Array.isArray(prop.value) ? normalizeArrayValue(prop.value) : prop.value;
97
+ next[name] = {
98
+ ...prop,
99
+ value: normalizedValue,
100
+ selectorValue: prop.selectorValue ?? normalizedValue
101
+ };
102
+ }
103
+ return next;
104
+ };
105
+ const pruned = pruneTree(tree);
106
+ Object.keys(tree).forEach((key) => delete tree[key]);
107
+ Object.assign(tree, pruned);
108
+ if (invalidProps.length) {
109
+ const location = describeLocation(file, code);
110
+ for (const name of invalidProps) console.warn(`[boss-css] classname-first skipped dynamic prop "${name}". Use ${name}={() => value}.${location}`);
111
+ }
112
+ for (const [name, prop] of Object.entries(tree)) {
113
+ const resolved = resolveDescriptor(api, name);
114
+ if (!resolved.descriptor) continue;
115
+ if (resolved.suffix) {
116
+ prop.named = resolved.suffix;
117
+ prop.rawName = resolved.raw;
118
+ }
119
+ const { aliases } = resolved.descriptor;
120
+ await api.trigger("onProp", {
121
+ name: resolved.name,
122
+ prop,
123
+ contexts: [],
124
+ file
125
+ }, ({ dependencies }) => {
126
+ return !dependencies || aliases.some((alias) => dependencies.has(alias));
127
+ });
128
+ }
129
+ };
130
+ const name = "classname-first";
131
+
132
+ //#endregion
133
+ Object.defineProperty(exports, 'server_exports', {
134
+ enumerable: true,
135
+ get: function () {
136
+ return server_exports;
137
+ }
138
+ });
139
+ exports.settings = settings;
@@ -0,0 +1,133 @@
1
+ import { __exportAll } from "../../_virtual/rolldown_runtime.mjs";
2
+
3
+ //#region src/strategy/classname-first/server.ts
4
+ var server_exports = /* @__PURE__ */ __exportAll({
5
+ name: () => name,
6
+ onBoot: () => onBoot,
7
+ onPropTree: () => onPropTree,
8
+ settings: () => settings
9
+ });
10
+ const settings = new Map([["emitRuntime", false], ["emitAllTokens", false]]);
11
+ let needsRuntime = false;
12
+ const isFunctionProp = (prop) => typeof prop?.isFn === "boolean" && prop.isFn;
13
+ const resolveDescriptor = (api, name) => {
14
+ return api.dictionary.resolve(name);
15
+ };
16
+ const normalizeArrayValue = (value) => {
17
+ return value.map((entry) => {
18
+ if (entry && typeof entry === "object" && "value" in entry) {
19
+ const raw = entry.value;
20
+ return Array.isArray(raw) ? normalizeArrayValue(raw) : raw;
21
+ }
22
+ return entry;
23
+ });
24
+ };
25
+ const describeLocation = (file, code) => {
26
+ if (!file?.path && !code) return "";
27
+ const parts = [];
28
+ if (file?.path) parts.push(file.path);
29
+ if (code) parts.push(code.trim());
30
+ return parts.length ? ` (${parts.join(" | ")})` : "";
31
+ };
32
+ const onBoot = async (api) => {
33
+ const runtimeConfig = api.runtime;
34
+ const hasRuntimeConfig = Boolean(runtimeConfig && (runtimeConfig.only !== void 0 || runtimeConfig.strategy));
35
+ const runtimeStrategy = runtimeConfig?.strategy ?? name;
36
+ const runtimeModule = hasRuntimeConfig ? "boss-css/strategy/runtime/runtime-only" : "boss-css/strategy/classname-first/browser";
37
+ const shouldEmitRuntime = () => needsRuntime || settings.get("emitRuntime") === true;
38
+ const runtimePlugin = { onBrowserObjectStart: api.file.js.import({
39
+ name: "onBrowserObjectStart",
40
+ from: runtimeModule
41
+ }, shouldEmitRuntime) };
42
+ if (hasRuntimeConfig) runtimePlugin.onInit = api.file.js.import({
43
+ name: "onInit",
44
+ from: runtimeModule
45
+ }, shouldEmitRuntime);
46
+ api.file.js.config({
47
+ from: runtimeModule,
48
+ config: { plugin: runtimePlugin }
49
+ }, shouldEmitRuntime);
50
+ api.file.js.config({
51
+ from: "boss-css/strategy/classname-first",
52
+ config: {
53
+ selectorPrefix: api.selectorPrefix,
54
+ selectorScope: api.selectorScope,
55
+ strategy: runtimeStrategy,
56
+ ...hasRuntimeConfig ? { runtime: runtimeConfig } : {}
57
+ }
58
+ }, shouldEmitRuntime);
59
+ api.strategy = name;
60
+ if (settings.get("emitAllTokens") === true || process.env.NODE_ENV !== "production") api.emitAllTokens = true;
61
+ };
62
+ const onPropTree = async (api, { tree, parser, file, code }) => {
63
+ if (api.runtime?.only === true) return;
64
+ const invalidProps = [];
65
+ const pruneTree = (node) => {
66
+ const next = {};
67
+ for (const [name, prop] of Object.entries(node)) {
68
+ const value = prop?.value;
69
+ const resolved = resolveDescriptor(api, name);
70
+ const isCssProp = Boolean(resolved.descriptor?.isCSSProp);
71
+ if (value && typeof value === "object" && !Array.isArray(value)) {
72
+ const nested = pruneTree(value);
73
+ if (Object.keys(nested).length) next[name] = {
74
+ ...prop,
75
+ value: nested
76
+ };
77
+ continue;
78
+ }
79
+ if (!isCssProp) {
80
+ next[name] = prop;
81
+ continue;
82
+ }
83
+ needsRuntime ||= parser === "jsx";
84
+ if (prop.dynamic && !isFunctionProp(prop)) {
85
+ invalidProps.push(name);
86
+ continue;
87
+ }
88
+ if (prop.dynamic && isFunctionProp(prop)) {
89
+ next[name] = {
90
+ ...prop,
91
+ value: null,
92
+ selectorValue: null
93
+ };
94
+ continue;
95
+ }
96
+ const normalizedValue = Array.isArray(prop.value) ? normalizeArrayValue(prop.value) : prop.value;
97
+ next[name] = {
98
+ ...prop,
99
+ value: normalizedValue,
100
+ selectorValue: prop.selectorValue ?? normalizedValue
101
+ };
102
+ }
103
+ return next;
104
+ };
105
+ const pruned = pruneTree(tree);
106
+ Object.keys(tree).forEach((key) => delete tree[key]);
107
+ Object.assign(tree, pruned);
108
+ if (invalidProps.length) {
109
+ const location = describeLocation(file, code);
110
+ for (const name of invalidProps) console.warn(`[boss-css] classname-first skipped dynamic prop "${name}". Use ${name}={() => value}.${location}`);
111
+ }
112
+ for (const [name, prop] of Object.entries(tree)) {
113
+ const resolved = resolveDescriptor(api, name);
114
+ if (!resolved.descriptor) continue;
115
+ if (resolved.suffix) {
116
+ prop.named = resolved.suffix;
117
+ prop.rawName = resolved.raw;
118
+ }
119
+ const { aliases } = resolved.descriptor;
120
+ await api.trigger("onProp", {
121
+ name: resolved.name,
122
+ prop,
123
+ contexts: [],
124
+ file
125
+ }, ({ dependencies }) => {
126
+ return !dependencies || aliases.some((alias) => dependencies.has(alias));
127
+ });
128
+ }
129
+ };
130
+ const name = "classname-first";
131
+
132
+ //#endregion
133
+ export { server_exports, settings };
@@ -0,0 +1,43 @@
1
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
+
3
+ //#region src/strategy/classname-only/server.ts
4
+ var server_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
5
+ name: () => name,
6
+ onBoot: () => onBoot,
7
+ onPropTree: () => onPropTree
8
+ });
9
+ const onBoot = async (api) => {
10
+ api.strategy = name;
11
+ };
12
+ const onPropTree = async (api, { tree, file }) => {
13
+ if (api.runtime?.only === true) return;
14
+ for (const [name, prop] of Object.entries(tree)) {
15
+ const resolved = api.dictionary.resolve(name);
16
+ if (!resolved.descriptor) continue;
17
+ if (resolved.suffix) {
18
+ prop.named = resolved.suffix;
19
+ prop.rawName = resolved.raw;
20
+ }
21
+ const { aliases } = resolved.descriptor;
22
+ await api.trigger("onProp", {
23
+ name: resolved.name,
24
+ prop,
25
+ contexts: [],
26
+ file
27
+ }, ({ dependencies }) => {
28
+ return !dependencies || aliases.some((alias) => dependencies.has(alias));
29
+ });
30
+ }
31
+ };
32
+ const name = "classname-only";
33
+
34
+ //#endregion
35
+ exports.name = name;
36
+ exports.onBoot = onBoot;
37
+ exports.onPropTree = onPropTree;
38
+ Object.defineProperty(exports, 'server_exports', {
39
+ enumerable: true,
40
+ get: function () {
41
+ return server_exports;
42
+ }
43
+ });
@@ -0,0 +1,35 @@
1
+ import { __exportAll } from "../../_virtual/rolldown_runtime.mjs";
2
+
3
+ //#region src/strategy/classname-only/server.ts
4
+ var server_exports = /* @__PURE__ */ __exportAll({
5
+ name: () => name,
6
+ onBoot: () => onBoot,
7
+ onPropTree: () => onPropTree
8
+ });
9
+ const onBoot = async (api) => {
10
+ api.strategy = name;
11
+ };
12
+ const onPropTree = async (api, { tree, file }) => {
13
+ if (api.runtime?.only === true) return;
14
+ for (const [name, prop] of Object.entries(tree)) {
15
+ const resolved = api.dictionary.resolve(name);
16
+ if (!resolved.descriptor) continue;
17
+ if (resolved.suffix) {
18
+ prop.named = resolved.suffix;
19
+ prop.rawName = resolved.raw;
20
+ }
21
+ const { aliases } = resolved.descriptor;
22
+ await api.trigger("onProp", {
23
+ name: resolved.name,
24
+ prop,
25
+ contexts: [],
26
+ file
27
+ }, ({ dependencies }) => {
28
+ return !dependencies || aliases.some((alias) => dependencies.has(alias));
29
+ });
30
+ }
31
+ };
32
+ const name = "classname-only";
33
+
34
+ //#endregion
35
+ export { name, onBoot, onPropTree, server_exports };
@@ -0,0 +1,61 @@
1
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
+ const require_framework = require('../../shared/framework.cjs');
3
+ const require_cx_index = require('../../cx/index.cjs');
4
+ let _boss_css_is_css_prop = require("@boss-css/is-css-prop");
5
+ _boss_css_is_css_prop = require_rolldown_runtime.__toESM(_boss_css_is_css_prop);
6
+
7
+ //#region src/strategy/inline-first/browser.ts
8
+ const name = "inline-first";
9
+ const onBrowserObjectStart = (api, { input, output = {}, tag, contexts = [] }) => {
10
+ const classNameProp = require_framework.getClassNameProp(api.framework);
11
+ const outputRecord = output;
12
+ outputRecord.style ??= {};
13
+ const inputRecord = input;
14
+ for (const prop in inputRecord) {
15
+ const value = inputRecord[prop];
16
+ const resolved = api.dictionary.resolve(prop);
17
+ const descriptor = resolved.descriptor;
18
+ const resolvedName = resolved.name;
19
+ if (prop === "child" && value && typeof value === "object" && !Array.isArray(value)) {
20
+ for (const [selector, childValue] of Object.entries(value)) {
21
+ const childContext = `[${selector.replace(/ /g, "_")}]`;
22
+ contexts.push(childContext);
23
+ api.trigger("onBrowserObjectStart", {
24
+ input: childValue,
25
+ output,
26
+ contexts
27
+ });
28
+ }
29
+ continue;
30
+ }
31
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) if (!descriptor || !descriptor.handler) {
32
+ contexts.push(prop);
33
+ api.trigger("onBrowserObjectStart", {
34
+ input: value,
35
+ output,
36
+ contexts
37
+ });
38
+ } else descriptor.handler({
39
+ value,
40
+ output: outputRecord,
41
+ contexts
42
+ });
43
+ else if (descriptor?.handler) descriptor.handler({
44
+ value,
45
+ output: outputRecord,
46
+ contexts
47
+ });
48
+ else if (!descriptor && !contexts.length && (0, _boss_css_is_css_prop.default)(tag, resolvedName)) outputRecord.style[resolvedName] = api.dictionary.toValue(value, resolvedName);
49
+ else {
50
+ const className = api.contextToClassName(resolvedName, null, contexts, false, api.selectorPrefix);
51
+ const cssVarName = api.contextToCSSVariable(resolvedName, null, contexts, api.selectorPrefix);
52
+ outputRecord.style[cssVarName] = api.dictionary.toValue(value, resolvedName);
53
+ outputRecord[classNameProp] = require_cx_index.cx(outputRecord[classNameProp], className);
54
+ }
55
+ }
56
+ contexts.pop();
57
+ };
58
+
59
+ //#endregion
60
+ exports.name = name;
61
+ exports.onBrowserObjectStart = onBrowserObjectStart;
@@ -0,0 +1,58 @@
1
+ import { getClassNameProp } from "../../shared/framework.mjs";
2
+ import { cx } from "../../cx/index.mjs";
3
+ import isCSSProp from "@boss-css/is-css-prop";
4
+
5
+ //#region src/strategy/inline-first/browser.ts
6
+ const name = "inline-first";
7
+ const onBrowserObjectStart = (api, { input, output = {}, tag, contexts = [] }) => {
8
+ const classNameProp = getClassNameProp(api.framework);
9
+ const outputRecord = output;
10
+ outputRecord.style ??= {};
11
+ const inputRecord = input;
12
+ for (const prop in inputRecord) {
13
+ const value = inputRecord[prop];
14
+ const resolved = api.dictionary.resolve(prop);
15
+ const descriptor = resolved.descriptor;
16
+ const resolvedName = resolved.name;
17
+ if (prop === "child" && value && typeof value === "object" && !Array.isArray(value)) {
18
+ for (const [selector, childValue] of Object.entries(value)) {
19
+ const childContext = `[${selector.replace(/ /g, "_")}]`;
20
+ contexts.push(childContext);
21
+ api.trigger("onBrowserObjectStart", {
22
+ input: childValue,
23
+ output,
24
+ contexts
25
+ });
26
+ }
27
+ continue;
28
+ }
29
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) if (!descriptor || !descriptor.handler) {
30
+ contexts.push(prop);
31
+ api.trigger("onBrowserObjectStart", {
32
+ input: value,
33
+ output,
34
+ contexts
35
+ });
36
+ } else descriptor.handler({
37
+ value,
38
+ output: outputRecord,
39
+ contexts
40
+ });
41
+ else if (descriptor?.handler) descriptor.handler({
42
+ value,
43
+ output: outputRecord,
44
+ contexts
45
+ });
46
+ else if (!descriptor && !contexts.length && isCSSProp(tag, resolvedName)) outputRecord.style[resolvedName] = api.dictionary.toValue(value, resolvedName);
47
+ else {
48
+ const className = api.contextToClassName(resolvedName, null, contexts, false, api.selectorPrefix);
49
+ const cssVarName = api.contextToCSSVariable(resolvedName, null, contexts, api.selectorPrefix);
50
+ outputRecord.style[cssVarName] = api.dictionary.toValue(value, resolvedName);
51
+ outputRecord[classNameProp] = cx(outputRecord[classNameProp], className);
52
+ }
53
+ }
54
+ contexts.pop();
55
+ };
56
+
57
+ //#endregion
58
+ export { name, onBrowserObjectStart };