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.
- package/README.md +1 -0
- package/dist/_virtual/rolldown_runtime.cjs +43 -0
- package/dist/_virtual/rolldown_runtime.mjs +20 -0
- package/dist/api/browser.cjs +54 -0
- package/dist/api/browser.mjs +48 -0
- package/dist/api/config.cjs +94 -0
- package/dist/api/config.mjs +91 -0
- package/dist/api/css.cjs +304 -0
- package/dist/api/css.mjs +303 -0
- package/dist/api/dictionary.cjs +218 -0
- package/dist/api/dictionary.mjs +215 -0
- package/dist/api/file/dts.cjs +21 -0
- package/dist/api/file/dts.mjs +21 -0
- package/dist/api/file/file.cjs +123 -0
- package/dist/api/file/file.mjs +120 -0
- package/dist/api/file/js.cjs +118 -0
- package/dist/api/file/js.mjs +116 -0
- package/dist/api/names.cjs +52 -0
- package/dist/api/names.mjs +46 -0
- package/dist/api/noopCss.cjs +37 -0
- package/dist/api/noopCss.mjs +36 -0
- package/dist/api/propTree.cjs +54 -0
- package/dist/api/propTree.mjs +48 -0
- package/dist/api/server.cjs +112 -0
- package/dist/api/server.mjs +106 -0
- package/dist/cli/build.cjs +1 -0
- package/dist/cli/build.mjs +3 -0
- package/dist/cli/index.cjs +30 -0
- package/dist/cli/index.mjs +29 -0
- package/dist/cli/tasks/build.cjs +24 -0
- package/dist/cli/tasks/build.mjs +23 -0
- package/dist/cli/tasks/choose.cjs +47 -0
- package/dist/cli/tasks/choose.mjs +46 -0
- package/dist/cli/tasks/compile.cjs +68 -0
- package/dist/cli/tasks/compile.mjs +67 -0
- package/dist/cli/tasks/dev.cjs +51 -0
- package/dist/cli/tasks/dev.mjs +48 -0
- package/dist/cli/tasks/init.cjs +1835 -0
- package/dist/cli/tasks/init.mjs +1831 -0
- package/dist/cli/tasks/watch.cjs +38 -0
- package/dist/cli/tasks/watch.mjs +37 -0
- package/dist/cli/templates/init.cjs +82 -0
- package/dist/cli/templates/init.mjs +78 -0
- package/dist/cli/types.cjs +13 -0
- package/dist/cli/types.mjs +13 -0
- package/dist/cli/utils.cjs +43 -0
- package/dist/cli/utils.mjs +41 -0
- package/dist/compile/classname-strategy.cjs +79 -0
- package/dist/compile/classname-strategy.mjs +77 -0
- package/dist/compile/classname.cjs +366 -0
- package/dist/compile/classname.mjs +360 -0
- package/dist/compile/index.cjs +238 -0
- package/dist/compile/index.mjs +235 -0
- package/dist/compile/jsx.cjs +803 -0
- package/dist/compile/jsx.mjs +800 -0
- package/dist/compile/prepared.cjs +88 -0
- package/dist/compile/prepared.mjs +87 -0
- package/dist/compile/runtime.cjs +33 -0
- package/dist/compile/runtime.mjs +32 -0
- package/dist/compile/transform.cjs +371 -0
- package/dist/compile/transform.mjs +369 -0
- package/dist/cx/index.cjs +93 -0
- package/dist/cx/index.mjs +85 -0
- package/dist/detect-fw/index.cjs +384 -0
- package/dist/detect-fw/index.mjs +379 -0
- package/dist/dev/client.cjs +39 -0
- package/dist/dev/client.mjs +38 -0
- package/dist/dev/plugin/browser.cjs +11 -0
- package/dist/dev/plugin/browser.mjs +9 -0
- package/dist/dev/plugin/server.cjs +86 -0
- package/dist/dev/plugin/server.mjs +78 -0
- package/dist/dev/port.cjs +46 -0
- package/dist/dev/port.mjs +43 -0
- package/dist/dev/runtime.cjs +28 -0
- package/dist/dev/runtime.mjs +29 -0
- package/dist/dev/server.cjs +808 -0
- package/dist/dev/server.mjs +805 -0
- package/dist/dev/shared.cjs +6 -0
- package/dist/dev/shared.mjs +5 -0
- package/dist/eslint-plugin/index.cjs +66 -0
- package/dist/eslint-plugin/index.mjs +66 -0
- package/dist/eslint-plugin/rules/classnames-only.cjs +68 -0
- package/dist/eslint-plugin/rules/classnames-only.mjs +68 -0
- package/dist/eslint-plugin/rules/format-classnames.cjs +137 -0
- package/dist/eslint-plugin/rules/format-classnames.mjs +136 -0
- package/dist/eslint-plugin/rules/no-unknown-classes.cjs +119 -0
- package/dist/eslint-plugin/rules/no-unknown-classes.mjs +119 -0
- package/dist/eslint-plugin/rules/prefer-classnames.cjs +69 -0
- package/dist/eslint-plugin/rules/prefer-classnames.mjs +69 -0
- package/dist/eslint-plugin/rules/prefer-token-values.cjs +197 -0
- package/dist/eslint-plugin/rules/prefer-token-values.mjs +197 -0
- package/dist/eslint-plugin/rules/props-only.cjs +115 -0
- package/dist/eslint-plugin/rules/props-only.mjs +115 -0
- package/dist/eslint-plugin/rules/redundant-cx.cjs +66 -0
- package/dist/eslint-plugin/rules/redundant-cx.mjs +66 -0
- package/dist/eslint-plugin/rules/require-prop-functions.cjs +130 -0
- package/dist/eslint-plugin/rules/require-prop-functions.mjs +130 -0
- package/dist/eslint-plugin/utils/api.cjs +30 -0
- package/dist/eslint-plugin/utils/api.mjs +29 -0
- package/dist/eslint-plugin/utils/ast.cjs +119 -0
- package/dist/eslint-plugin/utils/ast.mjs +112 -0
- package/dist/eslint-plugin/utils/boss-classes.cjs +185 -0
- package/dist/eslint-plugin/utils/boss-classes.mjs +175 -0
- package/dist/eslint-plugin/utils/defaults.cjs +99 -0
- package/dist/eslint-plugin/utils/defaults.mjs +93 -0
- package/dist/eslint-plugin/utils/format.cjs +20 -0
- package/dist/eslint-plugin/utils/format.mjs +19 -0
- package/dist/eslint-plugin/utils/order.cjs +76 -0
- package/dist/eslint-plugin/utils/order.mjs +76 -0
- package/dist/eslint-plugin/utils/property-order.cjs +449 -0
- package/dist/eslint-plugin/utils/property-order.mjs +448 -0
- package/dist/eslint-plugin/utils/static.cjs +36 -0
- package/dist/eslint-plugin/utils/static.mjs +35 -0
- package/dist/fontsource/directory.cjs +39588 -0
- package/dist/fontsource/directory.mjs +39587 -0
- package/dist/fontsource/server.cjs +291 -0
- package/dist/fontsource/server.mjs +282 -0
- package/dist/index.cjs +10 -0
- package/dist/index.mjs +6 -0
- package/dist/log/browser.cjs +28 -0
- package/dist/log/browser.mjs +28 -0
- package/dist/log/server.cjs +32 -0
- package/dist/log/server.mjs +30 -0
- package/dist/merge/index.cjs +590 -0
- package/dist/merge/index.mjs +586 -0
- package/dist/native/browser.cjs +78 -0
- package/dist/native/browser.mjs +77 -0
- package/dist/native/server.cjs +180 -0
- package/dist/native/server.mjs +176 -0
- package/dist/native/styleTypes.cjs +168 -0
- package/dist/native/styleTypes.mjs +164 -0
- package/dist/parser/classname/server.cjs +239 -0
- package/dist/parser/classname/server.mjs +232 -0
- package/dist/parser/jsx/browser.cjs +66 -0
- package/dist/parser/jsx/browser.mjs +63 -0
- package/dist/parser/jsx/extractCode.cjs +99 -0
- package/dist/parser/jsx/extractCode.mjs +98 -0
- package/dist/parser/jsx/extractPrepared.cjs +123 -0
- package/dist/parser/jsx/extractPrepared.mjs +122 -0
- package/dist/parser/jsx/extractProps.cjs +234 -0
- package/dist/parser/jsx/extractProps.mjs +232 -0
- package/dist/parser/jsx/isDOMProp.cjs +17 -0
- package/dist/parser/jsx/isDOMProp.mjs +15 -0
- package/dist/parser/jsx/native.cjs +110 -0
- package/dist/parser/jsx/native.mjs +108 -0
- package/dist/parser/jsx/runtime.cjs +4 -0
- package/dist/parser/jsx/runtime.mjs +3 -0
- package/dist/parser/jsx/server.cjs +278 -0
- package/dist/parser/jsx/server.mjs +268 -0
- package/dist/postcss/index.cjs +16 -0
- package/dist/postcss/index.mjs +16 -0
- package/dist/prop/at/runtime-only.cjs +90 -0
- package/dist/prop/at/runtime-only.mjs +88 -0
- package/dist/prop/at/server.cjs +282 -0
- package/dist/prop/at/server.mjs +268 -0
- package/dist/prop/at/shared.cjs +153 -0
- package/dist/prop/at/shared.mjs +144 -0
- package/dist/prop/bosswind/browser.cjs +18 -0
- package/dist/prop/bosswind/browser.mjs +16 -0
- package/dist/prop/bosswind/runtime-only.cjs +18 -0
- package/dist/prop/bosswind/runtime-only.mjs +16 -0
- package/dist/prop/bosswind/server.cjs +81 -0
- package/dist/prop/bosswind/server.mjs +72 -0
- package/dist/prop/bosswind/shared.cjs +861 -0
- package/dist/prop/bosswind/shared.mjs +855 -0
- package/dist/prop/bosswind/tailwind-theme.cjs +703 -0
- package/dist/prop/bosswind/tailwind-theme.mjs +702 -0
- package/dist/prop/child/runtime-only.cjs +18 -0
- package/dist/prop/child/runtime-only.mjs +15 -0
- package/dist/prop/child/server.cjs +81 -0
- package/dist/prop/child/server.mjs +72 -0
- package/dist/prop/css/getDtsTemplate.cjs +65 -0
- package/dist/prop/css/getDtsTemplate.mjs +63 -0
- package/dist/prop/css/runtime-only.cjs +14 -0
- package/dist/prop/css/runtime-only.mjs +13 -0
- package/dist/prop/css/server.cjs +99 -0
- package/dist/prop/css/server.mjs +90 -0
- package/dist/prop/pseudo/runtime-only.cjs +23 -0
- package/dist/prop/pseudo/runtime-only.mjs +21 -0
- package/dist/prop/pseudo/server.cjs +91 -0
- package/dist/prop/pseudo/server.mjs +82 -0
- package/dist/prop/pseudo/shared.cjs +61 -0
- package/dist/prop/pseudo/shared.mjs +60 -0
- package/dist/reset/server.cjs +34 -0
- package/dist/reset/server.mjs +26 -0
- package/dist/runtime/index.cjs +119 -0
- package/dist/runtime/index.mjs +118 -0
- package/dist/runtime/preact.cjs +4 -0
- package/dist/runtime/preact.mjs +3 -0
- package/dist/runtime/qwik.cjs +21 -0
- package/dist/runtime/qwik.mjs +18 -0
- package/dist/runtime/react.cjs +4 -0
- package/dist/runtime/react.mjs +3 -0
- package/dist/runtime/solid.cjs +15 -0
- package/dist/runtime/solid.mjs +14 -0
- package/dist/runtime/stencil.cjs +25 -0
- package/dist/runtime/stencil.mjs +21 -0
- package/dist/runtime/style.cjs +14 -0
- package/dist/runtime/style.mjs +13 -0
- package/dist/shared/boundaries.cjs +288 -0
- package/dist/shared/boundaries.mjs +285 -0
- package/dist/shared/customCss.cjs +212 -0
- package/dist/shared/customCss.mjs +211 -0
- package/dist/shared/debug.cjs +76 -0
- package/dist/shared/debug.mjs +74 -0
- package/dist/shared/file.cjs +21 -0
- package/dist/shared/file.mjs +19 -0
- package/dist/shared/framework.cjs +10 -0
- package/dist/shared/framework.mjs +9 -0
- package/dist/shared/json.cjs +58 -0
- package/dist/shared/json.mjs +57 -0
- package/dist/shared/types.cjs +11 -0
- package/dist/shared/types.mjs +10 -0
- package/dist/strategy/classic/runtime-only.cjs +190 -0
- package/dist/strategy/classic/runtime-only.mjs +186 -0
- package/dist/strategy/classname-first/runtime-only.cjs +138 -0
- package/dist/strategy/classname-first/runtime-only.mjs +134 -0
- package/dist/strategy/classname-first/server.cjs +139 -0
- package/dist/strategy/classname-first/server.mjs +133 -0
- package/dist/strategy/classname-only/server.cjs +43 -0
- package/dist/strategy/classname-only/server.mjs +35 -0
- package/dist/strategy/inline-first/browser.cjs +61 -0
- package/dist/strategy/inline-first/browser.mjs +58 -0
- package/dist/strategy/inline-first/runtime-only.cjs +159 -0
- package/dist/strategy/inline-first/runtime-only.mjs +155 -0
- package/dist/strategy/inline-first/server.cjs +92 -0
- package/dist/strategy/inline-first/server.mjs +83 -0
- package/dist/strategy/runtime/runtime-only.cjs +24 -0
- package/dist/strategy/runtime/runtime-only.mjs +22 -0
- package/dist/strategy/runtime/server.cjs +72 -0
- package/dist/strategy/runtime/server.mjs +63 -0
- package/dist/strategy/runtime-only/css.cjs +183 -0
- package/dist/strategy/runtime-only/css.mjs +181 -0
- package/dist/tasks/build.cjs +88 -0
- package/dist/tasks/build.mjs +84 -0
- package/dist/tasks/compile.cjs +12 -0
- package/dist/tasks/compile.mjs +12 -0
- package/dist/tasks/postcss.cjs +116 -0
- package/dist/tasks/postcss.mjs +113 -0
- package/dist/tasks/session.cjs +46 -0
- package/dist/tasks/session.mjs +42 -0
- package/dist/tasks/watch.cjs +102 -0
- package/dist/tasks/watch.mjs +99 -0
- package/dist/transform/cache.cjs +24 -0
- package/dist/transform/cache.mjs +21 -0
- package/dist/transform/processFile.cjs +26 -0
- package/dist/transform/processFile.mjs +24 -0
- package/dist/use/token/browser.cjs +65 -0
- package/dist/use/token/browser.mjs +61 -0
- package/dist/use/token/runtime-only.cjs +245 -0
- package/dist/use/token/runtime-only.mjs +239 -0
- package/dist/use/token/server.cjs +325 -0
- package/dist/use/token/server.mjs +313 -0
- package/dist/use/token/vars.cjs +47 -0
- package/dist/use/token/vars.mjs +46 -0
- package/package.json +300 -4
- package/src/api/config.d.ts +1 -0
- package/src/fontsource/types.d.ts +50 -0
- package/src/packages/document-create-element/createElement.browser.js +3 -0
- package/src/packages/document-create-element/createElement.js +7 -0
- package/src/packages/document-create-element/package.json +17 -0
- package/src/packages/is-css-prop/browser.js +13 -0
- package/src/packages/is-css-prop/index.js +13 -0
- package/src/packages/is-css-prop/package-lock.json +52 -0
- package/src/packages/is-css-prop/package.json +17 -0
- package/src/prop/css/csstype.json +4387 -0
- package/src/prop/css/package.json +3 -0
- package/src/reset/reset.css +259 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { createApi } from "../api/server.mjs";
|
|
2
|
+
import { resolveContentPaths } from "../shared/file.mjs";
|
|
3
|
+
import { resolveBoundaryOutputs } from "../shared/boundaries.mjs";
|
|
4
|
+
import { emitSession, resolveSessionPayload } from "../tasks/session.mjs";
|
|
5
|
+
import { getClassNameProp } from "../shared/framework.mjs";
|
|
6
|
+
import { collectBossClassTokensInSource, collectBossClassTokensInText, rewriteClassNameTokensInSource, rewriteClassNameTokensInText } from "./classname.mjs";
|
|
7
|
+
import { createClassNameMapper } from "./classname-strategy.mjs";
|
|
8
|
+
import { scanPrepared } from "./prepared.mjs";
|
|
9
|
+
import { transformSource } from "./transform.mjs";
|
|
10
|
+
import fs from "node:fs/promises";
|
|
11
|
+
import path from "node:path";
|
|
12
|
+
import { transform } from "lightningcss";
|
|
13
|
+
|
|
14
|
+
//#region src/compile/index.ts
|
|
15
|
+
const supportedExtensions = new Set([
|
|
16
|
+
".js",
|
|
17
|
+
".jsx",
|
|
18
|
+
".ts",
|
|
19
|
+
".tsx",
|
|
20
|
+
".mjs",
|
|
21
|
+
".cjs"
|
|
22
|
+
]);
|
|
23
|
+
async function compileProject(options) {
|
|
24
|
+
const { config, prod } = options;
|
|
25
|
+
const compileConfig = {
|
|
26
|
+
stats: "quick",
|
|
27
|
+
...config.compile ?? {}
|
|
28
|
+
};
|
|
29
|
+
const content = config.content;
|
|
30
|
+
const baseDir = process.cwd();
|
|
31
|
+
if (!content) throw new Error("compile: config.content is required");
|
|
32
|
+
const root = baseDir;
|
|
33
|
+
const tempOutDir = compileConfig.tempOutDir;
|
|
34
|
+
if (!prod && !tempOutDir) throw new Error("compile.tempOutDir is required when not running in prod mode.");
|
|
35
|
+
const outputRoot = prod ? root : path.resolve(root, tempOutDir);
|
|
36
|
+
const inputPaths = (await resolveContentPaths(content)).sort();
|
|
37
|
+
const sourceCache = /* @__PURE__ */ new Map();
|
|
38
|
+
const preparedByFile = /* @__PURE__ */ new Map();
|
|
39
|
+
const preparedRegistry = /* @__PURE__ */ new Map();
|
|
40
|
+
const preparedUsages = [];
|
|
41
|
+
const api = await createApi(config, true);
|
|
42
|
+
api.baseDir = baseDir;
|
|
43
|
+
const classNameStrategy = compileConfig.classNameStrategy ?? false;
|
|
44
|
+
const classNameMapper = classNameStrategy ? createClassNameMapper({
|
|
45
|
+
strategy: classNameStrategy,
|
|
46
|
+
prefix: api.selectorPrefix ?? ""
|
|
47
|
+
}) : null;
|
|
48
|
+
if (classNameMapper) {
|
|
49
|
+
const baseContextToClassName = api.contextToClassName;
|
|
50
|
+
api.contextToClassName = (name, value, contexts, escape = true, _prefix = "") => {
|
|
51
|
+
const raw = baseContextToClassName(name, value, contexts, false, "");
|
|
52
|
+
const mapped = classNameMapper.getOrCreate(raw);
|
|
53
|
+
if (!escape) return mapped;
|
|
54
|
+
return api.camelCaseToDash(api.escapeClassName(mapped));
|
|
55
|
+
};
|
|
56
|
+
const baseClassTokenToSelector = api.classTokenToSelector;
|
|
57
|
+
api.classTokenToSelector = (token) => baseClassTokenToSelector(classNameMapper.getOrCreate(token));
|
|
58
|
+
}
|
|
59
|
+
const sessionStart = await resolveSessionPayload(baseDir, config, "compile", "start");
|
|
60
|
+
await emitSession(api, sessionStart);
|
|
61
|
+
await emitSession(api, {
|
|
62
|
+
...sessionStart,
|
|
63
|
+
phase: "run"
|
|
64
|
+
});
|
|
65
|
+
const statsMode = compileConfig.stats ?? "quick";
|
|
66
|
+
const start = process.hrtime.bigint();
|
|
67
|
+
const fileResults = [];
|
|
68
|
+
for (const inputPath of inputPaths) {
|
|
69
|
+
if (!(await fs.stat(inputPath).catch(() => null))?.isFile()) continue;
|
|
70
|
+
const ext = path.extname(inputPath);
|
|
71
|
+
const source = await fs.readFile(inputPath, "utf8");
|
|
72
|
+
sourceCache.set(inputPath, source);
|
|
73
|
+
if (classNameMapper) (supportedExtensions.has(ext) ? collectBossClassTokensInSource(source, {
|
|
74
|
+
filename: inputPath,
|
|
75
|
+
api
|
|
76
|
+
}) : collectBossClassTokensInText(source, { api })).forEach((token) => classNameMapper.getOrCreate(token));
|
|
77
|
+
if (!supportedExtensions.has(ext)) continue;
|
|
78
|
+
const scan = scanPrepared(source, {
|
|
79
|
+
isTs: ext === ".ts" || ext === ".tsx",
|
|
80
|
+
isJsx: ext === ".jsx" || ext === ".tsx" || ext === ".js" || ext === ".mjs" || ext === ".cjs"
|
|
81
|
+
});
|
|
82
|
+
if (scan.definitions.length) {
|
|
83
|
+
const local = /* @__PURE__ */ new Map();
|
|
84
|
+
for (const definition of scan.definitions) {
|
|
85
|
+
local.set(definition.name, {
|
|
86
|
+
definition: definition.definition,
|
|
87
|
+
inlineable: definition.inlineable
|
|
88
|
+
});
|
|
89
|
+
preparedRegistry.set(definition.name, {
|
|
90
|
+
definition: definition.definition,
|
|
91
|
+
inlineable: definition.inlineable
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
preparedByFile.set(inputPath, local);
|
|
95
|
+
}
|
|
96
|
+
if (scan.usages.length) for (const usage of scan.usages) preparedUsages.push({
|
|
97
|
+
...usage,
|
|
98
|
+
file: inputPath
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
const preparedGlobal = /* @__PURE__ */ new Map();
|
|
102
|
+
for (const [name, entry] of preparedRegistry.entries()) if (entry.inlineable) preparedGlobal.set(name, entry.definition);
|
|
103
|
+
const preparedRuntime = /* @__PURE__ */ new Set();
|
|
104
|
+
for (const usage of preparedUsages) {
|
|
105
|
+
if (!compileConfig.spread && usage.hasSpread) {
|
|
106
|
+
preparedRuntime.add(usage.name);
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
if (preparedByFile.get(usage.file)?.get(usage.name)) continue;
|
|
110
|
+
if (preparedRegistry.get(usage.name)?.inlineable) continue;
|
|
111
|
+
preparedRuntime.add(usage.name);
|
|
112
|
+
}
|
|
113
|
+
const processFile = async (inputPath) => {
|
|
114
|
+
if (!(await fs.stat(inputPath).catch(() => null))?.isFile()) return;
|
|
115
|
+
const ext = path.extname(inputPath);
|
|
116
|
+
const relativePath = path.relative(root, inputPath);
|
|
117
|
+
const outputPath = prod ? inputPath : path.join(outputRoot, relativePath);
|
|
118
|
+
await fs.mkdir(path.dirname(outputPath), { recursive: true });
|
|
119
|
+
const source = sourceCache.get(inputPath) ?? await fs.readFile(inputPath, "utf8");
|
|
120
|
+
if (!supportedExtensions.has(ext)) {
|
|
121
|
+
const parseContent = rewriteClassNameTokensInText(source, { mapToken: classNameMapper ? () => void 0 : void 0 });
|
|
122
|
+
await api.trigger("onParse", {
|
|
123
|
+
content: parseContent,
|
|
124
|
+
path: inputPath
|
|
125
|
+
}, (plugin) => plugin.name === "classname");
|
|
126
|
+
if (!prod) if (classNameMapper) {
|
|
127
|
+
const rewritten = rewriteClassNameTokensInText(source, { mapToken: (token) => classNameMapper.get(token) });
|
|
128
|
+
await fs.writeFile(outputPath, rewritten, "utf8");
|
|
129
|
+
} else await fs.copyFile(inputPath, outputPath);
|
|
130
|
+
fileResults.push({
|
|
131
|
+
file: inputPath,
|
|
132
|
+
processed: false,
|
|
133
|
+
copied: !prod,
|
|
134
|
+
needsRuntime: false,
|
|
135
|
+
needsValueHelper: false,
|
|
136
|
+
replacedElements: 0
|
|
137
|
+
});
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const classNameSource = rewriteClassNameTokensInSource(source, {
|
|
141
|
+
filename: inputPath,
|
|
142
|
+
classNameProp: getClassNameProp(api.framework),
|
|
143
|
+
mapToken: classNameMapper ? () => void 0 : void 0
|
|
144
|
+
});
|
|
145
|
+
await api.trigger("onParse", {
|
|
146
|
+
content: classNameSource,
|
|
147
|
+
path: inputPath
|
|
148
|
+
}, (plugin) => plugin.name === "classname");
|
|
149
|
+
const transformed = await transformSource(source, {
|
|
150
|
+
api,
|
|
151
|
+
compile: compileConfig,
|
|
152
|
+
filename: inputPath,
|
|
153
|
+
preparedGlobal,
|
|
154
|
+
preparedLocal: new Map(Array.from(preparedByFile.get(inputPath)?.entries() ?? []).map(([key, value]) => [key, value.definition])),
|
|
155
|
+
preparedRuntime,
|
|
156
|
+
classNameMapper
|
|
157
|
+
});
|
|
158
|
+
fileResults.push({
|
|
159
|
+
file: inputPath,
|
|
160
|
+
processed: true,
|
|
161
|
+
copied: false,
|
|
162
|
+
needsRuntime: transformed.needsRuntime,
|
|
163
|
+
needsValueHelper: transformed.needsValueHelper,
|
|
164
|
+
replacedElements: transformed.replacedElements
|
|
165
|
+
});
|
|
166
|
+
await fs.writeFile(outputPath, transformed.code, "utf8");
|
|
167
|
+
};
|
|
168
|
+
if (classNameStrategy === "shortest" || classNameStrategy === "unicode") for (const inputPath of inputPaths) await processFile(inputPath);
|
|
169
|
+
else await Promise.all(inputPaths.map(processFile));
|
|
170
|
+
let cssBytes = 0;
|
|
171
|
+
let cssWritten = false;
|
|
172
|
+
let stylesheetPath = null;
|
|
173
|
+
if (!prod && api.css.text.trim()) {
|
|
174
|
+
const resolvedStylesheetPath = config.stylesheetPath ?? path.join(root, config.configDir ?? ".bo$$", "styles.css");
|
|
175
|
+
const outputs = (await resolveBoundaryOutputs(api, {
|
|
176
|
+
rootDir: root,
|
|
177
|
+
stylesheetPath: resolvedStylesheetPath,
|
|
178
|
+
boundaries: config.css?.boundaries
|
|
179
|
+
})).outputs.map((output) => {
|
|
180
|
+
const relative = path.relative(root, output.path);
|
|
181
|
+
return {
|
|
182
|
+
path: path.join(outputRoot, relative),
|
|
183
|
+
text: output.text
|
|
184
|
+
};
|
|
185
|
+
});
|
|
186
|
+
const globalOutputPath = path.resolve(path.join(outputRoot, path.relative(root, resolvedStylesheetPath)));
|
|
187
|
+
const outputSizes = /* @__PURE__ */ new Map();
|
|
188
|
+
for (const output of outputs) {
|
|
189
|
+
const minified = transform({
|
|
190
|
+
code: Buffer.from(output.text),
|
|
191
|
+
filename: output.path,
|
|
192
|
+
minify: true
|
|
193
|
+
});
|
|
194
|
+
await fs.mkdir(path.dirname(output.path), { recursive: true });
|
|
195
|
+
await fs.writeFile(output.path, minified.code.toString(), "utf8");
|
|
196
|
+
outputSizes.set(path.resolve(output.path), minified.code.length);
|
|
197
|
+
}
|
|
198
|
+
const globalOutput = outputs.find((output) => path.resolve(output.path) === globalOutputPath);
|
|
199
|
+
cssBytes = globalOutput ? outputSizes.get(path.resolve(globalOutput.path)) ?? 0 : 0;
|
|
200
|
+
cssWritten = true;
|
|
201
|
+
stylesheetPath = globalOutput?.path ?? globalOutputPath;
|
|
202
|
+
}
|
|
203
|
+
const durationMs = Number(process.hrtime.bigint() - start) / 1e6;
|
|
204
|
+
const runtimeFiles = fileResults.filter((result$1) => result$1.needsRuntime).map((result$1) => result$1.file);
|
|
205
|
+
const valueHelperFiles = fileResults.filter((result$1) => result$1.needsValueHelper).map((result$1) => result$1.file);
|
|
206
|
+
const filesProcessed = fileResults.filter((result$1) => result$1.processed).length;
|
|
207
|
+
const filesCopied = fileResults.filter((result$1) => result$1.copied).length;
|
|
208
|
+
const filesTotal = fileResults.length;
|
|
209
|
+
const filesSkipped = filesTotal - filesProcessed - filesCopied;
|
|
210
|
+
const elementsReplaced = fileResults.reduce((total, result$1) => total + result$1.replacedElements, 0);
|
|
211
|
+
const result = {
|
|
212
|
+
statsMode,
|
|
213
|
+
stats: {
|
|
214
|
+
outputMode: prod ? "prod" : "temp",
|
|
215
|
+
outputDir: outputRoot,
|
|
216
|
+
runtimeFree: runtimeFiles.length === 0,
|
|
217
|
+
runtimeFiles: runtimeFiles.map((file) => path.relative(root, file)),
|
|
218
|
+
valueHelperFiles: valueHelperFiles.map((file) => path.relative(root, file)),
|
|
219
|
+
filesProcessed,
|
|
220
|
+
filesCopied,
|
|
221
|
+
filesSkipped,
|
|
222
|
+
filesTotal,
|
|
223
|
+
elementsReplaced,
|
|
224
|
+
durationMs,
|
|
225
|
+
cssBytes,
|
|
226
|
+
cssWritten,
|
|
227
|
+
stylesheetPath
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
await emitSession(api, await resolveSessionPayload(baseDir, config, "compile", "stop"));
|
|
231
|
+
return result;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
//#endregion
|
|
235
|
+
export { compileProject };
|