boss-css 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
package/dist/api/css.mjs
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
//#region src/api/css.ts
|
|
2
|
+
var CSS = class extends Set {
|
|
3
|
+
api;
|
|
4
|
+
log;
|
|
5
|
+
current = null;
|
|
6
|
+
source = null;
|
|
7
|
+
ruleMeta = /* @__PURE__ */ new Map();
|
|
8
|
+
ruleSources = /* @__PURE__ */ new Map();
|
|
9
|
+
ruleIndex = 0;
|
|
10
|
+
imports = /* @__PURE__ */ new Set();
|
|
11
|
+
customBlocks = /* @__PURE__ */ new Map();
|
|
12
|
+
customByFile = /* @__PURE__ */ new Map();
|
|
13
|
+
rootSources = /* @__PURE__ */ new Map();
|
|
14
|
+
get text() {
|
|
15
|
+
const importRules = this.imports.size ? Array.from(this.imports).join("\n") : "";
|
|
16
|
+
const entries = Array.from(this).map((rule) => {
|
|
17
|
+
const meta = this.ruleMeta.get(rule);
|
|
18
|
+
return {
|
|
19
|
+
rule,
|
|
20
|
+
query: meta?.query ?? null,
|
|
21
|
+
index: meta?.index ?? 0
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
const baseRules = entries.filter((entry) => !entry.query).sort((a, b) => a.index - b.index).map((entry) => entry.rule);
|
|
25
|
+
const atRules = entries.filter((entry) => entry.query).sort((a, b) => this.compareAtRuleOrder(a, b)).map((entry) => entry.rule);
|
|
26
|
+
const orderedRules = [...baseRules, ...atRules].join("\n");
|
|
27
|
+
const rootRules = this.root.size ? `${this.api.selectorScope || ":root"} {
|
|
28
|
+
${Array.from(this.root).join("\n ")}
|
|
29
|
+
}
|
|
30
|
+
${orderedRules}` : orderedRules;
|
|
31
|
+
const customRules = this.getCustomText();
|
|
32
|
+
if (!importRules && !rootRules && !customRules) return "";
|
|
33
|
+
if (!importRules && !customRules) return rootRules;
|
|
34
|
+
if (!importRules && !rootRules) return customRules;
|
|
35
|
+
if (!customRules) return importRules ? `${importRules}\n${rootRules}` : rootRules;
|
|
36
|
+
if (!rootRules) return importRules ? `${importRules}\n${customRules}` : customRules;
|
|
37
|
+
return `${importRules}\n${rootRules}\n${customRules}`;
|
|
38
|
+
}
|
|
39
|
+
root = /* @__PURE__ */ new Set();
|
|
40
|
+
constructor(api) {
|
|
41
|
+
super();
|
|
42
|
+
this.api = api;
|
|
43
|
+
this.log = api.log.child("css");
|
|
44
|
+
}
|
|
45
|
+
setSource(source) {
|
|
46
|
+
this.source = source;
|
|
47
|
+
}
|
|
48
|
+
rule(property, value, options) {
|
|
49
|
+
if (!this.current) throw new Error("CSS:rule No current selector");
|
|
50
|
+
const suffix = options?.important ? " !important" : "";
|
|
51
|
+
this.current.values.add(`${property}: ${this.api.dictionary.toValue(value, property)}${suffix}`);
|
|
52
|
+
}
|
|
53
|
+
addImport(url) {
|
|
54
|
+
if (!url) return;
|
|
55
|
+
this.imports.add(`@import url("${url}");`);
|
|
56
|
+
}
|
|
57
|
+
addRule(rule, query = null, source = null) {
|
|
58
|
+
const wrapped = query ? `${query} { ${rule} }` : rule;
|
|
59
|
+
if (!this.has(wrapped)) {
|
|
60
|
+
this.add(wrapped);
|
|
61
|
+
this.ruleMeta.set(wrapped, {
|
|
62
|
+
query,
|
|
63
|
+
index: this.ruleIndex
|
|
64
|
+
});
|
|
65
|
+
this.ruleIndex += 1;
|
|
66
|
+
}
|
|
67
|
+
this.trackRuleSource(wrapped, source ?? this.source);
|
|
68
|
+
}
|
|
69
|
+
selector({ className, selector = null, pseudos = [], query = null, source = null }) {
|
|
70
|
+
this.log.log("selector", {
|
|
71
|
+
className,
|
|
72
|
+
selector,
|
|
73
|
+
pseudos,
|
|
74
|
+
query
|
|
75
|
+
});
|
|
76
|
+
if (!this.current) this.current = {
|
|
77
|
+
className: null,
|
|
78
|
+
selector: null,
|
|
79
|
+
pseudos: [],
|
|
80
|
+
values: /* @__PURE__ */ new Set(),
|
|
81
|
+
query: null,
|
|
82
|
+
source: null
|
|
83
|
+
};
|
|
84
|
+
const current = this.current;
|
|
85
|
+
if (query && current.query && query !== current.query) throw new Error(`CSS:selector Selector already has a query. Existing: ${current.query} Incoming: ${query}`);
|
|
86
|
+
const mergedPseudos = [];
|
|
87
|
+
for (const pseudo of [...current.pseudos, ...pseudos]) if (!mergedPseudos.includes(pseudo)) mergedPseudos.push(pseudo);
|
|
88
|
+
const next = {
|
|
89
|
+
pseudos: mergedPseudos,
|
|
90
|
+
query: query || current.query
|
|
91
|
+
};
|
|
92
|
+
if (selector) Object.assign(next, {
|
|
93
|
+
selector,
|
|
94
|
+
className: null
|
|
95
|
+
});
|
|
96
|
+
else if (className) Object.assign(next, { className });
|
|
97
|
+
if (source || this.source) next.source = source ?? this.source;
|
|
98
|
+
Object.assign(current, next);
|
|
99
|
+
}
|
|
100
|
+
write() {
|
|
101
|
+
this.log.log("write", this.current);
|
|
102
|
+
if (!this.current) throw new Error("CSS:write No current selector");
|
|
103
|
+
const current = this.current;
|
|
104
|
+
const baseSelector = current.selector || (current.className ? `.${current.className}` : null);
|
|
105
|
+
if (!baseSelector) throw new Error("CSS:write No className or selector");
|
|
106
|
+
const selector = [baseSelector, ...current.pseudos].join(":");
|
|
107
|
+
const selectorScope = typeof this.api.selectorScope === "string" ? this.api.selectorScope : "";
|
|
108
|
+
let string = `${selectorScope ? `${selectorScope}${selector}` : selector} { ${[...current.values].join(";")} }`;
|
|
109
|
+
if (current.query) string = `${current.query} { ${string} }`;
|
|
110
|
+
if (!this.has(string)) {
|
|
111
|
+
this.add(string);
|
|
112
|
+
this.ruleMeta.set(string, {
|
|
113
|
+
query: current.query,
|
|
114
|
+
index: this.ruleIndex
|
|
115
|
+
});
|
|
116
|
+
this.ruleIndex += 1;
|
|
117
|
+
}
|
|
118
|
+
this.trackRuleSource(string, current.source ?? this.source);
|
|
119
|
+
this.current = null;
|
|
120
|
+
}
|
|
121
|
+
compareAtRuleOrder(a, b) {
|
|
122
|
+
const aOrder = this.getAtRuleOrder(a.query, a.index);
|
|
123
|
+
const bOrder = this.getAtRuleOrder(b.query, b.index);
|
|
124
|
+
if (aOrder.group !== bOrder.group) return aOrder.group - bOrder.group;
|
|
125
|
+
if (aOrder.primary !== bOrder.primary) return aOrder.primary - bOrder.primary;
|
|
126
|
+
if (aOrder.secondary !== bOrder.secondary) return aOrder.secondary - bOrder.secondary;
|
|
127
|
+
return aOrder.index - bOrder.index;
|
|
128
|
+
}
|
|
129
|
+
getAtRuleOrder(query, index) {
|
|
130
|
+
if (!query) return {
|
|
131
|
+
group: 0,
|
|
132
|
+
primary: 0,
|
|
133
|
+
secondary: 0,
|
|
134
|
+
index
|
|
135
|
+
};
|
|
136
|
+
const normalized = query.trim().toLowerCase();
|
|
137
|
+
if (!normalized.startsWith("@media")) return {
|
|
138
|
+
group: 4,
|
|
139
|
+
primary: 0,
|
|
140
|
+
secondary: 0,
|
|
141
|
+
index
|
|
142
|
+
};
|
|
143
|
+
const minMatch = normalized.match(/min-width\s*:\s*(\d+(?:\.\d+)?)px/);
|
|
144
|
+
const maxMatch = normalized.match(/max-width\s*:\s*(\d+(?:\.\d+)?)px/);
|
|
145
|
+
const min = minMatch ? Number(minMatch[1]) : null;
|
|
146
|
+
const max = maxMatch ? Number(maxMatch[1]) : null;
|
|
147
|
+
if (min !== null && max !== null) return {
|
|
148
|
+
group: 1,
|
|
149
|
+
primary: min,
|
|
150
|
+
secondary: max,
|
|
151
|
+
index
|
|
152
|
+
};
|
|
153
|
+
if (max !== null) return {
|
|
154
|
+
group: 0,
|
|
155
|
+
primary: -max,
|
|
156
|
+
secondary: 0,
|
|
157
|
+
index
|
|
158
|
+
};
|
|
159
|
+
if (min !== null) return {
|
|
160
|
+
group: 2,
|
|
161
|
+
primary: min,
|
|
162
|
+
secondary: 0,
|
|
163
|
+
index
|
|
164
|
+
};
|
|
165
|
+
return {
|
|
166
|
+
group: 3,
|
|
167
|
+
primary: 0,
|
|
168
|
+
secondary: 0,
|
|
169
|
+
index
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
addRoot(value, source = null) {
|
|
173
|
+
if (!value) return;
|
|
174
|
+
this.root.add(value);
|
|
175
|
+
this.trackRootSource(value, source ?? this.source);
|
|
176
|
+
}
|
|
177
|
+
removeSource(source) {
|
|
178
|
+
if (!source) return;
|
|
179
|
+
for (const [rule, sources] of this.ruleSources.entries()) {
|
|
180
|
+
if (!sources.delete(source)) continue;
|
|
181
|
+
if (sources.size === 0) {
|
|
182
|
+
this.ruleSources.delete(rule);
|
|
183
|
+
this.ruleMeta.delete(rule);
|
|
184
|
+
this.delete(rule);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
for (const [declaration, sources] of this.rootSources.entries()) {
|
|
188
|
+
if (!sources.delete(source)) continue;
|
|
189
|
+
if (sources.size === 0) {
|
|
190
|
+
this.rootSources.delete(declaration);
|
|
191
|
+
this.root.delete(declaration);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
const customIds = this.customByFile.get(source);
|
|
195
|
+
if (customIds) {
|
|
196
|
+
for (const id of customIds) this.customBlocks.delete(id);
|
|
197
|
+
this.customByFile.delete(source);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
reset() {
|
|
201
|
+
this.clear();
|
|
202
|
+
this.root.clear();
|
|
203
|
+
this.imports.clear();
|
|
204
|
+
this.customBlocks.clear();
|
|
205
|
+
this.customByFile.clear();
|
|
206
|
+
this.ruleMeta.clear();
|
|
207
|
+
this.ruleSources.clear();
|
|
208
|
+
this.rootSources.clear();
|
|
209
|
+
this.ruleIndex = 0;
|
|
210
|
+
this.current = null;
|
|
211
|
+
this.source = null;
|
|
212
|
+
}
|
|
213
|
+
snapshot() {
|
|
214
|
+
const cloneSet = (set) => new Set(set);
|
|
215
|
+
const cloneSetMap = (map) => {
|
|
216
|
+
const next = /* @__PURE__ */ new Map();
|
|
217
|
+
for (const [key, value] of map.entries()) next.set(key, new Set(value));
|
|
218
|
+
return next;
|
|
219
|
+
};
|
|
220
|
+
const cloneRuleMeta = /* @__PURE__ */ new Map();
|
|
221
|
+
for (const [key, meta] of this.ruleMeta.entries()) cloneRuleMeta.set(key, {
|
|
222
|
+
query: meta.query ?? null,
|
|
223
|
+
index: meta.index
|
|
224
|
+
});
|
|
225
|
+
const cloneCustomBlocks = /* @__PURE__ */ new Map();
|
|
226
|
+
for (const [key, value] of this.customBlocks.entries()) cloneCustomBlocks.set(key, { ...value });
|
|
227
|
+
const cloneCustomByFile = /* @__PURE__ */ new Map();
|
|
228
|
+
for (const [key, value] of this.customByFile.entries()) cloneCustomByFile.set(key, new Set(value));
|
|
229
|
+
return {
|
|
230
|
+
rules: cloneSet(this),
|
|
231
|
+
root: cloneSet(this.root),
|
|
232
|
+
imports: cloneSet(this.imports),
|
|
233
|
+
ruleMeta: cloneRuleMeta,
|
|
234
|
+
ruleSources: cloneSetMap(this.ruleSources),
|
|
235
|
+
rootSources: cloneSetMap(this.rootSources),
|
|
236
|
+
customBlocks: cloneCustomBlocks,
|
|
237
|
+
customByFile: cloneCustomByFile,
|
|
238
|
+
ruleIndex: this.ruleIndex
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
restore(snapshot) {
|
|
242
|
+
const data = snapshot;
|
|
243
|
+
if (!data) return;
|
|
244
|
+
this.reset();
|
|
245
|
+
for (const rule of data.rules ?? []) this.add(rule);
|
|
246
|
+
for (const value of data.root ?? []) this.root.add(value);
|
|
247
|
+
for (const value of data.imports ?? []) this.imports.add(value);
|
|
248
|
+
if (data.ruleMeta) this.ruleMeta = new Map(data.ruleMeta);
|
|
249
|
+
if (data.ruleSources) this.ruleSources = new Map(data.ruleSources);
|
|
250
|
+
if (data.rootSources) this.rootSources = new Map(data.rootSources);
|
|
251
|
+
if (data.customBlocks) this.customBlocks = new Map(data.customBlocks);
|
|
252
|
+
if (data.customByFile) this.customByFile = new Map(data.customByFile);
|
|
253
|
+
this.ruleIndex = data.ruleIndex ?? 0;
|
|
254
|
+
}
|
|
255
|
+
syncCustomBlocks(file, blocks) {
|
|
256
|
+
const fileKey = file || "<unknown>";
|
|
257
|
+
const nextIds = /* @__PURE__ */ new Set();
|
|
258
|
+
for (const block of blocks) {
|
|
259
|
+
const cssText = block.cssText;
|
|
260
|
+
if (!cssText.trim()) continue;
|
|
261
|
+
const id = `${fileKey}:${block.start}-${block.end}`;
|
|
262
|
+
nextIds.add(id);
|
|
263
|
+
const existing = this.customBlocks.get(id);
|
|
264
|
+
if (!existing || existing.cssText !== cssText) this.customBlocks.set(id, {
|
|
265
|
+
cssText,
|
|
266
|
+
file: fileKey,
|
|
267
|
+
start: block.start,
|
|
268
|
+
end: block.end
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
const previous = this.customByFile.get(fileKey);
|
|
272
|
+
if (previous) {
|
|
273
|
+
for (const id of previous) if (!nextIds.has(id)) this.customBlocks.delete(id);
|
|
274
|
+
}
|
|
275
|
+
if (nextIds.size) this.customByFile.set(fileKey, nextIds);
|
|
276
|
+
else this.customByFile.delete(fileKey);
|
|
277
|
+
}
|
|
278
|
+
getCustomText() {
|
|
279
|
+
if (!this.customBlocks.size) return "";
|
|
280
|
+
return Array.from(this.customBlocks.values()).map((entry) => entry.cssText).join("\n");
|
|
281
|
+
}
|
|
282
|
+
trackRuleSource(rule, source) {
|
|
283
|
+
if (!source) return;
|
|
284
|
+
const existing = this.ruleSources.get(rule);
|
|
285
|
+
if (existing) {
|
|
286
|
+
existing.add(source);
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
this.ruleSources.set(rule, new Set([source]));
|
|
290
|
+
}
|
|
291
|
+
trackRootSource(rule, source) {
|
|
292
|
+
if (!source) return;
|
|
293
|
+
const existing = this.rootSources.get(rule);
|
|
294
|
+
if (existing) {
|
|
295
|
+
existing.add(source);
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
this.rootSources.set(rule, new Set([source]));
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
//#endregion
|
|
303
|
+
export { CSS };
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/api/dictionary.ts
|
|
3
|
+
var Dictionary = class Dictionary extends Map {
|
|
4
|
+
static Instance;
|
|
5
|
+
api;
|
|
6
|
+
constructor(api) {
|
|
7
|
+
super();
|
|
8
|
+
Dictionary.Instance = this;
|
|
9
|
+
this.api = api;
|
|
10
|
+
}
|
|
11
|
+
resolve(name) {
|
|
12
|
+
const direct = this.get(name);
|
|
13
|
+
if (direct) return {
|
|
14
|
+
descriptor: direct,
|
|
15
|
+
name,
|
|
16
|
+
raw: name,
|
|
17
|
+
suffix: null
|
|
18
|
+
};
|
|
19
|
+
if (typeof name !== "string") return {
|
|
20
|
+
descriptor: null,
|
|
21
|
+
name,
|
|
22
|
+
raw: name,
|
|
23
|
+
suffix: null
|
|
24
|
+
};
|
|
25
|
+
const underscoreIndex = name.indexOf("_");
|
|
26
|
+
if (underscoreIndex <= 0 || underscoreIndex === name.length - 1) return {
|
|
27
|
+
descriptor: null,
|
|
28
|
+
name,
|
|
29
|
+
raw: name,
|
|
30
|
+
suffix: null
|
|
31
|
+
};
|
|
32
|
+
const base = name.slice(0, underscoreIndex);
|
|
33
|
+
const suffix = name.slice(underscoreIndex + 1);
|
|
34
|
+
const descriptor = this.get(base);
|
|
35
|
+
if (!descriptor) return {
|
|
36
|
+
descriptor: null,
|
|
37
|
+
name,
|
|
38
|
+
raw: name,
|
|
39
|
+
suffix: null
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
descriptor,
|
|
43
|
+
name: base,
|
|
44
|
+
raw: name,
|
|
45
|
+
suffix
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
set(key, value) {
|
|
49
|
+
for (const alias of value.aliases) super.set(alias, value);
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
toValue(value, property) {
|
|
53
|
+
const propertyName = typeof property === "string" ? property : property?.property ?? property?.aliases?.[0];
|
|
54
|
+
switch (true) {
|
|
55
|
+
case Array.isArray(value): return value.map((v) => this.toValue(v, property)).join(" ");
|
|
56
|
+
case typeof value === "number":
|
|
57
|
+
case isNumericValue(value): {
|
|
58
|
+
const numericValue = typeof value === "number" ? value : Number(value);
|
|
59
|
+
if (propertyName && unitlessProperties.has(propertyName)) return numericValue === 0 ? 0 : `${value}`;
|
|
60
|
+
return numericValue === 0 ? 0 : `${value}${this.api.unit}`;
|
|
61
|
+
}
|
|
62
|
+
default: return value;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const unitlessProperties = new Set([
|
|
67
|
+
"animationIterationCount",
|
|
68
|
+
"aspectRatio",
|
|
69
|
+
"borderImageOutset",
|
|
70
|
+
"borderImageSlice",
|
|
71
|
+
"borderImageWidth",
|
|
72
|
+
"boxFlex",
|
|
73
|
+
"boxFlexGroup",
|
|
74
|
+
"boxOrdinalGroup",
|
|
75
|
+
"columnCount",
|
|
76
|
+
"columns",
|
|
77
|
+
"flex",
|
|
78
|
+
"flexGrow",
|
|
79
|
+
"flexPositive",
|
|
80
|
+
"flexShrink",
|
|
81
|
+
"flexNegative",
|
|
82
|
+
"flexOrder",
|
|
83
|
+
"gridArea",
|
|
84
|
+
"gridRow",
|
|
85
|
+
"gridRowEnd",
|
|
86
|
+
"gridRowSpan",
|
|
87
|
+
"gridRowStart",
|
|
88
|
+
"gridColumn",
|
|
89
|
+
"gridColumnEnd",
|
|
90
|
+
"gridColumnSpan",
|
|
91
|
+
"gridColumnStart",
|
|
92
|
+
"fontWeight",
|
|
93
|
+
"lineClamp",
|
|
94
|
+
"lineHeight",
|
|
95
|
+
"opacity",
|
|
96
|
+
"order",
|
|
97
|
+
"orphans",
|
|
98
|
+
"scale",
|
|
99
|
+
"tabSize",
|
|
100
|
+
"widows",
|
|
101
|
+
"zIndex",
|
|
102
|
+
"zoom",
|
|
103
|
+
"fillOpacity",
|
|
104
|
+
"floodOpacity",
|
|
105
|
+
"stopOpacity",
|
|
106
|
+
"strokeDasharray",
|
|
107
|
+
"strokeDashoffset",
|
|
108
|
+
"strokeMiterlimit",
|
|
109
|
+
"strokeOpacity",
|
|
110
|
+
"strokeWidth",
|
|
111
|
+
"MozAnimationIterationCount",
|
|
112
|
+
"MozBoxFlex",
|
|
113
|
+
"MozBoxFlexGroup",
|
|
114
|
+
"MozLineClamp",
|
|
115
|
+
"msAnimationIterationCount",
|
|
116
|
+
"msFlex",
|
|
117
|
+
"msFlexGrow",
|
|
118
|
+
"msFlexNegative",
|
|
119
|
+
"msFlexOrder",
|
|
120
|
+
"msFlexPositive",
|
|
121
|
+
"msFlexShrink",
|
|
122
|
+
"msGridColumn",
|
|
123
|
+
"msGridColumnSpan",
|
|
124
|
+
"msGridRow",
|
|
125
|
+
"msGridRowSpan",
|
|
126
|
+
"msZoom",
|
|
127
|
+
"WebkitAnimationIterationCount",
|
|
128
|
+
"WebkitBoxFlex",
|
|
129
|
+
"WebkitBoxFlexGroup",
|
|
130
|
+
"WebkitBoxOrdinalGroup",
|
|
131
|
+
"WebkitColumnCount",
|
|
132
|
+
"WebkitColumns",
|
|
133
|
+
"WebkitFlex",
|
|
134
|
+
"WebkitFlexGrow",
|
|
135
|
+
"WebkitFlexPositive",
|
|
136
|
+
"WebkitFlexShrink",
|
|
137
|
+
"WebkitLineClamp",
|
|
138
|
+
"animation-iteration-count",
|
|
139
|
+
"aspect-ratio",
|
|
140
|
+
"border-image-outset",
|
|
141
|
+
"border-image-slice",
|
|
142
|
+
"border-image-width",
|
|
143
|
+
"box-flex",
|
|
144
|
+
"box-flex-group",
|
|
145
|
+
"box-ordinal-group",
|
|
146
|
+
"column-count",
|
|
147
|
+
"columns",
|
|
148
|
+
"flex",
|
|
149
|
+
"flex-grow",
|
|
150
|
+
"flex-positive",
|
|
151
|
+
"flex-shrink",
|
|
152
|
+
"flex-negative",
|
|
153
|
+
"flex-order",
|
|
154
|
+
"grid-area",
|
|
155
|
+
"grid-row",
|
|
156
|
+
"grid-row-end",
|
|
157
|
+
"grid-row-span",
|
|
158
|
+
"grid-row-start",
|
|
159
|
+
"grid-column",
|
|
160
|
+
"grid-column-end",
|
|
161
|
+
"grid-column-span",
|
|
162
|
+
"grid-column-start",
|
|
163
|
+
"font-weight",
|
|
164
|
+
"line-clamp",
|
|
165
|
+
"line-height",
|
|
166
|
+
"opacity",
|
|
167
|
+
"order",
|
|
168
|
+
"orphans",
|
|
169
|
+
"scale",
|
|
170
|
+
"tab-size",
|
|
171
|
+
"widows",
|
|
172
|
+
"z-index",
|
|
173
|
+
"zoom",
|
|
174
|
+
"fill-opacity",
|
|
175
|
+
"flood-opacity",
|
|
176
|
+
"stop-opacity",
|
|
177
|
+
"stroke-dasharray",
|
|
178
|
+
"stroke-dashoffset",
|
|
179
|
+
"stroke-miterlimit",
|
|
180
|
+
"stroke-opacity",
|
|
181
|
+
"stroke-width",
|
|
182
|
+
"-moz-animation-iteration-count",
|
|
183
|
+
"-moz-box-flex",
|
|
184
|
+
"-moz-box-flex-group",
|
|
185
|
+
"-moz-line-clamp",
|
|
186
|
+
"-ms-animation-iteration-count",
|
|
187
|
+
"-ms-flex",
|
|
188
|
+
"-ms-flex-grow",
|
|
189
|
+
"-ms-flex-negative",
|
|
190
|
+
"-ms-flex-order",
|
|
191
|
+
"-ms-flex-positive",
|
|
192
|
+
"-ms-flex-shrink",
|
|
193
|
+
"-ms-grid-column",
|
|
194
|
+
"-ms-grid-column-span",
|
|
195
|
+
"-ms-grid-row",
|
|
196
|
+
"-ms-grid-row-span",
|
|
197
|
+
"-ms-zoom",
|
|
198
|
+
"-webkit-animation-iteration-count",
|
|
199
|
+
"-webkit-box-flex",
|
|
200
|
+
"-webkit-box-flex-group",
|
|
201
|
+
"-webkit-box-ordinal-group",
|
|
202
|
+
"-webkit-column-count",
|
|
203
|
+
"-webkit-columns",
|
|
204
|
+
"-webkit-flex",
|
|
205
|
+
"-webkit-flex-grow",
|
|
206
|
+
"-webkit-flex-positive",
|
|
207
|
+
"-webkit-flex-shrink",
|
|
208
|
+
"-webkit-line-clamp"
|
|
209
|
+
]);
|
|
210
|
+
const isNumericValue = (value) => {
|
|
211
|
+
if (typeof value === "number") return true;
|
|
212
|
+
return /^-?\d+(?:\.\d+)?$/.test(value);
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
//#endregion
|
|
216
|
+
exports.Dictionary = Dictionary;
|
|
217
|
+
exports.isNumericValue = isNumericValue;
|
|
218
|
+
exports.unitlessProperties = unitlessProperties;
|