boss-css 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (268) hide show
  1. package/README.md +1 -0
  2. package/dist/_virtual/rolldown_runtime.cjs +43 -0
  3. package/dist/_virtual/rolldown_runtime.mjs +20 -0
  4. package/dist/api/browser.cjs +54 -0
  5. package/dist/api/browser.mjs +48 -0
  6. package/dist/api/config.cjs +94 -0
  7. package/dist/api/config.mjs +91 -0
  8. package/dist/api/css.cjs +304 -0
  9. package/dist/api/css.mjs +303 -0
  10. package/dist/api/dictionary.cjs +218 -0
  11. package/dist/api/dictionary.mjs +215 -0
  12. package/dist/api/file/dts.cjs +21 -0
  13. package/dist/api/file/dts.mjs +21 -0
  14. package/dist/api/file/file.cjs +123 -0
  15. package/dist/api/file/file.mjs +120 -0
  16. package/dist/api/file/js.cjs +118 -0
  17. package/dist/api/file/js.mjs +116 -0
  18. package/dist/api/names.cjs +52 -0
  19. package/dist/api/names.mjs +46 -0
  20. package/dist/api/noopCss.cjs +37 -0
  21. package/dist/api/noopCss.mjs +36 -0
  22. package/dist/api/propTree.cjs +54 -0
  23. package/dist/api/propTree.mjs +48 -0
  24. package/dist/api/server.cjs +112 -0
  25. package/dist/api/server.mjs +106 -0
  26. package/dist/cli/build.cjs +1 -0
  27. package/dist/cli/build.mjs +3 -0
  28. package/dist/cli/index.cjs +30 -0
  29. package/dist/cli/index.mjs +29 -0
  30. package/dist/cli/tasks/build.cjs +24 -0
  31. package/dist/cli/tasks/build.mjs +23 -0
  32. package/dist/cli/tasks/choose.cjs +47 -0
  33. package/dist/cli/tasks/choose.mjs +46 -0
  34. package/dist/cli/tasks/compile.cjs +68 -0
  35. package/dist/cli/tasks/compile.mjs +67 -0
  36. package/dist/cli/tasks/dev.cjs +51 -0
  37. package/dist/cli/tasks/dev.mjs +48 -0
  38. package/dist/cli/tasks/init.cjs +1835 -0
  39. package/dist/cli/tasks/init.mjs +1831 -0
  40. package/dist/cli/tasks/watch.cjs +38 -0
  41. package/dist/cli/tasks/watch.mjs +37 -0
  42. package/dist/cli/templates/init.cjs +82 -0
  43. package/dist/cli/templates/init.mjs +78 -0
  44. package/dist/cli/types.cjs +13 -0
  45. package/dist/cli/types.mjs +13 -0
  46. package/dist/cli/utils.cjs +43 -0
  47. package/dist/cli/utils.mjs +41 -0
  48. package/dist/compile/classname-strategy.cjs +79 -0
  49. package/dist/compile/classname-strategy.mjs +77 -0
  50. package/dist/compile/classname.cjs +366 -0
  51. package/dist/compile/classname.mjs +360 -0
  52. package/dist/compile/index.cjs +238 -0
  53. package/dist/compile/index.mjs +235 -0
  54. package/dist/compile/jsx.cjs +803 -0
  55. package/dist/compile/jsx.mjs +800 -0
  56. package/dist/compile/prepared.cjs +88 -0
  57. package/dist/compile/prepared.mjs +87 -0
  58. package/dist/compile/runtime.cjs +33 -0
  59. package/dist/compile/runtime.mjs +32 -0
  60. package/dist/compile/transform.cjs +371 -0
  61. package/dist/compile/transform.mjs +369 -0
  62. package/dist/cx/index.cjs +93 -0
  63. package/dist/cx/index.mjs +85 -0
  64. package/dist/detect-fw/index.cjs +384 -0
  65. package/dist/detect-fw/index.mjs +379 -0
  66. package/dist/dev/client.cjs +39 -0
  67. package/dist/dev/client.mjs +38 -0
  68. package/dist/dev/plugin/browser.cjs +11 -0
  69. package/dist/dev/plugin/browser.mjs +9 -0
  70. package/dist/dev/plugin/server.cjs +86 -0
  71. package/dist/dev/plugin/server.mjs +78 -0
  72. package/dist/dev/port.cjs +46 -0
  73. package/dist/dev/port.mjs +43 -0
  74. package/dist/dev/runtime.cjs +28 -0
  75. package/dist/dev/runtime.mjs +29 -0
  76. package/dist/dev/server.cjs +808 -0
  77. package/dist/dev/server.mjs +805 -0
  78. package/dist/dev/shared.cjs +6 -0
  79. package/dist/dev/shared.mjs +5 -0
  80. package/dist/eslint-plugin/index.cjs +66 -0
  81. package/dist/eslint-plugin/index.mjs +66 -0
  82. package/dist/eslint-plugin/rules/classnames-only.cjs +68 -0
  83. package/dist/eslint-plugin/rules/classnames-only.mjs +68 -0
  84. package/dist/eslint-plugin/rules/format-classnames.cjs +137 -0
  85. package/dist/eslint-plugin/rules/format-classnames.mjs +136 -0
  86. package/dist/eslint-plugin/rules/no-unknown-classes.cjs +119 -0
  87. package/dist/eslint-plugin/rules/no-unknown-classes.mjs +119 -0
  88. package/dist/eslint-plugin/rules/prefer-classnames.cjs +69 -0
  89. package/dist/eslint-plugin/rules/prefer-classnames.mjs +69 -0
  90. package/dist/eslint-plugin/rules/prefer-token-values.cjs +197 -0
  91. package/dist/eslint-plugin/rules/prefer-token-values.mjs +197 -0
  92. package/dist/eslint-plugin/rules/props-only.cjs +115 -0
  93. package/dist/eslint-plugin/rules/props-only.mjs +115 -0
  94. package/dist/eslint-plugin/rules/redundant-cx.cjs +66 -0
  95. package/dist/eslint-plugin/rules/redundant-cx.mjs +66 -0
  96. package/dist/eslint-plugin/rules/require-prop-functions.cjs +130 -0
  97. package/dist/eslint-plugin/rules/require-prop-functions.mjs +130 -0
  98. package/dist/eslint-plugin/utils/api.cjs +30 -0
  99. package/dist/eslint-plugin/utils/api.mjs +29 -0
  100. package/dist/eslint-plugin/utils/ast.cjs +119 -0
  101. package/dist/eslint-plugin/utils/ast.mjs +112 -0
  102. package/dist/eslint-plugin/utils/boss-classes.cjs +185 -0
  103. package/dist/eslint-plugin/utils/boss-classes.mjs +175 -0
  104. package/dist/eslint-plugin/utils/defaults.cjs +99 -0
  105. package/dist/eslint-plugin/utils/defaults.mjs +93 -0
  106. package/dist/eslint-plugin/utils/format.cjs +20 -0
  107. package/dist/eslint-plugin/utils/format.mjs +19 -0
  108. package/dist/eslint-plugin/utils/order.cjs +76 -0
  109. package/dist/eslint-plugin/utils/order.mjs +76 -0
  110. package/dist/eslint-plugin/utils/property-order.cjs +449 -0
  111. package/dist/eslint-plugin/utils/property-order.mjs +448 -0
  112. package/dist/eslint-plugin/utils/static.cjs +36 -0
  113. package/dist/eslint-plugin/utils/static.mjs +35 -0
  114. package/dist/fontsource/directory.cjs +39588 -0
  115. package/dist/fontsource/directory.mjs +39587 -0
  116. package/dist/fontsource/server.cjs +291 -0
  117. package/dist/fontsource/server.mjs +282 -0
  118. package/dist/index.cjs +10 -0
  119. package/dist/index.mjs +6 -0
  120. package/dist/log/browser.cjs +28 -0
  121. package/dist/log/browser.mjs +28 -0
  122. package/dist/log/server.cjs +32 -0
  123. package/dist/log/server.mjs +30 -0
  124. package/dist/merge/index.cjs +590 -0
  125. package/dist/merge/index.mjs +586 -0
  126. package/dist/native/browser.cjs +78 -0
  127. package/dist/native/browser.mjs +77 -0
  128. package/dist/native/server.cjs +180 -0
  129. package/dist/native/server.mjs +176 -0
  130. package/dist/native/styleTypes.cjs +168 -0
  131. package/dist/native/styleTypes.mjs +164 -0
  132. package/dist/parser/classname/server.cjs +239 -0
  133. package/dist/parser/classname/server.mjs +232 -0
  134. package/dist/parser/jsx/browser.cjs +66 -0
  135. package/dist/parser/jsx/browser.mjs +63 -0
  136. package/dist/parser/jsx/extractCode.cjs +99 -0
  137. package/dist/parser/jsx/extractCode.mjs +98 -0
  138. package/dist/parser/jsx/extractPrepared.cjs +123 -0
  139. package/dist/parser/jsx/extractPrepared.mjs +122 -0
  140. package/dist/parser/jsx/extractProps.cjs +234 -0
  141. package/dist/parser/jsx/extractProps.mjs +232 -0
  142. package/dist/parser/jsx/isDOMProp.cjs +17 -0
  143. package/dist/parser/jsx/isDOMProp.mjs +15 -0
  144. package/dist/parser/jsx/native.cjs +110 -0
  145. package/dist/parser/jsx/native.mjs +108 -0
  146. package/dist/parser/jsx/runtime.cjs +4 -0
  147. package/dist/parser/jsx/runtime.mjs +3 -0
  148. package/dist/parser/jsx/server.cjs +278 -0
  149. package/dist/parser/jsx/server.mjs +268 -0
  150. package/dist/postcss/index.cjs +16 -0
  151. package/dist/postcss/index.mjs +16 -0
  152. package/dist/prop/at/runtime-only.cjs +90 -0
  153. package/dist/prop/at/runtime-only.mjs +88 -0
  154. package/dist/prop/at/server.cjs +282 -0
  155. package/dist/prop/at/server.mjs +268 -0
  156. package/dist/prop/at/shared.cjs +153 -0
  157. package/dist/prop/at/shared.mjs +144 -0
  158. package/dist/prop/bosswind/browser.cjs +18 -0
  159. package/dist/prop/bosswind/browser.mjs +16 -0
  160. package/dist/prop/bosswind/runtime-only.cjs +18 -0
  161. package/dist/prop/bosswind/runtime-only.mjs +16 -0
  162. package/dist/prop/bosswind/server.cjs +81 -0
  163. package/dist/prop/bosswind/server.mjs +72 -0
  164. package/dist/prop/bosswind/shared.cjs +861 -0
  165. package/dist/prop/bosswind/shared.mjs +855 -0
  166. package/dist/prop/bosswind/tailwind-theme.cjs +703 -0
  167. package/dist/prop/bosswind/tailwind-theme.mjs +702 -0
  168. package/dist/prop/child/runtime-only.cjs +18 -0
  169. package/dist/prop/child/runtime-only.mjs +15 -0
  170. package/dist/prop/child/server.cjs +81 -0
  171. package/dist/prop/child/server.mjs +72 -0
  172. package/dist/prop/css/getDtsTemplate.cjs +65 -0
  173. package/dist/prop/css/getDtsTemplate.mjs +63 -0
  174. package/dist/prop/css/runtime-only.cjs +14 -0
  175. package/dist/prop/css/runtime-only.mjs +13 -0
  176. package/dist/prop/css/server.cjs +99 -0
  177. package/dist/prop/css/server.mjs +90 -0
  178. package/dist/prop/pseudo/runtime-only.cjs +23 -0
  179. package/dist/prop/pseudo/runtime-only.mjs +21 -0
  180. package/dist/prop/pseudo/server.cjs +91 -0
  181. package/dist/prop/pseudo/server.mjs +82 -0
  182. package/dist/prop/pseudo/shared.cjs +61 -0
  183. package/dist/prop/pseudo/shared.mjs +60 -0
  184. package/dist/reset/server.cjs +34 -0
  185. package/dist/reset/server.mjs +26 -0
  186. package/dist/runtime/index.cjs +119 -0
  187. package/dist/runtime/index.mjs +118 -0
  188. package/dist/runtime/preact.cjs +4 -0
  189. package/dist/runtime/preact.mjs +3 -0
  190. package/dist/runtime/qwik.cjs +21 -0
  191. package/dist/runtime/qwik.mjs +18 -0
  192. package/dist/runtime/react.cjs +4 -0
  193. package/dist/runtime/react.mjs +3 -0
  194. package/dist/runtime/solid.cjs +15 -0
  195. package/dist/runtime/solid.mjs +14 -0
  196. package/dist/runtime/stencil.cjs +25 -0
  197. package/dist/runtime/stencil.mjs +21 -0
  198. package/dist/runtime/style.cjs +14 -0
  199. package/dist/runtime/style.mjs +13 -0
  200. package/dist/shared/boundaries.cjs +288 -0
  201. package/dist/shared/boundaries.mjs +285 -0
  202. package/dist/shared/customCss.cjs +212 -0
  203. package/dist/shared/customCss.mjs +211 -0
  204. package/dist/shared/debug.cjs +76 -0
  205. package/dist/shared/debug.mjs +74 -0
  206. package/dist/shared/file.cjs +21 -0
  207. package/dist/shared/file.mjs +19 -0
  208. package/dist/shared/framework.cjs +10 -0
  209. package/dist/shared/framework.mjs +9 -0
  210. package/dist/shared/json.cjs +58 -0
  211. package/dist/shared/json.mjs +57 -0
  212. package/dist/shared/types.cjs +11 -0
  213. package/dist/shared/types.mjs +10 -0
  214. package/dist/strategy/classic/runtime-only.cjs +190 -0
  215. package/dist/strategy/classic/runtime-only.mjs +186 -0
  216. package/dist/strategy/classname-first/runtime-only.cjs +138 -0
  217. package/dist/strategy/classname-first/runtime-only.mjs +134 -0
  218. package/dist/strategy/classname-first/server.cjs +139 -0
  219. package/dist/strategy/classname-first/server.mjs +133 -0
  220. package/dist/strategy/classname-only/server.cjs +43 -0
  221. package/dist/strategy/classname-only/server.mjs +35 -0
  222. package/dist/strategy/inline-first/browser.cjs +61 -0
  223. package/dist/strategy/inline-first/browser.mjs +58 -0
  224. package/dist/strategy/inline-first/runtime-only.cjs +159 -0
  225. package/dist/strategy/inline-first/runtime-only.mjs +155 -0
  226. package/dist/strategy/inline-first/server.cjs +92 -0
  227. package/dist/strategy/inline-first/server.mjs +83 -0
  228. package/dist/strategy/runtime/runtime-only.cjs +24 -0
  229. package/dist/strategy/runtime/runtime-only.mjs +22 -0
  230. package/dist/strategy/runtime/server.cjs +72 -0
  231. package/dist/strategy/runtime/server.mjs +63 -0
  232. package/dist/strategy/runtime-only/css.cjs +183 -0
  233. package/dist/strategy/runtime-only/css.mjs +181 -0
  234. package/dist/tasks/build.cjs +88 -0
  235. package/dist/tasks/build.mjs +84 -0
  236. package/dist/tasks/compile.cjs +12 -0
  237. package/dist/tasks/compile.mjs +12 -0
  238. package/dist/tasks/postcss.cjs +116 -0
  239. package/dist/tasks/postcss.mjs +113 -0
  240. package/dist/tasks/session.cjs +46 -0
  241. package/dist/tasks/session.mjs +42 -0
  242. package/dist/tasks/watch.cjs +102 -0
  243. package/dist/tasks/watch.mjs +99 -0
  244. package/dist/transform/cache.cjs +24 -0
  245. package/dist/transform/cache.mjs +21 -0
  246. package/dist/transform/processFile.cjs +26 -0
  247. package/dist/transform/processFile.mjs +24 -0
  248. package/dist/use/token/browser.cjs +65 -0
  249. package/dist/use/token/browser.mjs +61 -0
  250. package/dist/use/token/runtime-only.cjs +245 -0
  251. package/dist/use/token/runtime-only.mjs +239 -0
  252. package/dist/use/token/server.cjs +325 -0
  253. package/dist/use/token/server.mjs +313 -0
  254. package/dist/use/token/vars.cjs +47 -0
  255. package/dist/use/token/vars.mjs +46 -0
  256. package/package.json +300 -4
  257. package/src/api/config.d.ts +1 -0
  258. package/src/fontsource/types.d.ts +50 -0
  259. package/src/packages/document-create-element/createElement.browser.js +3 -0
  260. package/src/packages/document-create-element/createElement.js +7 -0
  261. package/src/packages/document-create-element/package.json +17 -0
  262. package/src/packages/is-css-prop/browser.js +13 -0
  263. package/src/packages/is-css-prop/index.js +13 -0
  264. package/src/packages/is-css-prop/package-lock.json +52 -0
  265. package/src/packages/is-css-prop/package.json +17 -0
  266. package/src/prop/css/csstype.json +4387 -0
  267. package/src/prop/css/package.json +3 -0
  268. package/src/reset/reset.css +259 -0
@@ -0,0 +1,108 @@
1
+ import { api } from "../../api/browser.mjs";
2
+ import { merge } from "../../merge/index.mjs";
3
+ import { cv, cx, scv, sv } from "../../cx/index.mjs";
4
+ import { createElement, forwardRef } from "react";
5
+ import { ActivityIndicator, FlatList, Image, Modal, Pressable, SafeAreaView, ScrollView, SectionList, Switch, Text, TextInput, TouchableHighlight, TouchableOpacity, TouchableWithoutFeedback, View } from "react-native";
6
+
7
+ //#region src/parser/jsx/native.ts
8
+ const nativeComponents = {
9
+ ActivityIndicator,
10
+ FlatList,
11
+ Image,
12
+ Modal,
13
+ Pressable,
14
+ SafeAreaView,
15
+ ScrollView,
16
+ SectionList,
17
+ Switch,
18
+ Text,
19
+ TextInput,
20
+ TouchableHighlight,
21
+ TouchableOpacity,
22
+ TouchableWithoutFeedback,
23
+ View
24
+ };
25
+ const registry = /* @__PURE__ */ new Map();
26
+ const resolveComponent = (tag) => {
27
+ if (!tag) return View;
28
+ if (typeof tag === "string") return nativeComponents[tag] ?? View;
29
+ return tag;
30
+ };
31
+ const getApi = () => {
32
+ if (!api) throw new Error("Boss runtime API is not initialized.");
33
+ return api;
34
+ };
35
+ function createComponent(tag) {
36
+ if (registry.has(tag)) return registry.get(tag);
37
+ const Component = forwardRef((props, ref) => {
38
+ return createElement(resolveComponent(tag), {
39
+ ...props,
40
+ ref
41
+ }, props.children);
42
+ });
43
+ registry.set(tag, Component);
44
+ return Component;
45
+ }
46
+ const getDisplayName = (tag) => {
47
+ if (typeof tag === "string") return tag;
48
+ return tag?.displayName || tag?.name || "Component";
49
+ };
50
+ function factory(tag) {
51
+ return function $$(props, ref) {
52
+ if (tag || ref !== void 0) {
53
+ let tagName = tag;
54
+ const { children, as, ...rest } = props ?? {};
55
+ const resolvedTag = (typeof as === "string" ? as : void 0) || tagName || "View";
56
+ const displayName = getDisplayName(resolvedTag);
57
+ const Component = createComponent(resolvedTag);
58
+ Component.displayName = displayName ? "$$." + displayName : "$$";
59
+ const output = {};
60
+ getApi().trigger("onBrowserObjectStart", {
61
+ input: rest,
62
+ tag: resolvedTag,
63
+ output
64
+ });
65
+ return createElement(Component, output, children);
66
+ }
67
+ return props;
68
+ };
69
+ }
70
+ const defaultElement = factory("View");
71
+ defaultElement.displayName = "$$";
72
+ defaultElement.merge = merge;
73
+ defaultElement.cx = cx;
74
+ defaultElement.cv = cv;
75
+ defaultElement.scv = scv;
76
+ defaultElement.sv = sv;
77
+ defaultElement.css = () => {};
78
+ defaultElement.$ = (input) => input;
79
+ const propIgnoreList = new Set([
80
+ "getDefaultProps",
81
+ "defaultProps",
82
+ "getDerivedStateFromProps",
83
+ "getChildContext",
84
+ "contextTypes",
85
+ "contextType",
86
+ "childContextTypes",
87
+ "propTypes",
88
+ "PropTypes"
89
+ ]);
90
+ const proxy = new Proxy(defaultElement, {
91
+ get(target, prop) {
92
+ if (typeof prop === "symbol" || propIgnoreList.has(prop)) return void 0;
93
+ const targetRecord = target;
94
+ return targetRecord[prop] ||= factory(prop);
95
+ },
96
+ set(target, prop, value) {
97
+ if (typeof prop !== "string") return true;
98
+ const targetRecord = target;
99
+ targetRecord[prop] = typeof prop === "string" && /^[A-Z]/.test(prop) ? (props) => factory(value?.as || "View")({
100
+ ...value,
101
+ ...props
102
+ }) : value;
103
+ return true;
104
+ }
105
+ });
106
+
107
+ //#endregion
108
+ export { factory, proxy };
@@ -0,0 +1,4 @@
1
+ const require_runtime_index = require('../../runtime/index.cjs');
2
+
3
+ exports.factory = require_runtime_index.factory;
4
+ exports.proxy = require_runtime_index.proxy;
@@ -0,0 +1,3 @@
1
+ import { factory, proxy } from "../../runtime/index.mjs";
2
+
3
+ export { factory, proxy };
@@ -0,0 +1,278 @@
1
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
+ const require_customCss = require('../../shared/customCss.cjs');
3
+ const require_extractCode = require('./extractCode.cjs');
4
+ const require_extractPrepared = require('./extractPrepared.cjs');
5
+ const require_extractProps = require('./extractProps.cjs');
6
+ const require_detect_fw_index = require('../../detect-fw/index.cjs');
7
+ let node_path = require("node:path");
8
+ node_path = require_rolldown_runtime.__toESM(node_path);
9
+ let _swc_core = require("@swc/core");
10
+
11
+ //#region src/parser/jsx/server.ts
12
+ var server_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
13
+ name: () => name,
14
+ onBoot: () => onBoot,
15
+ onParse: () => onParse,
16
+ settings: () => settings
17
+ });
18
+ const name = "jsx";
19
+ const settings = new Map([
20
+ ["name", "$$"],
21
+ ["pragma", "react"],
22
+ ["globals", true],
23
+ ["types", true],
24
+ ["emitRuntime", false]
25
+ ]);
26
+ /**
27
+ * Style:
28
+ *
29
+ * \`\`\`
30
+ * {
31
+ * textTransform: 'uppercase',
32
+ * width: 300,
33
+ * hover: {
34
+ * color: 'purple',
35
+ * },
36
+ * at: {
37
+ * mobile: { color: 'cyan' },
38
+ * },
39
+ * onClick: () => {},
40
+ * }
41
+ * \`\`\`
42
+ * PreparedUppercaseA: BaseFn<'div'> & $$JSXFinalProps<'div'>
43
+ */
44
+ let needsRuntime = false;
45
+ const preparedComponents = /* @__PURE__ */ new Map();
46
+ const syncPreparedDts = (api) => {
47
+ const entries = Array.from(preparedComponents.entries()).sort(([a], [b]) => a.localeCompare(b));
48
+ const lines = ["interface $$Prepared {"];
49
+ for (const [name, meta] of entries) {
50
+ const baseType = "\"div\"";
51
+ const getterType = `BaseFn<${baseType}>`;
52
+ const setterType = `$$PreparedDefinitionForSet<${baseType}>`;
53
+ const docLines = [];
54
+ const filePath = formatPreparedPath(meta.filePath);
55
+ if (filePath) docLines.push(`Declared in: ${filePath}`);
56
+ if (meta.styles) docLines.push(`Styles: ${sanitizeDocText(meta.styles)}`);
57
+ if (docLines.length) {
58
+ lines.push(" /**");
59
+ for (const line of docLines) lines.push(` * ${line}`);
60
+ lines.push(" */");
61
+ }
62
+ lines.push(` get ${name}(): ${getterType};`);
63
+ lines.push(` set ${name}(value: ${setterType});`);
64
+ }
65
+ lines.push("}");
66
+ api.file.js.dts.set("body", "jsx:prepared-interface", lines.join("\n"));
67
+ };
68
+ const onBoot = async (api) => {
69
+ needsRuntime = false;
70
+ preparedComponents.clear();
71
+ const needsRuntimeTest = () => needsRuntime || settings.get("emitRuntime") === true;
72
+ const proxyVar = api.file.js.import({
73
+ name: "proxy",
74
+ from: "boss-css/runtime"
75
+ }, needsRuntimeTest);
76
+ api.file.js.importAndConfig({
77
+ name: "onBrowserObjectStart",
78
+ from: "boss-css/parser/jsx/browser"
79
+ }, needsRuntimeTest);
80
+ settings.get("globals") && api.file.js.set("body", "jsx:globalThis", `globalThis.${settings.get("name")} = ${proxyVar}`, needsRuntimeTest);
81
+ api.file.js.set("body", "jsx:export-const", `export const ${settings.get("name")} = ${proxyVar}`, needsRuntimeTest);
82
+ api.file.js.set("foot", "jsx:export-default", `export default ${proxyVar}`, needsRuntimeTest);
83
+ const framework = await require_detect_fw_index.detectFramework({ config: api.userConfig ?? api });
84
+ const jsxTypes = require_detect_fw_index.getJsxTypes(framework);
85
+ const jsxNamespace = jsxTypes.typesNamespace;
86
+ const jsxTypesModule = jsxTypes.typesModule;
87
+ const elementType = jsxTypes.elementType;
88
+ const componentProps = jsxTypes.componentProps;
89
+ const classNameProp = framework.className ?? "className";
90
+ api.framework = framework;
91
+ const runtimeAdapterModule = `boss-css/runtime/${framework.name}`;
92
+ const runtimeApiVar = api.file.js.import({
93
+ name: "*",
94
+ as: "runtimeApi",
95
+ from: runtimeAdapterModule
96
+ }, needsRuntimeTest);
97
+ api.file.js.config({
98
+ from: runtimeAdapterModule,
99
+ config: {
100
+ runtimeApi: runtimeApiVar,
101
+ framework: {
102
+ name: framework.name,
103
+ className: classNameProp
104
+ }
105
+ }
106
+ }, needsRuntimeTest);
107
+ api.file.js.dts.set("head", "jsx:runtime", `import type * as BossJSX from '${jsxTypesModule}'`);
108
+ api.file.js.dts.set("body", "jsx:utils", `type BossIntrinsicElements = BossJSX.${jsxNamespace}.IntrinsicElements
109
+ type BossElement = BossJSX.${jsxNamespace}.Element
110
+ type BossElementType = ${elementType}
111
+ type BossComponentProps<C> = C extends keyof BossIntrinsicElements
112
+ ? BossIntrinsicElements[C]
113
+ : ${componentProps}
114
+ type AsProp<C extends BossElementType> = {
115
+ as?: C
116
+ }
117
+ type PolymorphicComponentProp<C extends BossElementType, Props = {}> = Props & BossComponentProps<C> & AsProp<C>
118
+ type PolymorphicComponentPropWithRef<C extends BossElementType, Props = {}> = PolymorphicComponentProp<C, Props> & {
119
+ ref?: unknown
120
+ }
121
+
122
+ type $$JSXFinalProps<C extends BossElementType> = PolymorphicComponentPropWithRef<C, $$FinalProps>
123
+ declare const $$PreparedBrand: unique symbol
124
+ type $$PreparedProps<Base extends BossElementType = 'div', C extends BossElementType = Base> = Omit<
125
+ $$JSXFinalProps<C>,
126
+ 'children' | 'ref'
127
+ > &
128
+ (C extends Base ? { as?: C } : { as: C })
129
+ type $$PreparedDefinition<Base extends BossElementType = 'div', C extends BossElementType = Base> = $$PreparedProps<Base, C> & {
130
+ readonly [typeof $$PreparedBrand]: true
131
+ }
132
+ type $$PreparedDefinitionForSet<Base extends BossElementType = 'div'> = {
133
+ readonly [typeof $$PreparedBrand]: true
134
+ }
135
+ type $$NoopFn = {
136
+ (props: $$PreparedProps<'div', 'div'>): $$PreparedDefinition<'div', 'div'>
137
+ <C extends BossElementType>(props: $$PreparedProps<'div', C> & { as: C }): $$PreparedDefinition<'div', C>
138
+ (input: string): string
139
+ }
140
+ type StyleFn = {
141
+ (...inputs: $$FinalProps[]): BossComponentProps<'div'>
142
+ }
143
+ type CssFn = {
144
+ (input: TemplateStringsArray, ...exprs: unknown[]): void
145
+ (input: string | Record<string, unknown>): void
146
+ }
147
+
148
+ // This is the base function which will become the proxy
149
+ type BaseFn<T extends BossElementType = 'div'> = {
150
+ <C extends BossElementType = T>(
151
+ props: $$JSXFinalProps<C>,
152
+ contexts?: unknown,
153
+ ): BossElement
154
+ }`);
155
+ syncPreparedDts(api);
156
+ api.file.js.dts.set("body", "jsx:proxy-start", `type ProxyCustomMembers = {
157
+ `).set("body", "jsx:proxy-utils", ` $: $$NoopFn
158
+ merge: (...inputs: import('boss-css/merge').MergeInput[]) => import('boss-css/merge').MergeOutput
159
+ cx: (...inputs: import('boss-css/cx').CxValue[]) => string
160
+ cv: typeof import('boss-css/cx').cv
161
+ scv: typeof import('boss-css/cx').scv
162
+ sv: typeof import('boss-css/cx').sv
163
+ css: CssFn
164
+ style: StyleFn
165
+ `).set("body", "jsx:proxy-custom-members", ``).set("body", "jsx:proxy-custom-members-end", `}`).set("body", "jsx:proxy-type", `type Proxy = BaseFn & {
166
+ [T in keyof BossIntrinsicElements]: BaseFn<T>
167
+ } & $$Prepared & ProxyCustomMembers`);
168
+ api.file.js.dts.replace("body", "$$:FinalProps", (value) => {
169
+ return `${value} & { ${/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(classNameProp) ? classNameProp : JSON.stringify(classNameProp)}?: import('boss-css/cx').CxValue }`;
170
+ });
171
+ api.file.js.dts.set("foot", "jsx:export", `export declare const $$: Proxy`);
172
+ if (settings.get("globals")) api.file.js.dts.set("foot", "jsx:globals", `declare global {
173
+ const $$: Proxy
174
+ }`);
175
+ api.file.js.dts.set("foot", "$$:default-export", `export default $$`);
176
+ };
177
+ const onParse = async (api, input) => {
178
+ const log = api.log.child("parser").child("jsx");
179
+ const { content } = input;
180
+ const filePath = input.path || input.file;
181
+ const prepared = require_extractPrepared.extractPreparedComponents(content, filePath);
182
+ let preparedDirty = false;
183
+ for (const entry of prepared) {
184
+ const existing = preparedComponents.get(entry.name);
185
+ if (!existing || existing.asTag !== entry.asTag || existing.asDynamic !== entry.asDynamic || existing.filePath !== entry.filePath || existing.styles !== entry.styles) {
186
+ preparedComponents.set(entry.name, entry);
187
+ preparedDirty = true;
188
+ }
189
+ }
190
+ if (preparedDirty) syncPreparedDts(api);
191
+ if (input.preparedOnly) return;
192
+ const extractedCodes = require_extractCode.extractCode(content);
193
+ const results = await require_extractProps.extractPropTrees(extractedCodes);
194
+ needsRuntime ||= !!results.length;
195
+ for (const [key, tree] of Object.entries(results)) {
196
+ log.log("onPropTree", tree);
197
+ await api.trigger("onPropTree", {
198
+ input: api.propTreeToObject(tree),
199
+ tree,
200
+ preferVariables: true,
201
+ file: input,
202
+ code: extractedCodes[key],
203
+ parser: "jsx"
204
+ });
205
+ }
206
+ if (filePath) {
207
+ const customBlocks = extractCustomCssBlocks(api, content, filePath);
208
+ api.css?.syncCustomBlocks?.(filePath, customBlocks);
209
+ }
210
+ };
211
+ const customCssExtensions = new Set([
212
+ ".js",
213
+ ".jsx",
214
+ ".ts",
215
+ ".tsx",
216
+ ".mjs",
217
+ ".cjs"
218
+ ]);
219
+ const extractCustomCssBlocks = (api, content, filePath) => {
220
+ const ext = node_path.default.extname(filePath);
221
+ if (!customCssExtensions.has(ext)) return [];
222
+ if (!content.includes("$$.css")) return [];
223
+ let program;
224
+ try {
225
+ const isTs = ext === ".ts" || ext === ".tsx";
226
+ const isJsx = ext === ".jsx" || ext === ".tsx" || ext === ".js" || ext === ".mjs" || ext === ".cjs";
227
+ program = (0, _swc_core.parseSync)(content, {
228
+ syntax: isTs ? "typescript" : "ecmascript",
229
+ tsx: isTs && isJsx,
230
+ jsx: !isTs && isJsx
231
+ });
232
+ } catch {
233
+ return [];
234
+ }
235
+ const blocks = [];
236
+ const walk = (node) => {
237
+ if (!node || typeof node !== "object") return;
238
+ if (Array.isArray(node)) {
239
+ node.forEach(walk);
240
+ return;
241
+ }
242
+ const record = node;
243
+ if (record.type === "TaggedTemplateExpression" || record.type === "CallExpression") {
244
+ const cssText = require_customCss.extractCustomCssText(node, api);
245
+ if (cssText != null) {
246
+ const start = record.span?.start ?? 0;
247
+ const end = record.span?.end ?? 0;
248
+ blocks.push({
249
+ start,
250
+ end,
251
+ cssText
252
+ });
253
+ }
254
+ }
255
+ for (const value of Object.values(record)) walk(value);
256
+ };
257
+ walk(program);
258
+ return blocks;
259
+ };
260
+ const formatPreparedPath = (filePath) => {
261
+ if (!filePath) return null;
262
+ const relative = node_path.default.relative(process.cwd(), filePath);
263
+ if (!relative || relative.startsWith("..")) return filePath;
264
+ return relative;
265
+ };
266
+ const sanitizeDocText = (value) => value.replace(/\*\//g, "*\\/");
267
+
268
+ //#endregion
269
+ exports.name = name;
270
+ exports.onBoot = onBoot;
271
+ exports.onParse = onParse;
272
+ Object.defineProperty(exports, 'server_exports', {
273
+ enumerable: true,
274
+ get: function () {
275
+ return server_exports;
276
+ }
277
+ });
278
+ exports.settings = settings;
@@ -0,0 +1,268 @@
1
+ import { __exportAll } from "../../_virtual/rolldown_runtime.mjs";
2
+ import { extractCustomCssText } from "../../shared/customCss.mjs";
3
+ import { extractCode } from "./extractCode.mjs";
4
+ import { extractPreparedComponents } from "./extractPrepared.mjs";
5
+ import { extractPropTrees } from "./extractProps.mjs";
6
+ import { detectFramework, getJsxTypes } from "../../detect-fw/index.mjs";
7
+ import path from "node:path";
8
+ import { parseSync } from "@swc/core";
9
+
10
+ //#region src/parser/jsx/server.ts
11
+ var server_exports = /* @__PURE__ */ __exportAll({
12
+ name: () => name,
13
+ onBoot: () => onBoot,
14
+ onParse: () => onParse,
15
+ settings: () => settings
16
+ });
17
+ const name = "jsx";
18
+ const settings = new Map([
19
+ ["name", "$$"],
20
+ ["pragma", "react"],
21
+ ["globals", true],
22
+ ["types", true],
23
+ ["emitRuntime", false]
24
+ ]);
25
+ /**
26
+ * Style:
27
+ *
28
+ * \`\`\`
29
+ * {
30
+ * textTransform: 'uppercase',
31
+ * width: 300,
32
+ * hover: {
33
+ * color: 'purple',
34
+ * },
35
+ * at: {
36
+ * mobile: { color: 'cyan' },
37
+ * },
38
+ * onClick: () => {},
39
+ * }
40
+ * \`\`\`
41
+ * PreparedUppercaseA: BaseFn<'div'> & $$JSXFinalProps<'div'>
42
+ */
43
+ let needsRuntime = false;
44
+ const preparedComponents = /* @__PURE__ */ new Map();
45
+ const syncPreparedDts = (api) => {
46
+ const entries = Array.from(preparedComponents.entries()).sort(([a], [b]) => a.localeCompare(b));
47
+ const lines = ["interface $$Prepared {"];
48
+ for (const [name, meta] of entries) {
49
+ const baseType = "\"div\"";
50
+ const getterType = `BaseFn<${baseType}>`;
51
+ const setterType = `$$PreparedDefinitionForSet<${baseType}>`;
52
+ const docLines = [];
53
+ const filePath = formatPreparedPath(meta.filePath);
54
+ if (filePath) docLines.push(`Declared in: ${filePath}`);
55
+ if (meta.styles) docLines.push(`Styles: ${sanitizeDocText(meta.styles)}`);
56
+ if (docLines.length) {
57
+ lines.push(" /**");
58
+ for (const line of docLines) lines.push(` * ${line}`);
59
+ lines.push(" */");
60
+ }
61
+ lines.push(` get ${name}(): ${getterType};`);
62
+ lines.push(` set ${name}(value: ${setterType});`);
63
+ }
64
+ lines.push("}");
65
+ api.file.js.dts.set("body", "jsx:prepared-interface", lines.join("\n"));
66
+ };
67
+ const onBoot = async (api) => {
68
+ needsRuntime = false;
69
+ preparedComponents.clear();
70
+ const needsRuntimeTest = () => needsRuntime || settings.get("emitRuntime") === true;
71
+ const proxyVar = api.file.js.import({
72
+ name: "proxy",
73
+ from: "boss-css/runtime"
74
+ }, needsRuntimeTest);
75
+ api.file.js.importAndConfig({
76
+ name: "onBrowserObjectStart",
77
+ from: "boss-css/parser/jsx/browser"
78
+ }, needsRuntimeTest);
79
+ settings.get("globals") && api.file.js.set("body", "jsx:globalThis", `globalThis.${settings.get("name")} = ${proxyVar}`, needsRuntimeTest);
80
+ api.file.js.set("body", "jsx:export-const", `export const ${settings.get("name")} = ${proxyVar}`, needsRuntimeTest);
81
+ api.file.js.set("foot", "jsx:export-default", `export default ${proxyVar}`, needsRuntimeTest);
82
+ const framework = await detectFramework({ config: api.userConfig ?? api });
83
+ const jsxTypes = getJsxTypes(framework);
84
+ const jsxNamespace = jsxTypes.typesNamespace;
85
+ const jsxTypesModule = jsxTypes.typesModule;
86
+ const elementType = jsxTypes.elementType;
87
+ const componentProps = jsxTypes.componentProps;
88
+ const classNameProp = framework.className ?? "className";
89
+ api.framework = framework;
90
+ const runtimeAdapterModule = `boss-css/runtime/${framework.name}`;
91
+ const runtimeApiVar = api.file.js.import({
92
+ name: "*",
93
+ as: "runtimeApi",
94
+ from: runtimeAdapterModule
95
+ }, needsRuntimeTest);
96
+ api.file.js.config({
97
+ from: runtimeAdapterModule,
98
+ config: {
99
+ runtimeApi: runtimeApiVar,
100
+ framework: {
101
+ name: framework.name,
102
+ className: classNameProp
103
+ }
104
+ }
105
+ }, needsRuntimeTest);
106
+ api.file.js.dts.set("head", "jsx:runtime", `import type * as BossJSX from '${jsxTypesModule}'`);
107
+ api.file.js.dts.set("body", "jsx:utils", `type BossIntrinsicElements = BossJSX.${jsxNamespace}.IntrinsicElements
108
+ type BossElement = BossJSX.${jsxNamespace}.Element
109
+ type BossElementType = ${elementType}
110
+ type BossComponentProps<C> = C extends keyof BossIntrinsicElements
111
+ ? BossIntrinsicElements[C]
112
+ : ${componentProps}
113
+ type AsProp<C extends BossElementType> = {
114
+ as?: C
115
+ }
116
+ type PolymorphicComponentProp<C extends BossElementType, Props = {}> = Props & BossComponentProps<C> & AsProp<C>
117
+ type PolymorphicComponentPropWithRef<C extends BossElementType, Props = {}> = PolymorphicComponentProp<C, Props> & {
118
+ ref?: unknown
119
+ }
120
+
121
+ type $$JSXFinalProps<C extends BossElementType> = PolymorphicComponentPropWithRef<C, $$FinalProps>
122
+ declare const $$PreparedBrand: unique symbol
123
+ type $$PreparedProps<Base extends BossElementType = 'div', C extends BossElementType = Base> = Omit<
124
+ $$JSXFinalProps<C>,
125
+ 'children' | 'ref'
126
+ > &
127
+ (C extends Base ? { as?: C } : { as: C })
128
+ type $$PreparedDefinition<Base extends BossElementType = 'div', C extends BossElementType = Base> = $$PreparedProps<Base, C> & {
129
+ readonly [typeof $$PreparedBrand]: true
130
+ }
131
+ type $$PreparedDefinitionForSet<Base extends BossElementType = 'div'> = {
132
+ readonly [typeof $$PreparedBrand]: true
133
+ }
134
+ type $$NoopFn = {
135
+ (props: $$PreparedProps<'div', 'div'>): $$PreparedDefinition<'div', 'div'>
136
+ <C extends BossElementType>(props: $$PreparedProps<'div', C> & { as: C }): $$PreparedDefinition<'div', C>
137
+ (input: string): string
138
+ }
139
+ type StyleFn = {
140
+ (...inputs: $$FinalProps[]): BossComponentProps<'div'>
141
+ }
142
+ type CssFn = {
143
+ (input: TemplateStringsArray, ...exprs: unknown[]): void
144
+ (input: string | Record<string, unknown>): void
145
+ }
146
+
147
+ // This is the base function which will become the proxy
148
+ type BaseFn<T extends BossElementType = 'div'> = {
149
+ <C extends BossElementType = T>(
150
+ props: $$JSXFinalProps<C>,
151
+ contexts?: unknown,
152
+ ): BossElement
153
+ }`);
154
+ syncPreparedDts(api);
155
+ api.file.js.dts.set("body", "jsx:proxy-start", `type ProxyCustomMembers = {
156
+ `).set("body", "jsx:proxy-utils", ` $: $$NoopFn
157
+ merge: (...inputs: import('boss-css/merge').MergeInput[]) => import('boss-css/merge').MergeOutput
158
+ cx: (...inputs: import('boss-css/cx').CxValue[]) => string
159
+ cv: typeof import('boss-css/cx').cv
160
+ scv: typeof import('boss-css/cx').scv
161
+ sv: typeof import('boss-css/cx').sv
162
+ css: CssFn
163
+ style: StyleFn
164
+ `).set("body", "jsx:proxy-custom-members", ``).set("body", "jsx:proxy-custom-members-end", `}`).set("body", "jsx:proxy-type", `type Proxy = BaseFn & {
165
+ [T in keyof BossIntrinsicElements]: BaseFn<T>
166
+ } & $$Prepared & ProxyCustomMembers`);
167
+ api.file.js.dts.replace("body", "$$:FinalProps", (value) => {
168
+ return `${value} & { ${/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(classNameProp) ? classNameProp : JSON.stringify(classNameProp)}?: import('boss-css/cx').CxValue }`;
169
+ });
170
+ api.file.js.dts.set("foot", "jsx:export", `export declare const $$: Proxy`);
171
+ if (settings.get("globals")) api.file.js.dts.set("foot", "jsx:globals", `declare global {
172
+ const $$: Proxy
173
+ }`);
174
+ api.file.js.dts.set("foot", "$$:default-export", `export default $$`);
175
+ };
176
+ const onParse = async (api, input) => {
177
+ const log = api.log.child("parser").child("jsx");
178
+ const { content } = input;
179
+ const filePath = input.path || input.file;
180
+ const prepared = extractPreparedComponents(content, filePath);
181
+ let preparedDirty = false;
182
+ for (const entry of prepared) {
183
+ const existing = preparedComponents.get(entry.name);
184
+ if (!existing || existing.asTag !== entry.asTag || existing.asDynamic !== entry.asDynamic || existing.filePath !== entry.filePath || existing.styles !== entry.styles) {
185
+ preparedComponents.set(entry.name, entry);
186
+ preparedDirty = true;
187
+ }
188
+ }
189
+ if (preparedDirty) syncPreparedDts(api);
190
+ if (input.preparedOnly) return;
191
+ const extractedCodes = extractCode(content);
192
+ const results = await extractPropTrees(extractedCodes);
193
+ needsRuntime ||= !!results.length;
194
+ for (const [key, tree] of Object.entries(results)) {
195
+ log.log("onPropTree", tree);
196
+ await api.trigger("onPropTree", {
197
+ input: api.propTreeToObject(tree),
198
+ tree,
199
+ preferVariables: true,
200
+ file: input,
201
+ code: extractedCodes[key],
202
+ parser: "jsx"
203
+ });
204
+ }
205
+ if (filePath) {
206
+ const customBlocks = extractCustomCssBlocks(api, content, filePath);
207
+ api.css?.syncCustomBlocks?.(filePath, customBlocks);
208
+ }
209
+ };
210
+ const customCssExtensions = new Set([
211
+ ".js",
212
+ ".jsx",
213
+ ".ts",
214
+ ".tsx",
215
+ ".mjs",
216
+ ".cjs"
217
+ ]);
218
+ const extractCustomCssBlocks = (api, content, filePath) => {
219
+ const ext = path.extname(filePath);
220
+ if (!customCssExtensions.has(ext)) return [];
221
+ if (!content.includes("$$.css")) return [];
222
+ let program;
223
+ try {
224
+ const isTs = ext === ".ts" || ext === ".tsx";
225
+ const isJsx = ext === ".jsx" || ext === ".tsx" || ext === ".js" || ext === ".mjs" || ext === ".cjs";
226
+ program = parseSync(content, {
227
+ syntax: isTs ? "typescript" : "ecmascript",
228
+ tsx: isTs && isJsx,
229
+ jsx: !isTs && isJsx
230
+ });
231
+ } catch {
232
+ return [];
233
+ }
234
+ const blocks = [];
235
+ const walk = (node) => {
236
+ if (!node || typeof node !== "object") return;
237
+ if (Array.isArray(node)) {
238
+ node.forEach(walk);
239
+ return;
240
+ }
241
+ const record = node;
242
+ if (record.type === "TaggedTemplateExpression" || record.type === "CallExpression") {
243
+ const cssText = extractCustomCssText(node, api);
244
+ if (cssText != null) {
245
+ const start = record.span?.start ?? 0;
246
+ const end = record.span?.end ?? 0;
247
+ blocks.push({
248
+ start,
249
+ end,
250
+ cssText
251
+ });
252
+ }
253
+ }
254
+ for (const value of Object.values(record)) walk(value);
255
+ };
256
+ walk(program);
257
+ return blocks;
258
+ };
259
+ const formatPreparedPath = (filePath) => {
260
+ if (!filePath) return null;
261
+ const relative = path.relative(process.cwd(), filePath);
262
+ if (!relative || relative.startsWith("..")) return filePath;
263
+ return relative;
264
+ };
265
+ const sanitizeDocText = (value) => value.replace(/\*\//g, "*\\/");
266
+
267
+ //#endregion
268
+ export { name, onBoot, onParse, server_exports, settings };
@@ -0,0 +1,16 @@
1
+ const require_postcss = require('../tasks/postcss.cjs');
2
+
3
+ //#region src/postcss/index.ts
4
+ function postcssPlugin(options = {}) {
5
+ return {
6
+ postcssPlugin: "boss-postcss-plugin",
7
+ plugins: [async (root, result) => {
8
+ await require_postcss.runPostcss(root, result, options);
9
+ }]
10
+ };
11
+ }
12
+ postcssPlugin.postcss = true;
13
+ var postcss_default = postcssPlugin;
14
+
15
+ //#endregion
16
+ module.exports = postcss_default;