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,291 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_directory = require('./directory.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
+
8
+ //#region src/fontsource/server.ts
9
+ var server_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
10
+ name: () => name,
11
+ onBoot: () => onBoot
12
+ });
13
+ const name = "fontsource";
14
+ const API_BASE = "https://api.fontsource.org";
15
+ const CDN_NPM_BASE = "https://cdn.jsdelivr.net/npm";
16
+ const fontDirectoryEntries = require_directory.fontDirectory;
17
+ const fontById = new Map(fontDirectoryEntries.map((entry) => [entry.id, entry]));
18
+ const versionCache = /* @__PURE__ */ new Map();
19
+ const cssCache = /* @__PURE__ */ new Map();
20
+ const normalizeFontName = (value) => value.toLowerCase().replace(/["']/g, "").replace(/[_\s]+/g, "-").replace(/-+/g, "-").trim();
21
+ const fontByFamily = new Map(fontDirectoryEntries.map((entry) => [normalizeFontName(entry.family), entry]));
22
+ const ensureArray = (value) => {
23
+ if (value == null) return [];
24
+ return Array.isArray(value) ? Array.from(value) : [value];
25
+ };
26
+ const isVariableConfig = (font) => font.variable === true;
27
+ const getFontEntry = (name) => {
28
+ if (!name) return null;
29
+ const normalized = normalizeFontName(name);
30
+ return fontById.get(normalized) || fontByFamily.get(normalized) || null;
31
+ };
32
+ const isValidNpmVersion = (value) => {
33
+ if (!value) return false;
34
+ if (value === "latest") return true;
35
+ return /^\d+\.\d+\.\d+/.test(value);
36
+ };
37
+ const fetchJson = async (url) => {
38
+ const response = await fetch(url);
39
+ if (!response.ok) throw new Error(`Fontsource request failed: ${response.status} ${response.statusText} (${url})`);
40
+ return response.json();
41
+ };
42
+ const resolveNpmVersion = async (id, variable, version) => {
43
+ if (isValidNpmVersion(version)) return version;
44
+ const cached = versionCache.get(id);
45
+ if (cached) return variable ? cached.latestVariable || cached.latest || "latest" : cached.latest || "latest";
46
+ const data = await fetchJson(`${API_BASE}/v1/version/${id}`);
47
+ versionCache.set(id, data);
48
+ return variable ? data.latestVariable || data.latest || "latest" : data.latest || "latest";
49
+ };
50
+ const resolveSubsets = (font, entry) => {
51
+ const subsets = ensureArray(font.subsets);
52
+ if (subsets.length) return subsets;
53
+ if (entry?.defSubset) return [entry.defSubset];
54
+ return entry?.subsets?.length ? Array.from(entry.subsets) : [];
55
+ };
56
+ const resolveWeights = (font, entry) => {
57
+ const weights = ensureArray(font.weights);
58
+ if (weights.length) return weights;
59
+ return entry?.weights?.length ? Array.from(entry.weights) : [];
60
+ };
61
+ const resolveStyles = (font, entry) => {
62
+ const styles = ensureArray(font.styles);
63
+ if (styles.length) return styles;
64
+ return entry?.styles?.length ? Array.from(entry.styles) : [];
65
+ };
66
+ const buildStaticCssFiles = (subsets, weights, styles) => {
67
+ const files = [];
68
+ const hasSubsets = subsets.length > 0;
69
+ const normalizedWeights = weights.length ? weights : ["400"];
70
+ const normalizedStyles = styles.length ? styles : ["normal"];
71
+ for (const weight of normalizedWeights) {
72
+ const weightValue = String(weight);
73
+ for (const style of normalizedStyles) {
74
+ const styleSuffix = style && style !== "normal" ? `-${style}` : "";
75
+ if (hasSubsets) for (const subset of subsets) files.push(`${subset}-${weightValue}${styleSuffix}.css`);
76
+ else files.push(`${weightValue}${styleSuffix}.css`);
77
+ }
78
+ }
79
+ return files;
80
+ };
81
+ const buildVariableCssFiles = (_font) => {
82
+ return ["index.css"];
83
+ };
84
+ const buildCssFiles = (font, entry) => {
85
+ if (isVariableConfig(font)) return buildVariableCssFiles(font);
86
+ return buildStaticCssFiles(resolveSubsets(font, entry), resolveWeights(font, entry), resolveStyles(font, entry));
87
+ };
88
+ const buildPackageName = (font, entry) => {
89
+ const id = entry?.id ?? normalizeFontName(font.name);
90
+ return font.variable ? `@fontsource-variable/${id}` : `@fontsource/${id}`;
91
+ };
92
+ const toVariationSettings = (axes) => {
93
+ if (!axes) return null;
94
+ const pairs = [];
95
+ for (const [axis, rawValue] of Object.entries(axes)) {
96
+ if (axis === "wght" || axis === "wdth" || axis === "ital") continue;
97
+ const value = Array.isArray(rawValue) ? rawValue[0] : rawValue;
98
+ if (value === void 0) continue;
99
+ pairs.push(`"${axis}" ${value}`);
100
+ }
101
+ return pairs.length ? pairs.join(", ") : null;
102
+ };
103
+ const updateDeclaration = (block, property, value) => {
104
+ const pattern = new RegExp(`${property}\\s*:[^;]*;`, "i");
105
+ if (pattern.test(block)) return block.replace(pattern, `${property}: ${value};`);
106
+ return block.replace(/}\s*$/, ` ${property}: ${value};\n}`);
107
+ };
108
+ const applyVariableAxes = (block, axes) => {
109
+ if (!axes) return block;
110
+ let next = block;
111
+ if (axes.wght !== void 0) {
112
+ const value = Array.isArray(axes.wght) ? `${axes.wght[0]} ${axes.wght[1]}` : `${axes.wght}`;
113
+ next = updateDeclaration(next, "font-weight", value);
114
+ }
115
+ if (axes.wdth !== void 0) {
116
+ const value = Array.isArray(axes.wdth) ? `${axes.wdth[0]}% ${axes.wdth[1]}%` : `${axes.wdth}%`;
117
+ next = updateDeclaration(next, "font-stretch", value);
118
+ }
119
+ if (axes.ital !== void 0) {
120
+ const value = axes.ital === 1 ? "italic" : "normal";
121
+ next = updateDeclaration(next, "font-style", value);
122
+ }
123
+ const variationSettings = toVariationSettings(axes);
124
+ if (variationSettings) next = updateDeclaration(next, "font-variation-settings", variationSettings);
125
+ return next;
126
+ };
127
+ const rewriteFontFace = (block, cssUrl, downloads, axes, fontFolder) => {
128
+ return applyVariableAxes(block.replace(/url\(([^)]+)\)/g, (match, rawUrl) => {
129
+ const cleaned = rawUrl.trim().replace(/^['"]|['"]$/g, "");
130
+ const resolvedUrl = new URL(cleaned, cssUrl);
131
+ const filename = node_path.default.basename(resolvedUrl.pathname);
132
+ const targetPath = fontFolder ? `${fontFolder}/${filename}` : filename;
133
+ downloads.set(resolvedUrl.href, targetPath);
134
+ return `url("./fonts/${targetPath}")`;
135
+ }), axes);
136
+ };
137
+ const fetchCss = async (url) => {
138
+ const cached = cssCache.get(url);
139
+ if (cached) return cached;
140
+ const response = await fetch(url);
141
+ if (!response.ok) throw new Error(`Fontsource CSS fetch failed: ${response.status} ${response.statusText} (${url})`);
142
+ const text = await response.text();
143
+ cssCache.set(url, text);
144
+ return text;
145
+ };
146
+ const fetchFontFiles = async (downloads, fontsDir) => {
147
+ if (!downloads.size) return;
148
+ await node_fs_promises.default.mkdir(fontsDir, { recursive: true });
149
+ for (const [url, filename] of downloads.entries()) {
150
+ const filePath = node_path.default.join(fontsDir, filename);
151
+ try {
152
+ await node_fs_promises.default.access(filePath);
153
+ continue;
154
+ } catch {}
155
+ const response = await fetch(url);
156
+ if (!response.ok) throw new Error(`Fontsource download failed: ${response.status} ${response.statusText} (${url})`);
157
+ const buffer = Buffer.from(await response.arrayBuffer());
158
+ await node_fs_promises.default.writeFile(filePath, buffer);
159
+ }
160
+ };
161
+ const readTextIfExists = async (filePath) => {
162
+ try {
163
+ return await node_fs_promises.default.readFile(filePath, "utf-8");
164
+ } catch {
165
+ return null;
166
+ }
167
+ };
168
+ const writeTextFile = async (filePath, text) => {
169
+ await node_fs_promises.default.mkdir(node_path.default.dirname(filePath), { recursive: true });
170
+ await node_fs_promises.default.writeFile(filePath, text);
171
+ };
172
+ const buildFontFolderName = (id, version, variable) => `${id}-${version}${variable ? "-variable" : ""}`;
173
+ const parseVersionFromFolder = (id, folderName, variable) => {
174
+ const prefix = `${id}-`;
175
+ const suffix = variable ? "-variable" : "";
176
+ if (!folderName.startsWith(prefix)) return null;
177
+ if (suffix && !folderName.endsWith(suffix)) return null;
178
+ return folderName.slice(prefix.length, suffix ? -suffix.length : void 0) || null;
179
+ };
180
+ const compareSemver = (a, b) => {
181
+ const aParts = a.split(".").map((v) => Number(v));
182
+ const bParts = b.split(".").map((v) => Number(v));
183
+ const length = Math.max(aParts.length, bParts.length);
184
+ for (let i = 0; i < length; i += 1) {
185
+ const aVal = Number.isFinite(aParts[i]) ? aParts[i] : 0;
186
+ const bVal = Number.isFinite(bParts[i]) ? bParts[i] : 0;
187
+ if (aVal !== bVal) return aVal - bVal;
188
+ }
189
+ return 0;
190
+ };
191
+ const findCachedVersion = async (fontsDir, id, variable) => {
192
+ try {
193
+ const versions = (await node_fs_promises.default.readdir(fontsDir, { withFileTypes: true })).filter((entry) => entry.isDirectory()).map((entry) => parseVersionFromFolder(id, entry.name, variable)).filter((value) => Boolean(value));
194
+ if (!versions.length) return null;
195
+ versions.sort(compareSemver);
196
+ return versions[versions.length - 1] ?? null;
197
+ } catch {
198
+ return null;
199
+ }
200
+ };
201
+ const mergeFontTokens = (api, tokens) => {
202
+ if (!tokens || Object.keys(tokens).length === 0) return;
203
+ const existing = api.tokens;
204
+ if (typeof existing === "function") {
205
+ api.tokens = (valueMap) => {
206
+ const base = existing(valueMap);
207
+ const font = {
208
+ ...base?.font ?? {},
209
+ ...tokens
210
+ };
211
+ return {
212
+ ...base ?? {},
213
+ font
214
+ };
215
+ };
216
+ return;
217
+ }
218
+ const existingRecord = existing ?? {};
219
+ const existingFont = existingRecord.font ?? {};
220
+ api.tokens = {
221
+ ...existingRecord,
222
+ font: {
223
+ ...existingFont,
224
+ ...tokens
225
+ }
226
+ };
227
+ };
228
+ const addFontFaceBlocks = (api, cssText, cssUrl, downloads, axes, fontFolder) => {
229
+ const blocks = cssText.match(/@font-face\s*{[^}]*}/g) || [];
230
+ for (const block of blocks) {
231
+ const next = rewriteFontFace(block, cssUrl, downloads, axes, fontFolder);
232
+ api.css.addRule(next.trim());
233
+ }
234
+ };
235
+ const onBoot = async (api) => {
236
+ if (api.runtime?.only) return;
237
+ const fonts = api.fonts;
238
+ if (!Array.isArray(fonts) || fonts.length === 0) return;
239
+ const importUrls = [];
240
+ const importSet = /* @__PURE__ */ new Set();
241
+ const downloads = /* @__PURE__ */ new Map();
242
+ const stylesDir = api.stylesheetPath ? node_path.default.dirname(api.stylesheetPath) : node_path.default.join(process.cwd(), api.folder ?? ".bo$$");
243
+ const fontsDir = node_path.default.join(stylesDir, "fonts");
244
+ const fontTokens = {};
245
+ for (const font of fonts) {
246
+ if (!font?.name) continue;
247
+ const entry = getFontEntry(font.name);
248
+ const id = entry?.id ?? normalizeFontName(font.name);
249
+ const packageName = buildPackageName(font, entry);
250
+ const isLocal = font.delivery === "local";
251
+ let npmVersion = isValidNpmVersion(font.version) ? font.version : null;
252
+ if (!npmVersion && isLocal) {
253
+ const cachedVersion = await findCachedVersion(fontsDir, id, font.variable === true);
254
+ if (isValidNpmVersion(cachedVersion)) npmVersion = cachedVersion;
255
+ }
256
+ if (!npmVersion) npmVersion = await resolveNpmVersion(id, font.variable === true, font.version);
257
+ const resolvedVersion = npmVersion ?? "latest";
258
+ const cssFiles = buildCssFiles(font, entry);
259
+ const axes = font.variable ? font.variableAxes : void 0;
260
+ const fontFolder = isLocal ? buildFontFolderName(id, resolvedVersion, font.variable === true) : null;
261
+ if (font.token) fontTokens[font.token] = entry?.family ?? font.name;
262
+ for (const file of cssFiles) {
263
+ const cssUrl = `${CDN_NPM_BASE}/${packageName}@${resolvedVersion}/${file}`;
264
+ if (isLocal) {
265
+ const cachePath = node_path.default.join(fontsDir, fontFolder ?? "", file);
266
+ let cssText = await readTextIfExists(cachePath);
267
+ if (!cssText) {
268
+ cssText = await fetchCss(cssUrl);
269
+ await writeTextFile(cachePath, cssText);
270
+ }
271
+ addFontFaceBlocks(api, cssText, cssUrl, downloads, axes, fontFolder ?? void 0);
272
+ } else if (!importSet.has(cssUrl)) {
273
+ importSet.add(cssUrl);
274
+ importUrls.push(cssUrl);
275
+ }
276
+ }
277
+ }
278
+ for (const url of importUrls) api.css.addImport(url);
279
+ mergeFontTokens(api, fontTokens);
280
+ await fetchFontFiles(downloads, fontsDir);
281
+ };
282
+
283
+ //#endregion
284
+ exports.name = name;
285
+ exports.onBoot = onBoot;
286
+ Object.defineProperty(exports, 'server_exports', {
287
+ enumerable: true,
288
+ get: function () {
289
+ return server_exports;
290
+ }
291
+ });
@@ -0,0 +1,282 @@
1
+ import { __exportAll } from "../_virtual/rolldown_runtime.mjs";
2
+ import { fontDirectory } from "./directory.mjs";
3
+ import fs from "node:fs/promises";
4
+ import path from "node:path";
5
+
6
+ //#region src/fontsource/server.ts
7
+ var server_exports = /* @__PURE__ */ __exportAll({
8
+ name: () => name,
9
+ onBoot: () => onBoot
10
+ });
11
+ const name = "fontsource";
12
+ const API_BASE = "https://api.fontsource.org";
13
+ const CDN_NPM_BASE = "https://cdn.jsdelivr.net/npm";
14
+ const fontDirectoryEntries = fontDirectory;
15
+ const fontById = new Map(fontDirectoryEntries.map((entry) => [entry.id, entry]));
16
+ const versionCache = /* @__PURE__ */ new Map();
17
+ const cssCache = /* @__PURE__ */ new Map();
18
+ const normalizeFontName = (value) => value.toLowerCase().replace(/["']/g, "").replace(/[_\s]+/g, "-").replace(/-+/g, "-").trim();
19
+ const fontByFamily = new Map(fontDirectoryEntries.map((entry) => [normalizeFontName(entry.family), entry]));
20
+ const ensureArray = (value) => {
21
+ if (value == null) return [];
22
+ return Array.isArray(value) ? Array.from(value) : [value];
23
+ };
24
+ const isVariableConfig = (font) => font.variable === true;
25
+ const getFontEntry = (name) => {
26
+ if (!name) return null;
27
+ const normalized = normalizeFontName(name);
28
+ return fontById.get(normalized) || fontByFamily.get(normalized) || null;
29
+ };
30
+ const isValidNpmVersion = (value) => {
31
+ if (!value) return false;
32
+ if (value === "latest") return true;
33
+ return /^\d+\.\d+\.\d+/.test(value);
34
+ };
35
+ const fetchJson = async (url) => {
36
+ const response = await fetch(url);
37
+ if (!response.ok) throw new Error(`Fontsource request failed: ${response.status} ${response.statusText} (${url})`);
38
+ return response.json();
39
+ };
40
+ const resolveNpmVersion = async (id, variable, version) => {
41
+ if (isValidNpmVersion(version)) return version;
42
+ const cached = versionCache.get(id);
43
+ if (cached) return variable ? cached.latestVariable || cached.latest || "latest" : cached.latest || "latest";
44
+ const data = await fetchJson(`${API_BASE}/v1/version/${id}`);
45
+ versionCache.set(id, data);
46
+ return variable ? data.latestVariable || data.latest || "latest" : data.latest || "latest";
47
+ };
48
+ const resolveSubsets = (font, entry) => {
49
+ const subsets = ensureArray(font.subsets);
50
+ if (subsets.length) return subsets;
51
+ if (entry?.defSubset) return [entry.defSubset];
52
+ return entry?.subsets?.length ? Array.from(entry.subsets) : [];
53
+ };
54
+ const resolveWeights = (font, entry) => {
55
+ const weights = ensureArray(font.weights);
56
+ if (weights.length) return weights;
57
+ return entry?.weights?.length ? Array.from(entry.weights) : [];
58
+ };
59
+ const resolveStyles = (font, entry) => {
60
+ const styles = ensureArray(font.styles);
61
+ if (styles.length) return styles;
62
+ return entry?.styles?.length ? Array.from(entry.styles) : [];
63
+ };
64
+ const buildStaticCssFiles = (subsets, weights, styles) => {
65
+ const files = [];
66
+ const hasSubsets = subsets.length > 0;
67
+ const normalizedWeights = weights.length ? weights : ["400"];
68
+ const normalizedStyles = styles.length ? styles : ["normal"];
69
+ for (const weight of normalizedWeights) {
70
+ const weightValue = String(weight);
71
+ for (const style of normalizedStyles) {
72
+ const styleSuffix = style && style !== "normal" ? `-${style}` : "";
73
+ if (hasSubsets) for (const subset of subsets) files.push(`${subset}-${weightValue}${styleSuffix}.css`);
74
+ else files.push(`${weightValue}${styleSuffix}.css`);
75
+ }
76
+ }
77
+ return files;
78
+ };
79
+ const buildVariableCssFiles = (_font) => {
80
+ return ["index.css"];
81
+ };
82
+ const buildCssFiles = (font, entry) => {
83
+ if (isVariableConfig(font)) return buildVariableCssFiles(font);
84
+ return buildStaticCssFiles(resolveSubsets(font, entry), resolveWeights(font, entry), resolveStyles(font, entry));
85
+ };
86
+ const buildPackageName = (font, entry) => {
87
+ const id = entry?.id ?? normalizeFontName(font.name);
88
+ return font.variable ? `@fontsource-variable/${id}` : `@fontsource/${id}`;
89
+ };
90
+ const toVariationSettings = (axes) => {
91
+ if (!axes) return null;
92
+ const pairs = [];
93
+ for (const [axis, rawValue] of Object.entries(axes)) {
94
+ if (axis === "wght" || axis === "wdth" || axis === "ital") continue;
95
+ const value = Array.isArray(rawValue) ? rawValue[0] : rawValue;
96
+ if (value === void 0) continue;
97
+ pairs.push(`"${axis}" ${value}`);
98
+ }
99
+ return pairs.length ? pairs.join(", ") : null;
100
+ };
101
+ const updateDeclaration = (block, property, value) => {
102
+ const pattern = new RegExp(`${property}\\s*:[^;]*;`, "i");
103
+ if (pattern.test(block)) return block.replace(pattern, `${property}: ${value};`);
104
+ return block.replace(/}\s*$/, ` ${property}: ${value};\n}`);
105
+ };
106
+ const applyVariableAxes = (block, axes) => {
107
+ if (!axes) return block;
108
+ let next = block;
109
+ if (axes.wght !== void 0) {
110
+ const value = Array.isArray(axes.wght) ? `${axes.wght[0]} ${axes.wght[1]}` : `${axes.wght}`;
111
+ next = updateDeclaration(next, "font-weight", value);
112
+ }
113
+ if (axes.wdth !== void 0) {
114
+ const value = Array.isArray(axes.wdth) ? `${axes.wdth[0]}% ${axes.wdth[1]}%` : `${axes.wdth}%`;
115
+ next = updateDeclaration(next, "font-stretch", value);
116
+ }
117
+ if (axes.ital !== void 0) {
118
+ const value = axes.ital === 1 ? "italic" : "normal";
119
+ next = updateDeclaration(next, "font-style", value);
120
+ }
121
+ const variationSettings = toVariationSettings(axes);
122
+ if (variationSettings) next = updateDeclaration(next, "font-variation-settings", variationSettings);
123
+ return next;
124
+ };
125
+ const rewriteFontFace = (block, cssUrl, downloads, axes, fontFolder) => {
126
+ return applyVariableAxes(block.replace(/url\(([^)]+)\)/g, (match, rawUrl) => {
127
+ const cleaned = rawUrl.trim().replace(/^['"]|['"]$/g, "");
128
+ const resolvedUrl = new URL(cleaned, cssUrl);
129
+ const filename = path.basename(resolvedUrl.pathname);
130
+ const targetPath = fontFolder ? `${fontFolder}/${filename}` : filename;
131
+ downloads.set(resolvedUrl.href, targetPath);
132
+ return `url("./fonts/${targetPath}")`;
133
+ }), axes);
134
+ };
135
+ const fetchCss = async (url) => {
136
+ const cached = cssCache.get(url);
137
+ if (cached) return cached;
138
+ const response = await fetch(url);
139
+ if (!response.ok) throw new Error(`Fontsource CSS fetch failed: ${response.status} ${response.statusText} (${url})`);
140
+ const text = await response.text();
141
+ cssCache.set(url, text);
142
+ return text;
143
+ };
144
+ const fetchFontFiles = async (downloads, fontsDir) => {
145
+ if (!downloads.size) return;
146
+ await fs.mkdir(fontsDir, { recursive: true });
147
+ for (const [url, filename] of downloads.entries()) {
148
+ const filePath = path.join(fontsDir, filename);
149
+ try {
150
+ await fs.access(filePath);
151
+ continue;
152
+ } catch {}
153
+ const response = await fetch(url);
154
+ if (!response.ok) throw new Error(`Fontsource download failed: ${response.status} ${response.statusText} (${url})`);
155
+ const buffer = Buffer.from(await response.arrayBuffer());
156
+ await fs.writeFile(filePath, buffer);
157
+ }
158
+ };
159
+ const readTextIfExists = async (filePath) => {
160
+ try {
161
+ return await fs.readFile(filePath, "utf-8");
162
+ } catch {
163
+ return null;
164
+ }
165
+ };
166
+ const writeTextFile = async (filePath, text) => {
167
+ await fs.mkdir(path.dirname(filePath), { recursive: true });
168
+ await fs.writeFile(filePath, text);
169
+ };
170
+ const buildFontFolderName = (id, version, variable) => `${id}-${version}${variable ? "-variable" : ""}`;
171
+ const parseVersionFromFolder = (id, folderName, variable) => {
172
+ const prefix = `${id}-`;
173
+ const suffix = variable ? "-variable" : "";
174
+ if (!folderName.startsWith(prefix)) return null;
175
+ if (suffix && !folderName.endsWith(suffix)) return null;
176
+ return folderName.slice(prefix.length, suffix ? -suffix.length : void 0) || null;
177
+ };
178
+ const compareSemver = (a, b) => {
179
+ const aParts = a.split(".").map((v) => Number(v));
180
+ const bParts = b.split(".").map((v) => Number(v));
181
+ const length = Math.max(aParts.length, bParts.length);
182
+ for (let i = 0; i < length; i += 1) {
183
+ const aVal = Number.isFinite(aParts[i]) ? aParts[i] : 0;
184
+ const bVal = Number.isFinite(bParts[i]) ? bParts[i] : 0;
185
+ if (aVal !== bVal) return aVal - bVal;
186
+ }
187
+ return 0;
188
+ };
189
+ const findCachedVersion = async (fontsDir, id, variable) => {
190
+ try {
191
+ const versions = (await fs.readdir(fontsDir, { withFileTypes: true })).filter((entry) => entry.isDirectory()).map((entry) => parseVersionFromFolder(id, entry.name, variable)).filter((value) => Boolean(value));
192
+ if (!versions.length) return null;
193
+ versions.sort(compareSemver);
194
+ return versions[versions.length - 1] ?? null;
195
+ } catch {
196
+ return null;
197
+ }
198
+ };
199
+ const mergeFontTokens = (api, tokens) => {
200
+ if (!tokens || Object.keys(tokens).length === 0) return;
201
+ const existing = api.tokens;
202
+ if (typeof existing === "function") {
203
+ api.tokens = (valueMap) => {
204
+ const base = existing(valueMap);
205
+ const font = {
206
+ ...base?.font ?? {},
207
+ ...tokens
208
+ };
209
+ return {
210
+ ...base ?? {},
211
+ font
212
+ };
213
+ };
214
+ return;
215
+ }
216
+ const existingRecord = existing ?? {};
217
+ const existingFont = existingRecord.font ?? {};
218
+ api.tokens = {
219
+ ...existingRecord,
220
+ font: {
221
+ ...existingFont,
222
+ ...tokens
223
+ }
224
+ };
225
+ };
226
+ const addFontFaceBlocks = (api, cssText, cssUrl, downloads, axes, fontFolder) => {
227
+ const blocks = cssText.match(/@font-face\s*{[^}]*}/g) || [];
228
+ for (const block of blocks) {
229
+ const next = rewriteFontFace(block, cssUrl, downloads, axes, fontFolder);
230
+ api.css.addRule(next.trim());
231
+ }
232
+ };
233
+ const onBoot = async (api) => {
234
+ if (api.runtime?.only) return;
235
+ const fonts = api.fonts;
236
+ if (!Array.isArray(fonts) || fonts.length === 0) return;
237
+ const importUrls = [];
238
+ const importSet = /* @__PURE__ */ new Set();
239
+ const downloads = /* @__PURE__ */ new Map();
240
+ const stylesDir = api.stylesheetPath ? path.dirname(api.stylesheetPath) : path.join(process.cwd(), api.folder ?? ".bo$$");
241
+ const fontsDir = path.join(stylesDir, "fonts");
242
+ const fontTokens = {};
243
+ for (const font of fonts) {
244
+ if (!font?.name) continue;
245
+ const entry = getFontEntry(font.name);
246
+ const id = entry?.id ?? normalizeFontName(font.name);
247
+ const packageName = buildPackageName(font, entry);
248
+ const isLocal = font.delivery === "local";
249
+ let npmVersion = isValidNpmVersion(font.version) ? font.version : null;
250
+ if (!npmVersion && isLocal) {
251
+ const cachedVersion = await findCachedVersion(fontsDir, id, font.variable === true);
252
+ if (isValidNpmVersion(cachedVersion)) npmVersion = cachedVersion;
253
+ }
254
+ if (!npmVersion) npmVersion = await resolveNpmVersion(id, font.variable === true, font.version);
255
+ const resolvedVersion = npmVersion ?? "latest";
256
+ const cssFiles = buildCssFiles(font, entry);
257
+ const axes = font.variable ? font.variableAxes : void 0;
258
+ const fontFolder = isLocal ? buildFontFolderName(id, resolvedVersion, font.variable === true) : null;
259
+ if (font.token) fontTokens[font.token] = entry?.family ?? font.name;
260
+ for (const file of cssFiles) {
261
+ const cssUrl = `${CDN_NPM_BASE}/${packageName}@${resolvedVersion}/${file}`;
262
+ if (isLocal) {
263
+ const cachePath = path.join(fontsDir, fontFolder ?? "", file);
264
+ let cssText = await readTextIfExists(cachePath);
265
+ if (!cssText) {
266
+ cssText = await fetchCss(cssUrl);
267
+ await writeTextFile(cachePath, cssText);
268
+ }
269
+ addFontFaceBlocks(api, cssText, cssUrl, downloads, axes, fontFolder ?? void 0);
270
+ } else if (!importSet.has(cssUrl)) {
271
+ importSet.add(cssUrl);
272
+ importUrls.push(cssUrl);
273
+ }
274
+ }
275
+ }
276
+ for (const url of importUrls) api.css.addImport(url);
277
+ mergeFontTokens(api, fontTokens);
278
+ await fetchFontFiles(downloads, fontsDir);
279
+ };
280
+
281
+ //#endregion
282
+ export { name, onBoot, server_exports };
package/dist/index.cjs ADDED
@@ -0,0 +1,10 @@
1
+ const require_build = require('./tasks/build.cjs');
2
+ const require_watch = require('./tasks/watch.cjs');
3
+ const require_compile = require('./tasks/compile.cjs');
4
+ const require_postcss = require('./tasks/postcss.cjs');
5
+
6
+ exports.resolveBuildConfig = require_build.resolveBuildConfig;
7
+ exports.runBuild = require_build.runBuild;
8
+ exports.runCompile = require_compile.runCompile;
9
+ exports.runPostcss = require_postcss.runPostcss;
10
+ exports.runWatch = require_watch.runWatch;
package/dist/index.mjs ADDED
@@ -0,0 +1,6 @@
1
+ import { resolveBuildConfig, runBuild } from "./tasks/build.mjs";
2
+ import { runWatch } from "./tasks/watch.mjs";
3
+ import { runCompile } from "./tasks/compile.mjs";
4
+ import { runPostcss } from "./tasks/postcss.mjs";
5
+
6
+ export { resolveBuildConfig, runBuild, runCompile, runPostcss, runWatch };
@@ -0,0 +1,28 @@
1
+ const require_debug = require('../shared/debug.cjs');
2
+
3
+ //#region src/log/browser.ts
4
+ const normalizeDebugValue = (debug) => debug === true ? "boss:*" : debug;
5
+ const createLogger = (namespace, debug) => {
6
+ const matcher = require_debug.createDebugMatcher(normalizeDebugValue(debug));
7
+ const cache = /* @__PURE__ */ new Map();
8
+ const getLogger = (nextNamespace) => {
9
+ const existing = cache.get(nextNamespace);
10
+ if (existing) return existing;
11
+ const enabled = matcher(nextNamespace);
12
+ const logger = {
13
+ namespace: nextNamespace,
14
+ enabled,
15
+ log: (...args) => {
16
+ if (!enabled) return;
17
+ console.log(nextNamespace, ...args);
18
+ },
19
+ child: (name) => getLogger(`${nextNamespace}:${name}`)
20
+ };
21
+ cache.set(nextNamespace, logger);
22
+ return logger;
23
+ };
24
+ return getLogger(namespace);
25
+ };
26
+
27
+ //#endregion
28
+ exports.createLogger = createLogger;
@@ -0,0 +1,28 @@
1
+ import { createDebugMatcher } from "../shared/debug.mjs";
2
+
3
+ //#region src/log/browser.ts
4
+ const normalizeDebugValue = (debug) => debug === true ? "boss:*" : debug;
5
+ const createLogger = (namespace, debug) => {
6
+ const matcher = createDebugMatcher(normalizeDebugValue(debug));
7
+ const cache = /* @__PURE__ */ new Map();
8
+ const getLogger = (nextNamespace) => {
9
+ const existing = cache.get(nextNamespace);
10
+ if (existing) return existing;
11
+ const enabled = matcher(nextNamespace);
12
+ const logger = {
13
+ namespace: nextNamespace,
14
+ enabled,
15
+ log: (...args) => {
16
+ if (!enabled) return;
17
+ console.log(nextNamespace, ...args);
18
+ },
19
+ child: (name) => getLogger(`${nextNamespace}:${name}`)
20
+ };
21
+ cache.set(nextNamespace, logger);
22
+ return logger;
23
+ };
24
+ return getLogger(namespace);
25
+ };
26
+
27
+ //#endregion
28
+ export { createLogger };
@@ -0,0 +1,32 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_debug = require('../shared/debug.cjs');
3
+ let debug = require("debug");
4
+ debug = require_rolldown_runtime.__toESM(debug);
5
+
6
+ //#region src/log/server.ts
7
+ const normalizeDebugValue = (debug$1) => debug$1 === true ? "boss:*" : debug$1;
8
+ const createLogger = (namespace, debug$1) => {
9
+ const matcher = require_debug.createDebugMatcher(normalizeDebugValue(debug$1));
10
+ const cache = /* @__PURE__ */ new Map();
11
+ const getLogger = (nextNamespace) => {
12
+ const existing = cache.get(nextNamespace);
13
+ if (existing) return existing;
14
+ const instance = (0, debug.default)(nextNamespace);
15
+ instance.enabled = matcher(nextNamespace);
16
+ const logger = {
17
+ namespace: nextNamespace,
18
+ enabled: instance.enabled,
19
+ log: (...args) => {
20
+ if (!instance.enabled) return;
21
+ instance(...args);
22
+ },
23
+ child: (name) => getLogger(`${nextNamespace}:${name}`)
24
+ };
25
+ cache.set(nextNamespace, logger);
26
+ return logger;
27
+ };
28
+ return getLogger(namespace);
29
+ };
30
+
31
+ //#endregion
32
+ exports.createLogger = createLogger;