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,183 @@
1
+
2
+ //#region src/strategy/runtime-only/css.ts
3
+ let baseStyleElement = null;
4
+ let baseSheet = null;
5
+ let atStyleElement = null;
6
+ let atSheet = null;
7
+ let atRuleIndex = 0;
8
+ const atRules = [];
9
+ const inserted = /* @__PURE__ */ new Set();
10
+ const canUseDom = () => typeof document !== "undefined" && typeof document.createElement === "function";
11
+ const ensureBaseSheet = () => {
12
+ if (baseSheet || !canUseDom()) return baseSheet;
13
+ baseStyleElement = document.querySelector("style[data-boss-runtime]");
14
+ if (!baseStyleElement) {
15
+ baseStyleElement = document.createElement("style");
16
+ baseStyleElement.setAttribute("data-boss-runtime", "");
17
+ document.head.appendChild(baseStyleElement);
18
+ }
19
+ baseSheet = baseStyleElement.sheet;
20
+ return baseSheet;
21
+ };
22
+ const ensureAtSheet = () => {
23
+ if (atSheet || !canUseDom()) return atSheet;
24
+ ensureBaseSheet();
25
+ atStyleElement = document.querySelector("style[data-boss-runtime-at]");
26
+ if (!atStyleElement) {
27
+ atStyleElement = document.createElement("style");
28
+ atStyleElement.setAttribute("data-boss-runtime-at", "");
29
+ const parent = baseStyleElement?.parentNode;
30
+ if (parent) parent.insertBefore(atStyleElement, baseStyleElement?.nextSibling ?? null);
31
+ else document.head.appendChild(atStyleElement);
32
+ }
33
+ atSheet = atStyleElement.sheet;
34
+ return atSheet;
35
+ };
36
+ const compareAtRuleOrder = (a, b) => {
37
+ if (a.group !== b.group) return a.group - b.group;
38
+ if (a.primary !== b.primary) return a.primary - b.primary;
39
+ if (a.secondary !== b.secondary) return a.secondary - b.secondary;
40
+ return a.index - b.index;
41
+ };
42
+ const getAtRuleOrder = (query, index) => {
43
+ const normalized = query.trim().toLowerCase();
44
+ if (!normalized.startsWith("@media")) return {
45
+ group: 4,
46
+ primary: 0,
47
+ secondary: 0,
48
+ index
49
+ };
50
+ const minMatch = normalized.match(/min-width\s*:\s*(\d+(?:\.\d+)?)px/);
51
+ const maxMatch = normalized.match(/max-width\s*:\s*(\d+(?:\.\d+)?)px/);
52
+ const min = minMatch ? Number(minMatch[1]) : null;
53
+ const max = maxMatch ? Number(maxMatch[1]) : null;
54
+ if (min !== null && max !== null) return {
55
+ group: 1,
56
+ primary: min,
57
+ secondary: max,
58
+ index
59
+ };
60
+ if (max !== null) return {
61
+ group: 0,
62
+ primary: -max,
63
+ secondary: 0,
64
+ index
65
+ };
66
+ if (min !== null) return {
67
+ group: 2,
68
+ primary: min,
69
+ secondary: 0,
70
+ index
71
+ };
72
+ return {
73
+ group: 3,
74
+ primary: 0,
75
+ secondary: 0,
76
+ index
77
+ };
78
+ };
79
+ const insertRule = (rule, key = rule, query = null) => {
80
+ if (inserted.has(key)) return;
81
+ inserted.add(key);
82
+ if (!query) {
83
+ const activeSheet$1 = ensureBaseSheet();
84
+ if (!activeSheet$1) return;
85
+ try {
86
+ activeSheet$1.insertRule(rule, activeSheet$1.cssRules.length);
87
+ } catch {
88
+ baseStyleElement?.appendChild(document.createTextNode(rule));
89
+ }
90
+ return;
91
+ }
92
+ const activeSheet = ensureAtSheet();
93
+ if (!activeSheet) return;
94
+ const order = getAtRuleOrder(query, atRuleIndex);
95
+ atRuleIndex += 1;
96
+ let insertIndex = atRules.length;
97
+ for (let i = 0; i < atRules.length; i += 1) if (compareAtRuleOrder(order, atRules[i].order) < 0) {
98
+ insertIndex = i;
99
+ break;
100
+ }
101
+ try {
102
+ activeSheet.insertRule(rule, insertIndex);
103
+ atRules.splice(insertIndex, 0, {
104
+ key,
105
+ order
106
+ });
107
+ } catch {
108
+ atStyleElement?.appendChild(document.createTextNode(rule));
109
+ atRules.push({
110
+ key,
111
+ order
112
+ });
113
+ }
114
+ };
115
+ var RuntimeCSS = class {
116
+ api;
117
+ current = null;
118
+ root = /* @__PURE__ */ new Set();
119
+ imports = /* @__PURE__ */ new Set();
120
+ constructor(api) {
121
+ this.api = api;
122
+ }
123
+ get text() {
124
+ return "";
125
+ }
126
+ addImport(_url) {}
127
+ addRoot(_value, _source) {}
128
+ removeSource(_source) {}
129
+ reset() {}
130
+ selector({ className, selector = null, pseudos = [], query = null }) {
131
+ if (!this.current) this.current = {
132
+ className: null,
133
+ selector: null,
134
+ pseudos: [],
135
+ values: /* @__PURE__ */ new Set(),
136
+ query: null
137
+ };
138
+ const current = this.current;
139
+ if (query && current.query && query !== current.query) throw new Error(`RuntimeCSS:selector Selector already has a query. Existing: ${current.query} Incoming: ${query}`);
140
+ const mergedPseudos = [];
141
+ for (const pseudo of [...current.pseudos, ...pseudos]) if (!mergedPseudos.includes(pseudo)) mergedPseudos.push(pseudo);
142
+ const next = {
143
+ pseudos: mergedPseudos,
144
+ query: query || current.query
145
+ };
146
+ if (selector) Object.assign(next, {
147
+ selector,
148
+ className: null
149
+ });
150
+ else if (className) Object.assign(next, { className });
151
+ Object.assign(current, next);
152
+ }
153
+ rule(property, value, options) {
154
+ if (!this.current) throw new Error("RuntimeCSS:rule No current selector");
155
+ const suffix = options?.important ? " !important" : "";
156
+ this.current.values.add(`${property}: ${this.api.dictionary.toValue(value, property)}${suffix}`);
157
+ }
158
+ addRule(rule, query = null, _source) {
159
+ const wrapped = query ? `${query} { ${rule} }` : rule;
160
+ insertRule(wrapped, wrapped, query);
161
+ }
162
+ write() {
163
+ if (!this.current) throw new Error("RuntimeCSS:write No current selector");
164
+ const current = this.current;
165
+ const baseSelector = current.selector || (current.className ? `.${current.className}` : null);
166
+ if (!baseSelector) throw new Error("RuntimeCSS:write No className or selector");
167
+ const selector = [baseSelector, ...current.pseudos].join(":");
168
+ const selectorScope = typeof this.api.selectorScope === "string" ? this.api.selectorScope : "";
169
+ const scopedSelector = selectorScope ? `${selectorScope}${selector}` : selector;
170
+ let rule = `${scopedSelector} { ${[...current.values].join(";")} }`;
171
+ if (current.query) rule = `${current.query} { ${rule} }`;
172
+ const key = `${current.query ?? ""}|${scopedSelector}|${[...current.values].join(";")}`;
173
+ insertRule(rule, key, current.query);
174
+ this.current = null;
175
+ }
176
+ };
177
+ const onInit = (api) => {
178
+ if (!api.css || !(api.css instanceof RuntimeCSS)) api.css = new RuntimeCSS(api);
179
+ };
180
+
181
+ //#endregion
182
+ exports.RuntimeCSS = RuntimeCSS;
183
+ exports.onInit = onInit;
@@ -0,0 +1,181 @@
1
+ //#region src/strategy/runtime-only/css.ts
2
+ let baseStyleElement = null;
3
+ let baseSheet = null;
4
+ let atStyleElement = null;
5
+ let atSheet = null;
6
+ let atRuleIndex = 0;
7
+ const atRules = [];
8
+ const inserted = /* @__PURE__ */ new Set();
9
+ const canUseDom = () => typeof document !== "undefined" && typeof document.createElement === "function";
10
+ const ensureBaseSheet = () => {
11
+ if (baseSheet || !canUseDom()) return baseSheet;
12
+ baseStyleElement = document.querySelector("style[data-boss-runtime]");
13
+ if (!baseStyleElement) {
14
+ baseStyleElement = document.createElement("style");
15
+ baseStyleElement.setAttribute("data-boss-runtime", "");
16
+ document.head.appendChild(baseStyleElement);
17
+ }
18
+ baseSheet = baseStyleElement.sheet;
19
+ return baseSheet;
20
+ };
21
+ const ensureAtSheet = () => {
22
+ if (atSheet || !canUseDom()) return atSheet;
23
+ ensureBaseSheet();
24
+ atStyleElement = document.querySelector("style[data-boss-runtime-at]");
25
+ if (!atStyleElement) {
26
+ atStyleElement = document.createElement("style");
27
+ atStyleElement.setAttribute("data-boss-runtime-at", "");
28
+ const parent = baseStyleElement?.parentNode;
29
+ if (parent) parent.insertBefore(atStyleElement, baseStyleElement?.nextSibling ?? null);
30
+ else document.head.appendChild(atStyleElement);
31
+ }
32
+ atSheet = atStyleElement.sheet;
33
+ return atSheet;
34
+ };
35
+ const compareAtRuleOrder = (a, b) => {
36
+ if (a.group !== b.group) return a.group - b.group;
37
+ if (a.primary !== b.primary) return a.primary - b.primary;
38
+ if (a.secondary !== b.secondary) return a.secondary - b.secondary;
39
+ return a.index - b.index;
40
+ };
41
+ const getAtRuleOrder = (query, index) => {
42
+ const normalized = query.trim().toLowerCase();
43
+ if (!normalized.startsWith("@media")) return {
44
+ group: 4,
45
+ primary: 0,
46
+ secondary: 0,
47
+ index
48
+ };
49
+ const minMatch = normalized.match(/min-width\s*:\s*(\d+(?:\.\d+)?)px/);
50
+ const maxMatch = normalized.match(/max-width\s*:\s*(\d+(?:\.\d+)?)px/);
51
+ const min = minMatch ? Number(minMatch[1]) : null;
52
+ const max = maxMatch ? Number(maxMatch[1]) : null;
53
+ if (min !== null && max !== null) return {
54
+ group: 1,
55
+ primary: min,
56
+ secondary: max,
57
+ index
58
+ };
59
+ if (max !== null) return {
60
+ group: 0,
61
+ primary: -max,
62
+ secondary: 0,
63
+ index
64
+ };
65
+ if (min !== null) return {
66
+ group: 2,
67
+ primary: min,
68
+ secondary: 0,
69
+ index
70
+ };
71
+ return {
72
+ group: 3,
73
+ primary: 0,
74
+ secondary: 0,
75
+ index
76
+ };
77
+ };
78
+ const insertRule = (rule, key = rule, query = null) => {
79
+ if (inserted.has(key)) return;
80
+ inserted.add(key);
81
+ if (!query) {
82
+ const activeSheet$1 = ensureBaseSheet();
83
+ if (!activeSheet$1) return;
84
+ try {
85
+ activeSheet$1.insertRule(rule, activeSheet$1.cssRules.length);
86
+ } catch {
87
+ baseStyleElement?.appendChild(document.createTextNode(rule));
88
+ }
89
+ return;
90
+ }
91
+ const activeSheet = ensureAtSheet();
92
+ if (!activeSheet) return;
93
+ const order = getAtRuleOrder(query, atRuleIndex);
94
+ atRuleIndex += 1;
95
+ let insertIndex = atRules.length;
96
+ for (let i = 0; i < atRules.length; i += 1) if (compareAtRuleOrder(order, atRules[i].order) < 0) {
97
+ insertIndex = i;
98
+ break;
99
+ }
100
+ try {
101
+ activeSheet.insertRule(rule, insertIndex);
102
+ atRules.splice(insertIndex, 0, {
103
+ key,
104
+ order
105
+ });
106
+ } catch {
107
+ atStyleElement?.appendChild(document.createTextNode(rule));
108
+ atRules.push({
109
+ key,
110
+ order
111
+ });
112
+ }
113
+ };
114
+ var RuntimeCSS = class {
115
+ api;
116
+ current = null;
117
+ root = /* @__PURE__ */ new Set();
118
+ imports = /* @__PURE__ */ new Set();
119
+ constructor(api) {
120
+ this.api = api;
121
+ }
122
+ get text() {
123
+ return "";
124
+ }
125
+ addImport(_url) {}
126
+ addRoot(_value, _source) {}
127
+ removeSource(_source) {}
128
+ reset() {}
129
+ selector({ className, selector = null, pseudos = [], query = null }) {
130
+ if (!this.current) this.current = {
131
+ className: null,
132
+ selector: null,
133
+ pseudos: [],
134
+ values: /* @__PURE__ */ new Set(),
135
+ query: null
136
+ };
137
+ const current = this.current;
138
+ if (query && current.query && query !== current.query) throw new Error(`RuntimeCSS:selector Selector already has a query. Existing: ${current.query} Incoming: ${query}`);
139
+ const mergedPseudos = [];
140
+ for (const pseudo of [...current.pseudos, ...pseudos]) if (!mergedPseudos.includes(pseudo)) mergedPseudos.push(pseudo);
141
+ const next = {
142
+ pseudos: mergedPseudos,
143
+ query: query || current.query
144
+ };
145
+ if (selector) Object.assign(next, {
146
+ selector,
147
+ className: null
148
+ });
149
+ else if (className) Object.assign(next, { className });
150
+ Object.assign(current, next);
151
+ }
152
+ rule(property, value, options) {
153
+ if (!this.current) throw new Error("RuntimeCSS:rule No current selector");
154
+ const suffix = options?.important ? " !important" : "";
155
+ this.current.values.add(`${property}: ${this.api.dictionary.toValue(value, property)}${suffix}`);
156
+ }
157
+ addRule(rule, query = null, _source) {
158
+ const wrapped = query ? `${query} { ${rule} }` : rule;
159
+ insertRule(wrapped, wrapped, query);
160
+ }
161
+ write() {
162
+ if (!this.current) throw new Error("RuntimeCSS:write No current selector");
163
+ const current = this.current;
164
+ const baseSelector = current.selector || (current.className ? `.${current.className}` : null);
165
+ if (!baseSelector) throw new Error("RuntimeCSS:write No className or selector");
166
+ const selector = [baseSelector, ...current.pseudos].join(":");
167
+ const selectorScope = typeof this.api.selectorScope === "string" ? this.api.selectorScope : "";
168
+ const scopedSelector = selectorScope ? `${selectorScope}${selector}` : selector;
169
+ let rule = `${scopedSelector} { ${[...current.values].join(";")} }`;
170
+ if (current.query) rule = `${current.query} { ${rule} }`;
171
+ const key = `${current.query ?? ""}|${scopedSelector}|${[...current.values].join(";")}`;
172
+ insertRule(rule, key, current.query);
173
+ this.current = null;
174
+ }
175
+ };
176
+ const onInit = (api) => {
177
+ if (!api.css || !(api.css instanceof RuntimeCSS)) api.css = new RuntimeCSS(api);
178
+ };
179
+
180
+ //#endregion
181
+ export { RuntimeCSS, onInit };
@@ -0,0 +1,88 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_api_server = require('../api/server.cjs');
3
+ const require_file = require('../shared/file.cjs');
4
+ const require_boundaries = require('../shared/boundaries.cjs');
5
+ const require_session = require('./session.cjs');
6
+ let node_fs_promises = require("node:fs/promises");
7
+ node_fs_promises = require_rolldown_runtime.__toESM(node_fs_promises);
8
+ let node_path = require("node:path");
9
+ node_path = require_rolldown_runtime.__toESM(node_path);
10
+
11
+ //#region src/tasks/build.ts
12
+ const resolveBuildConfig = (userConfig, baseDir = process.cwd()) => {
13
+ const configDir = userConfig.configDir ?? ".bo$$";
14
+ const folder = userConfig.folder ?? configDir;
15
+ const stylesheetPath = userConfig.stylesheetPath ?? node_path.default.join(baseDir, configDir, "styles.css");
16
+ return {
17
+ config: {
18
+ ...userConfig,
19
+ folder,
20
+ stylesheetPath,
21
+ configDir
22
+ },
23
+ folderPath: node_path.default.resolve(baseDir, folder),
24
+ stylesheetPath: node_path.default.isAbsolute(stylesheetPath) ? stylesheetPath : node_path.default.resolve(baseDir, stylesheetPath),
25
+ runtimeOnly: userConfig.runtime?.only === true
26
+ };
27
+ };
28
+ const runBuild = async (userConfig, options = {}) => {
29
+ const baseDir = options.baseDir ?? process.cwd();
30
+ const start = process.hrtime.bigint();
31
+ const { config, folderPath, stylesheetPath, runtimeOnly } = resolveBuildConfig(userConfig, baseDir);
32
+ if (!config.content) throw new Error("boss build requires config.content in .bo$$/config.js or package.json.");
33
+ const api = await require_api_server.createApi(config, true);
34
+ api.baseDir = baseDir;
35
+ const sessionStart = await require_session.resolveSessionPayload(baseDir, config, "build", "start");
36
+ await require_session.emitSession(api, sessionStart);
37
+ await require_session.emitSession(api, {
38
+ ...sessionStart,
39
+ phase: "run"
40
+ });
41
+ const inputPaths = await require_file.resolveContentPaths(config.content);
42
+ const parsedFiles = [];
43
+ await Promise.all(inputPaths.map(async (inputPath) => {
44
+ if (!(await node_fs_promises.default.stat(inputPath).catch(() => null))?.isFile()) return;
45
+ const content = await node_fs_promises.default.readFile(inputPath, "utf8");
46
+ parsedFiles.push(inputPath);
47
+ await api.trigger("onParse", {
48
+ content,
49
+ path: inputPath
50
+ });
51
+ }));
52
+ await node_fs_promises.default.mkdir(folderPath, { recursive: true });
53
+ if (api.strategy !== "classname-only") {
54
+ await api.file.js.write();
55
+ if (api.file.native?.hasContent) await api.file.native.write();
56
+ }
57
+ let cssPath = null;
58
+ let cssBytes = 0;
59
+ let boundaryPaths = [];
60
+ if (!runtimeOnly) {
61
+ const boundaryResult = await require_boundaries.resolveBoundaryOutputs(api, {
62
+ rootDir: baseDir,
63
+ stylesheetPath,
64
+ boundaries: config.css?.boundaries
65
+ });
66
+ boundaryPaths = boundaryResult.boundaryFiles;
67
+ for (const output of boundaryResult.outputs) {
68
+ await node_fs_promises.default.mkdir(node_path.default.dirname(output.path), { recursive: true });
69
+ await node_fs_promises.default.writeFile(output.path, output.text, "utf8");
70
+ }
71
+ const globalOutput = boundaryResult.outputs.find((output) => output.path === stylesheetPath);
72
+ cssPath = stylesheetPath;
73
+ cssBytes = Buffer.byteLength(globalOutput?.text ?? "");
74
+ }
75
+ const durationMs = Number(process.hrtime.bigint() - start) / 1e6;
76
+ await require_session.emitSession(api, await require_session.resolveSessionPayload(baseDir, config, "build", "stop"));
77
+ return {
78
+ filesParsed: parsedFiles.length,
79
+ cssPath,
80
+ cssBytes,
81
+ durationMs,
82
+ boundaryPaths
83
+ };
84
+ };
85
+
86
+ //#endregion
87
+ exports.resolveBuildConfig = resolveBuildConfig;
88
+ exports.runBuild = runBuild;
@@ -0,0 +1,84 @@
1
+ import { createApi } from "../api/server.mjs";
2
+ import { resolveContentPaths } from "../shared/file.mjs";
3
+ import { resolveBoundaryOutputs } from "../shared/boundaries.mjs";
4
+ import { emitSession, resolveSessionPayload } from "./session.mjs";
5
+ import fs from "node:fs/promises";
6
+ import path from "node:path";
7
+
8
+ //#region src/tasks/build.ts
9
+ const resolveBuildConfig = (userConfig, baseDir = process.cwd()) => {
10
+ const configDir = userConfig.configDir ?? ".bo$$";
11
+ const folder = userConfig.folder ?? configDir;
12
+ const stylesheetPath = userConfig.stylesheetPath ?? path.join(baseDir, configDir, "styles.css");
13
+ return {
14
+ config: {
15
+ ...userConfig,
16
+ folder,
17
+ stylesheetPath,
18
+ configDir
19
+ },
20
+ folderPath: path.resolve(baseDir, folder),
21
+ stylesheetPath: path.isAbsolute(stylesheetPath) ? stylesheetPath : path.resolve(baseDir, stylesheetPath),
22
+ runtimeOnly: userConfig.runtime?.only === true
23
+ };
24
+ };
25
+ const runBuild = async (userConfig, options = {}) => {
26
+ const baseDir = options.baseDir ?? process.cwd();
27
+ const start = process.hrtime.bigint();
28
+ const { config, folderPath, stylesheetPath, runtimeOnly } = resolveBuildConfig(userConfig, baseDir);
29
+ if (!config.content) throw new Error("boss build requires config.content in .bo$$/config.js or package.json.");
30
+ const api = await createApi(config, true);
31
+ api.baseDir = baseDir;
32
+ const sessionStart = await resolveSessionPayload(baseDir, config, "build", "start");
33
+ await emitSession(api, sessionStart);
34
+ await emitSession(api, {
35
+ ...sessionStart,
36
+ phase: "run"
37
+ });
38
+ const inputPaths = await resolveContentPaths(config.content);
39
+ const parsedFiles = [];
40
+ await Promise.all(inputPaths.map(async (inputPath) => {
41
+ if (!(await fs.stat(inputPath).catch(() => null))?.isFile()) return;
42
+ const content = await fs.readFile(inputPath, "utf8");
43
+ parsedFiles.push(inputPath);
44
+ await api.trigger("onParse", {
45
+ content,
46
+ path: inputPath
47
+ });
48
+ }));
49
+ await fs.mkdir(folderPath, { recursive: true });
50
+ if (api.strategy !== "classname-only") {
51
+ await api.file.js.write();
52
+ if (api.file.native?.hasContent) await api.file.native.write();
53
+ }
54
+ let cssPath = null;
55
+ let cssBytes = 0;
56
+ let boundaryPaths = [];
57
+ if (!runtimeOnly) {
58
+ const boundaryResult = await resolveBoundaryOutputs(api, {
59
+ rootDir: baseDir,
60
+ stylesheetPath,
61
+ boundaries: config.css?.boundaries
62
+ });
63
+ boundaryPaths = boundaryResult.boundaryFiles;
64
+ for (const output of boundaryResult.outputs) {
65
+ await fs.mkdir(path.dirname(output.path), { recursive: true });
66
+ await fs.writeFile(output.path, output.text, "utf8");
67
+ }
68
+ const globalOutput = boundaryResult.outputs.find((output) => output.path === stylesheetPath);
69
+ cssPath = stylesheetPath;
70
+ cssBytes = Buffer.byteLength(globalOutput?.text ?? "");
71
+ }
72
+ const durationMs = Number(process.hrtime.bigint() - start) / 1e6;
73
+ await emitSession(api, await resolveSessionPayload(baseDir, config, "build", "stop"));
74
+ return {
75
+ filesParsed: parsedFiles.length,
76
+ cssPath,
77
+ cssBytes,
78
+ durationMs,
79
+ boundaryPaths
80
+ };
81
+ };
82
+
83
+ //#endregion
84
+ export { resolveBuildConfig, runBuild };
@@ -0,0 +1,12 @@
1
+ const require_index = require('../compile/index.cjs');
2
+
3
+ //#region src/tasks/compile.ts
4
+ const runCompile = async ({ config, prod = false }) => {
5
+ return require_index.compileProject({
6
+ config,
7
+ prod
8
+ });
9
+ };
10
+
11
+ //#endregion
12
+ exports.runCompile = runCompile;
@@ -0,0 +1,12 @@
1
+ import { compileProject } from "../compile/index.mjs";
2
+
3
+ //#region src/tasks/compile.ts
4
+ const runCompile = async ({ config, prod = false }) => {
5
+ return compileProject({
6
+ config,
7
+ prod
8
+ });
9
+ };
10
+
11
+ //#endregion
12
+ export { runCompile };
@@ -0,0 +1,116 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_api_server = require('../api/server.cjs');
3
+ const require_file = require('../shared/file.cjs');
4
+ const require_boundaries = require('../shared/boundaries.cjs');
5
+ const require_session = require('./session.cjs');
6
+ const require_api_config = require('../api/config.cjs');
7
+ const require_cache = require('../transform/cache.cjs');
8
+ const require_processFile = require('../transform/processFile.cjs');
9
+ let node_path = require("node:path");
10
+ node_path = require_rolldown_runtime.__toESM(node_path);
11
+ let postcss = require("postcss");
12
+ postcss = require_rolldown_runtime.__toESM(postcss);
13
+
14
+ //#region src/tasks/postcss.ts
15
+ const configPromises = /* @__PURE__ */ new Map();
16
+ const apiCache = /* @__PURE__ */ new Map();
17
+ const knownFiles = /* @__PURE__ */ new Map();
18
+ const runQueues = /* @__PURE__ */ new Map();
19
+ const sessionStarted = /* @__PURE__ */ new Set();
20
+ const isTruthyEnv = (value) => Boolean(value) && value !== "0" && value !== "false";
21
+ const isTurbopackEnv = () => [
22
+ process.env.TURBOPACK,
23
+ process.env.__NEXT_TURBOPACK,
24
+ process.env.__NEXT_TURBOPACK__,
25
+ process.env.NEXT_TURBOPACK
26
+ ].some(isTruthyEnv);
27
+ const resolveConfig = (baseDir) => {
28
+ const key = baseDir ?? "__default__";
29
+ if (!configPromises.has(key)) configPromises.set(key, require_api_config.loadConfig(baseDir));
30
+ return configPromises.get(key);
31
+ };
32
+ const resolveApi = async (baseDir) => {
33
+ const key = baseDir ?? "__default__";
34
+ if (!apiCache.has(key)) apiCache.set(key, (async () => {
35
+ const api = await require_api_server.createApi(await resolveConfig(baseDir), true);
36
+ api.baseDir = baseDir ?? process.cwd();
37
+ return { api };
38
+ })());
39
+ return apiCache.get(key);
40
+ };
41
+ const runPostcss = async (root, result, options = {}) => {
42
+ const dirDependencies = options.dirDependencies ?? !isTurbopackEnv();
43
+ const baseDir = options.baseDir;
44
+ const { messages } = result;
45
+ const config = await resolveConfig(baseDir);
46
+ const { api } = await resolveApi(baseDir);
47
+ const { content, stylesheetPath } = api;
48
+ const queueKey = baseDir ?? "__default__";
49
+ const run = (runQueues.get(queueKey) ?? Promise.resolve()).catch(() => {}).then(async () => {
50
+ const inputFile = root.source?.input?.file;
51
+ const fromFile = result.opts?.from;
52
+ const filePath = typeof inputFile === "string" ? inputFile : typeof fromFile === "string" ? fromFile : void 0;
53
+ const resolvedFile = filePath ? node_path.default.resolve(filePath) : null;
54
+ const resolvedStylesheet = node_path.default.resolve(stylesheetPath);
55
+ if (resolvedFile && resolvedFile !== resolvedStylesheet && !resolvedFile.endsWith(".boss.css")) return;
56
+ if (!sessionStarted.has(queueKey)) {
57
+ sessionStarted.add(queueKey);
58
+ await require_session.emitSession(api, await require_session.resolveSessionPayload(baseDir ?? process.cwd(), config, "postcss", "start"));
59
+ }
60
+ await require_session.emitSession(api, await require_session.resolveSessionPayload(baseDir ?? process.cwd(), config, "postcss", "run"));
61
+ const resolvedPaths = (await require_file.resolveContentPaths(content)).map((entry) => node_path.default.resolve(entry));
62
+ const previousFiles = knownFiles.get(queueKey) ?? /* @__PURE__ */ new Set();
63
+ const nextFiles = new Set(resolvedPaths);
64
+ for (const file of previousFiles) if (!nextFiles.has(file)) {
65
+ api.css?.removeSource?.(file);
66
+ require_cache.cache.delete(file);
67
+ }
68
+ knownFiles.set(queueKey, nextFiles);
69
+ const promises = [];
70
+ resolvedPaths.forEach((file) => {
71
+ if (require_cache.setCache(file, { isFile: true })) messages.push({
72
+ type: "dependency",
73
+ file
74
+ });
75
+ if (dirDependencies) {
76
+ const dir = node_path.default.dirname(file);
77
+ if (!require_cache.cache.has(dir)) {
78
+ messages.push({
79
+ type: "dir-dependency",
80
+ dir
81
+ });
82
+ require_cache.setCache(dir, { isFile: false });
83
+ }
84
+ }
85
+ promises.push(require_processFile.default(file));
86
+ });
87
+ const processedFiles = await Promise.allSettled(promises);
88
+ const onParsePromises = [];
89
+ for (const settled of processedFiles) {
90
+ if (settled.status !== "fulfilled") continue;
91
+ const processed = settled.value;
92
+ const value = processed?.value;
93
+ if (!value || !processed?.changed) continue;
94
+ const changedPath = value.path ? node_path.default.resolve(value.path) : null;
95
+ if (changedPath) api.css?.removeSource?.(changedPath);
96
+ onParsePromises.push(api.trigger("onParse", value));
97
+ }
98
+ await Promise.allSettled(onParsePromises);
99
+ const boundaryResult = await require_boundaries.resolveBoundaryOutputs(api, {
100
+ rootDir: baseDir ?? process.cwd(),
101
+ stylesheetPath,
102
+ boundaries: config.css?.boundaries
103
+ });
104
+ const outputText = new Map(boundaryResult.outputs.map((output) => [node_path.default.resolve(output.path), output.text])).get(resolvedFile ?? resolvedStylesheet);
105
+ if (outputText !== void 0) result.root = postcss.default.parse(outputText, result.opts);
106
+ if (api.strategy !== "classname-only") {
107
+ api.file.js.write();
108
+ if (api.file.native?.hasContent) api.file.native.write();
109
+ }
110
+ });
111
+ runQueues.set(queueKey, run);
112
+ await run;
113
+ };
114
+
115
+ //#endregion
116
+ exports.runPostcss = runPostcss;