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,16 @@
|
|
|
1
|
+
import { runPostcss } from "../tasks/postcss.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/postcss/index.ts
|
|
4
|
+
function postcssPlugin(options = {}) {
|
|
5
|
+
return {
|
|
6
|
+
postcssPlugin: "boss-postcss-plugin",
|
|
7
|
+
plugins: [async (root, result) => {
|
|
8
|
+
await runPostcss(root, result, options);
|
|
9
|
+
}]
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
postcssPlugin.postcss = true;
|
|
13
|
+
var postcss_default = postcssPlugin;
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { postcss_default as default };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
const require_shared = require('./shared.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/prop/at/runtime-only.ts
|
|
4
|
+
const atValuesCache = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
const buildQuery = (from, to) => {
|
|
6
|
+
if (from === null && to === null) return "";
|
|
7
|
+
if (from === null) return `@media screen and (max-width: ${to}px)`;
|
|
8
|
+
if (to === null) return `@media screen and (min-width: ${from}px)`;
|
|
9
|
+
return `@media screen and (min-width: ${from}px) and (max-width: ${to}px)`;
|
|
10
|
+
};
|
|
11
|
+
const getAtValues = (api) => {
|
|
12
|
+
if (atValuesCache.has(api)) return atValuesCache.get(api);
|
|
13
|
+
const values = new Map(require_shared.baseAtValues);
|
|
14
|
+
const breakpoints = getAtBreakpoints(api);
|
|
15
|
+
Object.entries(breakpoints).forEach(([name, [from, to]]) => {
|
|
16
|
+
values.set(name, buildQuery(from, to));
|
|
17
|
+
if (!name.endsWith("+") && !name.endsWith("-")) {
|
|
18
|
+
values.set(`${name}+`, buildQuery(from, null));
|
|
19
|
+
values.set(`${name}-`, buildQuery(null, to));
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
atValuesCache.set(api, values);
|
|
23
|
+
return values;
|
|
24
|
+
};
|
|
25
|
+
const getAtBreakpoints = (api) => ({
|
|
26
|
+
...require_shared.defaultBreakpoints,
|
|
27
|
+
...api.breakpoints ?? {}
|
|
28
|
+
});
|
|
29
|
+
const getContainerInfo = (contexts) => {
|
|
30
|
+
for (let i = contexts.length - 1; i >= 0; i -= 1) {
|
|
31
|
+
const info = require_shared.parseContainerContext(contexts[i]);
|
|
32
|
+
if (info) return {
|
|
33
|
+
...info,
|
|
34
|
+
index: i
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
};
|
|
39
|
+
const resolveMediaQuery = (api, key) => {
|
|
40
|
+
const direct = getAtValues(api).get(key);
|
|
41
|
+
if (direct) return direct;
|
|
42
|
+
const range = require_shared.parseRangeKey(key, getAtBreakpoints(api), api.unit ?? "px");
|
|
43
|
+
if (range) return require_shared.buildMediaQuery(range) ?? key;
|
|
44
|
+
return key;
|
|
45
|
+
};
|
|
46
|
+
const resolveContainerQuery = (api, key, name) => {
|
|
47
|
+
if (key.startsWith("@")) return key;
|
|
48
|
+
const range = require_shared.parseRangeKey(key, getAtBreakpoints(api), api.unit ?? "px");
|
|
49
|
+
if (range) return require_shared.buildContainerQuery(range, name);
|
|
50
|
+
return `${name ? `@container ${name}` : "@container"} ${key}`;
|
|
51
|
+
};
|
|
52
|
+
const resolveAtQuery = (api, contexts) => {
|
|
53
|
+
const atIndex = contexts.lastIndexOf("at");
|
|
54
|
+
if (atIndex !== -1 && contexts[atIndex + 1]) {
|
|
55
|
+
const containerInfo$1 = require_shared.parseContainerContext(contexts[atIndex + 1]);
|
|
56
|
+
if (containerInfo$1) {
|
|
57
|
+
const key$1 = contexts[atIndex + 2];
|
|
58
|
+
if (!key$1) return null;
|
|
59
|
+
return resolveContainerQuery(api, key$1, containerInfo$1.name);
|
|
60
|
+
}
|
|
61
|
+
const key = contexts[atIndex + 1];
|
|
62
|
+
return resolveMediaQuery(api, key);
|
|
63
|
+
}
|
|
64
|
+
const containerInfo = getContainerInfo(contexts);
|
|
65
|
+
if (containerInfo) {
|
|
66
|
+
const key = contexts[containerInfo.index + 1];
|
|
67
|
+
if (key) return resolveContainerQuery(api, key, containerInfo.name);
|
|
68
|
+
}
|
|
69
|
+
for (let i = contexts.length - 1; i >= 0; i -= 1) {
|
|
70
|
+
const key = contexts[i];
|
|
71
|
+
if (key.startsWith("@")) return key;
|
|
72
|
+
const range = require_shared.parseRangeKey(key, getAtBreakpoints(api), api.unit ?? "px");
|
|
73
|
+
if (range) return require_shared.buildMediaQuery(range) ?? key;
|
|
74
|
+
const values = getAtValues(api);
|
|
75
|
+
if (values.has(key)) return values.get(key);
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
};
|
|
79
|
+
const name = "at";
|
|
80
|
+
const onInit = (api) => {
|
|
81
|
+
api.breakpoints = {
|
|
82
|
+
...require_shared.defaultBreakpoints,
|
|
83
|
+
...api.breakpoints ?? {}
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
//#endregion
|
|
88
|
+
exports.name = name;
|
|
89
|
+
exports.onInit = onInit;
|
|
90
|
+
exports.resolveAtQuery = resolveAtQuery;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { baseAtValues, buildContainerQuery, buildMediaQuery, defaultBreakpoints, parseContainerContext, parseRangeKey } from "./shared.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/prop/at/runtime-only.ts
|
|
4
|
+
const atValuesCache = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
const buildQuery = (from, to) => {
|
|
6
|
+
if (from === null && to === null) return "";
|
|
7
|
+
if (from === null) return `@media screen and (max-width: ${to}px)`;
|
|
8
|
+
if (to === null) return `@media screen and (min-width: ${from}px)`;
|
|
9
|
+
return `@media screen and (min-width: ${from}px) and (max-width: ${to}px)`;
|
|
10
|
+
};
|
|
11
|
+
const getAtValues = (api) => {
|
|
12
|
+
if (atValuesCache.has(api)) return atValuesCache.get(api);
|
|
13
|
+
const values = new Map(baseAtValues);
|
|
14
|
+
const breakpoints = getAtBreakpoints(api);
|
|
15
|
+
Object.entries(breakpoints).forEach(([name, [from, to]]) => {
|
|
16
|
+
values.set(name, buildQuery(from, to));
|
|
17
|
+
if (!name.endsWith("+") && !name.endsWith("-")) {
|
|
18
|
+
values.set(`${name}+`, buildQuery(from, null));
|
|
19
|
+
values.set(`${name}-`, buildQuery(null, to));
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
atValuesCache.set(api, values);
|
|
23
|
+
return values;
|
|
24
|
+
};
|
|
25
|
+
const getAtBreakpoints = (api) => ({
|
|
26
|
+
...defaultBreakpoints,
|
|
27
|
+
...api.breakpoints ?? {}
|
|
28
|
+
});
|
|
29
|
+
const getContainerInfo = (contexts) => {
|
|
30
|
+
for (let i = contexts.length - 1; i >= 0; i -= 1) {
|
|
31
|
+
const info = parseContainerContext(contexts[i]);
|
|
32
|
+
if (info) return {
|
|
33
|
+
...info,
|
|
34
|
+
index: i
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
};
|
|
39
|
+
const resolveMediaQuery = (api, key) => {
|
|
40
|
+
const direct = getAtValues(api).get(key);
|
|
41
|
+
if (direct) return direct;
|
|
42
|
+
const range = parseRangeKey(key, getAtBreakpoints(api), api.unit ?? "px");
|
|
43
|
+
if (range) return buildMediaQuery(range) ?? key;
|
|
44
|
+
return key;
|
|
45
|
+
};
|
|
46
|
+
const resolveContainerQuery = (api, key, name) => {
|
|
47
|
+
if (key.startsWith("@")) return key;
|
|
48
|
+
const range = parseRangeKey(key, getAtBreakpoints(api), api.unit ?? "px");
|
|
49
|
+
if (range) return buildContainerQuery(range, name);
|
|
50
|
+
return `${name ? `@container ${name}` : "@container"} ${key}`;
|
|
51
|
+
};
|
|
52
|
+
const resolveAtQuery = (api, contexts) => {
|
|
53
|
+
const atIndex = contexts.lastIndexOf("at");
|
|
54
|
+
if (atIndex !== -1 && contexts[atIndex + 1]) {
|
|
55
|
+
const containerInfo$1 = parseContainerContext(contexts[atIndex + 1]);
|
|
56
|
+
if (containerInfo$1) {
|
|
57
|
+
const key$1 = contexts[atIndex + 2];
|
|
58
|
+
if (!key$1) return null;
|
|
59
|
+
return resolveContainerQuery(api, key$1, containerInfo$1.name);
|
|
60
|
+
}
|
|
61
|
+
const key = contexts[atIndex + 1];
|
|
62
|
+
return resolveMediaQuery(api, key);
|
|
63
|
+
}
|
|
64
|
+
const containerInfo = getContainerInfo(contexts);
|
|
65
|
+
if (containerInfo) {
|
|
66
|
+
const key = contexts[containerInfo.index + 1];
|
|
67
|
+
if (key) return resolveContainerQuery(api, key, containerInfo.name);
|
|
68
|
+
}
|
|
69
|
+
for (let i = contexts.length - 1; i >= 0; i -= 1) {
|
|
70
|
+
const key = contexts[i];
|
|
71
|
+
if (key.startsWith("@")) return key;
|
|
72
|
+
const range = parseRangeKey(key, getAtBreakpoints(api), api.unit ?? "px");
|
|
73
|
+
if (range) return buildMediaQuery(range) ?? key;
|
|
74
|
+
const values = getAtValues(api);
|
|
75
|
+
if (values.has(key)) return values.get(key);
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
};
|
|
79
|
+
const name = "at";
|
|
80
|
+
const onInit = (api) => {
|
|
81
|
+
api.breakpoints = {
|
|
82
|
+
...defaultBreakpoints,
|
|
83
|
+
...api.breakpoints ?? {}
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
//#endregion
|
|
88
|
+
export { name, onInit, resolveAtQuery };
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_prop_pseudo_server = require('../pseudo/server.cjs');
|
|
3
|
+
const require_shared = require('./shared.cjs');
|
|
4
|
+
let _emotion_hash = require("@emotion/hash");
|
|
5
|
+
_emotion_hash = require_rolldown_runtime.__toESM(_emotion_hash);
|
|
6
|
+
|
|
7
|
+
//#region src/prop/at/server.ts
|
|
8
|
+
var server_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
9
|
+
DOWN: () => DOWN,
|
|
10
|
+
UP: () => UP,
|
|
11
|
+
dependencies: () => dependencies,
|
|
12
|
+
name: () => name,
|
|
13
|
+
onBoot: () => onBoot,
|
|
14
|
+
onProp: () => onProp,
|
|
15
|
+
onReady: () => onReady,
|
|
16
|
+
values: () => values
|
|
17
|
+
});
|
|
18
|
+
const UP = "+";
|
|
19
|
+
const DOWN = "-";
|
|
20
|
+
const name = "at";
|
|
21
|
+
const dependencies = new Set([
|
|
22
|
+
"at",
|
|
23
|
+
"container",
|
|
24
|
+
"keyframes"
|
|
25
|
+
]);
|
|
26
|
+
const values = new Map([...require_shared.baseAtValues]);
|
|
27
|
+
const onBoot = async (api) => {
|
|
28
|
+
const baseBreakpoints = {
|
|
29
|
+
...require_shared.defaultBreakpoints,
|
|
30
|
+
...api.breakpoints ?? {}
|
|
31
|
+
};
|
|
32
|
+
api.breakpoints = { ...baseBreakpoints };
|
|
33
|
+
const breakpoints = api.breakpoints;
|
|
34
|
+
Object.entries(breakpoints).forEach(([name, [from, to]]) => [
|
|
35
|
+
["", [from, to]],
|
|
36
|
+
[UP, [from, null]],
|
|
37
|
+
[DOWN, [null, to]]
|
|
38
|
+
].forEach(([symbol, fromTo]) => breakpoints[`${name}${symbol}`] = fromTo));
|
|
39
|
+
Object.entries(breakpoints).forEach(([name, [from, to]]) => {
|
|
40
|
+
dependencies.add(name);
|
|
41
|
+
if (from === null) values.set(name, `@media screen and (max-width: ${to}px)`);
|
|
42
|
+
else if (to === null) values.set(name, `@media screen and (min-width: ${from}px)`);
|
|
43
|
+
else values.set(name, `@media screen and (min-width: ${from}px) and (max-width: ${to}px)`);
|
|
44
|
+
});
|
|
45
|
+
Array.from(values.keys()).forEach((name) => dependencies.add(name));
|
|
46
|
+
api.file.js.dts.set("body", `pseudo:AtPropsShorthandsInterfaceStart`, `export interface $$AtPropsShorthands {`);
|
|
47
|
+
for (const name of dependencies) {
|
|
48
|
+
if (name === "container") continue;
|
|
49
|
+
const description = name === "keyframes" ? "@keyframes" : values.get(name) ?? "";
|
|
50
|
+
const prop = {
|
|
51
|
+
property: name,
|
|
52
|
+
aliases: [name],
|
|
53
|
+
description
|
|
54
|
+
};
|
|
55
|
+
api.dictionary.set(name, prop);
|
|
56
|
+
name !== "at" && api.file.js.dts.set("body", `at:${name}:description`, prop.description).set("body", `at:${name}:declaration`, ` "${name}"?: ${name === "keyframes" ? "$$KeyframesProps" : "$$FinalProps"}\n`);
|
|
57
|
+
}
|
|
58
|
+
api.file.js.dts.set("body", `pseudo:AtPropsShorthandsInterfaceEnd`, `}`).set("body", "$$:KeyframesProps", `export type $$KeyframesProps = {
|
|
59
|
+
[key: string]: $$FinalProps
|
|
60
|
+
}`).set("body", "$$:AtNamedProps", `export type $$AtNamedProps = {
|
|
61
|
+
[key in \`container_\${string}\`]?: StandardProperties['container'] | $$FinalProps
|
|
62
|
+
} & {
|
|
63
|
+
[key in \`keyframes_\${string}\`]?: $$KeyframesProps
|
|
64
|
+
}`).set("body", `$$:AtProps`, `export type $$AtProps = {
|
|
65
|
+
at?: {
|
|
66
|
+
[key: string]: $$FinalProps | $$KeyframesProps
|
|
67
|
+
} & { [key: \`keyframes \${string}\`]: $$KeyframesProps } & $$AtPropsShorthands & $$AtNamedProps
|
|
68
|
+
} & $$AtPropsShorthands & $$AtNamedProps`).replace("body", `$$:FinalProps`, (v) => `${v} & $$AtProps`);
|
|
69
|
+
const runtimeConfig = api.runtime;
|
|
70
|
+
if (Boolean(runtimeConfig && (runtimeConfig.only !== void 0 || runtimeConfig.strategy))) {
|
|
71
|
+
api.file.js.importAndConfig({
|
|
72
|
+
name: "onInit",
|
|
73
|
+
from: "boss-css/prop/at/runtime-only"
|
|
74
|
+
}, () => true);
|
|
75
|
+
api.file.js.config({
|
|
76
|
+
from: "boss-css/prop/at/runtime-only",
|
|
77
|
+
config: { breakpoints: baseBreakpoints }
|
|
78
|
+
}, () => true);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const onReady = async (api) => {
|
|
82
|
+
const updateFinalProps = (value) => {
|
|
83
|
+
const content = typeof value === "string" ? value : value?.content;
|
|
84
|
+
if (typeof content !== "string") return value;
|
|
85
|
+
if (!content.includes("StandardProperties")) return content;
|
|
86
|
+
if (content.includes(`Omit<StandardProperties, 'container'>`)) return content;
|
|
87
|
+
return content.replace(" & StandardProperties", () => {
|
|
88
|
+
return ` & Omit<StandardProperties, 'container'> & { container?: StandardProperties['container'] | $$FinalProps }`;
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
api.file.js.dts.replace("body", "$$:FinalProps", updateFinalProps);
|
|
92
|
+
};
|
|
93
|
+
const isContainerContext = (value) => Boolean(require_shared.parseContainerContext(value));
|
|
94
|
+
const isKeyframesContext = (value) => Boolean(require_shared.parseKeyframesContext(value));
|
|
95
|
+
const getContainerInfo = (contexts) => {
|
|
96
|
+
for (let i = contexts.length - 1; i >= 0; i -= 1) {
|
|
97
|
+
const info = require_shared.parseContainerContext(contexts[i]);
|
|
98
|
+
if (info) return info;
|
|
99
|
+
}
|
|
100
|
+
return null;
|
|
101
|
+
};
|
|
102
|
+
const getContainerInfoWithIndex = (contexts) => {
|
|
103
|
+
for (let i = contexts.length - 1; i >= 0; i -= 1) {
|
|
104
|
+
const info = require_shared.parseContainerContext(contexts[i]);
|
|
105
|
+
if (info) return {
|
|
106
|
+
...info,
|
|
107
|
+
index: i
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
111
|
+
};
|
|
112
|
+
const resolveMediaQuery = (api, key) => {
|
|
113
|
+
const direct = values.get(key);
|
|
114
|
+
if (direct) return direct;
|
|
115
|
+
const range = require_shared.parseRangeKey(key, api.breakpoints ?? {}, api.unit ?? "px");
|
|
116
|
+
if (range) return require_shared.buildMediaQuery(range) ?? key;
|
|
117
|
+
return key;
|
|
118
|
+
};
|
|
119
|
+
const resolveContainerQuery = (api, key, name) => {
|
|
120
|
+
if (key.startsWith("@")) return key;
|
|
121
|
+
const range = require_shared.parseRangeKey(key, api.breakpoints ?? {}, api.unit ?? "px");
|
|
122
|
+
if (range) return require_shared.buildContainerQuery(range, name);
|
|
123
|
+
return `${name ? `@container ${name}` : "@container"} ${key}`;
|
|
124
|
+
};
|
|
125
|
+
const resolveAtQuery = (api, contexts, key) => {
|
|
126
|
+
const containerInfo = getContainerInfo(contexts);
|
|
127
|
+
if (containerInfo) return resolveContainerQuery(api, key, containerInfo.name);
|
|
128
|
+
return resolveMediaQuery(api, key);
|
|
129
|
+
};
|
|
130
|
+
const resolveQueryFromContexts = (api, contexts) => {
|
|
131
|
+
const atIndex = contexts.lastIndexOf("at");
|
|
132
|
+
if (atIndex !== -1 && contexts[atIndex + 1]) {
|
|
133
|
+
const containerInfo$1 = require_shared.parseContainerContext(contexts[atIndex + 1]);
|
|
134
|
+
if (containerInfo$1) {
|
|
135
|
+
const key$1 = contexts[atIndex + 2];
|
|
136
|
+
if (!key$1) return null;
|
|
137
|
+
return resolveContainerQuery(api, key$1, containerInfo$1.name);
|
|
138
|
+
}
|
|
139
|
+
const key = contexts[atIndex + 1];
|
|
140
|
+
return resolveMediaQuery(api, key);
|
|
141
|
+
}
|
|
142
|
+
const containerInfo = getContainerInfoWithIndex(contexts);
|
|
143
|
+
if (containerInfo) {
|
|
144
|
+
const key = contexts[containerInfo.index + 1];
|
|
145
|
+
if (key) return resolveContainerQuery(api, key, containerInfo.name);
|
|
146
|
+
}
|
|
147
|
+
for (let i = contexts.length - 1; i >= 0; i -= 1) {
|
|
148
|
+
const key = contexts[i];
|
|
149
|
+
if (key.startsWith("@")) return key;
|
|
150
|
+
const range = require_shared.parseRangeKey(key, api.breakpoints ?? {}, api.unit ?? "px");
|
|
151
|
+
if (range) return require_shared.buildMediaQuery(range) ?? key;
|
|
152
|
+
const direct = values.get(key);
|
|
153
|
+
if (direct) return direct;
|
|
154
|
+
}
|
|
155
|
+
return null;
|
|
156
|
+
};
|
|
157
|
+
const buildAutoKeyframesName = (api, contexts) => {
|
|
158
|
+
return `kf-${(0, _emotion_hash.default)(`${api.selectorPrefix ?? ""}|${contexts.join("|")}`)}`;
|
|
159
|
+
};
|
|
160
|
+
const onProp = async (api, { name, prop, contexts, preferVariables, file }) => {
|
|
161
|
+
const isAt = name === "at";
|
|
162
|
+
const contextName = prop?.named ? `${name} ${prop.named}` : name;
|
|
163
|
+
const handleKeyframes = async (entries, activeContexts) => {
|
|
164
|
+
const keyframesContext = activeContexts.at(-1);
|
|
165
|
+
if (!keyframesContext) return;
|
|
166
|
+
const keyframesInfo = require_shared.parseKeyframesContext(keyframesContext);
|
|
167
|
+
if (!keyframesInfo) return;
|
|
168
|
+
const keyframesName = keyframesInfo.name ?? buildAutoKeyframesName(api, activeContexts);
|
|
169
|
+
const query = resolveQueryFromContexts(api, activeContexts);
|
|
170
|
+
const frames = /* @__PURE__ */ new Map();
|
|
171
|
+
const selectors = /* @__PURE__ */ new Set();
|
|
172
|
+
for (const [step, stepProp] of Object.entries(entries)) {
|
|
173
|
+
if (!stepProp?.value || typeof stepProp.value !== "object" || Array.isArray(stepProp.value)) continue;
|
|
174
|
+
const normalizedStep = require_shared.normalizeKeyframeStep(step);
|
|
175
|
+
if (!normalizedStep) continue;
|
|
176
|
+
const stepContexts = [...activeContexts, step];
|
|
177
|
+
const stepEntries = stepProp.value;
|
|
178
|
+
for (const [propName, propValue] of Object.entries(stepEntries)) {
|
|
179
|
+
if (!propValue || typeof propValue !== "object" || Array.isArray(propValue)) continue;
|
|
180
|
+
const resolved = api.dictionary.resolve(propName);
|
|
181
|
+
const descriptor = resolved.descriptor;
|
|
182
|
+
const isCustomProperty = typeof propName === "string" && propName.startsWith("--");
|
|
183
|
+
if (!descriptor?.isCSSProp && !isCustomProperty) continue;
|
|
184
|
+
const propertyName = isCustomProperty ? propName : descriptor?.property ?? api.camelCaseToDash(propName);
|
|
185
|
+
const selectorValue = propValue.selectorValue ?? (preferVariables ? null : propValue.value);
|
|
186
|
+
const classToken = propValue.classToken;
|
|
187
|
+
const resolvedName = resolved?.name ?? propName;
|
|
188
|
+
const className = classToken ? null : api.contextToClassName(resolvedName, selectorValue, stepContexts, true, api.selectorPrefix);
|
|
189
|
+
const baseSelector = classToken ? api.classTokenToSelector(classToken) : `.${className}`;
|
|
190
|
+
const pseudoChain = stepContexts.filter((context) => require_prop_pseudo_server.dependencies.has(context));
|
|
191
|
+
const baseWithPseudos = pseudoChain.length ? `${baseSelector}:${pseudoChain.join(":")}` : baseSelector;
|
|
192
|
+
const selector = api.applyChildSelectors(baseWithPseudos, stepContexts);
|
|
193
|
+
selectors.add(selector);
|
|
194
|
+
const value = propValue.value === null ? `var(${api.contextToCSSVariable(resolvedName, null, stepContexts, api.selectorPrefix)})` : String(api.dictionary.toValue(propValue.value, propertyName));
|
|
195
|
+
if (!frames.has(normalizedStep)) frames.set(normalizedStep, /* @__PURE__ */ new Map());
|
|
196
|
+
frames.get(normalizedStep)?.set(propertyName, value);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (!frames.size) return;
|
|
200
|
+
api.css.addRule(require_shared.buildKeyframesRule(keyframesName, frames), query);
|
|
201
|
+
const needsImportant = api.strategy === "inline-first" && preferVariables === true && activeContexts.length > 0;
|
|
202
|
+
for (const selector of selectors) {
|
|
203
|
+
api.css.selector({
|
|
204
|
+
selector,
|
|
205
|
+
query
|
|
206
|
+
});
|
|
207
|
+
api.css.rule("animation-name", keyframesName, needsImportant ? { important: true } : void 0);
|
|
208
|
+
api.css.write();
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
const processEntries = async (entries, nextContexts) => {
|
|
212
|
+
for (const [key, styleProp] of Object.entries(entries)) {
|
|
213
|
+
if (!styleProp?.value || typeof styleProp.value !== "object" || Array.isArray(styleProp.value)) continue;
|
|
214
|
+
const styleEntries = styleProp.value;
|
|
215
|
+
if (isContainerContext(key)) {
|
|
216
|
+
nextContexts.push(key);
|
|
217
|
+
await processEntries(styleEntries, nextContexts);
|
|
218
|
+
nextContexts.pop();
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
if (isKeyframesContext(key)) {
|
|
222
|
+
nextContexts.push(key);
|
|
223
|
+
await handleKeyframes(styleEntries, nextContexts);
|
|
224
|
+
nextContexts.pop();
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
nextContexts.push(key);
|
|
228
|
+
const query = resolveAtQuery(api, nextContexts, key);
|
|
229
|
+
for (const i in styleEntries) {
|
|
230
|
+
const entry = styleEntries[i];
|
|
231
|
+
const classToken = entry?.classToken;
|
|
232
|
+
const resolved = api.dictionary.resolve(i);
|
|
233
|
+
const resolvedName = resolved.descriptor ? resolved.name : i;
|
|
234
|
+
if (resolved.suffix) {
|
|
235
|
+
entry.named = resolved.suffix;
|
|
236
|
+
entry.rawName = resolved.raw;
|
|
237
|
+
}
|
|
238
|
+
const selectorValue = entry?.selectorValue ?? (preferVariables ? null : entry.value);
|
|
239
|
+
const className = classToken ? null : api.contextToClassName(resolvedName, selectorValue, nextContexts, true, api.selectorPrefix);
|
|
240
|
+
const baseSelector = classToken ? api.classTokenToSelector(classToken) : `.${className}`;
|
|
241
|
+
const pseudoChain = nextContexts.filter((context) => require_prop_pseudo_server.dependencies.has(context));
|
|
242
|
+
const baseWithPseudos = pseudoChain.length ? `${baseSelector}:${pseudoChain.join(":")}` : baseSelector;
|
|
243
|
+
const selector = api.applyChildSelectors(baseWithPseudos, nextContexts);
|
|
244
|
+
if (query && entry && !entry.query) entry.query = query;
|
|
245
|
+
api.css.selector({
|
|
246
|
+
selector,
|
|
247
|
+
query
|
|
248
|
+
});
|
|
249
|
+
await api.trigger("onProp", {
|
|
250
|
+
name: resolvedName,
|
|
251
|
+
prop: entry,
|
|
252
|
+
contexts: nextContexts,
|
|
253
|
+
preferVariables,
|
|
254
|
+
file
|
|
255
|
+
}, ({ dependencies }) => {
|
|
256
|
+
return !dependencies || dependencies.has(resolvedName);
|
|
257
|
+
});
|
|
258
|
+
if (api.css.current) api.css.write();
|
|
259
|
+
}
|
|
260
|
+
nextContexts.pop();
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
if (isAt) contexts.push(name);
|
|
264
|
+
await processEntries(isAt ? prop.value : { [contextName]: { value: prop.value } }, contexts);
|
|
265
|
+
if (isAt) contexts.pop();
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
//#endregion
|
|
269
|
+
exports.DOWN = DOWN;
|
|
270
|
+
exports.UP = UP;
|
|
271
|
+
exports.dependencies = dependencies;
|
|
272
|
+
exports.name = name;
|
|
273
|
+
exports.onBoot = onBoot;
|
|
274
|
+
exports.onProp = onProp;
|
|
275
|
+
exports.onReady = onReady;
|
|
276
|
+
Object.defineProperty(exports, 'server_exports', {
|
|
277
|
+
enumerable: true,
|
|
278
|
+
get: function () {
|
|
279
|
+
return server_exports;
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
exports.values = values;
|