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
package/README.md ADDED
@@ -0,0 +1 @@
1
+ boss-css
@@ -0,0 +1,43 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __exportAll = (all, symbols) => {
9
+ let target = {};
10
+ for (var name in all) {
11
+ __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true
14
+ });
15
+ }
16
+ if (symbols) {
17
+ __defProp(target, Symbol.toStringTag, { value: "Module" });
18
+ }
19
+ return target;
20
+ };
21
+ var __copyProps = (to, from, except, desc) => {
22
+ if (from && typeof from === "object" || typeof from === "function") {
23
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
24
+ key = keys[i];
25
+ if (!__hasOwnProp.call(to, key) && key !== except) {
26
+ __defProp(to, key, {
27
+ get: ((k) => from[k]).bind(null, key),
28
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
29
+ });
30
+ }
31
+ }
32
+ }
33
+ return to;
34
+ };
35
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
36
+ value: mod,
37
+ enumerable: true
38
+ }) : target, mod));
39
+
40
+ //#endregion
41
+
42
+ exports.__exportAll = __exportAll;
43
+ exports.__toESM = __toESM;
@@ -0,0 +1,20 @@
1
+ import { createRequire } from "node:module";
2
+
3
+ //#region rolldown:runtime
4
+ var __defProp = Object.defineProperty;
5
+ var __exportAll = (all, symbols) => {
6
+ let target = {};
7
+ for (var name in all) {
8
+ __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ }
13
+ if (symbols) {
14
+ __defProp(target, Symbol.toStringTag, { value: "Module" });
15
+ }
16
+ return target;
17
+ };
18
+
19
+ //#endregion
20
+ export { __exportAll };
@@ -0,0 +1,54 @@
1
+ const require_dictionary = require('./dictionary.cjs');
2
+ const require_names = require('./names.cjs');
3
+ const require_debug = require('../shared/debug.cjs');
4
+ const require_browser = require('../log/browser.cjs');
5
+
6
+ //#region src/api/browser.ts
7
+ let api = null;
8
+ function createApi(config, force = false) {
9
+ if (!force && api) return api;
10
+ const debug = require_debug.resolveDebugValue(config.debug);
11
+ const resolvedConfig = {
12
+ ...config,
13
+ debug
14
+ };
15
+ const logRoot = require_browser.createLogger("boss", debug);
16
+ logRoot.child("api").log("Create browser API");
17
+ api = {
18
+ unit: "px",
19
+ trigger,
20
+ isBrowser: true,
21
+ log: logRoot,
22
+ ...resolvedConfig,
23
+ plugins: Array.isArray(resolvedConfig.plugins) ? resolvedConfig.plugins : [],
24
+ contextToCSSVariable: require_names.contextToCSSVariable,
25
+ contextToClassName: require_names.contextToClassName,
26
+ camelCaseToDash: require_names.camelCaseToDash,
27
+ dashToCamelCase: require_names.dashToCamelCase
28
+ };
29
+ api.dictionary = new require_dictionary.Dictionary(api);
30
+ trigger("onInit");
31
+ return api;
32
+ }
33
+ function trigger(eventName, data, test = () => true) {
34
+ if (!api) return;
35
+ const currentApi = api;
36
+ const log = currentApi.log.child("api").child("trigger");
37
+ for (const plugin of currentApi.plugins) {
38
+ if (!plugin[eventName] || !test(plugin)) continue;
39
+ const handlers = Array.isArray(plugin[eventName]) ? plugin[eventName] : [plugin[eventName]];
40
+ for (const [index, handler] of Object.entries(handlers)) {
41
+ log.log(eventName, plugin.name, `${+index + 1}/${handlers.length}`);
42
+ handler(currentApi, data);
43
+ }
44
+ }
45
+ }
46
+
47
+ //#endregion
48
+ Object.defineProperty(exports, 'api', {
49
+ enumerable: true,
50
+ get: function () {
51
+ return api;
52
+ }
53
+ });
54
+ exports.createApi = createApi;
@@ -0,0 +1,48 @@
1
+ import { Dictionary } from "./dictionary.mjs";
2
+ import { camelCaseToDash, contextToCSSVariable, contextToClassName, dashToCamelCase } from "./names.mjs";
3
+ import { resolveDebugValue } from "../shared/debug.mjs";
4
+ import { createLogger } from "../log/browser.mjs";
5
+
6
+ //#region src/api/browser.ts
7
+ let api = null;
8
+ function createApi(config, force = false) {
9
+ if (!force && api) return api;
10
+ const debug = resolveDebugValue(config.debug);
11
+ const resolvedConfig = {
12
+ ...config,
13
+ debug
14
+ };
15
+ const logRoot = createLogger("boss", debug);
16
+ logRoot.child("api").log("Create browser API");
17
+ api = {
18
+ unit: "px",
19
+ trigger,
20
+ isBrowser: true,
21
+ log: logRoot,
22
+ ...resolvedConfig,
23
+ plugins: Array.isArray(resolvedConfig.plugins) ? resolvedConfig.plugins : [],
24
+ contextToCSSVariable,
25
+ contextToClassName,
26
+ camelCaseToDash,
27
+ dashToCamelCase
28
+ };
29
+ api.dictionary = new Dictionary(api);
30
+ trigger("onInit");
31
+ return api;
32
+ }
33
+ function trigger(eventName, data, test = () => true) {
34
+ if (!api) return;
35
+ const currentApi = api;
36
+ const log = currentApi.log.child("api").child("trigger");
37
+ for (const plugin of currentApi.plugins) {
38
+ if (!plugin[eventName] || !test(plugin)) continue;
39
+ const handlers = Array.isArray(plugin[eventName]) ? plugin[eventName] : [plugin[eventName]];
40
+ for (const [index, handler] of Object.entries(handlers)) {
41
+ log.log(eventName, plugin.name, `${+index + 1}/${handlers.length}`);
42
+ handler(currentApi, data);
43
+ }
44
+ }
45
+ }
46
+
47
+ //#endregion
48
+ export { api, createApi };
@@ -0,0 +1,94 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_json = require('../shared/json.cjs');
3
+ let node_fs_promises = require("node:fs/promises");
4
+ node_fs_promises = require_rolldown_runtime.__toESM(node_fs_promises);
5
+ let node_path = require("node:path");
6
+ node_path = require_rolldown_runtime.__toESM(node_path);
7
+ let node_url = require("node:url");
8
+
9
+ //#region src/api/config.ts
10
+ const defaultConfig = {
11
+ configDir: ".bo$$",
12
+ unit: "px"
13
+ };
14
+ async function loadConfig(baseDir = process.cwd()) {
15
+ const packageJSONPath = node_path.default.join(baseDir, "package.json");
16
+ let packageJSON = {};
17
+ try {
18
+ packageJSON = require_json.parseJson(await node_fs_promises.default.readFile(packageJSONPath, "utf8"), {
19
+ filePath: packageJSONPath,
20
+ allowTrailingCommas: true
21
+ });
22
+ } catch {
23
+ packageJSON = {};
24
+ }
25
+ const rawPackageConfig = packageJSON["bo$$"];
26
+ const packageConfig = rawPackageConfig && typeof rawPackageConfig === "object" ? rawPackageConfig : {};
27
+ const config = {
28
+ ...defaultConfig,
29
+ ...packageConfig
30
+ };
31
+ const resolvedConfig = await resolveConfigPath(baseDir, config.configDir);
32
+ const userConfig = await loadUserConfig(resolvedConfig.userConfigPath);
33
+ const compile = {
34
+ tempOutDir: node_path.default.join(resolvedConfig.configDir, "compiled"),
35
+ ...config.compile ?? {},
36
+ ...userConfig.compile ?? {}
37
+ };
38
+ const css = {
39
+ ...config.css ?? {},
40
+ ...userConfig.css ?? {}
41
+ };
42
+ const runtime = {
43
+ ...config.runtime ?? {},
44
+ ...userConfig.runtime ?? {}
45
+ };
46
+ const plugins = Array.isArray(userConfig.plugins) ? userConfig.plugins : config.plugins ?? [];
47
+ return {
48
+ ...config,
49
+ ...userConfig,
50
+ css,
51
+ compile,
52
+ plugins,
53
+ runtime,
54
+ configDir: resolvedConfig.configDir,
55
+ stylesheetPath: node_path.default.join(baseDir, resolvedConfig.configDir, "styles.css")
56
+ };
57
+ }
58
+ async function loadUserConfig(userConfigPath) {
59
+ try {
60
+ await node_fs_promises.default.access(userConfigPath);
61
+ } catch {
62
+ return {};
63
+ }
64
+ return (await import((0, node_url.pathToFileURL)(userConfigPath).href)).default ?? {};
65
+ }
66
+ async function resolveConfigPath(baseDir, configDir) {
67
+ const primary = node_path.default.join(baseDir, configDir, "config.js");
68
+ if (await hasFile(primary)) return {
69
+ configDir,
70
+ userConfigPath: primary
71
+ };
72
+ if (configDir === ".bo$$") {
73
+ const fallback = node_path.default.join(baseDir, "src", ".bo$$", "config.js");
74
+ if (await hasFile(fallback)) return {
75
+ configDir: node_path.default.join("src", ".bo$$"),
76
+ userConfigPath: fallback
77
+ };
78
+ }
79
+ return {
80
+ configDir,
81
+ userConfigPath: primary
82
+ };
83
+ }
84
+ async function hasFile(filePath) {
85
+ try {
86
+ await node_fs_promises.default.access(filePath);
87
+ return true;
88
+ } catch {
89
+ return false;
90
+ }
91
+ }
92
+
93
+ //#endregion
94
+ exports.loadConfig = loadConfig;
@@ -0,0 +1,91 @@
1
+ import { parseJson } from "../shared/json.mjs";
2
+ import fs from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { pathToFileURL } from "node:url";
5
+
6
+ //#region src/api/config.ts
7
+ const defaultConfig = {
8
+ configDir: ".bo$$",
9
+ unit: "px"
10
+ };
11
+ async function loadConfig(baseDir = process.cwd()) {
12
+ const packageJSONPath = path.join(baseDir, "package.json");
13
+ let packageJSON = {};
14
+ try {
15
+ packageJSON = parseJson(await fs.readFile(packageJSONPath, "utf8"), {
16
+ filePath: packageJSONPath,
17
+ allowTrailingCommas: true
18
+ });
19
+ } catch {
20
+ packageJSON = {};
21
+ }
22
+ const rawPackageConfig = packageJSON["bo$$"];
23
+ const packageConfig = rawPackageConfig && typeof rawPackageConfig === "object" ? rawPackageConfig : {};
24
+ const config = {
25
+ ...defaultConfig,
26
+ ...packageConfig
27
+ };
28
+ const resolvedConfig = await resolveConfigPath(baseDir, config.configDir);
29
+ const userConfig = await loadUserConfig(resolvedConfig.userConfigPath);
30
+ const compile = {
31
+ tempOutDir: path.join(resolvedConfig.configDir, "compiled"),
32
+ ...config.compile ?? {},
33
+ ...userConfig.compile ?? {}
34
+ };
35
+ const css = {
36
+ ...config.css ?? {},
37
+ ...userConfig.css ?? {}
38
+ };
39
+ const runtime = {
40
+ ...config.runtime ?? {},
41
+ ...userConfig.runtime ?? {}
42
+ };
43
+ const plugins = Array.isArray(userConfig.plugins) ? userConfig.plugins : config.plugins ?? [];
44
+ return {
45
+ ...config,
46
+ ...userConfig,
47
+ css,
48
+ compile,
49
+ plugins,
50
+ runtime,
51
+ configDir: resolvedConfig.configDir,
52
+ stylesheetPath: path.join(baseDir, resolvedConfig.configDir, "styles.css")
53
+ };
54
+ }
55
+ async function loadUserConfig(userConfigPath) {
56
+ try {
57
+ await fs.access(userConfigPath);
58
+ } catch {
59
+ return {};
60
+ }
61
+ return (await import(pathToFileURL(userConfigPath).href)).default ?? {};
62
+ }
63
+ async function resolveConfigPath(baseDir, configDir) {
64
+ const primary = path.join(baseDir, configDir, "config.js");
65
+ if (await hasFile(primary)) return {
66
+ configDir,
67
+ userConfigPath: primary
68
+ };
69
+ if (configDir === ".bo$$") {
70
+ const fallback = path.join(baseDir, "src", ".bo$$", "config.js");
71
+ if (await hasFile(fallback)) return {
72
+ configDir: path.join("src", ".bo$$"),
73
+ userConfigPath: fallback
74
+ };
75
+ }
76
+ return {
77
+ configDir,
78
+ userConfigPath: primary
79
+ };
80
+ }
81
+ async function hasFile(filePath) {
82
+ try {
83
+ await fs.access(filePath);
84
+ return true;
85
+ } catch {
86
+ return false;
87
+ }
88
+ }
89
+
90
+ //#endregion
91
+ export { loadConfig };
@@ -0,0 +1,304 @@
1
+
2
+ //#region src/api/css.ts
3
+ var CSS = class extends Set {
4
+ api;
5
+ log;
6
+ current = null;
7
+ source = null;
8
+ ruleMeta = /* @__PURE__ */ new Map();
9
+ ruleSources = /* @__PURE__ */ new Map();
10
+ ruleIndex = 0;
11
+ imports = /* @__PURE__ */ new Set();
12
+ customBlocks = /* @__PURE__ */ new Map();
13
+ customByFile = /* @__PURE__ */ new Map();
14
+ rootSources = /* @__PURE__ */ new Map();
15
+ get text() {
16
+ const importRules = this.imports.size ? Array.from(this.imports).join("\n") : "";
17
+ const entries = Array.from(this).map((rule) => {
18
+ const meta = this.ruleMeta.get(rule);
19
+ return {
20
+ rule,
21
+ query: meta?.query ?? null,
22
+ index: meta?.index ?? 0
23
+ };
24
+ });
25
+ const baseRules = entries.filter((entry) => !entry.query).sort((a, b) => a.index - b.index).map((entry) => entry.rule);
26
+ const atRules = entries.filter((entry) => entry.query).sort((a, b) => this.compareAtRuleOrder(a, b)).map((entry) => entry.rule);
27
+ const orderedRules = [...baseRules, ...atRules].join("\n");
28
+ const rootRules = this.root.size ? `${this.api.selectorScope || ":root"} {
29
+ ${Array.from(this.root).join("\n ")}
30
+ }
31
+ ${orderedRules}` : orderedRules;
32
+ const customRules = this.getCustomText();
33
+ if (!importRules && !rootRules && !customRules) return "";
34
+ if (!importRules && !customRules) return rootRules;
35
+ if (!importRules && !rootRules) return customRules;
36
+ if (!customRules) return importRules ? `${importRules}\n${rootRules}` : rootRules;
37
+ if (!rootRules) return importRules ? `${importRules}\n${customRules}` : customRules;
38
+ return `${importRules}\n${rootRules}\n${customRules}`;
39
+ }
40
+ root = /* @__PURE__ */ new Set();
41
+ constructor(api) {
42
+ super();
43
+ this.api = api;
44
+ this.log = api.log.child("css");
45
+ }
46
+ setSource(source) {
47
+ this.source = source;
48
+ }
49
+ rule(property, value, options) {
50
+ if (!this.current) throw new Error("CSS:rule No current selector");
51
+ const suffix = options?.important ? " !important" : "";
52
+ this.current.values.add(`${property}: ${this.api.dictionary.toValue(value, property)}${suffix}`);
53
+ }
54
+ addImport(url) {
55
+ if (!url) return;
56
+ this.imports.add(`@import url("${url}");`);
57
+ }
58
+ addRule(rule, query = null, source = null) {
59
+ const wrapped = query ? `${query} { ${rule} }` : rule;
60
+ if (!this.has(wrapped)) {
61
+ this.add(wrapped);
62
+ this.ruleMeta.set(wrapped, {
63
+ query,
64
+ index: this.ruleIndex
65
+ });
66
+ this.ruleIndex += 1;
67
+ }
68
+ this.trackRuleSource(wrapped, source ?? this.source);
69
+ }
70
+ selector({ className, selector = null, pseudos = [], query = null, source = null }) {
71
+ this.log.log("selector", {
72
+ className,
73
+ selector,
74
+ pseudos,
75
+ query
76
+ });
77
+ if (!this.current) this.current = {
78
+ className: null,
79
+ selector: null,
80
+ pseudos: [],
81
+ values: /* @__PURE__ */ new Set(),
82
+ query: null,
83
+ source: null
84
+ };
85
+ const current = this.current;
86
+ if (query && current.query && query !== current.query) throw new Error(`CSS:selector Selector already has a query. Existing: ${current.query} Incoming: ${query}`);
87
+ const mergedPseudos = [];
88
+ for (const pseudo of [...current.pseudos, ...pseudos]) if (!mergedPseudos.includes(pseudo)) mergedPseudos.push(pseudo);
89
+ const next = {
90
+ pseudos: mergedPseudos,
91
+ query: query || current.query
92
+ };
93
+ if (selector) Object.assign(next, {
94
+ selector,
95
+ className: null
96
+ });
97
+ else if (className) Object.assign(next, { className });
98
+ if (source || this.source) next.source = source ?? this.source;
99
+ Object.assign(current, next);
100
+ }
101
+ write() {
102
+ this.log.log("write", this.current);
103
+ if (!this.current) throw new Error("CSS:write No current selector");
104
+ const current = this.current;
105
+ const baseSelector = current.selector || (current.className ? `.${current.className}` : null);
106
+ if (!baseSelector) throw new Error("CSS:write No className or selector");
107
+ const selector = [baseSelector, ...current.pseudos].join(":");
108
+ const selectorScope = typeof this.api.selectorScope === "string" ? this.api.selectorScope : "";
109
+ let string = `${selectorScope ? `${selectorScope}${selector}` : selector} { ${[...current.values].join(";")} }`;
110
+ if (current.query) string = `${current.query} { ${string} }`;
111
+ if (!this.has(string)) {
112
+ this.add(string);
113
+ this.ruleMeta.set(string, {
114
+ query: current.query,
115
+ index: this.ruleIndex
116
+ });
117
+ this.ruleIndex += 1;
118
+ }
119
+ this.trackRuleSource(string, current.source ?? this.source);
120
+ this.current = null;
121
+ }
122
+ compareAtRuleOrder(a, b) {
123
+ const aOrder = this.getAtRuleOrder(a.query, a.index);
124
+ const bOrder = this.getAtRuleOrder(b.query, b.index);
125
+ if (aOrder.group !== bOrder.group) return aOrder.group - bOrder.group;
126
+ if (aOrder.primary !== bOrder.primary) return aOrder.primary - bOrder.primary;
127
+ if (aOrder.secondary !== bOrder.secondary) return aOrder.secondary - bOrder.secondary;
128
+ return aOrder.index - bOrder.index;
129
+ }
130
+ getAtRuleOrder(query, index) {
131
+ if (!query) return {
132
+ group: 0,
133
+ primary: 0,
134
+ secondary: 0,
135
+ index
136
+ };
137
+ const normalized = query.trim().toLowerCase();
138
+ if (!normalized.startsWith("@media")) return {
139
+ group: 4,
140
+ primary: 0,
141
+ secondary: 0,
142
+ index
143
+ };
144
+ const minMatch = normalized.match(/min-width\s*:\s*(\d+(?:\.\d+)?)px/);
145
+ const maxMatch = normalized.match(/max-width\s*:\s*(\d+(?:\.\d+)?)px/);
146
+ const min = minMatch ? Number(minMatch[1]) : null;
147
+ const max = maxMatch ? Number(maxMatch[1]) : null;
148
+ if (min !== null && max !== null) return {
149
+ group: 1,
150
+ primary: min,
151
+ secondary: max,
152
+ index
153
+ };
154
+ if (max !== null) return {
155
+ group: 0,
156
+ primary: -max,
157
+ secondary: 0,
158
+ index
159
+ };
160
+ if (min !== null) return {
161
+ group: 2,
162
+ primary: min,
163
+ secondary: 0,
164
+ index
165
+ };
166
+ return {
167
+ group: 3,
168
+ primary: 0,
169
+ secondary: 0,
170
+ index
171
+ };
172
+ }
173
+ addRoot(value, source = null) {
174
+ if (!value) return;
175
+ this.root.add(value);
176
+ this.trackRootSource(value, source ?? this.source);
177
+ }
178
+ removeSource(source) {
179
+ if (!source) return;
180
+ for (const [rule, sources] of this.ruleSources.entries()) {
181
+ if (!sources.delete(source)) continue;
182
+ if (sources.size === 0) {
183
+ this.ruleSources.delete(rule);
184
+ this.ruleMeta.delete(rule);
185
+ this.delete(rule);
186
+ }
187
+ }
188
+ for (const [declaration, sources] of this.rootSources.entries()) {
189
+ if (!sources.delete(source)) continue;
190
+ if (sources.size === 0) {
191
+ this.rootSources.delete(declaration);
192
+ this.root.delete(declaration);
193
+ }
194
+ }
195
+ const customIds = this.customByFile.get(source);
196
+ if (customIds) {
197
+ for (const id of customIds) this.customBlocks.delete(id);
198
+ this.customByFile.delete(source);
199
+ }
200
+ }
201
+ reset() {
202
+ this.clear();
203
+ this.root.clear();
204
+ this.imports.clear();
205
+ this.customBlocks.clear();
206
+ this.customByFile.clear();
207
+ this.ruleMeta.clear();
208
+ this.ruleSources.clear();
209
+ this.rootSources.clear();
210
+ this.ruleIndex = 0;
211
+ this.current = null;
212
+ this.source = null;
213
+ }
214
+ snapshot() {
215
+ const cloneSet = (set) => new Set(set);
216
+ const cloneSetMap = (map) => {
217
+ const next = /* @__PURE__ */ new Map();
218
+ for (const [key, value] of map.entries()) next.set(key, new Set(value));
219
+ return next;
220
+ };
221
+ const cloneRuleMeta = /* @__PURE__ */ new Map();
222
+ for (const [key, meta] of this.ruleMeta.entries()) cloneRuleMeta.set(key, {
223
+ query: meta.query ?? null,
224
+ index: meta.index
225
+ });
226
+ const cloneCustomBlocks = /* @__PURE__ */ new Map();
227
+ for (const [key, value] of this.customBlocks.entries()) cloneCustomBlocks.set(key, { ...value });
228
+ const cloneCustomByFile = /* @__PURE__ */ new Map();
229
+ for (const [key, value] of this.customByFile.entries()) cloneCustomByFile.set(key, new Set(value));
230
+ return {
231
+ rules: cloneSet(this),
232
+ root: cloneSet(this.root),
233
+ imports: cloneSet(this.imports),
234
+ ruleMeta: cloneRuleMeta,
235
+ ruleSources: cloneSetMap(this.ruleSources),
236
+ rootSources: cloneSetMap(this.rootSources),
237
+ customBlocks: cloneCustomBlocks,
238
+ customByFile: cloneCustomByFile,
239
+ ruleIndex: this.ruleIndex
240
+ };
241
+ }
242
+ restore(snapshot) {
243
+ const data = snapshot;
244
+ if (!data) return;
245
+ this.reset();
246
+ for (const rule of data.rules ?? []) this.add(rule);
247
+ for (const value of data.root ?? []) this.root.add(value);
248
+ for (const value of data.imports ?? []) this.imports.add(value);
249
+ if (data.ruleMeta) this.ruleMeta = new Map(data.ruleMeta);
250
+ if (data.ruleSources) this.ruleSources = new Map(data.ruleSources);
251
+ if (data.rootSources) this.rootSources = new Map(data.rootSources);
252
+ if (data.customBlocks) this.customBlocks = new Map(data.customBlocks);
253
+ if (data.customByFile) this.customByFile = new Map(data.customByFile);
254
+ this.ruleIndex = data.ruleIndex ?? 0;
255
+ }
256
+ syncCustomBlocks(file, blocks) {
257
+ const fileKey = file || "<unknown>";
258
+ const nextIds = /* @__PURE__ */ new Set();
259
+ for (const block of blocks) {
260
+ const cssText = block.cssText;
261
+ if (!cssText.trim()) continue;
262
+ const id = `${fileKey}:${block.start}-${block.end}`;
263
+ nextIds.add(id);
264
+ const existing = this.customBlocks.get(id);
265
+ if (!existing || existing.cssText !== cssText) this.customBlocks.set(id, {
266
+ cssText,
267
+ file: fileKey,
268
+ start: block.start,
269
+ end: block.end
270
+ });
271
+ }
272
+ const previous = this.customByFile.get(fileKey);
273
+ if (previous) {
274
+ for (const id of previous) if (!nextIds.has(id)) this.customBlocks.delete(id);
275
+ }
276
+ if (nextIds.size) this.customByFile.set(fileKey, nextIds);
277
+ else this.customByFile.delete(fileKey);
278
+ }
279
+ getCustomText() {
280
+ if (!this.customBlocks.size) return "";
281
+ return Array.from(this.customBlocks.values()).map((entry) => entry.cssText).join("\n");
282
+ }
283
+ trackRuleSource(rule, source) {
284
+ if (!source) return;
285
+ const existing = this.ruleSources.get(rule);
286
+ if (existing) {
287
+ existing.add(source);
288
+ return;
289
+ }
290
+ this.ruleSources.set(rule, new Set([source]));
291
+ }
292
+ trackRootSource(rule, source) {
293
+ if (!source) return;
294
+ const existing = this.rootSources.get(rule);
295
+ if (existing) {
296
+ existing.add(source);
297
+ return;
298
+ }
299
+ this.rootSources.set(rule, new Set([source]));
300
+ }
301
+ };
302
+
303
+ //#endregion
304
+ exports.CSS = CSS;