boss-css 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,164 @@
1
+ import { createRequire } from "node:module";
2
+ import fs from "node:fs/promises";
3
+ import path from "node:path";
4
+ import fg from "fast-glob";
5
+
6
+ //#region src/native/styleTypes.ts
7
+ const interfaceNames = new Set([
8
+ "ViewStyle",
9
+ "TextStyle",
10
+ "ImageStyle"
11
+ ]);
12
+ const normalizeType = (value) => value.replace(/\s+/g, " ").replace(/;$/, "").trim();
13
+ const parseInterfaces = (source) => {
14
+ const interfaces = /* @__PURE__ */ new Map();
15
+ const lines = source.split("\n");
16
+ let current = null;
17
+ let comment = [];
18
+ let pendingProp = null;
19
+ const interfaceRegexp = /^\s*(?:export\s+)?interface\s+([A-Za-z0-9_]+)(?:\s+extends\s+([^ {]+(?:\s*,\s*[^ {]+)*))?\s*\{/;
20
+ const propRegexp = /^\s+(?:readonly\s+)?["']?([A-Za-z0-9_]+)["']?\??:\s*(.+)$/;
21
+ for (const line of lines) {
22
+ const interfaceMatch = line.match(interfaceRegexp);
23
+ if (interfaceMatch) {
24
+ const [, name, extendsRaw] = interfaceMatch;
25
+ const entry = {
26
+ name,
27
+ extends: extendsRaw ? extendsRaw.split(",").map((value) => value.trim()) : [],
28
+ props: /* @__PURE__ */ new Map()
29
+ };
30
+ interfaces.set(name, entry);
31
+ current = entry;
32
+ comment = [];
33
+ pendingProp = null;
34
+ continue;
35
+ }
36
+ if (current && line.trim() === "}") {
37
+ current = null;
38
+ comment = [];
39
+ pendingProp = null;
40
+ continue;
41
+ }
42
+ if (!current) continue;
43
+ if (line.trim().startsWith("/**")) {
44
+ const trimmed = line.trim().replace(/^\/\*\* ?/, "");
45
+ if (trimmed.includes("*/")) comment = [trimmed.replace(/\*\/$/, "").trim()];
46
+ else comment = [trimmed];
47
+ continue;
48
+ }
49
+ if (comment.length && line.trim().startsWith("*")) {
50
+ const trimmed = line.trim().replace(/^\* ?/, "");
51
+ if (!trimmed.endsWith("*/")) {
52
+ comment.push(trimmed);
53
+ continue;
54
+ }
55
+ comment.push(trimmed.replace(/\*\/$/, "").trim());
56
+ continue;
57
+ }
58
+ if (pendingProp) {
59
+ pendingProp.type += ` ${line.trim()}`;
60
+ if (line.includes(";")) {
61
+ const propType = normalizeType(pendingProp.type);
62
+ current.props.set(pendingProp.name, {
63
+ name: pendingProp.name,
64
+ type: propType,
65
+ description: comment.join("\n").trim() || void 0
66
+ });
67
+ pendingProp = null;
68
+ comment = [];
69
+ }
70
+ continue;
71
+ }
72
+ const propMatch = line.match(propRegexp);
73
+ if (!propMatch) continue;
74
+ const [, rawName, typeRaw] = propMatch;
75
+ if (rawName.startsWith("[")) continue;
76
+ const typeValue = typeRaw.trim();
77
+ if (!line.includes(";")) {
78
+ pendingProp = {
79
+ name: rawName,
80
+ type: typeValue
81
+ };
82
+ continue;
83
+ }
84
+ current.props.set(rawName, {
85
+ name: rawName,
86
+ type: normalizeType(typeValue),
87
+ description: comment.join("\n").trim() || void 0
88
+ });
89
+ comment = [];
90
+ }
91
+ return interfaces;
92
+ };
93
+ const mergeProps = (target, source) => {
94
+ for (const [name, prop] of source.entries()) {
95
+ const existing = target.get(name);
96
+ if (!existing) {
97
+ target.set(name, { ...prop });
98
+ continue;
99
+ }
100
+ if (existing.type !== prop.type) {
101
+ const types = new Set([existing.type, prop.type]);
102
+ existing.type = Array.from(types).join(" | ");
103
+ }
104
+ if (!existing.description && prop.description) existing.description = prop.description;
105
+ }
106
+ };
107
+ const collectProps = (name, interfaces, visited = /* @__PURE__ */ new Set()) => {
108
+ if (visited.has(name)) return /* @__PURE__ */ new Map();
109
+ visited.add(name);
110
+ const entry = interfaces.get(name);
111
+ if (!entry) return /* @__PURE__ */ new Map();
112
+ const merged = /* @__PURE__ */ new Map();
113
+ for (const parent of entry.extends) mergeProps(merged, collectProps(parent, interfaces, visited));
114
+ mergeProps(merged, entry.props);
115
+ return merged;
116
+ };
117
+ const resolveReactNativeRoot = async () => {
118
+ const require = createRequire(process.cwd() + "/package.json");
119
+ let packageJsonPath;
120
+ try {
121
+ packageJsonPath = require.resolve("react-native/package.json");
122
+ } catch (error) {
123
+ throw new Error("native: react-native is not installed in this project.");
124
+ }
125
+ const packageJson = JSON.parse(await fs.readFile(packageJsonPath, "utf-8"));
126
+ return {
127
+ root: path.dirname(packageJsonPath),
128
+ typesEntry: packageJson.types || packageJson.typings
129
+ };
130
+ };
131
+ const findStyleSheetTypesFile = async (root, typesEntry) => {
132
+ const candidates = await fg(["**/StyleSheetTypes.d.ts", "**/StyleSheetTypes.ts"], {
133
+ cwd: root,
134
+ absolute: true,
135
+ suppressErrors: true
136
+ });
137
+ if (candidates.length) return candidates[0];
138
+ if (typesEntry) {
139
+ const entryPath = path.join(root, typesEntry);
140
+ if ((await fs.readFile(entryPath, "utf-8").catch(() => "")).includes("interface ViewStyle")) return entryPath;
141
+ }
142
+ const fallback = await fg(["**/*.d.ts"], {
143
+ cwd: root,
144
+ absolute: true,
145
+ suppressErrors: true
146
+ });
147
+ for (const file of fallback) if ((await fs.readFile(file, "utf-8").catch(() => "")).includes("interface ViewStyle")) return file;
148
+ return null;
149
+ };
150
+ const loadReactNativeStyleProps = async () => {
151
+ const { root, typesEntry } = await resolveReactNativeRoot();
152
+ const typesFile = await findStyleSheetTypesFile(root, typesEntry);
153
+ if (!typesFile) throw new Error("native: unable to locate React Native style type definitions.");
154
+ const interfaces = parseInterfaces(await fs.readFile(typesFile, "utf-8"));
155
+ const merged = /* @__PURE__ */ new Map();
156
+ for (const name of interfaceNames) mergeProps(merged, collectProps(name, interfaces));
157
+ return {
158
+ props: merged,
159
+ sourcePath: typesFile
160
+ };
161
+ };
162
+
163
+ //#endregion
164
+ export { loadReactNativeStyleProps };
@@ -0,0 +1,239 @@
1
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
+
3
+ //#region src/parser/classname/server.ts
4
+ var server_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
5
+ name: () => name,
6
+ onParse: () => onParse
7
+ });
8
+ const name = "classname";
9
+ const onParse = async (api, input) => {
10
+ if (api.runtime?.only) return;
11
+ const log = api.log.child("parser").child("classname");
12
+ const { content } = input;
13
+ const { codes: extractedCodes } = extractCode(content);
14
+ const results = await Promise.all(extractedCodes.map((v) => extractPropTree(v, api)));
15
+ for (const [key, tree] of Object.entries(results)) {
16
+ if (!Object.keys(tree).length) continue;
17
+ log.log("onPropTree", tree);
18
+ await api.trigger("onPropTree", {
19
+ input: api.propTreeToObject(tree),
20
+ tree,
21
+ preferVariables: false,
22
+ file: input,
23
+ code: extractedCodes[key],
24
+ parser: "classname"
25
+ });
26
+ }
27
+ };
28
+ const templateRegexp = /`([\S\s]+?)`/g;
29
+ const quoteRegexps = [
30
+ /"(.+?)"/g,
31
+ /'(.+?)'/g,
32
+ templateRegexp
33
+ ];
34
+ const extractCode = (content) => {
35
+ const results = [];
36
+ for (const regexp of quoteRegexps) {
37
+ const matches = content.matchAll(regexp);
38
+ const isTemplate = regexp === templateRegexp;
39
+ for (const match of matches) {
40
+ const [, code] = match;
41
+ if (isTemplate && code.includes("${")) {
42
+ console.warn("[boss-css] classname parser skipped template literals with expressions. Classnames must be static.");
43
+ console.warn(code);
44
+ continue;
45
+ }
46
+ results.push(code);
47
+ }
48
+ }
49
+ return { codes: results };
50
+ };
51
+ const extractPropTree = async (string, api) => {
52
+ const tree = {};
53
+ const selectorTokens = /* @__PURE__ */ new Map();
54
+ const selectors = splitSelectors(string.replace(/[\n\r]/g, " "));
55
+ const resolveDescriptor = (fragment) => {
56
+ if (getChildSelector(fragment)) return api.dictionary.resolve("child");
57
+ return api.dictionary.resolve(fragment);
58
+ };
59
+ selectors.forEach((selector) => {
60
+ const grouped = parseGroupedSelector(selector);
61
+ if (grouped) {
62
+ const rawFragments$1 = splitFragments(grouped.prefix);
63
+ if (!resolveDescriptor(stripImportantSuffix(rawFragments$1[0])).descriptor || rawFragments$1.length === 0) return;
64
+ const fragments = expandFragments(rawFragments$1);
65
+ grouped.entries.forEach(({ name, rawValue }) => {
66
+ if (!resolveDescriptor(name).descriptor?.isCSSProp) return;
67
+ const { value: value$1, important: important$1 } = parseImportantValue(rawValue);
68
+ const prop = { value: value$1 };
69
+ if (important$1) prop.important = true;
70
+ const path$1 = [...fragments, name];
71
+ const key = pathKey(path$1);
72
+ createPropPath([...path$1], prop, tree);
73
+ selectorTokens.set(key, selector);
74
+ });
75
+ return;
76
+ }
77
+ const rawFragments = splitFragments(selector);
78
+ let value = null;
79
+ let important = false;
80
+ const path = [];
81
+ const descriptor = resolveDescriptor(rawFragments.length === 1 ? stripImportantSuffix(rawFragments[0]) : rawFragments[0]).descriptor;
82
+ if (!descriptor || rawFragments.length === 1 && !descriptor.single) return;
83
+ for (const [index, fragment] of Object.entries(rawFragments)) {
84
+ const isLast = rawFragments.length === +index + 1;
85
+ if (path.length && isLast) {
86
+ const parsed = parseImportantValue(fragment);
87
+ value = parsed.value;
88
+ important = parsed.important;
89
+ } else {
90
+ const cleanedFragment = stripImportantSuffix(fragment);
91
+ if (isLast && rawFragments.length === 1 && cleanedFragment !== fragment) important = true;
92
+ const childSelector = getChildSelector(cleanedFragment);
93
+ if (childSelector) path.push("child", childSelector);
94
+ else path.push(cleanedFragment);
95
+ }
96
+ }
97
+ if (path.length) {
98
+ const lastProp = path.at(-1);
99
+ if (!(lastProp ? resolveDescriptor(lastProp).descriptor : null)?.isCSSProp) return;
100
+ const key = pathKey(path);
101
+ const prop = { value };
102
+ if (important) {
103
+ prop.important = true;
104
+ prop.classToken = selector;
105
+ }
106
+ createPropPath([...path], prop, tree);
107
+ selectorTokens.delete(key);
108
+ }
109
+ });
110
+ applySelectorTokens(tree, selectorTokens);
111
+ return tree;
112
+ };
113
+ const splitSelectors = (string) => splitOutside(string, " ");
114
+ const splitFragments = (selector) => splitOutside(selector, ":");
115
+ const splitGroupedEntries = (body) => splitOutside(body, ";");
116
+ const splitGroupedEntry = (entry) => splitOnceOutside(entry, ":");
117
+ const parseGroupedSelector = (selector) => {
118
+ if (!selector.endsWith("}")) return null;
119
+ const groupStart = findGroupStart(selector);
120
+ if (groupStart === -1) return null;
121
+ const prefix = selector.slice(0, groupStart);
122
+ const entries = splitGroupedEntries(selector.slice(groupStart + 2, -1)).map((entry) => entry.trim()).filter(Boolean).map((entry) => {
123
+ const parts = splitGroupedEntry(entry);
124
+ if (!parts) return null;
125
+ const [name, rawValue] = parts;
126
+ return {
127
+ name: name.trim(),
128
+ rawValue: rawValue.trim()
129
+ };
130
+ }).filter((entry) => Boolean(entry));
131
+ if (!entries.length) return null;
132
+ return {
133
+ prefix,
134
+ entries
135
+ };
136
+ };
137
+ const splitOutside = (input, delimiter) => {
138
+ const results = [];
139
+ let current = "";
140
+ let braceDepth = 0;
141
+ let bracketDepth = 0;
142
+ for (const char of input) {
143
+ if (char === "{") braceDepth += 1;
144
+ if (char === "}") braceDepth = Math.max(0, braceDepth - 1);
145
+ if (char === "[") bracketDepth += 1;
146
+ if (char === "]") bracketDepth = Math.max(0, bracketDepth - 1);
147
+ if (char === delimiter && braceDepth === 0 && bracketDepth === 0) {
148
+ if (current) results.push(current);
149
+ current = "";
150
+ continue;
151
+ }
152
+ current += char;
153
+ }
154
+ if (current) results.push(current);
155
+ return results;
156
+ };
157
+ const splitOnceOutside = (input, delimiter) => {
158
+ let braceDepth = 0;
159
+ let bracketDepth = 0;
160
+ for (let i = 0; i < input.length; i += 1) {
161
+ const char = input[i];
162
+ if (char === "{") braceDepth += 1;
163
+ if (char === "}") braceDepth = Math.max(0, braceDepth - 1);
164
+ if (char === "[") bracketDepth += 1;
165
+ if (char === "]") bracketDepth = Math.max(0, bracketDepth - 1);
166
+ if (char === delimiter && braceDepth === 0 && bracketDepth === 0) return [input.slice(0, i), input.slice(i + 1)];
167
+ }
168
+ return null;
169
+ };
170
+ const findGroupStart = (selector) => {
171
+ let bracketDepth = 0;
172
+ for (let i = 0; i < selector.length - 1; i += 1) {
173
+ const char = selector[i];
174
+ if (char === "[") bracketDepth += 1;
175
+ if (char === "]") bracketDepth = Math.max(0, bracketDepth - 1);
176
+ if (bracketDepth === 0 && selector[i] === ":" && selector[i + 1] === "{") return i;
177
+ }
178
+ return -1;
179
+ };
180
+ const getChildSelector = (fragment) => {
181
+ if (!fragment || !fragment.startsWith("[") || !fragment.endsWith("]")) return null;
182
+ return fragment.slice(1, -1);
183
+ };
184
+ const expandFragments = (fragments) => {
185
+ const path = [];
186
+ for (const fragment of fragments) {
187
+ const childSelector = getChildSelector(fragment);
188
+ if (childSelector) path.push("child", childSelector);
189
+ else path.push(fragment);
190
+ }
191
+ return path;
192
+ };
193
+ const parseValue = (rawValue) => {
194
+ return rawValue.includes("_") ? rawValue.split("_") : rawValue;
195
+ };
196
+ const parseImportantValue = (rawValue) => {
197
+ if (!rawValue) return {
198
+ value: rawValue,
199
+ important: false
200
+ };
201
+ const important = rawValue.endsWith("!");
202
+ return {
203
+ value: parseValue(important ? rawValue.slice(0, -1) : rawValue),
204
+ important
205
+ };
206
+ };
207
+ const stripImportantSuffix = (fragment) => {
208
+ return fragment && fragment.endsWith("!") ? fragment.slice(0, -1) : fragment;
209
+ };
210
+ const pathKey = (path) => path.join(">");
211
+ const createPropPath = (path, prop, obj) => {
212
+ const last = path.pop();
213
+ if (!last) return;
214
+ for (const key of path) {
215
+ obj[key] = obj[key] || { value: {} };
216
+ const next = obj[key].value;
217
+ if (!next || typeof next !== "object" || Array.isArray(next)) return;
218
+ obj = next;
219
+ }
220
+ typeof obj === "object" && (obj[last] = prop);
221
+ };
222
+ const applySelectorTokens = (tree, selectorTokens, path = []) => {
223
+ Object.entries(tree).forEach(([name, prop]) => {
224
+ const nextPath = [...path, name];
225
+ const token = selectorTokens.get(pathKey(nextPath));
226
+ if (token) prop.classToken = token;
227
+ if (prop.value && typeof prop.value === "object" && !Array.isArray(prop.value)) applySelectorTokens(prop.value, selectorTokens, nextPath);
228
+ });
229
+ };
230
+
231
+ //#endregion
232
+ exports.name = name;
233
+ exports.onParse = onParse;
234
+ Object.defineProperty(exports, 'server_exports', {
235
+ enumerable: true,
236
+ get: function () {
237
+ return server_exports;
238
+ }
239
+ });
@@ -0,0 +1,232 @@
1
+ import { __exportAll } from "../../_virtual/rolldown_runtime.mjs";
2
+
3
+ //#region src/parser/classname/server.ts
4
+ var server_exports = /* @__PURE__ */ __exportAll({
5
+ name: () => name,
6
+ onParse: () => onParse
7
+ });
8
+ const name = "classname";
9
+ const onParse = async (api, input) => {
10
+ if (api.runtime?.only) return;
11
+ const log = api.log.child("parser").child("classname");
12
+ const { content } = input;
13
+ const { codes: extractedCodes } = extractCode(content);
14
+ const results = await Promise.all(extractedCodes.map((v) => extractPropTree(v, api)));
15
+ for (const [key, tree] of Object.entries(results)) {
16
+ if (!Object.keys(tree).length) continue;
17
+ log.log("onPropTree", tree);
18
+ await api.trigger("onPropTree", {
19
+ input: api.propTreeToObject(tree),
20
+ tree,
21
+ preferVariables: false,
22
+ file: input,
23
+ code: extractedCodes[key],
24
+ parser: "classname"
25
+ });
26
+ }
27
+ };
28
+ const templateRegexp = /`([\S\s]+?)`/g;
29
+ const quoteRegexps = [
30
+ /"(.+?)"/g,
31
+ /'(.+?)'/g,
32
+ templateRegexp
33
+ ];
34
+ const extractCode = (content) => {
35
+ const results = [];
36
+ for (const regexp of quoteRegexps) {
37
+ const matches = content.matchAll(regexp);
38
+ const isTemplate = regexp === templateRegexp;
39
+ for (const match of matches) {
40
+ const [, code] = match;
41
+ if (isTemplate && code.includes("${")) {
42
+ console.warn("[boss-css] classname parser skipped template literals with expressions. Classnames must be static.");
43
+ console.warn(code);
44
+ continue;
45
+ }
46
+ results.push(code);
47
+ }
48
+ }
49
+ return { codes: results };
50
+ };
51
+ const extractPropTree = async (string, api) => {
52
+ const tree = {};
53
+ const selectorTokens = /* @__PURE__ */ new Map();
54
+ const selectors = splitSelectors(string.replace(/[\n\r]/g, " "));
55
+ const resolveDescriptor = (fragment) => {
56
+ if (getChildSelector(fragment)) return api.dictionary.resolve("child");
57
+ return api.dictionary.resolve(fragment);
58
+ };
59
+ selectors.forEach((selector) => {
60
+ const grouped = parseGroupedSelector(selector);
61
+ if (grouped) {
62
+ const rawFragments$1 = splitFragments(grouped.prefix);
63
+ if (!resolveDescriptor(stripImportantSuffix(rawFragments$1[0])).descriptor || rawFragments$1.length === 0) return;
64
+ const fragments = expandFragments(rawFragments$1);
65
+ grouped.entries.forEach(({ name, rawValue }) => {
66
+ if (!resolveDescriptor(name).descriptor?.isCSSProp) return;
67
+ const { value: value$1, important: important$1 } = parseImportantValue(rawValue);
68
+ const prop = { value: value$1 };
69
+ if (important$1) prop.important = true;
70
+ const path$1 = [...fragments, name];
71
+ const key = pathKey(path$1);
72
+ createPropPath([...path$1], prop, tree);
73
+ selectorTokens.set(key, selector);
74
+ });
75
+ return;
76
+ }
77
+ const rawFragments = splitFragments(selector);
78
+ let value = null;
79
+ let important = false;
80
+ const path = [];
81
+ const descriptor = resolveDescriptor(rawFragments.length === 1 ? stripImportantSuffix(rawFragments[0]) : rawFragments[0]).descriptor;
82
+ if (!descriptor || rawFragments.length === 1 && !descriptor.single) return;
83
+ for (const [index, fragment] of Object.entries(rawFragments)) {
84
+ const isLast = rawFragments.length === +index + 1;
85
+ if (path.length && isLast) {
86
+ const parsed = parseImportantValue(fragment);
87
+ value = parsed.value;
88
+ important = parsed.important;
89
+ } else {
90
+ const cleanedFragment = stripImportantSuffix(fragment);
91
+ if (isLast && rawFragments.length === 1 && cleanedFragment !== fragment) important = true;
92
+ const childSelector = getChildSelector(cleanedFragment);
93
+ if (childSelector) path.push("child", childSelector);
94
+ else path.push(cleanedFragment);
95
+ }
96
+ }
97
+ if (path.length) {
98
+ const lastProp = path.at(-1);
99
+ if (!(lastProp ? resolveDescriptor(lastProp).descriptor : null)?.isCSSProp) return;
100
+ const key = pathKey(path);
101
+ const prop = { value };
102
+ if (important) {
103
+ prop.important = true;
104
+ prop.classToken = selector;
105
+ }
106
+ createPropPath([...path], prop, tree);
107
+ selectorTokens.delete(key);
108
+ }
109
+ });
110
+ applySelectorTokens(tree, selectorTokens);
111
+ return tree;
112
+ };
113
+ const splitSelectors = (string) => splitOutside(string, " ");
114
+ const splitFragments = (selector) => splitOutside(selector, ":");
115
+ const splitGroupedEntries = (body) => splitOutside(body, ";");
116
+ const splitGroupedEntry = (entry) => splitOnceOutside(entry, ":");
117
+ const parseGroupedSelector = (selector) => {
118
+ if (!selector.endsWith("}")) return null;
119
+ const groupStart = findGroupStart(selector);
120
+ if (groupStart === -1) return null;
121
+ const prefix = selector.slice(0, groupStart);
122
+ const entries = splitGroupedEntries(selector.slice(groupStart + 2, -1)).map((entry) => entry.trim()).filter(Boolean).map((entry) => {
123
+ const parts = splitGroupedEntry(entry);
124
+ if (!parts) return null;
125
+ const [name, rawValue] = parts;
126
+ return {
127
+ name: name.trim(),
128
+ rawValue: rawValue.trim()
129
+ };
130
+ }).filter((entry) => Boolean(entry));
131
+ if (!entries.length) return null;
132
+ return {
133
+ prefix,
134
+ entries
135
+ };
136
+ };
137
+ const splitOutside = (input, delimiter) => {
138
+ const results = [];
139
+ let current = "";
140
+ let braceDepth = 0;
141
+ let bracketDepth = 0;
142
+ for (const char of input) {
143
+ if (char === "{") braceDepth += 1;
144
+ if (char === "}") braceDepth = Math.max(0, braceDepth - 1);
145
+ if (char === "[") bracketDepth += 1;
146
+ if (char === "]") bracketDepth = Math.max(0, bracketDepth - 1);
147
+ if (char === delimiter && braceDepth === 0 && bracketDepth === 0) {
148
+ if (current) results.push(current);
149
+ current = "";
150
+ continue;
151
+ }
152
+ current += char;
153
+ }
154
+ if (current) results.push(current);
155
+ return results;
156
+ };
157
+ const splitOnceOutside = (input, delimiter) => {
158
+ let braceDepth = 0;
159
+ let bracketDepth = 0;
160
+ for (let i = 0; i < input.length; i += 1) {
161
+ const char = input[i];
162
+ if (char === "{") braceDepth += 1;
163
+ if (char === "}") braceDepth = Math.max(0, braceDepth - 1);
164
+ if (char === "[") bracketDepth += 1;
165
+ if (char === "]") bracketDepth = Math.max(0, bracketDepth - 1);
166
+ if (char === delimiter && braceDepth === 0 && bracketDepth === 0) return [input.slice(0, i), input.slice(i + 1)];
167
+ }
168
+ return null;
169
+ };
170
+ const findGroupStart = (selector) => {
171
+ let bracketDepth = 0;
172
+ for (let i = 0; i < selector.length - 1; i += 1) {
173
+ const char = selector[i];
174
+ if (char === "[") bracketDepth += 1;
175
+ if (char === "]") bracketDepth = Math.max(0, bracketDepth - 1);
176
+ if (bracketDepth === 0 && selector[i] === ":" && selector[i + 1] === "{") return i;
177
+ }
178
+ return -1;
179
+ };
180
+ const getChildSelector = (fragment) => {
181
+ if (!fragment || !fragment.startsWith("[") || !fragment.endsWith("]")) return null;
182
+ return fragment.slice(1, -1);
183
+ };
184
+ const expandFragments = (fragments) => {
185
+ const path = [];
186
+ for (const fragment of fragments) {
187
+ const childSelector = getChildSelector(fragment);
188
+ if (childSelector) path.push("child", childSelector);
189
+ else path.push(fragment);
190
+ }
191
+ return path;
192
+ };
193
+ const parseValue = (rawValue) => {
194
+ return rawValue.includes("_") ? rawValue.split("_") : rawValue;
195
+ };
196
+ const parseImportantValue = (rawValue) => {
197
+ if (!rawValue) return {
198
+ value: rawValue,
199
+ important: false
200
+ };
201
+ const important = rawValue.endsWith("!");
202
+ return {
203
+ value: parseValue(important ? rawValue.slice(0, -1) : rawValue),
204
+ important
205
+ };
206
+ };
207
+ const stripImportantSuffix = (fragment) => {
208
+ return fragment && fragment.endsWith("!") ? fragment.slice(0, -1) : fragment;
209
+ };
210
+ const pathKey = (path) => path.join(">");
211
+ const createPropPath = (path, prop, obj) => {
212
+ const last = path.pop();
213
+ if (!last) return;
214
+ for (const key of path) {
215
+ obj[key] = obj[key] || { value: {} };
216
+ const next = obj[key].value;
217
+ if (!next || typeof next !== "object" || Array.isArray(next)) return;
218
+ obj = next;
219
+ }
220
+ typeof obj === "object" && (obj[last] = prop);
221
+ };
222
+ const applySelectorTokens = (tree, selectorTokens, path = []) => {
223
+ Object.entries(tree).forEach(([name, prop]) => {
224
+ const nextPath = [...path, name];
225
+ const token = selectorTokens.get(pathKey(nextPath));
226
+ if (token) prop.classToken = token;
227
+ if (prop.value && typeof prop.value === "object" && !Array.isArray(prop.value)) applySelectorTokens(prop.value, selectorTokens, nextPath);
228
+ });
229
+ };
230
+
231
+ //#endregion
232
+ export { name, onParse, server_exports };
@@ -0,0 +1,66 @@
1
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
+ const require_framework = require('../../shared/framework.cjs');
3
+ const require_isDOMProp = require('./isDOMProp.cjs');
4
+ const require_cx_index = require('../../cx/index.cjs');
5
+ let _boss_css_is_css_prop = require("@boss-css/is-css-prop");
6
+ _boss_css_is_css_prop = require_rolldown_runtime.__toESM(_boss_css_is_css_prop);
7
+
8
+ //#region src/parser/jsx/browser.ts
9
+ const ignoredProps = new Set([
10
+ "ref",
11
+ "children",
12
+ "dangerouslySetInnerHtml",
13
+ "key"
14
+ ]);
15
+ const name = "jsx";
16
+ const onBrowserObjectStart = (api, { input, tag = "div", contexts = [], output = {} }) => {
17
+ const log = api.log.child("runtime").child("jsx");
18
+ log.log("browserObject:start", input, output, contexts);
19
+ if (contexts.length) return;
20
+ const isClassnameFirst = api.strategy === "classname-first";
21
+ const classNameProp = require_framework.getClassNameProp(api.framework);
22
+ let tokenOverrides = null;
23
+ for (const prop in input) {
24
+ if (prop === "tokens") {
25
+ tokenOverrides = input[prop];
26
+ delete input[prop];
27
+ continue;
28
+ }
29
+ if (prop === classNameProp) {
30
+ output[classNameProp] = require_cx_index.cx(output[classNameProp], input[prop]);
31
+ delete input[prop];
32
+ continue;
33
+ }
34
+ if (prop === "style") {
35
+ const styleValue = input[prop];
36
+ if (styleValue && typeof styleValue === "object" && !Array.isArray(styleValue)) output.style = {
37
+ ...output.style ?? {},
38
+ ...styleValue
39
+ };
40
+ else if (styleValue !== void 0) output.style = styleValue;
41
+ delete input[prop];
42
+ continue;
43
+ }
44
+ if (ignoredProps.has(prop) || require_isDOMProp.default(tag, prop)) {
45
+ output[prop] = input[prop];
46
+ delete input[prop];
47
+ continue;
48
+ }
49
+ if (typeof input[prop] === "function") {
50
+ if (isClassnameFirst && (0, _boss_css_is_css_prop.default)(tag, prop)) continue;
51
+ input[prop] = input[prop]();
52
+ }
53
+ }
54
+ if (tokenOverrides && typeof api.tokenVars === "function") {
55
+ const resolved = typeof tokenOverrides === "function" ? tokenOverrides() : tokenOverrides;
56
+ if (resolved && typeof resolved === "object") output.style = {
57
+ ...output.style ?? {},
58
+ ...api.tokenVars(resolved)
59
+ };
60
+ }
61
+ log.log("browserObject:end", input, output);
62
+ };
63
+
64
+ //#endregion
65
+ exports.name = name;
66
+ exports.onBrowserObjectStart = onBrowserObjectStart;