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,159 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_framework = require('../../shared/framework.cjs');
|
|
3
|
+
const require_cx_index = require('../../cx/index.cjs');
|
|
4
|
+
const require_use_token_runtime_only = require('../../use/token/runtime-only.cjs');
|
|
5
|
+
const require_shared = require('../../prop/at/shared.cjs');
|
|
6
|
+
const require_prop_at_runtime_only = require('../../prop/at/runtime-only.cjs');
|
|
7
|
+
const require_prop_child_runtime_only = require('../../prop/child/runtime-only.cjs');
|
|
8
|
+
const require_prop_css_runtime_only = require('../../prop/css/runtime-only.cjs');
|
|
9
|
+
let _emotion_hash = require("@emotion/hash");
|
|
10
|
+
_emotion_hash = require_rolldown_runtime.__toESM(_emotion_hash);
|
|
11
|
+
let _boss_css_is_css_prop = require("@boss-css/is-css-prop");
|
|
12
|
+
_boss_css_is_css_prop = require_rolldown_runtime.__toESM(_boss_css_is_css_prop);
|
|
13
|
+
|
|
14
|
+
//#region src/strategy/inline-first/runtime-only.ts
|
|
15
|
+
const name = "inline-first";
|
|
16
|
+
const resolveRuntimeValue = (value) => {
|
|
17
|
+
if (typeof value !== "function") return value;
|
|
18
|
+
return resolveRuntimeValue(value());
|
|
19
|
+
};
|
|
20
|
+
const buildAutoKeyframesName = (api, contexts) => {
|
|
21
|
+
return `kf-${(0, _emotion_hash.default)(`${api.selectorPrefix ?? ""}|${contexts.join("|")}`)}`;
|
|
22
|
+
};
|
|
23
|
+
const handleKeyframes = (api, { output, tag, contexts, prop, value }) => {
|
|
24
|
+
const info = require_shared.parseKeyframesContext(prop);
|
|
25
|
+
if (!info || !value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
26
|
+
const classNameProp = require_framework.getClassNameProp(api.framework);
|
|
27
|
+
const keyframesContexts = [...contexts, prop];
|
|
28
|
+
const keyframesName = info.name ?? buildAutoKeyframesName(api, keyframesContexts);
|
|
29
|
+
const query = require_prop_at_runtime_only.resolveAtQuery(api, keyframesContexts);
|
|
30
|
+
const frames = /* @__PURE__ */ new Map();
|
|
31
|
+
const selectors = /* @__PURE__ */ new Set();
|
|
32
|
+
output.style ??= {};
|
|
33
|
+
for (const [step, stepValue] of Object.entries(value)) {
|
|
34
|
+
if (!stepValue || typeof stepValue !== "object" || Array.isArray(stepValue)) continue;
|
|
35
|
+
const normalizedStep = require_shared.normalizeKeyframeStep(step);
|
|
36
|
+
if (!normalizedStep) continue;
|
|
37
|
+
const stepContexts = [...keyframesContexts, step];
|
|
38
|
+
for (const [propName, rawValue] of Object.entries(stepValue)) {
|
|
39
|
+
if (!(0, _boss_css_is_css_prop.default)(tag, propName)) continue;
|
|
40
|
+
let resolved = resolveRuntimeValue(rawValue);
|
|
41
|
+
const token = require_use_token_runtime_only.resolveRuntimeToken(api, propName, resolved);
|
|
42
|
+
if (token) resolved = token.value;
|
|
43
|
+
const cssVarName = api.contextToCSSVariable(propName, null, stepContexts, api.selectorPrefix);
|
|
44
|
+
output.style[cssVarName] = api.dictionary.toValue(resolved, propName);
|
|
45
|
+
const className = api.contextToClassName(propName, null, stepContexts, false, api.selectorPrefix);
|
|
46
|
+
const cssClassName = api.contextToClassName(propName, null, stepContexts, true, api.selectorPrefix);
|
|
47
|
+
output[classNameProp] = require_cx_index.cx(output[classNameProp], className);
|
|
48
|
+
const selector = require_prop_css_runtime_only.buildRuntimeSelector(cssClassName, stepContexts);
|
|
49
|
+
selectors.add(selector);
|
|
50
|
+
const propertyName = require_prop_css_runtime_only.resolvePropertyName(propName);
|
|
51
|
+
const valueText = `var(${cssVarName})`;
|
|
52
|
+
if (!frames.has(normalizedStep)) frames.set(normalizedStep, /* @__PURE__ */ new Map());
|
|
53
|
+
frames.get(normalizedStep)?.set(propertyName, valueText);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (!frames.size) return true;
|
|
57
|
+
const css = api.css;
|
|
58
|
+
if (!css) return true;
|
|
59
|
+
css.addRule(require_shared.buildKeyframesRule(keyframesName, frames), query);
|
|
60
|
+
for (const selector of selectors) {
|
|
61
|
+
css.selector({
|
|
62
|
+
selector,
|
|
63
|
+
query
|
|
64
|
+
});
|
|
65
|
+
css.rule("animation-name", keyframesName, { important: true });
|
|
66
|
+
css.write();
|
|
67
|
+
}
|
|
68
|
+
return true;
|
|
69
|
+
};
|
|
70
|
+
const insertRuntimeRule = (api, className, contexts, prop, value) => {
|
|
71
|
+
const selector = require_prop_css_runtime_only.buildRuntimeSelector(className, contexts);
|
|
72
|
+
const query = require_prop_at_runtime_only.resolveAtQuery(api, contexts);
|
|
73
|
+
const property = require_prop_css_runtime_only.resolvePropertyName(prop);
|
|
74
|
+
const css = api.css;
|
|
75
|
+
if (!css) return;
|
|
76
|
+
css.selector({
|
|
77
|
+
selector,
|
|
78
|
+
query
|
|
79
|
+
});
|
|
80
|
+
css.rule(property, value, { important: true });
|
|
81
|
+
css.write();
|
|
82
|
+
};
|
|
83
|
+
const onBrowserObjectStart = (api, { input, output = {}, tag, contexts = [] }) => {
|
|
84
|
+
const classNameProp = require_framework.getClassNameProp(api.framework);
|
|
85
|
+
const outputRecord = output;
|
|
86
|
+
const inputRecord = input;
|
|
87
|
+
outputRecord.style ??= {};
|
|
88
|
+
for (const prop in inputRecord) {
|
|
89
|
+
const rawValue = inputRecord[prop];
|
|
90
|
+
const resolved = api.dictionary.resolve(prop);
|
|
91
|
+
const descriptor = resolved.descriptor;
|
|
92
|
+
const resolvedName = resolved.name;
|
|
93
|
+
if (prop === "child" && rawValue && typeof rawValue === "object" && !Array.isArray(rawValue)) {
|
|
94
|
+
for (const [selector, childValue] of Object.entries(rawValue)) {
|
|
95
|
+
const childContext = require_prop_child_runtime_only.createChildContext(selector);
|
|
96
|
+
contexts.push(childContext);
|
|
97
|
+
api.trigger("onBrowserObjectStart", {
|
|
98
|
+
input: childValue,
|
|
99
|
+
output,
|
|
100
|
+
contexts,
|
|
101
|
+
tag
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (rawValue && typeof rawValue === "object" && !Array.isArray(rawValue)) {
|
|
107
|
+
if (handleKeyframes(api, {
|
|
108
|
+
output: outputRecord,
|
|
109
|
+
tag,
|
|
110
|
+
contexts,
|
|
111
|
+
prop,
|
|
112
|
+
value: rawValue
|
|
113
|
+
})) continue;
|
|
114
|
+
if (descriptor?.handler) {
|
|
115
|
+
descriptor.handler({
|
|
116
|
+
value: rawValue,
|
|
117
|
+
output: outputRecord,
|
|
118
|
+
contexts
|
|
119
|
+
});
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
contexts.push(prop);
|
|
123
|
+
api.trigger("onBrowserObjectStart", {
|
|
124
|
+
input: rawValue,
|
|
125
|
+
output,
|
|
126
|
+
contexts,
|
|
127
|
+
tag
|
|
128
|
+
});
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
let value = resolveRuntimeValue(rawValue);
|
|
132
|
+
const token = require_use_token_runtime_only.resolveRuntimeToken(api, resolvedName, value);
|
|
133
|
+
if (token) value = token.value;
|
|
134
|
+
if (descriptor?.handler) {
|
|
135
|
+
descriptor.handler({
|
|
136
|
+
value,
|
|
137
|
+
output: outputRecord,
|
|
138
|
+
contexts
|
|
139
|
+
});
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
const cssProp = (0, _boss_css_is_css_prop.default)(tag, resolvedName);
|
|
143
|
+
if (!contexts.length && cssProp) {
|
|
144
|
+
outputRecord.style[resolvedName] = api.dictionary.toValue(value, resolvedName);
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
const className = api.contextToClassName(resolvedName, null, contexts, false, api.selectorPrefix);
|
|
148
|
+
const cssClassName = api.contextToClassName(resolvedName, null, contexts, true, api.selectorPrefix);
|
|
149
|
+
const cssVarName = api.contextToCSSVariable(resolvedName, null, contexts, api.selectorPrefix);
|
|
150
|
+
outputRecord.style[cssVarName] = api.dictionary.toValue(value, resolvedName);
|
|
151
|
+
outputRecord[classNameProp] = require_cx_index.cx(outputRecord[classNameProp], className);
|
|
152
|
+
if (cssProp) insertRuntimeRule(api, cssClassName, contexts, resolvedName, `var(${cssVarName})`);
|
|
153
|
+
}
|
|
154
|
+
contexts.pop();
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
//#endregion
|
|
158
|
+
exports.name = name;
|
|
159
|
+
exports.onBrowserObjectStart = onBrowserObjectStart;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { getClassNameProp } from "../../shared/framework.mjs";
|
|
2
|
+
import { cx } from "../../cx/index.mjs";
|
|
3
|
+
import { resolveRuntimeToken } from "../../use/token/runtime-only.mjs";
|
|
4
|
+
import { buildKeyframesRule, normalizeKeyframeStep, parseKeyframesContext } from "../../prop/at/shared.mjs";
|
|
5
|
+
import { resolveAtQuery } from "../../prop/at/runtime-only.mjs";
|
|
6
|
+
import { createChildContext } from "../../prop/child/runtime-only.mjs";
|
|
7
|
+
import { buildRuntimeSelector, resolvePropertyName } from "../../prop/css/runtime-only.mjs";
|
|
8
|
+
import hash from "@emotion/hash";
|
|
9
|
+
import isCSSProp from "@boss-css/is-css-prop";
|
|
10
|
+
|
|
11
|
+
//#region src/strategy/inline-first/runtime-only.ts
|
|
12
|
+
const name = "inline-first";
|
|
13
|
+
const resolveRuntimeValue = (value) => {
|
|
14
|
+
if (typeof value !== "function") return value;
|
|
15
|
+
return resolveRuntimeValue(value());
|
|
16
|
+
};
|
|
17
|
+
const buildAutoKeyframesName = (api, contexts) => {
|
|
18
|
+
return `kf-${hash(`${api.selectorPrefix ?? ""}|${contexts.join("|")}`)}`;
|
|
19
|
+
};
|
|
20
|
+
const handleKeyframes = (api, { output, tag, contexts, prop, value }) => {
|
|
21
|
+
const info = parseKeyframesContext(prop);
|
|
22
|
+
if (!info || !value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
23
|
+
const classNameProp = getClassNameProp(api.framework);
|
|
24
|
+
const keyframesContexts = [...contexts, prop];
|
|
25
|
+
const keyframesName = info.name ?? buildAutoKeyframesName(api, keyframesContexts);
|
|
26
|
+
const query = resolveAtQuery(api, keyframesContexts);
|
|
27
|
+
const frames = /* @__PURE__ */ new Map();
|
|
28
|
+
const selectors = /* @__PURE__ */ new Set();
|
|
29
|
+
output.style ??= {};
|
|
30
|
+
for (const [step, stepValue] of Object.entries(value)) {
|
|
31
|
+
if (!stepValue || typeof stepValue !== "object" || Array.isArray(stepValue)) continue;
|
|
32
|
+
const normalizedStep = normalizeKeyframeStep(step);
|
|
33
|
+
if (!normalizedStep) continue;
|
|
34
|
+
const stepContexts = [...keyframesContexts, step];
|
|
35
|
+
for (const [propName, rawValue] of Object.entries(stepValue)) {
|
|
36
|
+
if (!isCSSProp(tag, propName)) continue;
|
|
37
|
+
let resolved = resolveRuntimeValue(rawValue);
|
|
38
|
+
const token = resolveRuntimeToken(api, propName, resolved);
|
|
39
|
+
if (token) resolved = token.value;
|
|
40
|
+
const cssVarName = api.contextToCSSVariable(propName, null, stepContexts, api.selectorPrefix);
|
|
41
|
+
output.style[cssVarName] = api.dictionary.toValue(resolved, propName);
|
|
42
|
+
const className = api.contextToClassName(propName, null, stepContexts, false, api.selectorPrefix);
|
|
43
|
+
const cssClassName = api.contextToClassName(propName, null, stepContexts, true, api.selectorPrefix);
|
|
44
|
+
output[classNameProp] = cx(output[classNameProp], className);
|
|
45
|
+
const selector = buildRuntimeSelector(cssClassName, stepContexts);
|
|
46
|
+
selectors.add(selector);
|
|
47
|
+
const propertyName = resolvePropertyName(propName);
|
|
48
|
+
const valueText = `var(${cssVarName})`;
|
|
49
|
+
if (!frames.has(normalizedStep)) frames.set(normalizedStep, /* @__PURE__ */ new Map());
|
|
50
|
+
frames.get(normalizedStep)?.set(propertyName, valueText);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (!frames.size) return true;
|
|
54
|
+
const css = api.css;
|
|
55
|
+
if (!css) return true;
|
|
56
|
+
css.addRule(buildKeyframesRule(keyframesName, frames), query);
|
|
57
|
+
for (const selector of selectors) {
|
|
58
|
+
css.selector({
|
|
59
|
+
selector,
|
|
60
|
+
query
|
|
61
|
+
});
|
|
62
|
+
css.rule("animation-name", keyframesName, { important: true });
|
|
63
|
+
css.write();
|
|
64
|
+
}
|
|
65
|
+
return true;
|
|
66
|
+
};
|
|
67
|
+
const insertRuntimeRule = (api, className, contexts, prop, value) => {
|
|
68
|
+
const selector = buildRuntimeSelector(className, contexts);
|
|
69
|
+
const query = resolveAtQuery(api, contexts);
|
|
70
|
+
const property = resolvePropertyName(prop);
|
|
71
|
+
const css = api.css;
|
|
72
|
+
if (!css) return;
|
|
73
|
+
css.selector({
|
|
74
|
+
selector,
|
|
75
|
+
query
|
|
76
|
+
});
|
|
77
|
+
css.rule(property, value, { important: true });
|
|
78
|
+
css.write();
|
|
79
|
+
};
|
|
80
|
+
const onBrowserObjectStart = (api, { input, output = {}, tag, contexts = [] }) => {
|
|
81
|
+
const classNameProp = getClassNameProp(api.framework);
|
|
82
|
+
const outputRecord = output;
|
|
83
|
+
const inputRecord = input;
|
|
84
|
+
outputRecord.style ??= {};
|
|
85
|
+
for (const prop in inputRecord) {
|
|
86
|
+
const rawValue = inputRecord[prop];
|
|
87
|
+
const resolved = api.dictionary.resolve(prop);
|
|
88
|
+
const descriptor = resolved.descriptor;
|
|
89
|
+
const resolvedName = resolved.name;
|
|
90
|
+
if (prop === "child" && rawValue && typeof rawValue === "object" && !Array.isArray(rawValue)) {
|
|
91
|
+
for (const [selector, childValue] of Object.entries(rawValue)) {
|
|
92
|
+
const childContext = createChildContext(selector);
|
|
93
|
+
contexts.push(childContext);
|
|
94
|
+
api.trigger("onBrowserObjectStart", {
|
|
95
|
+
input: childValue,
|
|
96
|
+
output,
|
|
97
|
+
contexts,
|
|
98
|
+
tag
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (rawValue && typeof rawValue === "object" && !Array.isArray(rawValue)) {
|
|
104
|
+
if (handleKeyframes(api, {
|
|
105
|
+
output: outputRecord,
|
|
106
|
+
tag,
|
|
107
|
+
contexts,
|
|
108
|
+
prop,
|
|
109
|
+
value: rawValue
|
|
110
|
+
})) continue;
|
|
111
|
+
if (descriptor?.handler) {
|
|
112
|
+
descriptor.handler({
|
|
113
|
+
value: rawValue,
|
|
114
|
+
output: outputRecord,
|
|
115
|
+
contexts
|
|
116
|
+
});
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
contexts.push(prop);
|
|
120
|
+
api.trigger("onBrowserObjectStart", {
|
|
121
|
+
input: rawValue,
|
|
122
|
+
output,
|
|
123
|
+
contexts,
|
|
124
|
+
tag
|
|
125
|
+
});
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
let value = resolveRuntimeValue(rawValue);
|
|
129
|
+
const token = resolveRuntimeToken(api, resolvedName, value);
|
|
130
|
+
if (token) value = token.value;
|
|
131
|
+
if (descriptor?.handler) {
|
|
132
|
+
descriptor.handler({
|
|
133
|
+
value,
|
|
134
|
+
output: outputRecord,
|
|
135
|
+
contexts
|
|
136
|
+
});
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
const cssProp = isCSSProp(tag, resolvedName);
|
|
140
|
+
if (!contexts.length && cssProp) {
|
|
141
|
+
outputRecord.style[resolvedName] = api.dictionary.toValue(value, resolvedName);
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
const className = api.contextToClassName(resolvedName, null, contexts, false, api.selectorPrefix);
|
|
145
|
+
const cssClassName = api.contextToClassName(resolvedName, null, contexts, true, api.selectorPrefix);
|
|
146
|
+
const cssVarName = api.contextToCSSVariable(resolvedName, null, contexts, api.selectorPrefix);
|
|
147
|
+
outputRecord.style[cssVarName] = api.dictionary.toValue(value, resolvedName);
|
|
148
|
+
outputRecord[classNameProp] = cx(outputRecord[classNameProp], className);
|
|
149
|
+
if (cssProp) insertRuntimeRule(api, cssClassName, contexts, resolvedName, `var(${cssVarName})`);
|
|
150
|
+
}
|
|
151
|
+
contexts.pop();
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
//#endregion
|
|
155
|
+
export { name, onBrowserObjectStart };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/strategy/inline-first/server.ts
|
|
4
|
+
var server_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
5
|
+
name: () => name,
|
|
6
|
+
onBoot: () => onBoot,
|
|
7
|
+
onPropTree: () => onPropTree,
|
|
8
|
+
settings: () => settings
|
|
9
|
+
});
|
|
10
|
+
const settings = new Map([["emitRuntime", false]]);
|
|
11
|
+
let needsRuntime = false;
|
|
12
|
+
const resolveDescriptor = (api, name) => {
|
|
13
|
+
return api.dictionary.resolve(name);
|
|
14
|
+
};
|
|
15
|
+
const onBoot = async (api) => {
|
|
16
|
+
const runtimeConfig = api.runtime;
|
|
17
|
+
const hasRuntimeConfig = Boolean(runtimeConfig && (runtimeConfig.only !== void 0 || runtimeConfig.strategy));
|
|
18
|
+
const runtimeStrategy = runtimeConfig?.strategy ?? name;
|
|
19
|
+
const runtimeModule = hasRuntimeConfig ? "boss-css/strategy/runtime/runtime-only" : "boss-css/strategy/inline-first/browser";
|
|
20
|
+
const shouldEmitRuntime = () => Boolean(needsRuntime || settings.get("emitRuntime") === true);
|
|
21
|
+
const runtimePlugin = { onBrowserObjectStart: api.file.js.import({
|
|
22
|
+
name: "onBrowserObjectStart",
|
|
23
|
+
from: runtimeModule
|
|
24
|
+
}, shouldEmitRuntime) };
|
|
25
|
+
if (hasRuntimeConfig) runtimePlugin.onInit = api.file.js.import({
|
|
26
|
+
name: "onInit",
|
|
27
|
+
from: runtimeModule
|
|
28
|
+
}, shouldEmitRuntime);
|
|
29
|
+
api.file.js.config({
|
|
30
|
+
from: runtimeModule,
|
|
31
|
+
config: { plugin: runtimePlugin }
|
|
32
|
+
}, shouldEmitRuntime);
|
|
33
|
+
api.file.js.config({
|
|
34
|
+
from: "boss-css/strategy/inline-first",
|
|
35
|
+
config: {
|
|
36
|
+
selectorPrefix: api.selectorPrefix,
|
|
37
|
+
selectorScope: api.selectorScope,
|
|
38
|
+
strategy: runtimeStrategy,
|
|
39
|
+
...hasRuntimeConfig ? { runtime: runtimeConfig } : {}
|
|
40
|
+
}
|
|
41
|
+
}, shouldEmitRuntime);
|
|
42
|
+
api.strategy = name;
|
|
43
|
+
};
|
|
44
|
+
const onPropTree = async (api, { input, tree, preferVariables, parser, file }) => {
|
|
45
|
+
if (api.runtime?.only === true) return;
|
|
46
|
+
tree = api.mapPropTree(tree, (name, prop, depth) => {
|
|
47
|
+
let result = prop;
|
|
48
|
+
const isCSSProp = api.dictionary.resolve(name).descriptor?.isCSSProp;
|
|
49
|
+
if (preferVariables && isCSSProp) {
|
|
50
|
+
needsRuntime ||= parser === "jsx";
|
|
51
|
+
result = {
|
|
52
|
+
...prop,
|
|
53
|
+
value: null
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
});
|
|
58
|
+
for (const [name, prop] of Object.entries(tree)) {
|
|
59
|
+
const resolved = resolveDescriptor(api, name);
|
|
60
|
+
if (!resolved.descriptor) continue;
|
|
61
|
+
if (resolved.suffix) {
|
|
62
|
+
prop.named = resolved.suffix;
|
|
63
|
+
prop.rawName = resolved.raw;
|
|
64
|
+
}
|
|
65
|
+
const { aliases, isCSSProp, property } = resolved.descriptor;
|
|
66
|
+
const resolvedName = resolved.name;
|
|
67
|
+
const isContainerQueryProp = resolvedName === "container" && prop?.value && typeof prop.value === "object" && !Array.isArray(prop.value);
|
|
68
|
+
if (preferVariables && isCSSProp && property === api.camelCaseToDash(resolvedName) && !isContainerQueryProp) continue;
|
|
69
|
+
await api.trigger("onProp", {
|
|
70
|
+
name: resolvedName,
|
|
71
|
+
prop,
|
|
72
|
+
contexts: [],
|
|
73
|
+
preferVariables,
|
|
74
|
+
file
|
|
75
|
+
}, ({ dependencies }) => {
|
|
76
|
+
return !dependencies || aliases.some((alias) => dependencies.has(alias));
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const name = "inline-first";
|
|
81
|
+
|
|
82
|
+
//#endregion
|
|
83
|
+
exports.name = name;
|
|
84
|
+
exports.onBoot = onBoot;
|
|
85
|
+
exports.onPropTree = onPropTree;
|
|
86
|
+
Object.defineProperty(exports, 'server_exports', {
|
|
87
|
+
enumerable: true,
|
|
88
|
+
get: function () {
|
|
89
|
+
return server_exports;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
exports.settings = settings;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { __exportAll } from "../../_virtual/rolldown_runtime.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/strategy/inline-first/server.ts
|
|
4
|
+
var server_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
name: () => name,
|
|
6
|
+
onBoot: () => onBoot,
|
|
7
|
+
onPropTree: () => onPropTree,
|
|
8
|
+
settings: () => settings
|
|
9
|
+
});
|
|
10
|
+
const settings = new Map([["emitRuntime", false]]);
|
|
11
|
+
let needsRuntime = false;
|
|
12
|
+
const resolveDescriptor = (api, name) => {
|
|
13
|
+
return api.dictionary.resolve(name);
|
|
14
|
+
};
|
|
15
|
+
const onBoot = async (api) => {
|
|
16
|
+
const runtimeConfig = api.runtime;
|
|
17
|
+
const hasRuntimeConfig = Boolean(runtimeConfig && (runtimeConfig.only !== void 0 || runtimeConfig.strategy));
|
|
18
|
+
const runtimeStrategy = runtimeConfig?.strategy ?? name;
|
|
19
|
+
const runtimeModule = hasRuntimeConfig ? "boss-css/strategy/runtime/runtime-only" : "boss-css/strategy/inline-first/browser";
|
|
20
|
+
const shouldEmitRuntime = () => Boolean(needsRuntime || settings.get("emitRuntime") === true);
|
|
21
|
+
const runtimePlugin = { onBrowserObjectStart: api.file.js.import({
|
|
22
|
+
name: "onBrowserObjectStart",
|
|
23
|
+
from: runtimeModule
|
|
24
|
+
}, shouldEmitRuntime) };
|
|
25
|
+
if (hasRuntimeConfig) runtimePlugin.onInit = api.file.js.import({
|
|
26
|
+
name: "onInit",
|
|
27
|
+
from: runtimeModule
|
|
28
|
+
}, shouldEmitRuntime);
|
|
29
|
+
api.file.js.config({
|
|
30
|
+
from: runtimeModule,
|
|
31
|
+
config: { plugin: runtimePlugin }
|
|
32
|
+
}, shouldEmitRuntime);
|
|
33
|
+
api.file.js.config({
|
|
34
|
+
from: "boss-css/strategy/inline-first",
|
|
35
|
+
config: {
|
|
36
|
+
selectorPrefix: api.selectorPrefix,
|
|
37
|
+
selectorScope: api.selectorScope,
|
|
38
|
+
strategy: runtimeStrategy,
|
|
39
|
+
...hasRuntimeConfig ? { runtime: runtimeConfig } : {}
|
|
40
|
+
}
|
|
41
|
+
}, shouldEmitRuntime);
|
|
42
|
+
api.strategy = name;
|
|
43
|
+
};
|
|
44
|
+
const onPropTree = async (api, { input, tree, preferVariables, parser, file }) => {
|
|
45
|
+
if (api.runtime?.only === true) return;
|
|
46
|
+
tree = api.mapPropTree(tree, (name, prop, depth) => {
|
|
47
|
+
let result = prop;
|
|
48
|
+
const isCSSProp = api.dictionary.resolve(name).descriptor?.isCSSProp;
|
|
49
|
+
if (preferVariables && isCSSProp) {
|
|
50
|
+
needsRuntime ||= parser === "jsx";
|
|
51
|
+
result = {
|
|
52
|
+
...prop,
|
|
53
|
+
value: null
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
});
|
|
58
|
+
for (const [name, prop] of Object.entries(tree)) {
|
|
59
|
+
const resolved = resolveDescriptor(api, name);
|
|
60
|
+
if (!resolved.descriptor) continue;
|
|
61
|
+
if (resolved.suffix) {
|
|
62
|
+
prop.named = resolved.suffix;
|
|
63
|
+
prop.rawName = resolved.raw;
|
|
64
|
+
}
|
|
65
|
+
const { aliases, isCSSProp, property } = resolved.descriptor;
|
|
66
|
+
const resolvedName = resolved.name;
|
|
67
|
+
const isContainerQueryProp = resolvedName === "container" && prop?.value && typeof prop.value === "object" && !Array.isArray(prop.value);
|
|
68
|
+
if (preferVariables && isCSSProp && property === api.camelCaseToDash(resolvedName) && !isContainerQueryProp) continue;
|
|
69
|
+
await api.trigger("onProp", {
|
|
70
|
+
name: resolvedName,
|
|
71
|
+
prop,
|
|
72
|
+
contexts: [],
|
|
73
|
+
preferVariables,
|
|
74
|
+
file
|
|
75
|
+
}, ({ dependencies }) => {
|
|
76
|
+
return !dependencies || aliases.some((alias) => dependencies.has(alias));
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const name = "inline-first";
|
|
81
|
+
|
|
82
|
+
//#endregion
|
|
83
|
+
export { name, onBoot, onPropTree, server_exports, settings };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const require_strategy_inline_first_runtime_only = require('../inline-first/runtime-only.cjs');
|
|
2
|
+
const require_strategy_runtime_only_css = require('../runtime-only/css.cjs');
|
|
3
|
+
const require_strategy_classname_first_runtime_only = require('../classname-first/runtime-only.cjs');
|
|
4
|
+
const require_strategy_classic_runtime_only = require('../classic/runtime-only.cjs');
|
|
5
|
+
|
|
6
|
+
//#region src/strategy/runtime/runtime-only.ts
|
|
7
|
+
const name = "runtime";
|
|
8
|
+
const onInit = require_strategy_runtime_only_css.onInit;
|
|
9
|
+
const getRuntimeHandler = (api) => {
|
|
10
|
+
switch (api.strategy) {
|
|
11
|
+
case "classname-first": return require_strategy_classname_first_runtime_only.onBrowserObjectStart;
|
|
12
|
+
case "classic": return require_strategy_classic_runtime_only.onBrowserObjectStart;
|
|
13
|
+
case "inline-first":
|
|
14
|
+
default: return require_strategy_inline_first_runtime_only.onBrowserObjectStart;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const onBrowserObjectStart = (api, payload) => {
|
|
18
|
+
return getRuntimeHandler(api)(api, payload);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.name = name;
|
|
23
|
+
exports.onBrowserObjectStart = onBrowserObjectStart;
|
|
24
|
+
exports.onInit = onInit;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { onBrowserObjectStart as onBrowserObjectStart$1 } from "../inline-first/runtime-only.mjs";
|
|
2
|
+
import { onInit as onInit$1 } from "../runtime-only/css.mjs";
|
|
3
|
+
import { onBrowserObjectStart as onBrowserObjectStart$2 } from "../classname-first/runtime-only.mjs";
|
|
4
|
+
import { onBrowserObjectStart as onBrowserObjectStart$3 } from "../classic/runtime-only.mjs";
|
|
5
|
+
|
|
6
|
+
//#region src/strategy/runtime/runtime-only.ts
|
|
7
|
+
const name = "runtime";
|
|
8
|
+
const onInit = onInit$1;
|
|
9
|
+
const getRuntimeHandler = (api) => {
|
|
10
|
+
switch (api.strategy) {
|
|
11
|
+
case "classname-first": return onBrowserObjectStart$2;
|
|
12
|
+
case "classic": return onBrowserObjectStart$3;
|
|
13
|
+
case "inline-first":
|
|
14
|
+
default: return onBrowserObjectStart$1;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const onBrowserObjectStart = (api, payload) => {
|
|
18
|
+
return getRuntimeHandler(api)(api, payload);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { name, onBrowserObjectStart, onInit };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_strategy_inline_first_server = require('../inline-first/server.cjs');
|
|
3
|
+
const require_server = require('../classname-first/server.cjs');
|
|
4
|
+
|
|
5
|
+
//#region src/strategy/runtime/server.ts
|
|
6
|
+
var server_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
7
|
+
name: () => name,
|
|
8
|
+
onBoot: () => onBoot,
|
|
9
|
+
onPropTree: () => onPropTree,
|
|
10
|
+
settings: () => settings
|
|
11
|
+
});
|
|
12
|
+
const name = "runtime";
|
|
13
|
+
const settings = new Map([["emitRuntime", false], ["emitAllTokens", false]]);
|
|
14
|
+
let needsRuntime = false;
|
|
15
|
+
const resolveRuntimeStrategy = (api) => api.runtime?.strategy ?? "inline-first";
|
|
16
|
+
const resolveServerStrategy = (strategy) => {
|
|
17
|
+
if (strategy === "classname-first") return require_server.server_exports;
|
|
18
|
+
return require_strategy_inline_first_server.server_exports;
|
|
19
|
+
};
|
|
20
|
+
const onBoot = async (api) => {
|
|
21
|
+
const runtimeStrategy = resolveRuntimeStrategy(api);
|
|
22
|
+
const runtimeConfig = api.runtime ?? {};
|
|
23
|
+
const shouldEmitRuntime = () => needsRuntime || settings.get("emitRuntime") === true;
|
|
24
|
+
const runtimeModule = "boss-css/strategy/runtime/runtime-only";
|
|
25
|
+
const onBrowserObjectStartVar = api.file.js.import({
|
|
26
|
+
name: "onBrowserObjectStart",
|
|
27
|
+
from: runtimeModule
|
|
28
|
+
}, shouldEmitRuntime);
|
|
29
|
+
const onInitVar = api.file.js.import({
|
|
30
|
+
name: "onInit",
|
|
31
|
+
from: runtimeModule
|
|
32
|
+
}, shouldEmitRuntime);
|
|
33
|
+
api.file.js.config({
|
|
34
|
+
from: runtimeModule,
|
|
35
|
+
config: { plugin: {
|
|
36
|
+
onInit: onInitVar,
|
|
37
|
+
onBrowserObjectStart: onBrowserObjectStartVar
|
|
38
|
+
} }
|
|
39
|
+
}, shouldEmitRuntime);
|
|
40
|
+
api.file.js.config({
|
|
41
|
+
from: "boss-css/strategy/runtime",
|
|
42
|
+
config: {
|
|
43
|
+
selectorPrefix: api.selectorPrefix,
|
|
44
|
+
selectorScope: api.selectorScope,
|
|
45
|
+
strategy: runtimeStrategy,
|
|
46
|
+
runtime: runtimeConfig
|
|
47
|
+
}
|
|
48
|
+
}, shouldEmitRuntime);
|
|
49
|
+
api.strategy = runtimeStrategy;
|
|
50
|
+
if (runtimeStrategy === "classname-first") {
|
|
51
|
+
if (settings.get("emitAllTokens") === true || process.env.NODE_ENV !== "production") api.emitAllTokens = true;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const onPropTree = async (api, data) => {
|
|
55
|
+
needsRuntime ||= data?.parser === "jsx";
|
|
56
|
+
if (api.runtime?.only === true) return;
|
|
57
|
+
const serverStrategy = resolveServerStrategy(resolveRuntimeStrategy(api));
|
|
58
|
+
if (!serverStrategy.onPropTree) return;
|
|
59
|
+
await serverStrategy.onPropTree(api, data);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
//#endregion
|
|
63
|
+
exports.name = name;
|
|
64
|
+
exports.onBoot = onBoot;
|
|
65
|
+
exports.onPropTree = onPropTree;
|
|
66
|
+
Object.defineProperty(exports, 'server_exports', {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function () {
|
|
69
|
+
return server_exports;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
exports.settings = settings;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { __exportAll } from "../../_virtual/rolldown_runtime.mjs";
|
|
2
|
+
import { server_exports as server_exports$1 } from "../inline-first/server.mjs";
|
|
3
|
+
import { server_exports as server_exports$2 } from "../classname-first/server.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/strategy/runtime/server.ts
|
|
6
|
+
var server_exports = /* @__PURE__ */ __exportAll({
|
|
7
|
+
name: () => name,
|
|
8
|
+
onBoot: () => onBoot,
|
|
9
|
+
onPropTree: () => onPropTree,
|
|
10
|
+
settings: () => settings
|
|
11
|
+
});
|
|
12
|
+
const name = "runtime";
|
|
13
|
+
const settings = new Map([["emitRuntime", false], ["emitAllTokens", false]]);
|
|
14
|
+
let needsRuntime = false;
|
|
15
|
+
const resolveRuntimeStrategy = (api) => api.runtime?.strategy ?? "inline-first";
|
|
16
|
+
const resolveServerStrategy = (strategy) => {
|
|
17
|
+
if (strategy === "classname-first") return server_exports$2;
|
|
18
|
+
return server_exports$1;
|
|
19
|
+
};
|
|
20
|
+
const onBoot = async (api) => {
|
|
21
|
+
const runtimeStrategy = resolveRuntimeStrategy(api);
|
|
22
|
+
const runtimeConfig = api.runtime ?? {};
|
|
23
|
+
const shouldEmitRuntime = () => needsRuntime || settings.get("emitRuntime") === true;
|
|
24
|
+
const runtimeModule = "boss-css/strategy/runtime/runtime-only";
|
|
25
|
+
const onBrowserObjectStartVar = api.file.js.import({
|
|
26
|
+
name: "onBrowserObjectStart",
|
|
27
|
+
from: runtimeModule
|
|
28
|
+
}, shouldEmitRuntime);
|
|
29
|
+
const onInitVar = api.file.js.import({
|
|
30
|
+
name: "onInit",
|
|
31
|
+
from: runtimeModule
|
|
32
|
+
}, shouldEmitRuntime);
|
|
33
|
+
api.file.js.config({
|
|
34
|
+
from: runtimeModule,
|
|
35
|
+
config: { plugin: {
|
|
36
|
+
onInit: onInitVar,
|
|
37
|
+
onBrowserObjectStart: onBrowserObjectStartVar
|
|
38
|
+
} }
|
|
39
|
+
}, shouldEmitRuntime);
|
|
40
|
+
api.file.js.config({
|
|
41
|
+
from: "boss-css/strategy/runtime",
|
|
42
|
+
config: {
|
|
43
|
+
selectorPrefix: api.selectorPrefix,
|
|
44
|
+
selectorScope: api.selectorScope,
|
|
45
|
+
strategy: runtimeStrategy,
|
|
46
|
+
runtime: runtimeConfig
|
|
47
|
+
}
|
|
48
|
+
}, shouldEmitRuntime);
|
|
49
|
+
api.strategy = runtimeStrategy;
|
|
50
|
+
if (runtimeStrategy === "classname-first") {
|
|
51
|
+
if (settings.get("emitAllTokens") === true || process.env.NODE_ENV !== "production") api.emitAllTokens = true;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const onPropTree = async (api, data) => {
|
|
55
|
+
needsRuntime ||= data?.parser === "jsx";
|
|
56
|
+
if (api.runtime?.only === true) return;
|
|
57
|
+
const serverStrategy = resolveServerStrategy(resolveRuntimeStrategy(api));
|
|
58
|
+
if (!serverStrategy.onPropTree) return;
|
|
59
|
+
await serverStrategy.onPropTree(api, data);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
//#endregion
|
|
63
|
+
export { name, onBoot, onPropTree, server_exports, settings };
|