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,116 @@
1
+ import File from "./file.mjs";
2
+ import Dts from "./dts.mjs";
3
+ import hash from "@emotion/hash";
4
+
5
+ //#region src/api/file/js.ts
6
+ var JS = class extends File {
7
+ _d;
8
+ get dts() {
9
+ return this._d ??= new Dts(this.api, { path: this.options.path.replace(/\.js$/, ".d.ts") });
10
+ }
11
+ get headers() {
12
+ return [
13
+ ...super.headers,
14
+ ["$$:eslint-disable", { content: "/* eslint-disable */" }],
15
+ ["$$:ts-nocheck", { content: "// @ts-nocheck" }]
16
+ ];
17
+ }
18
+ import({ name = null, from, as = null }, test = () => true) {
19
+ const imports = this.get("import");
20
+ if (name === "*") {
21
+ const alias = as ?? `namespace_${hash(from)}`;
22
+ if (imports.has(alias)) return alias;
23
+ imports.set(alias, {
24
+ content: `import * as ${alias} from '${from}'`,
25
+ test
26
+ });
27
+ return alias;
28
+ }
29
+ const key = `${name}_${hash(from)}`;
30
+ if (imports.has(key)) return key;
31
+ if (name === "default") imports.set(key, {
32
+ content: `import ${key} from '${from}'`,
33
+ test
34
+ });
35
+ else if (name) imports.set(key, {
36
+ content: `import { ${name} as ${key} } from '${from}'`,
37
+ test
38
+ });
39
+ else imports.set(key, {
40
+ content: `import '${from}'`,
41
+ test
42
+ });
43
+ return key;
44
+ }
45
+ _configs = /* @__PURE__ */ new Map();
46
+ config({ from, config }, test = () => true) {
47
+ const existing = this._configs.get(from);
48
+ const configEntry = {
49
+ ...existing,
50
+ config: {
51
+ ...existing?.config,
52
+ ...config
53
+ },
54
+ test
55
+ };
56
+ if (existing?.plugin && config?.plugin) configEntry.config.plugin = {
57
+ ...existing.config.plugin,
58
+ ...config.plugin
59
+ };
60
+ this._configs.set(from, configEntry);
61
+ const testHasConfig = () => Array.from(this._configs.values()).some(({ test: test$1 }) => !test$1 || test$1());
62
+ const createApiVar = this.import({
63
+ name: "createApi",
64
+ from: "boss-css/api/browser"
65
+ }, testHasConfig);
66
+ this.set("body", "$$:createApiStart", `${createApiVar}({`, testHasConfig);
67
+ const serializeConfigValue = (value, keyHint) => JSON.stringify(value, (k, v) => {
68
+ const name = k || keyHint;
69
+ if (typeof v === "string" && name) {
70
+ if (v.startsWith(`${name}_`)) return `$$__${v}__$$`;
71
+ if (name === "runtimeApi" && v === name) return `$$__${v}__$$`;
72
+ }
73
+ return v;
74
+ }, 2).replace(/"\$\$__|__\$\$"/g, "");
75
+ this.set("body", "$$:createApiRoot", () => {
76
+ const results = [];
77
+ for (const conf of this._configs.values()) {
78
+ if (conf.test && !conf.test()) continue;
79
+ Object.entries(conf.config).forEach(([key, value]) => {
80
+ if (key === "plugin" || key === "plugins") return;
81
+ if (value === void 0) return;
82
+ results.push(`${key}: ${serializeConfigValue(value, key)},`);
83
+ });
84
+ }
85
+ return results.join("\n");
86
+ }, testHasConfig);
87
+ this.set("body", "$$:createApiPlugins", () => {
88
+ const results = [];
89
+ for (const conf of this._configs.values()) {
90
+ if (conf.test && !conf.test()) continue;
91
+ if (!conf.config?.plugin) continue;
92
+ results.push(`${serializeConfigValue(conf.config.plugin)}`);
93
+ }
94
+ return results.length ? `plugins: [${results.join(",\n")}],` : "";
95
+ }, testHasConfig);
96
+ this.set("body", "$$:createApiEnd", `})`, testHasConfig);
97
+ }
98
+ importAndConfig({ name, from }, test = () => true) {
99
+ const key = this.import({
100
+ name,
101
+ from
102
+ }, test);
103
+ this.config({
104
+ from,
105
+ config: { plugin: { [name]: key } }
106
+ }, test);
107
+ return key;
108
+ }
109
+ async write() {
110
+ await super.write();
111
+ await this.dts.write();
112
+ }
113
+ };
114
+
115
+ //#endregion
116
+ export { JS as default };
@@ -0,0 +1,52 @@
1
+ require("css.escape");
2
+
3
+ //#region src/api/names.ts
4
+ const contextToClassName = (name, value, contexts, escape = true, prefix = "") => {
5
+ const parts = value !== null ? [name, Array.isArray(value) ? value.join("_") : String(value)] : [name];
6
+ const className = `${prefix}${[...contexts, ...parts].join(":")}`;
7
+ return escape ? camelCaseToDash(escapeClassName(className)) : camelCaseToDash(className.replace(/ /g, "_"));
8
+ };
9
+ const contextToCSSVariable = (name, value, contexts, prefix = "") => {
10
+ return camelCaseToDash(escapeCSSVariable(`--${prefix}${[...contexts, name].join("-")}`));
11
+ };
12
+ const escapeCSSVariable = (css) => {
13
+ return css.replace(/ /g, "-").replace(/([^a-z0-9-_])/gi, "\\$1");
14
+ };
15
+ const escapeClassName = (css) => {
16
+ return CSS.escape(css.replace(/ /g, "_")).replace(/([^\\]):/g, "\\:");
17
+ };
18
+ const escapeAttributeValue = (value) => {
19
+ return value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
20
+ };
21
+ const classTokenToSelector = (token) => {
22
+ if (token.includes("{") || token.includes("}")) return `[class~="${escapeAttributeValue(token)}"]`;
23
+ return `.${escapeClassName(token)}`;
24
+ };
25
+ const dashToCamelCase = (str) => {
26
+ return str.replace(/-([a-z])/g, (_, a) => a.toUpperCase());
27
+ };
28
+ const camelCaseToDash = (str) => {
29
+ return str.replace(/([a-z])([A-Z])/g, (_, a, b) => `${a}-${b.toLowerCase()}`);
30
+ };
31
+ const isChildSelectorContext = (context) => {
32
+ return context.startsWith("[") && context.endsWith("]") && context.length > 2;
33
+ };
34
+ const normalizeChildSelectorContext = (context) => {
35
+ if (!isChildSelectorContext(context)) return null;
36
+ return context.slice(1, -1).replace(/_/g, " ").trim();
37
+ };
38
+ const applyChildSelectors = (baseSelector, contexts) => {
39
+ return contexts.map(normalizeChildSelectorContext).filter((selector) => Boolean(selector)).reduce((current, selector) => {
40
+ if (selector.includes("&")) return selector.replace(/&/g, current);
41
+ return `${current} ${selector}`.trim();
42
+ }, baseSelector);
43
+ };
44
+
45
+ //#endregion
46
+ exports.applyChildSelectors = applyChildSelectors;
47
+ exports.camelCaseToDash = camelCaseToDash;
48
+ exports.classTokenToSelector = classTokenToSelector;
49
+ exports.contextToCSSVariable = contextToCSSVariable;
50
+ exports.contextToClassName = contextToClassName;
51
+ exports.dashToCamelCase = dashToCamelCase;
52
+ exports.escapeClassName = escapeClassName;
@@ -0,0 +1,46 @@
1
+ import "css.escape";
2
+
3
+ //#region src/api/names.ts
4
+ const contextToClassName = (name, value, contexts, escape = true, prefix = "") => {
5
+ const parts = value !== null ? [name, Array.isArray(value) ? value.join("_") : String(value)] : [name];
6
+ const className = `${prefix}${[...contexts, ...parts].join(":")}`;
7
+ return escape ? camelCaseToDash(escapeClassName(className)) : camelCaseToDash(className.replace(/ /g, "_"));
8
+ };
9
+ const contextToCSSVariable = (name, value, contexts, prefix = "") => {
10
+ return camelCaseToDash(escapeCSSVariable(`--${prefix}${[...contexts, name].join("-")}`));
11
+ };
12
+ const escapeCSSVariable = (css) => {
13
+ return css.replace(/ /g, "-").replace(/([^a-z0-9-_])/gi, "\\$1");
14
+ };
15
+ const escapeClassName = (css) => {
16
+ return CSS.escape(css.replace(/ /g, "_")).replace(/([^\\]):/g, "\\:");
17
+ };
18
+ const escapeAttributeValue = (value) => {
19
+ return value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
20
+ };
21
+ const classTokenToSelector = (token) => {
22
+ if (token.includes("{") || token.includes("}")) return `[class~="${escapeAttributeValue(token)}"]`;
23
+ return `.${escapeClassName(token)}`;
24
+ };
25
+ const dashToCamelCase = (str) => {
26
+ return str.replace(/-([a-z])/g, (_, a) => a.toUpperCase());
27
+ };
28
+ const camelCaseToDash = (str) => {
29
+ return str.replace(/([a-z])([A-Z])/g, (_, a, b) => `${a}-${b.toLowerCase()}`);
30
+ };
31
+ const isChildSelectorContext = (context) => {
32
+ return context.startsWith("[") && context.endsWith("]") && context.length > 2;
33
+ };
34
+ const normalizeChildSelectorContext = (context) => {
35
+ if (!isChildSelectorContext(context)) return null;
36
+ return context.slice(1, -1).replace(/_/g, " ").trim();
37
+ };
38
+ const applyChildSelectors = (baseSelector, contexts) => {
39
+ return contexts.map(normalizeChildSelectorContext).filter((selector) => Boolean(selector)).reduce((current, selector) => {
40
+ if (selector.includes("&")) return selector.replace(/&/g, current);
41
+ return `${current} ${selector}`.trim();
42
+ }, baseSelector);
43
+ };
44
+
45
+ //#endregion
46
+ export { applyChildSelectors, camelCaseToDash, classTokenToSelector, contextToCSSVariable, contextToClassName, dashToCamelCase, escapeClassName };
@@ -0,0 +1,37 @@
1
+
2
+ //#region src/api/noopCss.ts
3
+ var NoopCSS = class {
4
+ api;
5
+ imports = /* @__PURE__ */ new Set();
6
+ root = /* @__PURE__ */ new Set();
7
+ rootSources = /* @__PURE__ */ new Map();
8
+ customBlocks = /* @__PURE__ */ new Map();
9
+ customByFile = /* @__PURE__ */ new Map();
10
+ ruleMeta = /* @__PURE__ */ new Map();
11
+ ruleSources = /* @__PURE__ */ new Map();
12
+ source = null;
13
+ constructor(api) {
14
+ this.api = api;
15
+ }
16
+ get text() {
17
+ return "";
18
+ }
19
+ selector() {}
20
+ rule() {}
21
+ addRoot() {}
22
+ removeSource() {}
23
+ addImport() {}
24
+ addRule() {}
25
+ compareAtRuleOrder() {
26
+ return 0;
27
+ }
28
+ write() {}
29
+ reset() {}
30
+ syncCustomBlocks() {}
31
+ getCustomText() {
32
+ return "";
33
+ }
34
+ };
35
+
36
+ //#endregion
37
+ exports.NoopCSS = NoopCSS;
@@ -0,0 +1,36 @@
1
+ //#region src/api/noopCss.ts
2
+ var NoopCSS = class {
3
+ api;
4
+ imports = /* @__PURE__ */ new Set();
5
+ root = /* @__PURE__ */ new Set();
6
+ rootSources = /* @__PURE__ */ new Map();
7
+ customBlocks = /* @__PURE__ */ new Map();
8
+ customByFile = /* @__PURE__ */ new Map();
9
+ ruleMeta = /* @__PURE__ */ new Map();
10
+ ruleSources = /* @__PURE__ */ new Map();
11
+ source = null;
12
+ constructor(api) {
13
+ this.api = api;
14
+ }
15
+ get text() {
16
+ return "";
17
+ }
18
+ selector() {}
19
+ rule() {}
20
+ addRoot() {}
21
+ removeSource() {}
22
+ addImport() {}
23
+ addRule() {}
24
+ compareAtRuleOrder() {
25
+ return 0;
26
+ }
27
+ write() {}
28
+ reset() {}
29
+ syncCustomBlocks() {}
30
+ getCustomText() {
31
+ return "";
32
+ }
33
+ };
34
+
35
+ //#endregion
36
+ export { NoopCSS };
@@ -0,0 +1,54 @@
1
+
2
+ //#region src/api/propTree.ts
3
+ function objectToPropTree(obj, output = {}) {
4
+ Object.entries(obj).forEach(([name, value]) => {
5
+ const prop = { value };
6
+ if (value !== null && typeof value === "object" && !Array.isArray(value)) {
7
+ prop.value = {};
8
+ objectToPropTree(value, prop.value);
9
+ }
10
+ output[name] = prop;
11
+ });
12
+ return output;
13
+ }
14
+ function propTreeToObject(tree) {
15
+ return Object.entries(tree).reduce((acc, [name, prop]) => {
16
+ if (!prop.value !== null) acc[name] = prop.value;
17
+ return acc;
18
+ }, {});
19
+ }
20
+ function propTreeToArray(tree) {
21
+ return tree.map((prop) => prop.value);
22
+ }
23
+ function propTreeToValue(tree) {
24
+ if (Array.isArray(tree)) return propTreeToArray(tree);
25
+ if (tree && typeof tree === "object") {
26
+ if ("value" in tree) return tree.value ?? tree;
27
+ return propTreeToObject(tree);
28
+ }
29
+ return tree?.value ?? tree;
30
+ }
31
+ function walkPropTree(tree, callback) {
32
+ Object.entries(tree).forEach(([name, prop]) => {
33
+ callback(name, prop);
34
+ if (prop.value && typeof prop.value === "object" && !Array.isArray(prop.value)) walkPropTree(prop.value, callback);
35
+ });
36
+ }
37
+ function mapPropTree(tree, callback, depth = 0) {
38
+ return Object.entries(tree).reduce((acc, [name, prop]) => {
39
+ if (prop.value && typeof prop.value === "object" && !Array.isArray(prop.value)) acc[name] = {
40
+ ...prop,
41
+ value: mapPropTree(prop.value, callback, depth + 1)
42
+ };
43
+ else acc[name] = callback(name, prop, depth);
44
+ return acc;
45
+ }, tree);
46
+ }
47
+
48
+ //#endregion
49
+ exports.mapPropTree = mapPropTree;
50
+ exports.objectToPropTree = objectToPropTree;
51
+ exports.propTreeToArray = propTreeToArray;
52
+ exports.propTreeToObject = propTreeToObject;
53
+ exports.propTreeToValue = propTreeToValue;
54
+ exports.walkPropTree = walkPropTree;
@@ -0,0 +1,48 @@
1
+ //#region src/api/propTree.ts
2
+ function objectToPropTree(obj, output = {}) {
3
+ Object.entries(obj).forEach(([name, value]) => {
4
+ const prop = { value };
5
+ if (value !== null && typeof value === "object" && !Array.isArray(value)) {
6
+ prop.value = {};
7
+ objectToPropTree(value, prop.value);
8
+ }
9
+ output[name] = prop;
10
+ });
11
+ return output;
12
+ }
13
+ function propTreeToObject(tree) {
14
+ return Object.entries(tree).reduce((acc, [name, prop]) => {
15
+ if (!prop.value !== null) acc[name] = prop.value;
16
+ return acc;
17
+ }, {});
18
+ }
19
+ function propTreeToArray(tree) {
20
+ return tree.map((prop) => prop.value);
21
+ }
22
+ function propTreeToValue(tree) {
23
+ if (Array.isArray(tree)) return propTreeToArray(tree);
24
+ if (tree && typeof tree === "object") {
25
+ if ("value" in tree) return tree.value ?? tree;
26
+ return propTreeToObject(tree);
27
+ }
28
+ return tree?.value ?? tree;
29
+ }
30
+ function walkPropTree(tree, callback) {
31
+ Object.entries(tree).forEach(([name, prop]) => {
32
+ callback(name, prop);
33
+ if (prop.value && typeof prop.value === "object" && !Array.isArray(prop.value)) walkPropTree(prop.value, callback);
34
+ });
35
+ }
36
+ function mapPropTree(tree, callback, depth = 0) {
37
+ return Object.entries(tree).reduce((acc, [name, prop]) => {
38
+ if (prop.value && typeof prop.value === "object" && !Array.isArray(prop.value)) acc[name] = {
39
+ ...prop,
40
+ value: mapPropTree(prop.value, callback, depth + 1)
41
+ };
42
+ else acc[name] = callback(name, prop, depth);
43
+ return acc;
44
+ }, tree);
45
+ }
46
+
47
+ //#endregion
48
+ export { mapPropTree, objectToPropTree, propTreeToArray, propTreeToObject, propTreeToValue, walkPropTree };
@@ -0,0 +1,112 @@
1
+ const require_dictionary = require('./dictionary.cjs');
2
+ const require_css = require('./css.cjs');
3
+ const require_api_noopCss = require('./noopCss.cjs');
4
+ const require_propTree = require('./propTree.cjs');
5
+ const require_names = require('./names.cjs');
6
+ const require_js = require('./file/js.cjs');
7
+ const require_debug = require('../shared/debug.cjs');
8
+ const require_server = require('../log/server.cjs');
9
+
10
+ //#region src/api/server.ts
11
+ let api = null;
12
+ async function createApi(config, force = false) {
13
+ if (!force && api) return api;
14
+ const debug = require_debug.resolveDebugValue(config.debug);
15
+ const resolvedConfig = {
16
+ ...config,
17
+ debug
18
+ };
19
+ const logRoot = require_server.createLogger("boss", debug);
20
+ logRoot.child("api").log("Create server API");
21
+ api = {
22
+ unit: "px",
23
+ trigger,
24
+ isServer: true,
25
+ log: logRoot,
26
+ userConfig: resolvedConfig,
27
+ ...resolvedConfig,
28
+ plugins: Array.isArray(resolvedConfig.plugins) ? resolvedConfig.plugins : [],
29
+ file: {},
30
+ propTreeToObject: require_propTree.propTreeToObject,
31
+ propTreeToArray: require_propTree.propTreeToArray,
32
+ propTreeToValue: require_propTree.propTreeToValue,
33
+ walkPropTree: require_propTree.walkPropTree,
34
+ objectToPropTree: require_propTree.objectToPropTree,
35
+ mapPropTree: require_propTree.mapPropTree,
36
+ escapeClassName: require_names.escapeClassName,
37
+ contextToCSSVariable: require_names.contextToCSSVariable,
38
+ contextToClassName: require_names.contextToClassName,
39
+ camelCaseToDash: require_names.camelCaseToDash,
40
+ dashToCamelCase: require_names.dashToCamelCase,
41
+ classTokenToSelector: require_names.classTokenToSelector,
42
+ applyChildSelectors: require_names.applyChildSelectors
43
+ };
44
+ const runtimeOnly = config?.runtime?.only === true;
45
+ api.dictionary = new require_dictionary.Dictionary(api);
46
+ api.css = runtimeOnly ? new require_api_noopCss.NoopCSS(api) : new require_css.CSS(api);
47
+ api.file.js = new require_js.default(api, { path: "index.js" });
48
+ api.file.native = new require_js.default(api, { path: "native.js" });
49
+ const initBaseTypes = (dts, options) => {
50
+ const valueTypes = [
51
+ "string",
52
+ "number",
53
+ "boolean",
54
+ ...options.includeObject ? ["Record<string, any>"] : []
55
+ ];
56
+ const arrayTypes = valueTypes.concat("$$PropFunction").join(" | ");
57
+ dts.set("body", "$$:FinalProps", `export type $$FinalProps = {}`).set("body", "$$:PropFunction", `type $$PropFunction = (...args: any) => $$PropValues`).set("body", "$$:PropValues", `type $$PropValues =
58
+ | ${valueTypes.join("\n | ")}
59
+ | (${arrayTypes})[]
60
+ | $$PropFunction`);
61
+ };
62
+ initBaseTypes(api.file.js.dts, { includeObject: false });
63
+ initBaseTypes(api.file.native.dts, { includeObject: true });
64
+ await trigger("onBoot");
65
+ const autoLoadCss = config?.css?.autoLoad ?? true;
66
+ if (!runtimeOnly && autoLoadCss) api.file.js.import({ from: "./styles.css" });
67
+ await trigger("onReady");
68
+ return api;
69
+ }
70
+ async function trigger(eventName, data, test = () => true) {
71
+ if (!api) return;
72
+ const currentApi = api;
73
+ const log = currentApi.log.child("api").child("trigger");
74
+ const resolveSource = (input) => {
75
+ if (!input) return null;
76
+ if (typeof input.file === "string") return input.file ?? null;
77
+ if (input.file && typeof input.file?.path === "string") return input.file?.path ?? null;
78
+ if (typeof input.path === "string") return input.path ?? null;
79
+ return null;
80
+ };
81
+ const nextSource = resolveSource(data);
82
+ const previousSource = currentApi.css?.source ?? null;
83
+ const shouldSetSource = nextSource !== null && nextSource !== void 0;
84
+ if (currentApi.css && shouldSetSource) currentApi.css.setSource ? currentApi.css.setSource(nextSource) : currentApi.css.source = nextSource;
85
+ try {
86
+ for (const plugin of currentApi.plugins) {
87
+ if (!plugin[eventName]) continue;
88
+ const testResult = await test(plugin);
89
+ const dataName = data && typeof data === "object" && "name" in data ? String(data.name ?? "") : "";
90
+ log.log(`${!testResult ? "skip: " : ""}${eventName}${dataName ? `:${dataName}` : ""}`);
91
+ if (!testResult) continue;
92
+ const handlers = Array.isArray(plugin[eventName]) ? plugin[eventName] : [plugin[eventName]];
93
+ for (const [index, handler] of Object.entries(handlers)) {
94
+ log.log("|-", plugin.name, `${+index + 1}/${handlers.length}`);
95
+ await handler(currentApi, data)?.catch((err) => {
96
+ throw new Error(`Error in ${plugin.name}:${eventName} handler: ${err.message}`);
97
+ });
98
+ }
99
+ }
100
+ } finally {
101
+ if (currentApi.css && shouldSetSource) currentApi.css.setSource ? currentApi.css.setSource(previousSource) : currentApi.css.source = previousSource;
102
+ }
103
+ }
104
+
105
+ //#endregion
106
+ Object.defineProperty(exports, 'api', {
107
+ enumerable: true,
108
+ get: function () {
109
+ return api;
110
+ }
111
+ });
112
+ exports.createApi = createApi;
@@ -0,0 +1,106 @@
1
+ import { Dictionary } from "./dictionary.mjs";
2
+ import { CSS } from "./css.mjs";
3
+ import { NoopCSS } from "./noopCss.mjs";
4
+ import { mapPropTree, objectToPropTree, propTreeToArray, propTreeToObject, propTreeToValue, walkPropTree } from "./propTree.mjs";
5
+ import { applyChildSelectors, camelCaseToDash, classTokenToSelector, contextToCSSVariable, contextToClassName, dashToCamelCase, escapeClassName } from "./names.mjs";
6
+ import JS from "./file/js.mjs";
7
+ import { resolveDebugValue } from "../shared/debug.mjs";
8
+ import { createLogger } from "../log/server.mjs";
9
+
10
+ //#region src/api/server.ts
11
+ let api = null;
12
+ async function createApi(config, force = false) {
13
+ if (!force && api) return api;
14
+ const debug = resolveDebugValue(config.debug);
15
+ const resolvedConfig = {
16
+ ...config,
17
+ debug
18
+ };
19
+ const logRoot = createLogger("boss", debug);
20
+ logRoot.child("api").log("Create server API");
21
+ api = {
22
+ unit: "px",
23
+ trigger,
24
+ isServer: true,
25
+ log: logRoot,
26
+ userConfig: resolvedConfig,
27
+ ...resolvedConfig,
28
+ plugins: Array.isArray(resolvedConfig.plugins) ? resolvedConfig.plugins : [],
29
+ file: {},
30
+ propTreeToObject,
31
+ propTreeToArray,
32
+ propTreeToValue,
33
+ walkPropTree,
34
+ objectToPropTree,
35
+ mapPropTree,
36
+ escapeClassName,
37
+ contextToCSSVariable,
38
+ contextToClassName,
39
+ camelCaseToDash,
40
+ dashToCamelCase,
41
+ classTokenToSelector,
42
+ applyChildSelectors
43
+ };
44
+ const runtimeOnly = config?.runtime?.only === true;
45
+ api.dictionary = new Dictionary(api);
46
+ api.css = runtimeOnly ? new NoopCSS(api) : new CSS(api);
47
+ api.file.js = new JS(api, { path: "index.js" });
48
+ api.file.native = new JS(api, { path: "native.js" });
49
+ const initBaseTypes = (dts, options) => {
50
+ const valueTypes = [
51
+ "string",
52
+ "number",
53
+ "boolean",
54
+ ...options.includeObject ? ["Record<string, any>"] : []
55
+ ];
56
+ const arrayTypes = valueTypes.concat("$$PropFunction").join(" | ");
57
+ dts.set("body", "$$:FinalProps", `export type $$FinalProps = {}`).set("body", "$$:PropFunction", `type $$PropFunction = (...args: any) => $$PropValues`).set("body", "$$:PropValues", `type $$PropValues =
58
+ | ${valueTypes.join("\n | ")}
59
+ | (${arrayTypes})[]
60
+ | $$PropFunction`);
61
+ };
62
+ initBaseTypes(api.file.js.dts, { includeObject: false });
63
+ initBaseTypes(api.file.native.dts, { includeObject: true });
64
+ await trigger("onBoot");
65
+ const autoLoadCss = config?.css?.autoLoad ?? true;
66
+ if (!runtimeOnly && autoLoadCss) api.file.js.import({ from: "./styles.css" });
67
+ await trigger("onReady");
68
+ return api;
69
+ }
70
+ async function trigger(eventName, data, test = () => true) {
71
+ if (!api) return;
72
+ const currentApi = api;
73
+ const log = currentApi.log.child("api").child("trigger");
74
+ const resolveSource = (input) => {
75
+ if (!input) return null;
76
+ if (typeof input.file === "string") return input.file ?? null;
77
+ if (input.file && typeof input.file?.path === "string") return input.file?.path ?? null;
78
+ if (typeof input.path === "string") return input.path ?? null;
79
+ return null;
80
+ };
81
+ const nextSource = resolveSource(data);
82
+ const previousSource = currentApi.css?.source ?? null;
83
+ const shouldSetSource = nextSource !== null && nextSource !== void 0;
84
+ if (currentApi.css && shouldSetSource) currentApi.css.setSource ? currentApi.css.setSource(nextSource) : currentApi.css.source = nextSource;
85
+ try {
86
+ for (const plugin of currentApi.plugins) {
87
+ if (!plugin[eventName]) continue;
88
+ const testResult = await test(plugin);
89
+ const dataName = data && typeof data === "object" && "name" in data ? String(data.name ?? "") : "";
90
+ log.log(`${!testResult ? "skip: " : ""}${eventName}${dataName ? `:${dataName}` : ""}`);
91
+ if (!testResult) continue;
92
+ const handlers = Array.isArray(plugin[eventName]) ? plugin[eventName] : [plugin[eventName]];
93
+ for (const [index, handler] of Object.entries(handlers)) {
94
+ log.log("|-", plugin.name, `${+index + 1}/${handlers.length}`);
95
+ await handler(currentApi, data)?.catch((err) => {
96
+ throw new Error(`Error in ${plugin.name}:${eventName} handler: ${err.message}`);
97
+ });
98
+ }
99
+ }
100
+ } finally {
101
+ if (currentApi.css && shouldSetSource) currentApi.css.setSource ? currentApi.css.setSource(previousSource) : currentApi.css.source = previousSource;
102
+ }
103
+ }
104
+
105
+ //#endregion
106
+ export { api, createApi };
@@ -0,0 +1 @@
1
+ const require_build = require('../tasks/build.cjs');
@@ -0,0 +1,3 @@
1
+ import { resolveBuildConfig, runBuild } from "../tasks/build.mjs";
2
+
3
+ export { };
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env node
2
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
3
+ const require_api_config = require('../api/config.cjs');
4
+ const require_utils = require('./utils.cjs');
5
+ let _clack_prompts = require("@clack/prompts");
6
+ let yargs_yargs = require("yargs/yargs");
7
+ yargs_yargs = require_rolldown_runtime.__toESM(yargs_yargs);
8
+ let yargs_helpers = require("yargs/helpers");
9
+
10
+ //#region src/cli/index.ts
11
+ (0, _clack_prompts.intro)("boss");
12
+ (async () => {
13
+ const argv = (0, yargs_yargs.default)((0, yargs_helpers.hideBin)(process.argv)).parserConfiguration({
14
+ "camel-case-expansion": true,
15
+ "dot-notation": false,
16
+ "populate--": true
17
+ }).option("yes", {
18
+ alias: "y",
19
+ type: "boolean"
20
+ }).option("globals", { type: "boolean" }).option("eslint-plugin", { type: "boolean" }).option("port", { type: "number" }).option("max-port", { type: "number" }).help(false).version(false).parseSync();
21
+ const userConfig = await require_api_config.loadConfig();
22
+ await require_utils.runTask({
23
+ argv,
24
+ runtimeType: process.title,
25
+ procedures: [],
26
+ userConfig
27
+ });
28
+ })();
29
+
30
+ //#endregion
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+ import { loadConfig } from "../api/config.mjs";
3
+ import { runTask } from "./utils.mjs";
4
+ import { intro } from "@clack/prompts";
5
+ import yargs from "yargs/yargs";
6
+ import { hideBin } from "yargs/helpers";
7
+
8
+ //#region src/cli/index.ts
9
+ intro("boss");
10
+ (async () => {
11
+ const argv = yargs(hideBin(process.argv)).parserConfiguration({
12
+ "camel-case-expansion": true,
13
+ "dot-notation": false,
14
+ "populate--": true
15
+ }).option("yes", {
16
+ alias: "y",
17
+ type: "boolean"
18
+ }).option("globals", { type: "boolean" }).option("eslint-plugin", { type: "boolean" }).option("port", { type: "number" }).option("max-port", { type: "number" }).help(false).version(false).parseSync();
19
+ const userConfig = await loadConfig();
20
+ await runTask({
21
+ argv,
22
+ runtimeType: process.title,
23
+ procedures: [],
24
+ userConfig
25
+ });
26
+ })();
27
+
28
+ //#endregion
29
+ export { };