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
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/prop/child/runtime-only.ts
|
|
2
|
+
const name = "child";
|
|
3
|
+
const createChildContext = (selector) => {
|
|
4
|
+
return `[${selector.replace(/ /g, "_")}]`;
|
|
5
|
+
};
|
|
6
|
+
const onInit = (api) => {
|
|
7
|
+
api.dictionary.set("child", {
|
|
8
|
+
property: "child",
|
|
9
|
+
aliases: ["child"],
|
|
10
|
+
description: "Arbitrary selector nesting"
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { createChildContext, name, onInit };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_prop_pseudo_server = require('../pseudo/server.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/prop/child/server.ts
|
|
5
|
+
var server_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
6
|
+
dependencies: () => dependencies,
|
|
7
|
+
name: () => name,
|
|
8
|
+
onBoot: () => onBoot,
|
|
9
|
+
onProp: () => onProp
|
|
10
|
+
});
|
|
11
|
+
const name = "child";
|
|
12
|
+
const dependencies = new Set(["child"]);
|
|
13
|
+
const onBoot = async (api) => {
|
|
14
|
+
api.dictionary.set("child", {
|
|
15
|
+
property: "child",
|
|
16
|
+
aliases: ["child"],
|
|
17
|
+
description: "Arbitrary selector nesting"
|
|
18
|
+
});
|
|
19
|
+
api.file.js.dts.set("body", "child:ChildProps", `export type $$ChildProps = { child?: { [selector: string]: $$FinalProps } }`).replace("body", `$$:FinalProps`, (v) => `${v} & $$ChildProps`);
|
|
20
|
+
const runtimeConfig = api.runtime;
|
|
21
|
+
if (Boolean(runtimeConfig && (runtimeConfig.only !== void 0 || runtimeConfig.strategy))) api.file.js.importAndConfig({
|
|
22
|
+
name: "onInit",
|
|
23
|
+
from: "boss-css/prop/child/runtime-only"
|
|
24
|
+
}, () => true);
|
|
25
|
+
};
|
|
26
|
+
const onProp = async (api, { prop, contexts, preferVariables, file }) => {
|
|
27
|
+
const value = prop.value;
|
|
28
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return;
|
|
29
|
+
const entries = value;
|
|
30
|
+
for (const [rawSelector, selectorProp] of Object.entries(entries)) {
|
|
31
|
+
if (!selectorProp?.value || typeof selectorProp.value !== "object" || Array.isArray(selectorProp.value)) continue;
|
|
32
|
+
const childContext = `[${rawSelector.replace(/ /g, "_")}]`;
|
|
33
|
+
contexts.push(childContext);
|
|
34
|
+
const query = selectorProp.query ?? prop.query ?? null;
|
|
35
|
+
const pseudoChain = contexts.filter((context) => require_prop_pseudo_server.dependencies.has(context));
|
|
36
|
+
const childEntries = selectorProp.value;
|
|
37
|
+
for (const [name, childProp] of Object.entries(childEntries)) {
|
|
38
|
+
const resolved = api.dictionary.resolve(name);
|
|
39
|
+
const descriptor = resolved.descriptor;
|
|
40
|
+
if (!descriptor) continue;
|
|
41
|
+
if (resolved.suffix) {
|
|
42
|
+
childProp.named = resolved.suffix;
|
|
43
|
+
childProp.rawName = resolved.raw;
|
|
44
|
+
}
|
|
45
|
+
const classToken = childProp.classToken;
|
|
46
|
+
const selectorValue = childProp.selectorValue ?? childProp.value;
|
|
47
|
+
const className = classToken ? null : api.contextToClassName(resolved.name, selectorValue, contexts, true, api.selectorPrefix);
|
|
48
|
+
const baseSelector = classToken ? api.classTokenToSelector(classToken) : `.${className}`;
|
|
49
|
+
const baseWithPseudos = pseudoChain.length ? `${baseSelector}:${pseudoChain.join(":")}` : baseSelector;
|
|
50
|
+
const selector = api.applyChildSelectors(baseWithPseudos, contexts);
|
|
51
|
+
api.css.selector({
|
|
52
|
+
selector,
|
|
53
|
+
query
|
|
54
|
+
});
|
|
55
|
+
if (query && !childProp.query) childProp.query = query;
|
|
56
|
+
await api.trigger("onProp", {
|
|
57
|
+
name: resolved.name,
|
|
58
|
+
prop: childProp,
|
|
59
|
+
contexts,
|
|
60
|
+
preferVariables,
|
|
61
|
+
file
|
|
62
|
+
}, ({ dependencies }) => {
|
|
63
|
+
return !dependencies || dependencies.has(descriptor.property);
|
|
64
|
+
});
|
|
65
|
+
if (api.css.current) api.css.write();
|
|
66
|
+
}
|
|
67
|
+
contexts.pop();
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
exports.dependencies = dependencies;
|
|
73
|
+
exports.name = name;
|
|
74
|
+
exports.onBoot = onBoot;
|
|
75
|
+
exports.onProp = onProp;
|
|
76
|
+
Object.defineProperty(exports, 'server_exports', {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
get: function () {
|
|
79
|
+
return server_exports;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { __exportAll } from "../../_virtual/rolldown_runtime.mjs";
|
|
2
|
+
import { dependencies as dependencies$1 } from "../pseudo/server.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/prop/child/server.ts
|
|
5
|
+
var server_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
+
dependencies: () => dependencies,
|
|
7
|
+
name: () => name,
|
|
8
|
+
onBoot: () => onBoot,
|
|
9
|
+
onProp: () => onProp
|
|
10
|
+
});
|
|
11
|
+
const name = "child";
|
|
12
|
+
const dependencies = new Set(["child"]);
|
|
13
|
+
const onBoot = async (api) => {
|
|
14
|
+
api.dictionary.set("child", {
|
|
15
|
+
property: "child",
|
|
16
|
+
aliases: ["child"],
|
|
17
|
+
description: "Arbitrary selector nesting"
|
|
18
|
+
});
|
|
19
|
+
api.file.js.dts.set("body", "child:ChildProps", `export type $$ChildProps = { child?: { [selector: string]: $$FinalProps } }`).replace("body", `$$:FinalProps`, (v) => `${v} & $$ChildProps`);
|
|
20
|
+
const runtimeConfig = api.runtime;
|
|
21
|
+
if (Boolean(runtimeConfig && (runtimeConfig.only !== void 0 || runtimeConfig.strategy))) api.file.js.importAndConfig({
|
|
22
|
+
name: "onInit",
|
|
23
|
+
from: "boss-css/prop/child/runtime-only"
|
|
24
|
+
}, () => true);
|
|
25
|
+
};
|
|
26
|
+
const onProp = async (api, { prop, contexts, preferVariables, file }) => {
|
|
27
|
+
const value = prop.value;
|
|
28
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return;
|
|
29
|
+
const entries = value;
|
|
30
|
+
for (const [rawSelector, selectorProp] of Object.entries(entries)) {
|
|
31
|
+
if (!selectorProp?.value || typeof selectorProp.value !== "object" || Array.isArray(selectorProp.value)) continue;
|
|
32
|
+
const childContext = `[${rawSelector.replace(/ /g, "_")}]`;
|
|
33
|
+
contexts.push(childContext);
|
|
34
|
+
const query = selectorProp.query ?? prop.query ?? null;
|
|
35
|
+
const pseudoChain = contexts.filter((context) => dependencies$1.has(context));
|
|
36
|
+
const childEntries = selectorProp.value;
|
|
37
|
+
for (const [name, childProp] of Object.entries(childEntries)) {
|
|
38
|
+
const resolved = api.dictionary.resolve(name);
|
|
39
|
+
const descriptor = resolved.descriptor;
|
|
40
|
+
if (!descriptor) continue;
|
|
41
|
+
if (resolved.suffix) {
|
|
42
|
+
childProp.named = resolved.suffix;
|
|
43
|
+
childProp.rawName = resolved.raw;
|
|
44
|
+
}
|
|
45
|
+
const classToken = childProp.classToken;
|
|
46
|
+
const selectorValue = childProp.selectorValue ?? childProp.value;
|
|
47
|
+
const className = classToken ? null : api.contextToClassName(resolved.name, selectorValue, contexts, true, api.selectorPrefix);
|
|
48
|
+
const baseSelector = classToken ? api.classTokenToSelector(classToken) : `.${className}`;
|
|
49
|
+
const baseWithPseudos = pseudoChain.length ? `${baseSelector}:${pseudoChain.join(":")}` : baseSelector;
|
|
50
|
+
const selector = api.applyChildSelectors(baseWithPseudos, contexts);
|
|
51
|
+
api.css.selector({
|
|
52
|
+
selector,
|
|
53
|
+
query
|
|
54
|
+
});
|
|
55
|
+
if (query && !childProp.query) childProp.query = query;
|
|
56
|
+
await api.trigger("onProp", {
|
|
57
|
+
name: resolved.name,
|
|
58
|
+
prop: childProp,
|
|
59
|
+
contexts,
|
|
60
|
+
preferVariables,
|
|
61
|
+
file
|
|
62
|
+
}, ({ dependencies }) => {
|
|
63
|
+
return !dependencies || dependencies.has(descriptor.property);
|
|
64
|
+
});
|
|
65
|
+
if (api.css.current) api.css.write();
|
|
66
|
+
}
|
|
67
|
+
contexts.pop();
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
export { dependencies, name, onBoot, onProp, server_exports };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let node_fs_promises = require("node:fs/promises");
|
|
3
|
+
node_fs_promises = require_rolldown_runtime.__toESM(node_fs_promises);
|
|
4
|
+
let node_module = require("node:module");
|
|
5
|
+
|
|
6
|
+
//#region src/prop/css/getDtsTemplate.ts
|
|
7
|
+
const baseInterfaces = [
|
|
8
|
+
"StandardLonghandProperties",
|
|
9
|
+
"StandardShorthandProperties",
|
|
10
|
+
"VendorLonghandProperties",
|
|
11
|
+
"VendorShorthandProperties",
|
|
12
|
+
"ObsoleteProperties",
|
|
13
|
+
"SvgProperties",
|
|
14
|
+
"StandardLonghandPropertiesHyphen",
|
|
15
|
+
"StandardShorthandPropertiesHyphen",
|
|
16
|
+
"VendorLonghandPropertiesHyphen",
|
|
17
|
+
"VendorShorthandPropertiesHyphen",
|
|
18
|
+
"ObsoletePropertiesHyphen",
|
|
19
|
+
"SvgPropertiesHyphen"
|
|
20
|
+
];
|
|
21
|
+
const lcfirst = (str) => str.charAt(0).toLowerCase() + str.slice(1);
|
|
22
|
+
let cachedTemplate = null;
|
|
23
|
+
async function getDtsTemplate() {
|
|
24
|
+
if (cachedTemplate) return cachedTemplate;
|
|
25
|
+
const interfaces = [...baseInterfaces];
|
|
26
|
+
cachedTemplate = (async () => {
|
|
27
|
+
const cssTypeFilePath = (0, node_module.createRequire)(process.cwd() + "/package.json").resolve("csstype/index.d.ts");
|
|
28
|
+
const csstypeArray = (await node_fs_promises.default.readFile(cssTypeFilePath, "utf-8")).split("\n");
|
|
29
|
+
const csstypeObject = {};
|
|
30
|
+
const csstypeTemplate = [];
|
|
31
|
+
let iface = null;
|
|
32
|
+
let comment = [];
|
|
33
|
+
const propRegexp = /^ {2}["']?(.+?)["']?\?: ([a-zA-Z. |<>]+);?/;
|
|
34
|
+
for (const line of csstypeArray) if (line.includes(`export interface ${interfaces[0]}<`)) {
|
|
35
|
+
iface = interfaces[0];
|
|
36
|
+
csstypeTemplate.push([`css:interface:${iface}:start`, line]);
|
|
37
|
+
} else if (iface && line === "}") {
|
|
38
|
+
csstypeTemplate.push([`css:interface:${iface}:end`, line]);
|
|
39
|
+
iface = null;
|
|
40
|
+
interfaces.shift();
|
|
41
|
+
} else if (iface && (line === " */" || line.startsWith(" * @see"))) {} else if (iface && (line === " /**" || line.startsWith(" *"))) comment.push(line.replace(/^ ?\/?\*?\*/g, ""));
|
|
42
|
+
else if (iface && propRegexp.test(line)) {
|
|
43
|
+
const match = line.match(propRegexp);
|
|
44
|
+
if (!match) continue;
|
|
45
|
+
const [, _name, values] = match;
|
|
46
|
+
const name = lcfirst(_name);
|
|
47
|
+
csstypeObject[name] = {
|
|
48
|
+
description: csstypeObject[name]?.description || comment.join("\n"),
|
|
49
|
+
types: csstypeObject[name]?.types || values.trim().split("|").map((a) => a.trim()).filter((a) => a),
|
|
50
|
+
iface
|
|
51
|
+
};
|
|
52
|
+
csstypeTemplate.push([`css:${name}:description`, ""]);
|
|
53
|
+
csstypeTemplate.push([`css:${name}:declaration`, line.replace(/;$/, "").replace(`?: `, () => "?: $$PropValues | ")]);
|
|
54
|
+
comment = [];
|
|
55
|
+
} else if (csstypeTemplate.at(-1)?.[0] === null) {
|
|
56
|
+
const last = csstypeTemplate.at(-1);
|
|
57
|
+
if (last) last[1] += `\n${line}`;
|
|
58
|
+
} else csstypeTemplate.push([null, line]);
|
|
59
|
+
return [csstypeObject, csstypeTemplate];
|
|
60
|
+
})();
|
|
61
|
+
return cachedTemplate;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
exports.default = getDtsTemplate;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
|
|
4
|
+
//#region src/prop/css/getDtsTemplate.ts
|
|
5
|
+
const baseInterfaces = [
|
|
6
|
+
"StandardLonghandProperties",
|
|
7
|
+
"StandardShorthandProperties",
|
|
8
|
+
"VendorLonghandProperties",
|
|
9
|
+
"VendorShorthandProperties",
|
|
10
|
+
"ObsoleteProperties",
|
|
11
|
+
"SvgProperties",
|
|
12
|
+
"StandardLonghandPropertiesHyphen",
|
|
13
|
+
"StandardShorthandPropertiesHyphen",
|
|
14
|
+
"VendorLonghandPropertiesHyphen",
|
|
15
|
+
"VendorShorthandPropertiesHyphen",
|
|
16
|
+
"ObsoletePropertiesHyphen",
|
|
17
|
+
"SvgPropertiesHyphen"
|
|
18
|
+
];
|
|
19
|
+
const lcfirst = (str) => str.charAt(0).toLowerCase() + str.slice(1);
|
|
20
|
+
let cachedTemplate = null;
|
|
21
|
+
async function getDtsTemplate() {
|
|
22
|
+
if (cachedTemplate) return cachedTemplate;
|
|
23
|
+
const interfaces = [...baseInterfaces];
|
|
24
|
+
cachedTemplate = (async () => {
|
|
25
|
+
const cssTypeFilePath = createRequire(process.cwd() + "/package.json").resolve("csstype/index.d.ts");
|
|
26
|
+
const csstypeArray = (await fs.readFile(cssTypeFilePath, "utf-8")).split("\n");
|
|
27
|
+
const csstypeObject = {};
|
|
28
|
+
const csstypeTemplate = [];
|
|
29
|
+
let iface = null;
|
|
30
|
+
let comment = [];
|
|
31
|
+
const propRegexp = /^ {2}["']?(.+?)["']?\?: ([a-zA-Z. |<>]+);?/;
|
|
32
|
+
for (const line of csstypeArray) if (line.includes(`export interface ${interfaces[0]}<`)) {
|
|
33
|
+
iface = interfaces[0];
|
|
34
|
+
csstypeTemplate.push([`css:interface:${iface}:start`, line]);
|
|
35
|
+
} else if (iface && line === "}") {
|
|
36
|
+
csstypeTemplate.push([`css:interface:${iface}:end`, line]);
|
|
37
|
+
iface = null;
|
|
38
|
+
interfaces.shift();
|
|
39
|
+
} else if (iface && (line === " */" || line.startsWith(" * @see"))) {} else if (iface && (line === " /**" || line.startsWith(" *"))) comment.push(line.replace(/^ ?\/?\*?\*/g, ""));
|
|
40
|
+
else if (iface && propRegexp.test(line)) {
|
|
41
|
+
const match = line.match(propRegexp);
|
|
42
|
+
if (!match) continue;
|
|
43
|
+
const [, _name, values] = match;
|
|
44
|
+
const name = lcfirst(_name);
|
|
45
|
+
csstypeObject[name] = {
|
|
46
|
+
description: csstypeObject[name]?.description || comment.join("\n"),
|
|
47
|
+
types: csstypeObject[name]?.types || values.trim().split("|").map((a) => a.trim()).filter((a) => a),
|
|
48
|
+
iface
|
|
49
|
+
};
|
|
50
|
+
csstypeTemplate.push([`css:${name}:description`, ""]);
|
|
51
|
+
csstypeTemplate.push([`css:${name}:declaration`, line.replace(/;$/, "").replace(`?: `, () => "?: $$PropValues | ")]);
|
|
52
|
+
comment = [];
|
|
53
|
+
} else if (csstypeTemplate.at(-1)?.[0] === null) {
|
|
54
|
+
const last = csstypeTemplate.at(-1);
|
|
55
|
+
if (last) last[1] += `\n${line}`;
|
|
56
|
+
} else csstypeTemplate.push([null, line]);
|
|
57
|
+
return [csstypeObject, csstypeTemplate];
|
|
58
|
+
})();
|
|
59
|
+
return cachedTemplate;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
//#endregion
|
|
63
|
+
export { getDtsTemplate as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const require_names = require('../../api/names.cjs');
|
|
2
|
+
const require_shared = require('../pseudo/shared.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/prop/css/runtime-only.ts
|
|
5
|
+
const resolvePropertyName = (prop) => prop.includes("-") ? prop : require_names.camelCaseToDash(prop);
|
|
6
|
+
const buildRuntimeSelector = (className, contexts) => {
|
|
7
|
+
const baseSelector = `.${className}`;
|
|
8
|
+
const pseudoChain = contexts.filter((context) => require_shared.pseudoDependencies.has(context));
|
|
9
|
+
return require_names.applyChildSelectors(pseudoChain.length ? `${baseSelector}:${pseudoChain.join(":")}` : baseSelector, contexts);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
exports.buildRuntimeSelector = buildRuntimeSelector;
|
|
14
|
+
exports.resolvePropertyName = resolvePropertyName;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { applyChildSelectors, camelCaseToDash } from "../../api/names.mjs";
|
|
2
|
+
import { pseudoDependencies } from "../pseudo/shared.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/prop/css/runtime-only.ts
|
|
5
|
+
const resolvePropertyName = (prop) => prop.includes("-") ? prop : camelCaseToDash(prop);
|
|
6
|
+
const buildRuntimeSelector = (className, contexts) => {
|
|
7
|
+
const baseSelector = `.${className}`;
|
|
8
|
+
const pseudoChain = contexts.filter((context) => pseudoDependencies.has(context));
|
|
9
|
+
return applyChildSelectors(pseudoChain.length ? `${baseSelector}:${pseudoChain.join(":")}` : baseSelector, contexts);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { buildRuntimeSelector, resolvePropertyName };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_getDtsTemplate = require('./getDtsTemplate.cjs');
|
|
3
|
+
let _webref_css = require("@webref/css");
|
|
4
|
+
|
|
5
|
+
//#region src/prop/css/server.ts
|
|
6
|
+
var server_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
7
|
+
dependencies: () => dependencies,
|
|
8
|
+
name: () => name,
|
|
9
|
+
onBoot: () => onBoot,
|
|
10
|
+
onProp: () => onProp
|
|
11
|
+
});
|
|
12
|
+
const name = "css";
|
|
13
|
+
const dependencies = new Set(["css"]);
|
|
14
|
+
const onBoot = async (api) => {
|
|
15
|
+
const [typeObject, typeTemplate] = await require_getDtsTemplate.default();
|
|
16
|
+
api.file.js.dts.replace("body", `$$:FinalProps`, (v) => `${v} & StandardProperties`);
|
|
17
|
+
typeTemplate.forEach((entry) => {
|
|
18
|
+
api.file.js.dts.set("body", ...entry);
|
|
19
|
+
});
|
|
20
|
+
for (const [name, descriptor] of Object.entries(typeObject)) {
|
|
21
|
+
const item = {
|
|
22
|
+
property: api.camelCaseToDash(name),
|
|
23
|
+
description: descriptor.description ?? "",
|
|
24
|
+
values: descriptor.types ?? [],
|
|
25
|
+
initial: "",
|
|
26
|
+
csstype: descriptor,
|
|
27
|
+
isCSSProp: true,
|
|
28
|
+
aliases: [name],
|
|
29
|
+
single: false,
|
|
30
|
+
descriptor
|
|
31
|
+
};
|
|
32
|
+
if (descriptor.iface?.endsWith("Hyphen")) item.property = name;
|
|
33
|
+
api.dictionary.set(name, item);
|
|
34
|
+
dependencies.add(name);
|
|
35
|
+
}
|
|
36
|
+
const parsedFiles = await (0, _webref_css.listAll)();
|
|
37
|
+
const propertyList = Array.isArray(parsedFiles?.properties) ? parsedFiles.properties : Object.values(parsedFiles ?? {}).flatMap((entry) => entry?.properties ?? []);
|
|
38
|
+
for (const property of propertyList) {
|
|
39
|
+
if (!property?.styleDeclaration) continue;
|
|
40
|
+
const { styleDeclaration } = property;
|
|
41
|
+
const existing = api.dictionary.get(styleDeclaration[0]);
|
|
42
|
+
const existingAliases = existing?.aliases ?? [];
|
|
43
|
+
const existingDescription = existing?.description ?? "";
|
|
44
|
+
const existingUsage = existing?.usage;
|
|
45
|
+
const rawValues = Array.isArray(property.value) ? property.value : property.value ? [property.value] : [];
|
|
46
|
+
const item = {
|
|
47
|
+
description: `${existingDescription ? `${existingDescription}\n` : ""}\n\n**Webref definition**\n\n\`\`\`json\n${JSON.stringify(property, null, 2).replace(/\*\//g, "\\*\\/")}\n\`\`\``,
|
|
48
|
+
usage: existingUsage || property.value,
|
|
49
|
+
descriptor: property,
|
|
50
|
+
property: styleDeclaration[0],
|
|
51
|
+
aliases: [...new Set([...styleDeclaration, ...existingAliases])],
|
|
52
|
+
values: rawValues,
|
|
53
|
+
initial: existing?.initial ?? "",
|
|
54
|
+
isCSSProp: true,
|
|
55
|
+
single: false
|
|
56
|
+
};
|
|
57
|
+
api.dictionary.set(item.property, item);
|
|
58
|
+
item.aliases.forEach((prop) => dependencies.add(prop));
|
|
59
|
+
}
|
|
60
|
+
const missingProps = [];
|
|
61
|
+
for (const key of dependencies) {
|
|
62
|
+
const prop = api.dictionary.get(key);
|
|
63
|
+
if (!prop) continue;
|
|
64
|
+
const templateKey = `css:${key}:description`;
|
|
65
|
+
if (api.file.js.dts.get("body").has(templateKey)) api.file.js.dts.set("body", templateKey, prop.description);
|
|
66
|
+
else missingProps.push([key, prop]);
|
|
67
|
+
}
|
|
68
|
+
api.file.js.dts.set("body", `css:MissingPropsInterfaceStart`, `export interface $$CSSMissingProps {`);
|
|
69
|
+
for (const [key, prop] of missingProps) api.file.js.dts.set("body", `css:${key}:description`, prop.description).set("body", `css:${key}:declaration`, ` "${key}"?: $$PropValues | undefined\n`);
|
|
70
|
+
api.file.js.dts.set("body", `css:MissingPropsInterfaceEnd`, `}`);
|
|
71
|
+
};
|
|
72
|
+
const onProp = async (api, { name, prop, contexts, preferVariables }) => {
|
|
73
|
+
const { value, selectorValue = value, classToken, important } = prop;
|
|
74
|
+
const propertyName = api.dictionary.get(name)?.property ?? api.camelCaseToDash(name);
|
|
75
|
+
if (name === "container" && value && typeof value === "object" && !Array.isArray(value)) return;
|
|
76
|
+
if (!contexts.length) {
|
|
77
|
+
const selector = classToken ? api.classTokenToSelector(classToken) : null;
|
|
78
|
+
api.css.selector({
|
|
79
|
+
className: selector ? null : api.contextToClassName(name, selectorValue, contexts, true, api.selectorPrefix),
|
|
80
|
+
selector
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
const needsImportant = api.strategy === "inline-first" && preferVariables === true && contexts.length > 0;
|
|
84
|
+
const isImportant = Boolean(important || needsImportant);
|
|
85
|
+
api.css.rule(propertyName, value === null ? `var(${api.contextToCSSVariable(name, value, contexts, api.selectorPrefix)})` : value, isImportant ? { important: true } : void 0);
|
|
86
|
+
if (!contexts.length) api.css.write();
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
exports.dependencies = dependencies;
|
|
91
|
+
exports.name = name;
|
|
92
|
+
exports.onBoot = onBoot;
|
|
93
|
+
exports.onProp = onProp;
|
|
94
|
+
Object.defineProperty(exports, 'server_exports', {
|
|
95
|
+
enumerable: true,
|
|
96
|
+
get: function () {
|
|
97
|
+
return server_exports;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { __exportAll } from "../../_virtual/rolldown_runtime.mjs";
|
|
2
|
+
import getDtsTemplate from "./getDtsTemplate.mjs";
|
|
3
|
+
import { listAll } from "@webref/css";
|
|
4
|
+
|
|
5
|
+
//#region src/prop/css/server.ts
|
|
6
|
+
var server_exports = /* @__PURE__ */ __exportAll({
|
|
7
|
+
dependencies: () => dependencies,
|
|
8
|
+
name: () => name,
|
|
9
|
+
onBoot: () => onBoot,
|
|
10
|
+
onProp: () => onProp
|
|
11
|
+
});
|
|
12
|
+
const name = "css";
|
|
13
|
+
const dependencies = new Set(["css"]);
|
|
14
|
+
const onBoot = async (api) => {
|
|
15
|
+
const [typeObject, typeTemplate] = await getDtsTemplate();
|
|
16
|
+
api.file.js.dts.replace("body", `$$:FinalProps`, (v) => `${v} & StandardProperties`);
|
|
17
|
+
typeTemplate.forEach((entry) => {
|
|
18
|
+
api.file.js.dts.set("body", ...entry);
|
|
19
|
+
});
|
|
20
|
+
for (const [name, descriptor] of Object.entries(typeObject)) {
|
|
21
|
+
const item = {
|
|
22
|
+
property: api.camelCaseToDash(name),
|
|
23
|
+
description: descriptor.description ?? "",
|
|
24
|
+
values: descriptor.types ?? [],
|
|
25
|
+
initial: "",
|
|
26
|
+
csstype: descriptor,
|
|
27
|
+
isCSSProp: true,
|
|
28
|
+
aliases: [name],
|
|
29
|
+
single: false,
|
|
30
|
+
descriptor
|
|
31
|
+
};
|
|
32
|
+
if (descriptor.iface?.endsWith("Hyphen")) item.property = name;
|
|
33
|
+
api.dictionary.set(name, item);
|
|
34
|
+
dependencies.add(name);
|
|
35
|
+
}
|
|
36
|
+
const parsedFiles = await listAll();
|
|
37
|
+
const propertyList = Array.isArray(parsedFiles?.properties) ? parsedFiles.properties : Object.values(parsedFiles ?? {}).flatMap((entry) => entry?.properties ?? []);
|
|
38
|
+
for (const property of propertyList) {
|
|
39
|
+
if (!property?.styleDeclaration) continue;
|
|
40
|
+
const { styleDeclaration } = property;
|
|
41
|
+
const existing = api.dictionary.get(styleDeclaration[0]);
|
|
42
|
+
const existingAliases = existing?.aliases ?? [];
|
|
43
|
+
const existingDescription = existing?.description ?? "";
|
|
44
|
+
const existingUsage = existing?.usage;
|
|
45
|
+
const rawValues = Array.isArray(property.value) ? property.value : property.value ? [property.value] : [];
|
|
46
|
+
const item = {
|
|
47
|
+
description: `${existingDescription ? `${existingDescription}\n` : ""}\n\n**Webref definition**\n\n\`\`\`json\n${JSON.stringify(property, null, 2).replace(/\*\//g, "\\*\\/")}\n\`\`\``,
|
|
48
|
+
usage: existingUsage || property.value,
|
|
49
|
+
descriptor: property,
|
|
50
|
+
property: styleDeclaration[0],
|
|
51
|
+
aliases: [...new Set([...styleDeclaration, ...existingAliases])],
|
|
52
|
+
values: rawValues,
|
|
53
|
+
initial: existing?.initial ?? "",
|
|
54
|
+
isCSSProp: true,
|
|
55
|
+
single: false
|
|
56
|
+
};
|
|
57
|
+
api.dictionary.set(item.property, item);
|
|
58
|
+
item.aliases.forEach((prop) => dependencies.add(prop));
|
|
59
|
+
}
|
|
60
|
+
const missingProps = [];
|
|
61
|
+
for (const key of dependencies) {
|
|
62
|
+
const prop = api.dictionary.get(key);
|
|
63
|
+
if (!prop) continue;
|
|
64
|
+
const templateKey = `css:${key}:description`;
|
|
65
|
+
if (api.file.js.dts.get("body").has(templateKey)) api.file.js.dts.set("body", templateKey, prop.description);
|
|
66
|
+
else missingProps.push([key, prop]);
|
|
67
|
+
}
|
|
68
|
+
api.file.js.dts.set("body", `css:MissingPropsInterfaceStart`, `export interface $$CSSMissingProps {`);
|
|
69
|
+
for (const [key, prop] of missingProps) api.file.js.dts.set("body", `css:${key}:description`, prop.description).set("body", `css:${key}:declaration`, ` "${key}"?: $$PropValues | undefined\n`);
|
|
70
|
+
api.file.js.dts.set("body", `css:MissingPropsInterfaceEnd`, `}`);
|
|
71
|
+
};
|
|
72
|
+
const onProp = async (api, { name, prop, contexts, preferVariables }) => {
|
|
73
|
+
const { value, selectorValue = value, classToken, important } = prop;
|
|
74
|
+
const propertyName = api.dictionary.get(name)?.property ?? api.camelCaseToDash(name);
|
|
75
|
+
if (name === "container" && value && typeof value === "object" && !Array.isArray(value)) return;
|
|
76
|
+
if (!contexts.length) {
|
|
77
|
+
const selector = classToken ? api.classTokenToSelector(classToken) : null;
|
|
78
|
+
api.css.selector({
|
|
79
|
+
className: selector ? null : api.contextToClassName(name, selectorValue, contexts, true, api.selectorPrefix),
|
|
80
|
+
selector
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
const needsImportant = api.strategy === "inline-first" && preferVariables === true && contexts.length > 0;
|
|
84
|
+
const isImportant = Boolean(important || needsImportant);
|
|
85
|
+
api.css.rule(propertyName, value === null ? `var(${api.contextToCSSVariable(name, value, contexts, api.selectorPrefix)})` : value, isImportant ? { important: true } : void 0);
|
|
86
|
+
if (!contexts.length) api.css.write();
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
export { dependencies, name, onBoot, onProp, server_exports };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const require_shared = require('./shared.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/prop/pseudo/runtime-only.ts
|
|
4
|
+
const dependencies = require_shared.pseudoDependencies;
|
|
5
|
+
const name = "pseudo";
|
|
6
|
+
const onInit = (api) => {
|
|
7
|
+
for (const pseudo of dependencies) {
|
|
8
|
+
const prop = {
|
|
9
|
+
property: pseudo,
|
|
10
|
+
aliases: [pseudo],
|
|
11
|
+
description: `Pseudo class: ${pseudo}`,
|
|
12
|
+
values: [],
|
|
13
|
+
initial: "",
|
|
14
|
+
descriptor: {}
|
|
15
|
+
};
|
|
16
|
+
api.dictionary.set(pseudo, prop);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
exports.dependencies = dependencies;
|
|
22
|
+
exports.name = name;
|
|
23
|
+
exports.onInit = onInit;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { pseudoDependencies } from "./shared.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/prop/pseudo/runtime-only.ts
|
|
4
|
+
const dependencies = pseudoDependencies;
|
|
5
|
+
const name = "pseudo";
|
|
6
|
+
const onInit = (api) => {
|
|
7
|
+
for (const pseudo of dependencies) {
|
|
8
|
+
const prop = {
|
|
9
|
+
property: pseudo,
|
|
10
|
+
aliases: [pseudo],
|
|
11
|
+
description: `Pseudo class: ${pseudo}`,
|
|
12
|
+
values: [],
|
|
13
|
+
initial: "",
|
|
14
|
+
descriptor: {}
|
|
15
|
+
};
|
|
16
|
+
api.dictionary.set(pseudo, prop);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { dependencies, name, onInit };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_shared = require('./shared.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/prop/pseudo/server.ts
|
|
5
|
+
var server_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
6
|
+
dependencies: () => dependencies,
|
|
7
|
+
name: () => name,
|
|
8
|
+
onBoot: () => onBoot,
|
|
9
|
+
onProp: () => onProp
|
|
10
|
+
});
|
|
11
|
+
const onBoot = async (api) => {
|
|
12
|
+
api.log.child("prop").child("pseudo").log("onBoot");
|
|
13
|
+
api.file.js.dts.set("body", `pseudo:PseudoPropsInterfaceStart`, `export interface $$PseudoProps {`);
|
|
14
|
+
for (const name of dependencies) {
|
|
15
|
+
const prop = {
|
|
16
|
+
property: name,
|
|
17
|
+
aliases: [name],
|
|
18
|
+
description: `Pseudo class: ${name}`,
|
|
19
|
+
values: [],
|
|
20
|
+
initial: "",
|
|
21
|
+
descriptor: {}
|
|
22
|
+
};
|
|
23
|
+
api.dictionary.set(name, prop);
|
|
24
|
+
api.file.js.dts.set("body", `pseudo:${name}:description`, prop.description).set("body", `pseudo:${name}:declaration`, ` "${name}"?: $$FinalProps\n`);
|
|
25
|
+
}
|
|
26
|
+
api.file.js.dts.set("body", `pseudo:PseudoPropsInterfaceEnd`, `}`).replace("body", `$$:FinalProps`, (v) => `${v} & $$PseudoProps`);
|
|
27
|
+
const runtimeConfig = api.runtime;
|
|
28
|
+
if (Boolean(runtimeConfig && (runtimeConfig.only !== void 0 || runtimeConfig.strategy))) api.file.js.importAndConfig({
|
|
29
|
+
name: "onInit",
|
|
30
|
+
from: "boss-css/prop/pseudo/runtime-only"
|
|
31
|
+
}, () => true);
|
|
32
|
+
};
|
|
33
|
+
const onProp = async (api, { name: _name, prop, contexts, preferVariables, file }) => {
|
|
34
|
+
const _value = prop.value;
|
|
35
|
+
const log = api.log.child("prop").child("pseudo");
|
|
36
|
+
log.log("onProp", _name, _value, contexts);
|
|
37
|
+
contexts.push(_name);
|
|
38
|
+
const contextLength = contexts.length;
|
|
39
|
+
const query = prop.query ?? null;
|
|
40
|
+
const pseudoChain = contexts.filter((name) => dependencies.has(name));
|
|
41
|
+
if (!_value || typeof _value !== "object" || Array.isArray(_value)) {
|
|
42
|
+
contexts.pop();
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
for (const [name, prop$1] of Object.entries(_value)) {
|
|
46
|
+
const resolved = api.dictionary.resolve(name);
|
|
47
|
+
const descriptor = resolved.descriptor;
|
|
48
|
+
if (!descriptor) continue;
|
|
49
|
+
if (resolved.suffix) {
|
|
50
|
+
prop$1.named = resolved.suffix;
|
|
51
|
+
prop$1.rawName = resolved.raw;
|
|
52
|
+
}
|
|
53
|
+
const classToken = prop$1.classToken;
|
|
54
|
+
const selectorValue = api.strategy === "classname-first" || api.strategy === "classname-only" ? prop$1.selectorValue ?? prop$1.value : prop$1.value;
|
|
55
|
+
const className = classToken ? null : api.contextToClassName(resolved.name, selectorValue, contexts, true, api.selectorPrefix);
|
|
56
|
+
const baseSelector = classToken ? api.classTokenToSelector(classToken) : `.${className}`;
|
|
57
|
+
const baseWithPseudos = pseudoChain.length ? `${baseSelector}:${pseudoChain.join(":")}` : baseSelector;
|
|
58
|
+
const selector = api.applyChildSelectors(baseWithPseudos, contexts);
|
|
59
|
+
api.css.selector({
|
|
60
|
+
selector,
|
|
61
|
+
query
|
|
62
|
+
});
|
|
63
|
+
log.log("trigger:onProp", name, prop$1.value, contexts);
|
|
64
|
+
if (query && !prop$1.query) prop$1.query = query;
|
|
65
|
+
await api.trigger("onProp", {
|
|
66
|
+
name: resolved.name,
|
|
67
|
+
prop: prop$1,
|
|
68
|
+
contexts,
|
|
69
|
+
preferVariables,
|
|
70
|
+
file
|
|
71
|
+
}, ({ dependencies }) => {
|
|
72
|
+
return !dependencies || dependencies.has(descriptor.property);
|
|
73
|
+
});
|
|
74
|
+
if (contextLength === contexts.length && api.css.current) api.css.write();
|
|
75
|
+
}
|
|
76
|
+
contexts.pop();
|
|
77
|
+
};
|
|
78
|
+
const dependencies = require_shared.pseudoDependencies;
|
|
79
|
+
const name = "pseudo";
|
|
80
|
+
|
|
81
|
+
//#endregion
|
|
82
|
+
exports.dependencies = dependencies;
|
|
83
|
+
exports.name = name;
|
|
84
|
+
exports.onBoot = onBoot;
|
|
85
|
+
exports.onProp = onProp;
|
|
86
|
+
Object.defineProperty(exports, 'server_exports', {
|
|
87
|
+
enumerable: true,
|
|
88
|
+
get: function () {
|
|
89
|
+
return server_exports;
|
|
90
|
+
}
|
|
91
|
+
});
|