boss-css 0.0.13 → 0.0.15
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/LICENSE +21 -0
- package/README.md +146 -1
- package/dist/ai/server.cjs +1 -0
- package/dist/ai/server.mjs +1 -0
- package/dist/ai/skills.cjs +3 -0
- package/dist/ai/skills.mjs +3 -0
- package/dist/cli/tasks/init.cjs +43 -21
- package/dist/cli/tasks/init.mjs +43 -21
- package/dist/cli/templates/init.cjs +5 -5
- package/dist/cli/templates/init.mjs +5 -5
- package/dist/compile/jsx.cjs +4 -2
- package/dist/compile/jsx.mjs +4 -2
- package/dist/devtools-app/index.mjs +320 -0
- package/dist/devtools-app/monaco/vs/_commonjsHelpers-CT9FvmAN.js +1 -0
- package/dist/devtools-app/monaco/vs/abap-D-t0cyap.js +1 -0
- package/dist/devtools-app/monaco/vs/apex-CcIm7xu6.js +1 -0
- package/dist/devtools-app/monaco/vs/assets/css.worker-HnVq6Ewq.js +93 -0
- package/dist/devtools-app/monaco/vs/assets/editor.worker-Be8ye1pW.js +26 -0
- package/dist/devtools-app/monaco/vs/assets/html.worker-B51mlPHg.js +470 -0
- package/dist/devtools-app/monaco/vs/assets/json.worker-DKiEKt88.js +58 -0
- package/dist/devtools-app/monaco/vs/assets/ts.worker-CMbG-7ft.js +67731 -0
- package/dist/devtools-app/monaco/vs/azcli-BA0tQDCg.js +1 -0
- package/dist/devtools-app/monaco/vs/basic-languages/monaco.contribution.js +1 -0
- package/dist/devtools-app/monaco/vs/bat-C397hTD6.js +1 -0
- package/dist/devtools-app/monaco/vs/bicep-DF5aW17k.js +2 -0
- package/dist/devtools-app/monaco/vs/cameligo-plsz8qhj.js +1 -0
- package/dist/devtools-app/monaco/vs/clojure-Y2auQMzK.js +1 -0
- package/dist/devtools-app/monaco/vs/coffee-Bu45yuWE.js +1 -0
- package/dist/devtools-app/monaco/vs/cpp-CkKPQIni.js +1 -0
- package/dist/devtools-app/monaco/vs/csharp-CX28MZyh.js +1 -0
- package/dist/devtools-app/monaco/vs/csp-D8uWnyxW.js +1 -0
- package/dist/devtools-app/monaco/vs/css-CaeNmE3S.js +3 -0
- package/dist/devtools-app/monaco/vs/cssMode-CjiAH6dQ.js +1 -0
- package/dist/devtools-app/monaco/vs/cypher-DVThT8BS.js +1 -0
- package/dist/devtools-app/monaco/vs/dart-CmGfCvrO.js +1 -0
- package/dist/devtools-app/monaco/vs/dockerfile-CZqqYdch.js +1 -0
- package/dist/devtools-app/monaco/vs/ecl-30fUercY.js +1 -0
- package/dist/devtools-app/monaco/vs/editor/editor.main.css +1 -0
- package/dist/devtools-app/monaco/vs/editor/editor.main.js +5 -0
- package/dist/devtools-app/monaco/vs/editor.api-CalNCsUg.js +903 -0
- package/dist/devtools-app/monaco/vs/elixir-xjPaIfzF.js +1 -0
- package/dist/devtools-app/monaco/vs/flow9-DqtmStfK.js +1 -0
- package/dist/devtools-app/monaco/vs/freemarker2-Cz_sV6Md.js +3 -0
- package/dist/devtools-app/monaco/vs/fsharp-BOMdg4U1.js +1 -0
- package/dist/devtools-app/monaco/vs/go-D_hbi-Jt.js +1 -0
- package/dist/devtools-app/monaco/vs/graphql-CKUU4kLG.js +1 -0
- package/dist/devtools-app/monaco/vs/handlebars-OwglfO-1.js +1 -0
- package/dist/devtools-app/monaco/vs/hcl-DTaboeZW.js +1 -0
- package/dist/devtools-app/monaco/vs/html-Pa1xEWsY.js +1 -0
- package/dist/devtools-app/monaco/vs/htmlMode-Bz67EXwp.js +1 -0
- package/dist/devtools-app/monaco/vs/ini-CsNwO04R.js +1 -0
- package/dist/devtools-app/monaco/vs/java-CI4ZMsH9.js +1 -0
- package/dist/devtools-app/monaco/vs/javascript-PczUCGdz.js +1 -0
- package/dist/devtools-app/monaco/vs/jsonMode-DULH5oaX.js +7 -0
- package/dist/devtools-app/monaco/vs/julia-BwzEvaQw.js +1 -0
- package/dist/devtools-app/monaco/vs/kotlin-IUYPiTV8.js +1 -0
- package/dist/devtools-app/monaco/vs/language/css/monaco.contribution.js +1 -0
- package/dist/devtools-app/monaco/vs/language/html/monaco.contribution.js +1 -0
- package/dist/devtools-app/monaco/vs/language/json/monaco.contribution.js +1 -0
- package/dist/devtools-app/monaco/vs/language/typescript/monaco.contribution.js +1 -0
- package/dist/devtools-app/monaco/vs/less-C0eDYdqa.js +2 -0
- package/dist/devtools-app/monaco/vs/lexon-iON-Kj97.js +1 -0
- package/dist/devtools-app/monaco/vs/liquid-DqKjdPGy.js +1 -0
- package/dist/devtools-app/monaco/vs/loader.js +1368 -0
- package/dist/devtools-app/monaco/vs/lspLanguageFeatures-kM9O9rjY.js +4 -0
- package/dist/devtools-app/monaco/vs/lua-DtygF91M.js +1 -0
- package/dist/devtools-app/monaco/vs/m3-CsR4AuFi.js +1 -0
- package/dist/devtools-app/monaco/vs/markdown-C_rD0bIw.js +1 -0
- package/dist/devtools-app/monaco/vs/mdx-DEWtB1K5.js +1 -0
- package/dist/devtools-app/monaco/vs/mips-CiYP61RB.js +1 -0
- package/dist/devtools-app/monaco/vs/monaco.contribution-D2OdxNBt.js +1 -0
- package/dist/devtools-app/monaco/vs/monaco.contribution-DO3azKX8.js +1 -0
- package/dist/devtools-app/monaco/vs/monaco.contribution-EcChJV6a.js +1 -0
- package/dist/devtools-app/monaco/vs/monaco.contribution-qLAYrEOP.js +1 -0
- package/dist/devtools-app/monaco/vs/msdax-C38-sJlp.js +1 -0
- package/dist/devtools-app/monaco/vs/mysql-CdtbpvbG.js +1 -0
- package/dist/devtools-app/monaco/vs/nls.messages-loader.js +1 -0
- package/dist/devtools-app/monaco/vs/nls.messages.cs.js.js +17 -0
- package/dist/devtools-app/monaco/vs/nls.messages.de.js.js +17 -0
- package/dist/devtools-app/monaco/vs/nls.messages.es.js.js +17 -0
- package/dist/devtools-app/monaco/vs/nls.messages.fr.js.js +15 -0
- package/dist/devtools-app/monaco/vs/nls.messages.it.js.js +15 -0
- package/dist/devtools-app/monaco/vs/nls.messages.ja.js.js +17 -0
- package/dist/devtools-app/monaco/vs/nls.messages.js.js +10 -0
- package/dist/devtools-app/monaco/vs/nls.messages.ko.js.js +25 -0
- package/dist/devtools-app/monaco/vs/nls.messages.pl.js.js +17 -0
- package/dist/devtools-app/monaco/vs/nls.messages.pt-br.js.js +6 -0
- package/dist/devtools-app/monaco/vs/nls.messages.ru.js.js +17 -0
- package/dist/devtools-app/monaco/vs/nls.messages.tr.js.js +15 -0
- package/dist/devtools-app/monaco/vs/nls.messages.zh-cn.js.js +17 -0
- package/dist/devtools-app/monaco/vs/nls.messages.zh-tw.js.js +15 -0
- package/dist/devtools-app/monaco/vs/objective-c-CntZFaHX.js +1 -0
- package/dist/devtools-app/monaco/vs/pascal-r6kuqfl_.js +1 -0
- package/dist/devtools-app/monaco/vs/pascaligo-BiXoTmXh.js +1 -0
- package/dist/devtools-app/monaco/vs/perl-DABw_TcH.js +1 -0
- package/dist/devtools-app/monaco/vs/pgsql-me_jFXeX.js +1 -0
- package/dist/devtools-app/monaco/vs/php-D_kh-9LK.js +1 -0
- package/dist/devtools-app/monaco/vs/pla-VfZjczW0.js +1 -0
- package/dist/devtools-app/monaco/vs/postiats-BBSzz8Pk.js +1 -0
- package/dist/devtools-app/monaco/vs/powerquery-Dt-g_2cc.js +1 -0
- package/dist/devtools-app/monaco/vs/powershell-B-7ap1zc.js +1 -0
- package/dist/devtools-app/monaco/vs/protobuf-BmtuEB1A.js +2 -0
- package/dist/devtools-app/monaco/vs/pug-BRpRNeEb.js +1 -0
- package/dist/devtools-app/monaco/vs/python-Cr0UkIbn.js +1 -0
- package/dist/devtools-app/monaco/vs/qsharp-BzsFaUU9.js +1 -0
- package/dist/devtools-app/monaco/vs/r-f8dDdrp4.js +1 -0
- package/dist/devtools-app/monaco/vs/razor-BYAHOTkz.js +1 -0
- package/dist/devtools-app/monaco/vs/redis-fvZQY4PI.js +1 -0
- package/dist/devtools-app/monaco/vs/redshift-45Et0LQi.js +1 -0
- package/dist/devtools-app/monaco/vs/restructuredtext-C7UUFKFD.js +1 -0
- package/dist/devtools-app/monaco/vs/ruby-CZO8zYTz.js +1 -0
- package/dist/devtools-app/monaco/vs/rust-Bfetafyc.js +1 -0
- package/dist/devtools-app/monaco/vs/sb-3GYllVck.js +1 -0
- package/dist/devtools-app/monaco/vs/scala-foMgrKo1.js +1 -0
- package/dist/devtools-app/monaco/vs/scheme-CHdMtr7p.js +1 -0
- package/dist/devtools-app/monaco/vs/scss-C1cmLt9V.js +3 -0
- package/dist/devtools-app/monaco/vs/shell-ClXCKCEW.js +1 -0
- package/dist/devtools-app/monaco/vs/solidity-MZ6ExpPy.js +1 -0
- package/dist/devtools-app/monaco/vs/sophia-DWkuSsPQ.js +1 -0
- package/dist/devtools-app/monaco/vs/sparql-AUGFYSyk.js +1 -0
- package/dist/devtools-app/monaco/vs/sql-32GpJSV2.js +1 -0
- package/dist/devtools-app/monaco/vs/st-CuDFIVZ_.js +1 -0
- package/dist/devtools-app/monaco/vs/swift-n-2HociN.js +3 -0
- package/dist/devtools-app/monaco/vs/systemverilog-Ch4vA8Yt.js +1 -0
- package/dist/devtools-app/monaco/vs/tcl-D74tq1nH.js +1 -0
- package/dist/devtools-app/monaco/vs/tsMode-CZz1Umrk.js +11 -0
- package/dist/devtools-app/monaco/vs/twig-C6taOxMV.js +1 -0
- package/dist/devtools-app/monaco/vs/typescript-DfOrAzoV.js +1 -0
- package/dist/devtools-app/monaco/vs/typespec-D-PIh9Xw.js +1 -0
- package/dist/devtools-app/monaco/vs/vb-Dyb2648j.js +1 -0
- package/dist/devtools-app/monaco/vs/wgsl-BhLXMOR0.js +298 -0
- package/dist/devtools-app/monaco/vs/workers-DcJshg-q.js +1 -0
- package/dist/devtools-app/monaco/vs/xml-CdsdnY8S.js +1 -0
- package/dist/devtools-app/monaco/vs/yaml-DYGvmE88.js +1 -0
- package/dist/eslint-plugin/index.cjs +5 -2
- package/dist/eslint-plugin/index.mjs +5 -2
- package/dist/eslint-plugin/rules/prefer-unitless-values.cjs +217 -0
- package/dist/eslint-plugin/rules/prefer-unitless-values.mjs +217 -0
- package/dist/eslint-plugin/utils/api.cjs +3 -4
- package/dist/eslint-plugin/utils/api.mjs +2 -2
- package/dist/native/browser.cjs +14 -1
- package/dist/native/browser.mjs +14 -1
- package/dist/native/server.cjs +4 -4
- package/dist/native/server.mjs +4 -4
- package/dist/parser/classname/server.cjs +2 -0
- package/dist/parser/classname/server.mjs +2 -0
- package/dist/parser/jsx/server.cjs +13 -7
- package/dist/parser/jsx/server.mjs +13 -7
- package/dist/prop/at/server.cjs +6 -4
- package/dist/prop/at/server.mjs +6 -4
- package/dist/prop/at/shared.cjs +3 -3
- package/dist/prop/at/shared.mjs +3 -3
- package/dist/prop/bosswind/browser.cjs +3 -0
- package/dist/prop/bosswind/browser.mjs +3 -0
- package/dist/prop/bosswind/runtime-only.cjs +3 -0
- package/dist/prop/bosswind/runtime-only.mjs +3 -0
- package/dist/prop/bosswind/selectors.cjs +18 -0
- package/dist/prop/bosswind/selectors.mjs +16 -0
- package/dist/prop/bosswind/shared.cjs +93 -32
- package/dist/prop/bosswind/shared.mjs +94 -32
- package/dist/prop/child/server.cjs +3 -2
- package/dist/prop/child/server.mjs +3 -2
- package/dist/prop/css/server.cjs +2 -1
- package/dist/prop/css/server.mjs +2 -1
- package/dist/prop/pseudo/server.cjs +3 -2
- package/dist/prop/pseudo/server.mjs +3 -2
- package/dist/strategy/classname-first/browser.cjs +7 -1
- package/dist/strategy/classname-first/browser.mjs +7 -1
- package/dist/strategy/classname-first/runtime-only.cjs +15 -4
- package/dist/strategy/classname-first/runtime-only.mjs +15 -4
- package/dist/strategy/classname-first/server.cjs +1 -1
- package/dist/strategy/classname-first/server.mjs +1 -1
- package/dist/transform/cache.cjs +0 -3
- package/dist/transform/cache.mjs +0 -2
- package/dist/use/token/browser.cjs +17 -9
- package/dist/use/token/browser.mjs +18 -10
- package/dist/use/token/normalize.cjs +474 -0
- package/dist/use/token/normalize.mjs +473 -0
- package/dist/use/token/propMap.cjs +34 -5
- package/dist/use/token/propMap.mjs +34 -6
- package/dist/use/token/runtime-only.cjs +36 -47
- package/dist/use/token/runtime-only.mjs +37 -48
- package/dist/use/token/server.cjs +84 -17
- package/dist/use/token/server.mjs +85 -19
- package/dist/use/token/vars.cjs +14 -2
- package/dist/use/token/vars.mjs +15 -2
- package/package.json +13 -7
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { collectClassLiteralsFromExpression, compilePatterns, getCalleeName, getJSXAttributeName, getLiteralInfo, matchesPattern } from "../utils/ast.mjs";
|
|
2
|
+
import { DEFAULT_ATTRIBUTE_PATTERNS, DEFAULT_CALLEE_PATTERNS, DEFAULT_TAG_PATTERNS, DEFAULT_VARIABLE_PATTERNS } from "../utils/defaults.mjs";
|
|
3
|
+
import { buildLiteralReplacement } from "../utils/format.mjs";
|
|
4
|
+
import { getApi } from "../utils/api.mjs";
|
|
5
|
+
import { isCssPropName, parseGroupedSelector, splitClassList, splitFragments } from "../utils/boss-classes.mjs";
|
|
6
|
+
|
|
7
|
+
//#region src/eslint-plugin/rules/prefer-unitless-values.js
|
|
8
|
+
const RULE_NAME = "prefer-unitless-values";
|
|
9
|
+
const defaultOptions = {
|
|
10
|
+
attributes: DEFAULT_ATTRIBUTE_PATTERNS,
|
|
11
|
+
callees: DEFAULT_CALLEE_PATTERNS,
|
|
12
|
+
variables: DEFAULT_VARIABLE_PATTERNS,
|
|
13
|
+
tags: DEFAULT_TAG_PATTERNS,
|
|
14
|
+
additionalProps: [],
|
|
15
|
+
unit: null
|
|
16
|
+
};
|
|
17
|
+
const createPatterns = (options) => ({
|
|
18
|
+
attributes: compilePatterns(options.attributes),
|
|
19
|
+
callees: compilePatterns(options.callees),
|
|
20
|
+
variables: compilePatterns(options.variables),
|
|
21
|
+
tags: compilePatterns(options.tags)
|
|
22
|
+
});
|
|
23
|
+
const normalizeUnit = (value) => {
|
|
24
|
+
if (typeof value !== "string") return null;
|
|
25
|
+
const trimmed = value.trim();
|
|
26
|
+
return trimmed.length ? trimmed : null;
|
|
27
|
+
};
|
|
28
|
+
const escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
29
|
+
const createUnitValuePattern = (unit) => new RegExp(`(^|_)([+-]?(?:\\d*\\.\\d+|\\d+))${escapeRegExp(unit)}(?=(_|$))`, "g");
|
|
30
|
+
const stripDefaultUnitSuffixes = (rawValue, unit, pattern = createUnitValuePattern(unit)) => {
|
|
31
|
+
if (!rawValue || !unit) return null;
|
|
32
|
+
let changed = false;
|
|
33
|
+
const nextValue = rawValue.replace(pattern, (_, prefix, numberValue) => {
|
|
34
|
+
changed = true;
|
|
35
|
+
return `${prefix}${numberValue}`;
|
|
36
|
+
});
|
|
37
|
+
return changed ? nextValue : null;
|
|
38
|
+
};
|
|
39
|
+
const getSimpleTokenValueInfo = (token, extraProps) => {
|
|
40
|
+
const fragments = splitFragments(token);
|
|
41
|
+
if (!fragments.length) return null;
|
|
42
|
+
let propIndex = -1;
|
|
43
|
+
for (let i = 0; i < fragments.length; i += 1) if (isCssPropName(fragments[i], extraProps)) {
|
|
44
|
+
propIndex = i;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
if (propIndex === -1 || propIndex >= fragments.length - 1) return null;
|
|
48
|
+
return {
|
|
49
|
+
prop: fragments[propIndex],
|
|
50
|
+
value: fragments.slice(propIndex + 1).join(":"),
|
|
51
|
+
prefix: fragments.slice(0, propIndex + 1).join(":")
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
const rewriteGroupedToken = (token, unit, extraProps, pattern) => {
|
|
55
|
+
const grouped = parseGroupedSelector(token);
|
|
56
|
+
if (!grouped) return null;
|
|
57
|
+
let changed = false;
|
|
58
|
+
const entries = [];
|
|
59
|
+
const issues = [];
|
|
60
|
+
for (const entry of grouped.entries) {
|
|
61
|
+
const current = entry.rawValue;
|
|
62
|
+
const nextValue = isCssPropName(entry.name, extraProps) ? stripDefaultUnitSuffixes(current, unit, pattern) : null;
|
|
63
|
+
if (!nextValue) {
|
|
64
|
+
entries.push(entry);
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
changed = true;
|
|
68
|
+
entries.push({
|
|
69
|
+
...entry,
|
|
70
|
+
rawValue: nextValue
|
|
71
|
+
});
|
|
72
|
+
issues.push({
|
|
73
|
+
prop: entry.name,
|
|
74
|
+
value: current,
|
|
75
|
+
nextValue
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
if (!changed) return null;
|
|
79
|
+
return {
|
|
80
|
+
nextToken: `${grouped.prefix}:{${entries.map((entry) => `${entry.name}:${entry.rawValue}`).join(";")}}`,
|
|
81
|
+
issues
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
const rewriteSimpleToken = (token, unit, extraProps, pattern) => {
|
|
85
|
+
const valueInfo = getSimpleTokenValueInfo(token, extraProps);
|
|
86
|
+
if (!valueInfo) return null;
|
|
87
|
+
const nextValue = stripDefaultUnitSuffixes(valueInfo.value, unit, pattern);
|
|
88
|
+
if (!nextValue) return null;
|
|
89
|
+
return {
|
|
90
|
+
nextToken: `${valueInfo.prefix}:${nextValue}`,
|
|
91
|
+
issues: [{
|
|
92
|
+
prop: valueInfo.prop,
|
|
93
|
+
value: valueInfo.value,
|
|
94
|
+
nextValue
|
|
95
|
+
}]
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
const rewriteTokenUnitValues = (token, unit, extraProps, pattern = createUnitValuePattern(unit)) => rewriteGroupedToken(token, unit, extraProps, pattern) || rewriteSimpleToken(token, unit, extraProps, pattern);
|
|
99
|
+
const analyzeClassList = (classList, unit, extraProps) => {
|
|
100
|
+
const tokens = splitClassList(classList);
|
|
101
|
+
if (!tokens.length) return {
|
|
102
|
+
issues: [],
|
|
103
|
+
nextClassList: null
|
|
104
|
+
};
|
|
105
|
+
const pattern = createUnitValuePattern(unit);
|
|
106
|
+
let changed = false;
|
|
107
|
+
const issues = [];
|
|
108
|
+
const nextTokens = tokens.map((token) => {
|
|
109
|
+
const rewritten = rewriteTokenUnitValues(token, unit, extraProps, pattern);
|
|
110
|
+
if (!rewritten) return token;
|
|
111
|
+
changed = true;
|
|
112
|
+
issues.push(...rewritten.issues);
|
|
113
|
+
return rewritten.nextToken;
|
|
114
|
+
});
|
|
115
|
+
return {
|
|
116
|
+
issues,
|
|
117
|
+
nextClassList: changed ? nextTokens.join(" ") : null
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
const create = (context) => {
|
|
121
|
+
const sourceCode = context.getSourceCode();
|
|
122
|
+
const options = {
|
|
123
|
+
...defaultOptions,
|
|
124
|
+
...context.options[0] || {}
|
|
125
|
+
};
|
|
126
|
+
const patterns = createPatterns(options);
|
|
127
|
+
const extraProps = options.additionalProps?.length ? new Set(options.additionalProps) : null;
|
|
128
|
+
const { api } = getApi();
|
|
129
|
+
const unit = normalizeUnit(options.unit) || normalizeUnit(api?.unit) || "px";
|
|
130
|
+
if (!unit) return {};
|
|
131
|
+
const reportLiteral = (literal) => {
|
|
132
|
+
if (!literal || !literal.value) return;
|
|
133
|
+
const { issues, nextClassList } = analyzeClassList(literal.value, unit, extraProps);
|
|
134
|
+
if (!issues.length) return;
|
|
135
|
+
const preview = issues.slice(0, 3).map((issue) => `${issue.prop}:${issue.value} -> ${issue.prop}:${issue.nextValue}`).join(", ");
|
|
136
|
+
const remainder = issues.length > 3 ? ` (+${issues.length - 3} more)` : "";
|
|
137
|
+
context.report({
|
|
138
|
+
node: literal.node,
|
|
139
|
+
messageId: "preferUnitlessValues",
|
|
140
|
+
data: {
|
|
141
|
+
unit,
|
|
142
|
+
values: preview + remainder
|
|
143
|
+
},
|
|
144
|
+
fix: literal.canFix && nextClassList ? (fixer) => fixer.replaceText(literal.node, buildLiteralReplacement(literal.node, sourceCode, nextClassList)) : null
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
return {
|
|
148
|
+
JSXAttribute(node) {
|
|
149
|
+
const name = getJSXAttributeName(node);
|
|
150
|
+
if (!name || !matchesPattern(patterns.attributes, name)) return;
|
|
151
|
+
if (!node.value) return;
|
|
152
|
+
const literals = [];
|
|
153
|
+
collectClassLiteralsFromExpression(node.value, sourceCode, literals);
|
|
154
|
+
for (const literal of literals) reportLiteral(literal);
|
|
155
|
+
},
|
|
156
|
+
CallExpression(node) {
|
|
157
|
+
const calleeName = getCalleeName(node.callee);
|
|
158
|
+
if (!calleeName || !matchesPattern(patterns.callees, calleeName)) return;
|
|
159
|
+
const literals = [];
|
|
160
|
+
for (const argument of node.arguments) collectClassLiteralsFromExpression(argument, sourceCode, literals);
|
|
161
|
+
for (const literal of literals) reportLiteral(literal);
|
|
162
|
+
},
|
|
163
|
+
VariableDeclarator(node) {
|
|
164
|
+
if (!node.id || node.id.type !== "Identifier") return;
|
|
165
|
+
if (!matchesPattern(patterns.variables, node.id.name)) return;
|
|
166
|
+
const literals = [];
|
|
167
|
+
collectClassLiteralsFromExpression(node.init, sourceCode, literals);
|
|
168
|
+
for (const literal of literals) reportLiteral(literal);
|
|
169
|
+
},
|
|
170
|
+
TaggedTemplateExpression(node) {
|
|
171
|
+
const tagName = getCalleeName(node.tag);
|
|
172
|
+
if (!tagName || !matchesPattern(patterns.tags, tagName)) return;
|
|
173
|
+
const literal = getLiteralInfo(node.quasi, sourceCode);
|
|
174
|
+
if (literal) reportLiteral(literal);
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
var prefer_unitless_values_default = {
|
|
179
|
+
name: RULE_NAME,
|
|
180
|
+
meta: {
|
|
181
|
+
type: "suggestion",
|
|
182
|
+
docs: { description: "Prefer unitless numeric class values for the configured default unit (for example border:1_solid over border:1px_solid)." },
|
|
183
|
+
fixable: "code",
|
|
184
|
+
schema: [{
|
|
185
|
+
type: "object",
|
|
186
|
+
additionalProperties: false,
|
|
187
|
+
properties: {
|
|
188
|
+
attributes: {
|
|
189
|
+
type: "array",
|
|
190
|
+
items: { type: "string" }
|
|
191
|
+
},
|
|
192
|
+
callees: {
|
|
193
|
+
type: "array",
|
|
194
|
+
items: { type: "string" }
|
|
195
|
+
},
|
|
196
|
+
variables: {
|
|
197
|
+
type: "array",
|
|
198
|
+
items: { type: "string" }
|
|
199
|
+
},
|
|
200
|
+
tags: {
|
|
201
|
+
type: "array",
|
|
202
|
+
items: { type: "string" }
|
|
203
|
+
},
|
|
204
|
+
additionalProps: {
|
|
205
|
+
type: "array",
|
|
206
|
+
items: { type: "string" }
|
|
207
|
+
},
|
|
208
|
+
unit: { type: "string" }
|
|
209
|
+
}
|
|
210
|
+
}],
|
|
211
|
+
messages: { preferUnitlessValues: "Avoid hardcoded \"{{unit}}\" in Boss class values: {{values}}." }
|
|
212
|
+
},
|
|
213
|
+
create
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
//#endregion
|
|
217
|
+
export { prefer_unitless_values_default as default };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
let boss_css_api_config = require("boss-css/api/config");
|
|
1
|
+
const require_api_server = require('../../api/server.cjs');
|
|
2
|
+
const require_api_config = require('../../api/config.cjs');
|
|
4
3
|
|
|
5
4
|
//#region src/eslint-plugin/utils/api.js
|
|
6
5
|
let api = null;
|
|
@@ -10,7 +9,7 @@ const initApi = () => {
|
|
|
10
9
|
if (initPromise) return initPromise;
|
|
11
10
|
initPromise = (async () => {
|
|
12
11
|
try {
|
|
13
|
-
api = await
|
|
12
|
+
api = await require_api_server.createApi(await require_api_config.loadConfig(process.cwd()), true);
|
|
14
13
|
} catch (err) {
|
|
15
14
|
error = err;
|
|
16
15
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createApi } from "
|
|
2
|
-
import { loadConfig } from "
|
|
1
|
+
import { createApi } from "../../api/server.mjs";
|
|
2
|
+
import { loadConfig } from "../../api/config.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/eslint-plugin/utils/api.js
|
|
5
5
|
let api = null;
|
package/dist/native/browser.cjs
CHANGED
|
@@ -21,6 +21,18 @@ const normalizeValue = (value) => {
|
|
|
21
21
|
if (isNumericValue(value)) return typeof value === "string" ? Number(value) : value;
|
|
22
22
|
return value;
|
|
23
23
|
};
|
|
24
|
+
const resolveTokenLiteral = (api, tokenPath) => {
|
|
25
|
+
const tokens = typeof api.tokens === "function" ? api.tokens({}) : api.tokens;
|
|
26
|
+
if (!tokens || typeof tokens !== "object") return void 0;
|
|
27
|
+
const [group, ...rest] = tokenPath.split(".");
|
|
28
|
+
let current = tokens[group];
|
|
29
|
+
for (const key of rest) {
|
|
30
|
+
if (!current || typeof current !== "object") return void 0;
|
|
31
|
+
const next = current[key];
|
|
32
|
+
current = next && typeof next === "object" && "value" in next ? next.value : next;
|
|
33
|
+
}
|
|
34
|
+
return current;
|
|
35
|
+
};
|
|
24
36
|
const getStyleProps = (api) => {
|
|
25
37
|
if (!api.nativeStyleProps) return /* @__PURE__ */ new Set();
|
|
26
38
|
api.nativeStylePropSet ??= new Set(api.nativeStyleProps);
|
|
@@ -49,7 +61,8 @@ const onBrowserObjectStart = (api, { input, output = {} }) => {
|
|
|
49
61
|
let value = input[prop];
|
|
50
62
|
if (typeof value === "function") value = value();
|
|
51
63
|
const token = require_use_token_runtime_only.resolveRuntimeToken(api, prop, value);
|
|
52
|
-
if (token) value = token.value;
|
|
64
|
+
if (token) if (api.runtime?.only === true && typeof token.value === "string" && token.value.startsWith("var(") && token.tokenPath) value = resolveTokenLiteral(api, token.tokenPath) ?? token.value;
|
|
65
|
+
else value = token.value;
|
|
53
66
|
bossStyle[prop] = normalizeValue(value);
|
|
54
67
|
hasBossStyle = true;
|
|
55
68
|
delete input[prop];
|
package/dist/native/browser.mjs
CHANGED
|
@@ -21,6 +21,18 @@ const normalizeValue = (value) => {
|
|
|
21
21
|
if (isNumericValue(value)) return typeof value === "string" ? Number(value) : value;
|
|
22
22
|
return value;
|
|
23
23
|
};
|
|
24
|
+
const resolveTokenLiteral = (api, tokenPath) => {
|
|
25
|
+
const tokens = typeof api.tokens === "function" ? api.tokens({}) : api.tokens;
|
|
26
|
+
if (!tokens || typeof tokens !== "object") return void 0;
|
|
27
|
+
const [group, ...rest] = tokenPath.split(".");
|
|
28
|
+
let current = tokens[group];
|
|
29
|
+
for (const key of rest) {
|
|
30
|
+
if (!current || typeof current !== "object") return void 0;
|
|
31
|
+
const next = current[key];
|
|
32
|
+
current = next && typeof next === "object" && "value" in next ? next.value : next;
|
|
33
|
+
}
|
|
34
|
+
return current;
|
|
35
|
+
};
|
|
24
36
|
const getStyleProps = (api) => {
|
|
25
37
|
if (!api.nativeStyleProps) return /* @__PURE__ */ new Set();
|
|
26
38
|
api.nativeStylePropSet ??= new Set(api.nativeStyleProps);
|
|
@@ -49,7 +61,8 @@ const onBrowserObjectStart = (api, { input, output = {} }) => {
|
|
|
49
61
|
let value = input[prop];
|
|
50
62
|
if (typeof value === "function") value = value();
|
|
51
63
|
const token = resolveRuntimeToken(api, prop, value);
|
|
52
|
-
if (token) value = token.value;
|
|
64
|
+
if (token) if (api.runtime?.only === true && typeof token.value === "string" && token.value.startsWith("var(") && token.tokenPath) value = resolveTokenLiteral(api, token.tokenPath) ?? token.value;
|
|
65
|
+
else value = token.value;
|
|
53
66
|
bossStyle[prop] = normalizeValue(value);
|
|
54
67
|
hasBossStyle = true;
|
|
55
68
|
delete input[prop];
|
package/dist/native/server.cjs
CHANGED
|
@@ -134,10 +134,10 @@ type BaseFn<T extends React.ElementType = DefaultNativeElement> = {
|
|
|
134
134
|
api.file.native.dts.set("body", "jsx:proxy-start", `type ProxyCustomMembers = {
|
|
135
135
|
`).set("body", "jsx:proxy-utils", ` $: $$NoopFn
|
|
136
136
|
merge: (...inputs: import('boss-css/merge').MergeInput[]) => import('boss-css/merge').MergeOutput
|
|
137
|
-
cx: (...inputs: import('boss-css/
|
|
138
|
-
cv: typeof import('boss-css/
|
|
139
|
-
scv: typeof import('boss-css/
|
|
140
|
-
sv: typeof import('boss-css/
|
|
137
|
+
cx: (...inputs: import('boss-css/variants').CxValue[]) => string
|
|
138
|
+
cv: typeof import('boss-css/variants').cv
|
|
139
|
+
scv: typeof import('boss-css/variants').scv
|
|
140
|
+
sv: typeof import('boss-css/variants').sv
|
|
141
141
|
css: CssFn
|
|
142
142
|
style: StyleFn
|
|
143
143
|
`).set("body", "jsx:proxy-custom-members", ``).set("body", "jsx:proxy-custom-members-end", `}`).set("body", "jsx:proxy-type", `type Proxy = BaseFn & {
|
package/dist/native/server.mjs
CHANGED
|
@@ -133,10 +133,10 @@ type BaseFn<T extends React.ElementType = DefaultNativeElement> = {
|
|
|
133
133
|
api.file.native.dts.set("body", "jsx:proxy-start", `type ProxyCustomMembers = {
|
|
134
134
|
`).set("body", "jsx:proxy-utils", ` $: $$NoopFn
|
|
135
135
|
merge: (...inputs: import('boss-css/merge').MergeInput[]) => import('boss-css/merge').MergeOutput
|
|
136
|
-
cx: (...inputs: import('boss-css/
|
|
137
|
-
cv: typeof import('boss-css/
|
|
138
|
-
scv: typeof import('boss-css/
|
|
139
|
-
sv: typeof import('boss-css/
|
|
136
|
+
cx: (...inputs: import('boss-css/variants').CxValue[]) => string
|
|
137
|
+
cv: typeof import('boss-css/variants').cv
|
|
138
|
+
scv: typeof import('boss-css/variants').scv
|
|
139
|
+
sv: typeof import('boss-css/variants').sv
|
|
140
140
|
css: CssFn
|
|
141
141
|
style: StyleFn
|
|
142
142
|
`).set("body", "jsx:proxy-custom-members", ``).set("body", "jsx:proxy-custom-members-end", `}`).set("body", "jsx:proxy-type", `type Proxy = BaseFn & {
|
|
@@ -103,6 +103,8 @@ const extractPropTree = async (string, api) => {
|
|
|
103
103
|
prop.important = true;
|
|
104
104
|
prop.classToken = selector;
|
|
105
105
|
}
|
|
106
|
+
if (lastProp) prop.selectorName = lastProp;
|
|
107
|
+
prop.selectorValue = value;
|
|
106
108
|
createPropPath([...path], prop, tree);
|
|
107
109
|
selectorTokens.delete(key);
|
|
108
110
|
}
|
|
@@ -103,6 +103,8 @@ const extractPropTree = async (string, api) => {
|
|
|
103
103
|
prop.important = true;
|
|
104
104
|
prop.classToken = selector;
|
|
105
105
|
}
|
|
106
|
+
if (lastProp) prop.selectorName = lastProp;
|
|
107
|
+
prop.selectorValue = value;
|
|
106
108
|
createPropPath([...path], prop, tree);
|
|
107
109
|
selectorTokens.delete(key);
|
|
108
110
|
}
|
|
@@ -23,6 +23,11 @@ const settings = new Map([
|
|
|
23
23
|
["types", true],
|
|
24
24
|
["emitRuntime", false]
|
|
25
25
|
]);
|
|
26
|
+
const resolveGlobals = (api) => {
|
|
27
|
+
const configValue = api.userConfig?.jsx?.globals;
|
|
28
|
+
if (typeof configValue === "boolean") return configValue;
|
|
29
|
+
return settings.get("globals") !== false;
|
|
30
|
+
};
|
|
26
31
|
/**
|
|
27
32
|
* Style:
|
|
28
33
|
*
|
|
@@ -90,6 +95,7 @@ const onBoot = async (api) => {
|
|
|
90
95
|
needsRuntime = false;
|
|
91
96
|
preparedComponents.clear();
|
|
92
97
|
const needsRuntimeTest = () => needsRuntime || settings.get("emitRuntime") === true;
|
|
98
|
+
const globalsEnabled = resolveGlobals(api);
|
|
93
99
|
const proxyVar = api.file.js.import({
|
|
94
100
|
name: "proxy",
|
|
95
101
|
from: "boss-css/runtime"
|
|
@@ -98,7 +104,7 @@ const onBoot = async (api) => {
|
|
|
98
104
|
name: "onBrowserObjectStart",
|
|
99
105
|
from: "boss-css/parser/jsx/browser"
|
|
100
106
|
}, needsRuntimeTest);
|
|
101
|
-
|
|
107
|
+
globalsEnabled && api.file.js.set("body", "jsx:globalThis", `globalThis.${settings.get("name")} = ${proxyVar}`, needsRuntimeTest);
|
|
102
108
|
api.file.js.set("body", "jsx:export-const", `export const ${settings.get("name")} = ${proxyVar}`, needsRuntimeTest);
|
|
103
109
|
api.file.js.set("foot", "jsx:export-default", `export default ${proxyVar}`, needsRuntimeTest);
|
|
104
110
|
const framework = await require_detect_fw_index.detectFramework({ config: api.userConfig ?? api });
|
|
@@ -177,20 +183,20 @@ type BaseFn<T extends BossElementType = 'div'> = {
|
|
|
177
183
|
api.file.js.dts.set("body", "jsx:proxy-start", `type ProxyCustomMembers = {
|
|
178
184
|
`).set("body", "jsx:proxy-utils", ` $: $$NoopFn
|
|
179
185
|
merge: (...inputs: import('boss-css/merge').MergeInput[]) => import('boss-css/merge').MergeOutput
|
|
180
|
-
cx: (...inputs: import('boss-css/
|
|
181
|
-
cv: typeof import('boss-css/
|
|
182
|
-
scv: typeof import('boss-css/
|
|
183
|
-
sv: typeof import('boss-css/
|
|
186
|
+
cx: (...inputs: import('boss-css/variants').CxValue[]) => string
|
|
187
|
+
cv: typeof import('boss-css/variants').cv
|
|
188
|
+
scv: typeof import('boss-css/variants').scv
|
|
189
|
+
sv: typeof import('boss-css/variants').sv
|
|
184
190
|
css: CssFn
|
|
185
191
|
style: StyleFn
|
|
186
192
|
`).set("body", "jsx:proxy-custom-members", ``).set("body", "jsx:proxy-custom-members-end", `}`).set("body", "jsx:proxy-type", `type Proxy = BaseFn & {
|
|
187
193
|
[T in keyof BossIntrinsicElements]: BaseFn<T>
|
|
188
194
|
} & $$Prepared & ProxyCustomMembers`);
|
|
189
195
|
api.file.js.dts.replace("body", "$$:FinalProps", (value) => {
|
|
190
|
-
return `${value} & { ${/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(classNameProp) ? classNameProp : JSON.stringify(classNameProp)}?: import('boss-css/
|
|
196
|
+
return `${value} & { ${/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(classNameProp) ? classNameProp : JSON.stringify(classNameProp)}?: import('boss-css/variants').CxValue }`;
|
|
191
197
|
});
|
|
192
198
|
api.file.js.dts.set("foot", "jsx:export", `export declare const $$: Proxy`);
|
|
193
|
-
if (
|
|
199
|
+
if (globalsEnabled) api.file.js.dts.set("foot", "jsx:globals", `declare global {
|
|
194
200
|
const $$: Proxy
|
|
195
201
|
}`);
|
|
196
202
|
api.file.js.dts.set("foot", "$$:default-export", `export default $$`);
|
|
@@ -22,6 +22,11 @@ const settings = new Map([
|
|
|
22
22
|
["types", true],
|
|
23
23
|
["emitRuntime", false]
|
|
24
24
|
]);
|
|
25
|
+
const resolveGlobals = (api) => {
|
|
26
|
+
const configValue = api.userConfig?.jsx?.globals;
|
|
27
|
+
if (typeof configValue === "boolean") return configValue;
|
|
28
|
+
return settings.get("globals") !== false;
|
|
29
|
+
};
|
|
25
30
|
/**
|
|
26
31
|
* Style:
|
|
27
32
|
*
|
|
@@ -89,6 +94,7 @@ const onBoot = async (api) => {
|
|
|
89
94
|
needsRuntime = false;
|
|
90
95
|
preparedComponents.clear();
|
|
91
96
|
const needsRuntimeTest = () => needsRuntime || settings.get("emitRuntime") === true;
|
|
97
|
+
const globalsEnabled = resolveGlobals(api);
|
|
92
98
|
const proxyVar = api.file.js.import({
|
|
93
99
|
name: "proxy",
|
|
94
100
|
from: "boss-css/runtime"
|
|
@@ -97,7 +103,7 @@ const onBoot = async (api) => {
|
|
|
97
103
|
name: "onBrowserObjectStart",
|
|
98
104
|
from: "boss-css/parser/jsx/browser"
|
|
99
105
|
}, needsRuntimeTest);
|
|
100
|
-
|
|
106
|
+
globalsEnabled && api.file.js.set("body", "jsx:globalThis", `globalThis.${settings.get("name")} = ${proxyVar}`, needsRuntimeTest);
|
|
101
107
|
api.file.js.set("body", "jsx:export-const", `export const ${settings.get("name")} = ${proxyVar}`, needsRuntimeTest);
|
|
102
108
|
api.file.js.set("foot", "jsx:export-default", `export default ${proxyVar}`, needsRuntimeTest);
|
|
103
109
|
const framework = await detectFramework({ config: api.userConfig ?? api });
|
|
@@ -176,20 +182,20 @@ type BaseFn<T extends BossElementType = 'div'> = {
|
|
|
176
182
|
api.file.js.dts.set("body", "jsx:proxy-start", `type ProxyCustomMembers = {
|
|
177
183
|
`).set("body", "jsx:proxy-utils", ` $: $$NoopFn
|
|
178
184
|
merge: (...inputs: import('boss-css/merge').MergeInput[]) => import('boss-css/merge').MergeOutput
|
|
179
|
-
cx: (...inputs: import('boss-css/
|
|
180
|
-
cv: typeof import('boss-css/
|
|
181
|
-
scv: typeof import('boss-css/
|
|
182
|
-
sv: typeof import('boss-css/
|
|
185
|
+
cx: (...inputs: import('boss-css/variants').CxValue[]) => string
|
|
186
|
+
cv: typeof import('boss-css/variants').cv
|
|
187
|
+
scv: typeof import('boss-css/variants').scv
|
|
188
|
+
sv: typeof import('boss-css/variants').sv
|
|
183
189
|
css: CssFn
|
|
184
190
|
style: StyleFn
|
|
185
191
|
`).set("body", "jsx:proxy-custom-members", ``).set("body", "jsx:proxy-custom-members-end", `}`).set("body", "jsx:proxy-type", `type Proxy = BaseFn & {
|
|
186
192
|
[T in keyof BossIntrinsicElements]: BaseFn<T>
|
|
187
193
|
} & $$Prepared & ProxyCustomMembers`);
|
|
188
194
|
api.file.js.dts.replace("body", "$$:FinalProps", (value) => {
|
|
189
|
-
return `${value} & { ${/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(classNameProp) ? classNameProp : JSON.stringify(classNameProp)}?: import('boss-css/
|
|
195
|
+
return `${value} & { ${/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(classNameProp) ? classNameProp : JSON.stringify(classNameProp)}?: import('boss-css/variants').CxValue }`;
|
|
190
196
|
});
|
|
191
197
|
api.file.js.dts.set("foot", "jsx:export", `export declare const $$: Proxy`);
|
|
192
|
-
if (
|
|
198
|
+
if (globalsEnabled) api.file.js.dts.set("foot", "jsx:globals", `declare global {
|
|
193
199
|
const $$: Proxy
|
|
194
200
|
}`);
|
|
195
201
|
api.file.js.dts.set("foot", "$$:default-export", `export default $$`);
|
package/dist/prop/at/server.cjs
CHANGED
|
@@ -204,10 +204,11 @@ const onProp = async (api, { name, prop, contexts, preferVariables, file }) => {
|
|
|
204
204
|
const isCustomProperty = typeof propName === "string" && propName.startsWith("--");
|
|
205
205
|
if (!descriptor?.isCSSProp && !isCustomProperty) continue;
|
|
206
206
|
const propertyName = isCustomProperty ? propName : descriptor?.property ?? api.camelCaseToDash(propName);
|
|
207
|
-
const selectorValue = propValue.selectorValue
|
|
207
|
+
const selectorValue = preferVariables ? null : propValue.selectorValue !== void 0 ? propValue.selectorValue : propValue.value;
|
|
208
208
|
const classToken = propValue.classToken;
|
|
209
209
|
const resolvedName = resolved?.name ?? propName;
|
|
210
|
-
const
|
|
210
|
+
const selectorName = propValue.selectorName ?? resolvedName;
|
|
211
|
+
const className = classToken ? null : api.contextToClassName(selectorName, selectorValue, stepContexts, true, api.selectorPrefix);
|
|
211
212
|
const baseSelector = classToken ? api.classTokenToSelector(classToken) : `.${className}`;
|
|
212
213
|
const pseudoChain = stepContexts.filter((context) => require_prop_pseudo_server.dependencies.has(context));
|
|
213
214
|
const baseWithPseudos = pseudoChain.length ? `${baseSelector}:${pseudoChain.join(":")}` : baseSelector;
|
|
@@ -253,12 +254,13 @@ const onProp = async (api, { name, prop, contexts, preferVariables, file }) => {
|
|
|
253
254
|
const classToken = entry?.classToken;
|
|
254
255
|
const resolved = api.dictionary.resolve(i);
|
|
255
256
|
const resolvedName = resolved.descriptor ? resolved.name : i;
|
|
257
|
+
const selectorName = entry?.selectorName ?? resolvedName;
|
|
256
258
|
if (resolved.suffix) {
|
|
257
259
|
entry.named = resolved.suffix;
|
|
258
260
|
entry.rawName = resolved.raw;
|
|
259
261
|
}
|
|
260
|
-
const selectorValue = entry?.selectorValue
|
|
261
|
-
const className = classToken ? null : api.contextToClassName(
|
|
262
|
+
const selectorValue = preferVariables ? null : entry?.selectorValue !== void 0 ? entry.selectorValue : entry.value;
|
|
263
|
+
const className = classToken ? null : api.contextToClassName(selectorName, selectorValue, nextContexts, true, api.selectorPrefix);
|
|
262
264
|
const baseSelector = classToken ? api.classTokenToSelector(classToken) : `.${className}`;
|
|
263
265
|
const pseudoChain = nextContexts.filter((context) => require_prop_pseudo_server.dependencies.has(context));
|
|
264
266
|
const baseWithPseudos = pseudoChain.length ? `${baseSelector}:${pseudoChain.join(":")}` : baseSelector;
|
package/dist/prop/at/server.mjs
CHANGED
|
@@ -203,10 +203,11 @@ const onProp = async (api, { name, prop, contexts, preferVariables, file }) => {
|
|
|
203
203
|
const isCustomProperty = typeof propName === "string" && propName.startsWith("--");
|
|
204
204
|
if (!descriptor?.isCSSProp && !isCustomProperty) continue;
|
|
205
205
|
const propertyName = isCustomProperty ? propName : descriptor?.property ?? api.camelCaseToDash(propName);
|
|
206
|
-
const selectorValue = propValue.selectorValue
|
|
206
|
+
const selectorValue = preferVariables ? null : propValue.selectorValue !== void 0 ? propValue.selectorValue : propValue.value;
|
|
207
207
|
const classToken = propValue.classToken;
|
|
208
208
|
const resolvedName = resolved?.name ?? propName;
|
|
209
|
-
const
|
|
209
|
+
const selectorName = propValue.selectorName ?? resolvedName;
|
|
210
|
+
const className = classToken ? null : api.contextToClassName(selectorName, selectorValue, stepContexts, true, api.selectorPrefix);
|
|
210
211
|
const baseSelector = classToken ? api.classTokenToSelector(classToken) : `.${className}`;
|
|
211
212
|
const pseudoChain = stepContexts.filter((context) => dependencies$1.has(context));
|
|
212
213
|
const baseWithPseudos = pseudoChain.length ? `${baseSelector}:${pseudoChain.join(":")}` : baseSelector;
|
|
@@ -252,12 +253,13 @@ const onProp = async (api, { name, prop, contexts, preferVariables, file }) => {
|
|
|
252
253
|
const classToken = entry?.classToken;
|
|
253
254
|
const resolved = api.dictionary.resolve(i);
|
|
254
255
|
const resolvedName = resolved.descriptor ? resolved.name : i;
|
|
256
|
+
const selectorName = entry?.selectorName ?? resolvedName;
|
|
255
257
|
if (resolved.suffix) {
|
|
256
258
|
entry.named = resolved.suffix;
|
|
257
259
|
entry.rawName = resolved.raw;
|
|
258
260
|
}
|
|
259
|
-
const selectorValue = entry?.selectorValue
|
|
260
|
-
const className = classToken ? null : api.contextToClassName(
|
|
261
|
+
const selectorValue = preferVariables ? null : entry?.selectorValue !== void 0 ? entry.selectorValue : entry.value;
|
|
262
|
+
const className = classToken ? null : api.contextToClassName(selectorName, selectorValue, nextContexts, true, api.selectorPrefix);
|
|
261
263
|
const baseSelector = classToken ? api.classTokenToSelector(classToken) : `.${className}`;
|
|
262
264
|
const pseudoChain = nextContexts.filter((context) => dependencies$1.has(context));
|
|
263
265
|
const baseWithPseudos = pseudoChain.length ? `${baseSelector}:${pseudoChain.join(":")}` : baseSelector;
|
package/dist/prop/at/shared.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
|
|
2
2
|
//#region src/prop/at/shared.ts
|
|
3
3
|
const defaultBreakpoints = {
|
|
4
|
-
micro: [
|
|
4
|
+
micro: [0, 375],
|
|
5
5
|
mobile: [376, 639],
|
|
6
6
|
tablet: [640, 1023],
|
|
7
7
|
small: [1024, 1439],
|
|
8
8
|
medium: [1440, 1919],
|
|
9
|
-
large: [1920,
|
|
10
|
-
device: [
|
|
9
|
+
large: [1920, 1e5],
|
|
10
|
+
device: [0, 1023]
|
|
11
11
|
};
|
|
12
12
|
const baseAtValues = [
|
|
13
13
|
["dark", "@media screen and (prefers-color-scheme: dark)"],
|
package/dist/prop/at/shared.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
//#region src/prop/at/shared.ts
|
|
2
2
|
const defaultBreakpoints = {
|
|
3
|
-
micro: [
|
|
3
|
+
micro: [0, 375],
|
|
4
4
|
mobile: [376, 639],
|
|
5
5
|
tablet: [640, 1023],
|
|
6
6
|
small: [1024, 1439],
|
|
7
7
|
medium: [1440, 1919],
|
|
8
|
-
large: [1920,
|
|
9
|
-
device: [
|
|
8
|
+
large: [1920, 1e5],
|
|
9
|
+
device: [0, 1023]
|
|
10
10
|
};
|
|
11
11
|
const baseAtValues = [
|
|
12
12
|
["dark", "@media screen and (prefers-color-scheme: dark)"],
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const require_selectors = require('./selectors.cjs');
|
|
1
2
|
const require_shared = require('./shared.cjs');
|
|
2
3
|
|
|
3
4
|
//#region src/prop/bosswind/browser.ts
|
|
@@ -10,6 +11,8 @@ const onBrowserObjectStart = (api, { input }) => {
|
|
|
10
11
|
const rewritten = require_shared.rewriteBosswindInput(api, input, api.bosswind ?? {});
|
|
11
12
|
Object.keys(input).forEach((key) => delete input[key]);
|
|
12
13
|
Object.assign(input, rewritten);
|
|
14
|
+
const selectorMap = require_selectors.getBosswindSelectorMap(rewritten);
|
|
15
|
+
if (selectorMap) require_selectors.setBosswindSelectorMap(input, selectorMap);
|
|
13
16
|
};
|
|
14
17
|
|
|
15
18
|
//#endregion
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getBosswindSelectorMap, setBosswindSelectorMap } from "./selectors.mjs";
|
|
1
2
|
import { registerBosswindDictionary, rewriteBosswindInput } from "./shared.mjs";
|
|
2
3
|
|
|
3
4
|
//#region src/prop/bosswind/browser.ts
|
|
@@ -10,6 +11,8 @@ const onBrowserObjectStart = (api, { input }) => {
|
|
|
10
11
|
const rewritten = rewriteBosswindInput(api, input, api.bosswind ?? {});
|
|
11
12
|
Object.keys(input).forEach((key) => delete input[key]);
|
|
12
13
|
Object.assign(input, rewritten);
|
|
14
|
+
const selectorMap = getBosswindSelectorMap(rewritten);
|
|
15
|
+
if (selectorMap) setBosswindSelectorMap(input, selectorMap);
|
|
13
16
|
};
|
|
14
17
|
|
|
15
18
|
//#endregion
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const require_selectors = require('./selectors.cjs');
|
|
1
2
|
const require_shared = require('./shared.cjs');
|
|
2
3
|
|
|
3
4
|
//#region src/prop/bosswind/runtime-only.ts
|
|
@@ -10,6 +11,8 @@ const onBrowserObjectStart = (api, { input }) => {
|
|
|
10
11
|
const rewritten = require_shared.rewriteBosswindInput(api, input, api.bosswind ?? {});
|
|
11
12
|
Object.keys(input).forEach((key) => delete input[key]);
|
|
12
13
|
Object.assign(input, rewritten);
|
|
14
|
+
const selectorMap = require_selectors.getBosswindSelectorMap(rewritten);
|
|
15
|
+
if (selectorMap) require_selectors.setBosswindSelectorMap(input, selectorMap);
|
|
13
16
|
};
|
|
14
17
|
|
|
15
18
|
//#endregion
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getBosswindSelectorMap, setBosswindSelectorMap } from "./selectors.mjs";
|
|
1
2
|
import { registerBosswindDictionary, rewriteBosswindInput } from "./shared.mjs";
|
|
2
3
|
|
|
3
4
|
//#region src/prop/bosswind/runtime-only.ts
|
|
@@ -10,6 +11,8 @@ const onBrowserObjectStart = (api, { input }) => {
|
|
|
10
11
|
const rewritten = rewriteBosswindInput(api, input, api.bosswind ?? {});
|
|
11
12
|
Object.keys(input).forEach((key) => delete input[key]);
|
|
12
13
|
Object.assign(input, rewritten);
|
|
14
|
+
const selectorMap = getBosswindSelectorMap(rewritten);
|
|
15
|
+
if (selectorMap) setBosswindSelectorMap(input, selectorMap);
|
|
13
16
|
};
|
|
14
17
|
|
|
15
18
|
//#endregion
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/prop/bosswind/selectors.ts
|
|
3
|
+
const bosswindSelectorKey = Symbol.for("bosswind.selectorMap");
|
|
4
|
+
const getBosswindSelectorMap = (input) => {
|
|
5
|
+
if (!input || typeof input !== "object") return void 0;
|
|
6
|
+
return input[bosswindSelectorKey];
|
|
7
|
+
};
|
|
8
|
+
const setBosswindSelectorMap = (input, selectors) => {
|
|
9
|
+
Object.defineProperty(input, bosswindSelectorKey, {
|
|
10
|
+
value: selectors,
|
|
11
|
+
enumerable: false,
|
|
12
|
+
configurable: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.getBosswindSelectorMap = getBosswindSelectorMap;
|
|
18
|
+
exports.setBosswindSelectorMap = setBosswindSelectorMap;
|