@fluentic/style 0.1.0-beta.14 → 0.1.0-beta.16
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/CHANGELOG.md +18 -0
- package/atomic/className.ts +4 -0
- package/atomic/rule.ts +15 -7
- package/atomic/utils/selector.ts +12 -3
- package/builder/classname/class_name_builder.ts +1 -1
- package/builder/data/const.ts +2 -0
- package/builder/data/data.ts +1 -1
- package/builder/data/merge/scope.ts +7 -0
- package/builder/data/merge/style.ts +12 -3
- package/builder/data/state.ts +1 -0
- package/builder/selector_override.ts +1 -1
- package/builder/selector_override_core.ts +17 -3
- package/builder/types/alias.ts +1 -1
- package/compiler/extract/extract.ts +21 -75
- package/compiler/extract/types.ts +4 -1
- package/compiler/transform/debug/plugin.ts +22 -0
- package/compiler/transform/evaluator/evaluator.ts +4 -1
- package/compiler/transform/extract/chain/chain.ts +82 -22
- package/compiler/transform/extract/chain/extract_chain.ts +2 -0
- package/compiler/transform/extract/plugin.ts +51 -25
- package/compiler/transform/extract/utils/imports.ts +4 -1
- package/compiler/transform/extract/utils/replacement.ts +2 -2
- package/compiler/transform/utils/babel.ts +1 -1
- package/compiler/utils/constants.ts +1 -0
- package/config/config/css.ts +5 -3
- package/config/configure.ts +4 -0
- package/config/document.ts +23 -0
- package/css/globalSheet.ts +66 -0
- package/css/index.ts +4 -1
- package/css/sheet.ts +34 -14
- package/dist/{className-yhJCGT0F.js → className-CC5PHcXI.js} +9 -2
- package/dist/className-CC5PHcXI.js.map +1 -0
- package/dist/{combine-CC9bY-hu.js → combine-BpOQWCtM.js} +5 -5
- package/dist/combine-BpOQWCtM.js.map +1 -0
- package/dist/compiler/index.mjs +1 -1
- package/dist/{compiler-Ct5xGIeu.mjs → compiler-AOb_VaKQ.mjs} +464 -166
- package/dist/compiler-AOb_VaKQ.mjs.map +1 -0
- package/dist/config/index.js +2 -2
- package/dist/{config-CCgsVvyR.js → config-B70LIQhi.js} +2 -2
- package/dist/{config-CCgsVvyR.js.map → config-B70LIQhi.js.map} +1 -1
- package/dist/{config-BiiMS4rU.js → config-BK7oK4Hx.js} +25 -4
- package/dist/config-BK7oK4Hx.js.map +1 -0
- package/dist/{config-DZKR6gH1.js → config-DFxeuT46.js} +4 -4
- package/dist/{config-DZKR6gH1.js.map → config-DFxeuT46.js.map} +1 -1
- package/dist/{css-IecKRNxs.js → css-BkNqUfLD.js} +112 -73
- package/dist/css-BkNqUfLD.js.map +1 -0
- package/dist/{css-WaHZ6gxv.js → css-C7tcD3IO.js} +611 -213
- package/dist/css-C7tcD3IO.js.map +1 -0
- package/dist/css-Cdxkur4h.js +414 -0
- package/dist/css-Cdxkur4h.js.map +1 -0
- package/dist/css.js +2 -2
- package/dist/css_extra-BC1Z_hDy.js +8 -0
- package/dist/{css_extra-DDeJc2Cu.js.map → css_extra-BC1Z_hDy.js.map} +1 -1
- package/dist/{css_extra-DDeJc2Cu.js → css_extra-qzi_eFFf.js} +2 -2
- package/dist/css_extra-qzi_eFFf.js.map +1 -0
- package/dist/{data-BgZmL55Y.js → data-MrBhvIQZ.js} +28 -19
- package/dist/data-MrBhvIQZ.js.map +1 -0
- package/dist/{debug-D-1hhd0G.js → debug-Bo43rBKc.js} +6 -9
- package/dist/debug-Bo43rBKc.js.map +1 -0
- package/dist/dev/rsc.js +134 -25
- package/dist/dev/rsc.js.map +1 -1
- package/dist/{dev-CBRbVaeq.js → dev-BoEgFs_x.js} +6 -6
- package/dist/{dev-CBRbVaeq.js.map → dev-BoEgFs_x.js.map} +1 -1
- package/dist/dev.js +1 -1
- package/dist/dialect/extracted/index.js +1 -1
- package/dist/dialect/index.js +1 -1
- package/dist/{elementMarker-CJcfpKL1.js → elementMarker-nYeJnJPQ.js} +334 -53
- package/dist/elementMarker-nYeJnJPQ.js.map +1 -0
- package/dist/entry/dev/adapter/preact.js +1 -1
- package/dist/entry/dev/adapter/react.js +1 -1
- package/dist/entry/dev/adapter/solid.js +1 -1
- package/dist/entry/dev/css.js +3 -3
- package/dist/entry/dev/jsx-dev-runtime.js +2 -2
- package/dist/entry/dev/jsx-runtime.js +2 -2
- package/dist/entry/dev.js +11 -11
- package/dist/entry/prod/adapter/preact.js +1 -1
- package/dist/entry/prod/adapter/react.js +1 -1
- package/dist/entry/prod/adapter/solid.js +1 -1
- package/dist/entry/prod/css.js +3 -3
- package/dist/entry/prod/extract.js.map +1 -1
- package/dist/entry/prod.js +3 -3
- package/dist/entry/rsc-dev/adapter/preact.js +1 -1
- package/dist/entry/rsc-dev/adapter/react.js +1 -1
- package/dist/entry/rsc-dev/adapter/solid.js +1 -1
- package/dist/entry/rsc-dev/css.js +4 -3
- package/dist/entry/rsc-dev/dev.js +129 -24
- package/dist/entry/rsc-dev/dev.js.map +1 -1
- package/dist/entry/rsc-dev/jsx-dev-runtime.js +5 -4
- package/dist/entry/rsc-dev/jsx-dev-runtime.js.map +1 -1
- package/dist/entry/rsc-dev/jsx-runtime.js +2 -2
- package/dist/entry/rsc-dev.js +8 -7
- package/dist/entry/rsc-dev.js.map +1 -1
- package/dist/entry/rsc-prod/css.js +4 -4
- package/dist/entry/rsc-prod.js +4 -4
- package/dist/{rules-Dz-szpPu.js → env-BcNl1tsJ.js} +59 -21
- package/dist/env-BcNl1tsJ.js.map +1 -0
- package/dist/{getClassName-DtkplEIt.js → getClassName-5yYUibKw.js} +2 -2
- package/dist/{getClassName-DtkplEIt.js.map → getClassName-5yYUibKw.js.map} +1 -1
- package/dist/getClassName-9CsXbNls.js.map +1 -1
- package/dist/{getClassName-CeoxISNW.js → getClassName-B3azD1TO.js} +6 -4
- package/dist/getClassName-B3azD1TO.js.map +1 -0
- package/dist/{getClassName-BNe3Ycyy.js → getClassName-CkTq92nR.js} +4 -4
- package/dist/{getClassName-BNe3Ycyy.js.map → getClassName-CkTq92nR.js.map} +1 -1
- package/dist/{global-UOHFwqHN.js → global-DGcWZODV.js} +4 -7
- package/dist/{global-UOHFwqHN.js.map → global-DGcWZODV.js.map} +1 -1
- package/dist/{css-BhoclXaw.js → globalSheet-CdgVpvCb.js} +185 -426
- package/dist/globalSheet-CdgVpvCb.js.map +1 -0
- package/dist/{hash-DlXmmPPm.js → hash-CjTP-uES.js} +4 -4
- package/dist/hash-CjTP-uES.js.map +1 -0
- package/dist/index.js +9 -9
- package/dist/jsx/jsx-dev-runtime.js +1 -1
- package/dist/jsx/jsx-dev-runtime.server.js +3 -3
- package/dist/jsx/jsx-dev-runtime.server.js.map +1 -1
- package/dist/jsx/jsx-runtime.js +1 -1
- package/dist/jsx/jsx-runtime.server.js +4 -4
- package/dist/jsx/jsx-runtime.server.js.map +1 -1
- package/dist/{jsx-8TwYuvgM.js → jsx-DA1LD8nU.js} +4 -4
- package/dist/{jsx-8TwYuvgM.js.map → jsx-DA1LD8nU.js.map} +1 -1
- package/dist/jsx_runtime-pt7DOZOE.js +13 -0
- package/dist/jsx_runtime-pt7DOZOE.js.map +1 -0
- package/dist/{loader-BVebGteg.mjs → loader-fAuIjIik.mjs} +3 -3
- package/dist/{loader-BVebGteg.mjs.map → loader-fAuIjIik.mjs.map} +1 -1
- package/dist/{misc-Bs2DgdG7.mjs → misc-CyZgGtc9.mjs} +3 -3
- package/dist/{misc-Bs2DgdG7.mjs.map → misc-CyZgGtc9.mjs.map} +1 -1
- package/dist/{namedTokens-CwniouKk.js → namedTokens-paLD-Pdk.js} +2 -2
- package/dist/{namedTokens-CwniouKk.js.map → namedTokens-paLD-Pdk.js.map} +1 -1
- package/dist/plugin/farm/index.mjs +3 -3
- package/dist/plugin/nextjs/index.mjs +4 -4
- package/dist/plugin/nextjs/loader.mjs +7 -5
- package/dist/plugin/nextjs/loader.mjs.map +1 -1
- package/dist/plugin/parcel/index.cjs +1 -1
- package/dist/plugin/parcel/index.mjs +2 -2
- package/dist/plugin/parcel/optimizer.cjs +1 -1
- package/dist/plugin/parcel/optimizer.mjs +2 -2
- package/dist/plugin/parcel/resolver.cjs +1 -1
- package/dist/plugin/parcel/resolver.mjs +2 -2
- package/dist/plugin/parcel/runtime.cjs +1 -1
- package/dist/plugin/parcel/runtime.mjs +1 -1
- package/dist/plugin/parcel/transformer.cjs +1 -1
- package/dist/plugin/parcel/transformer.mjs +2 -2
- package/dist/plugin/rspack/index.mjs +2 -2
- package/dist/plugin/vite/index.mjs +3 -3
- package/dist/plugin/webpack/index.mjs +2 -2
- package/dist/plugin/webpack/loader.mjs +2 -2
- package/dist/presets/tailwind/index.js +3 -3
- package/dist/{registry-D1n78rd7.mjs → registry-BMijh1CM.mjs} +2 -2
- package/dist/{registry-D1n78rd7.mjs.map → registry-BMijh1CM.mjs.map} +1 -1
- package/dist/{resolveClassNameRuntime-BJcykzdl.js → resolveClassNameRuntime-B6vKNL5y.js} +2 -2
- package/dist/{resolveClassNameRuntime-BJcykzdl.js.map → resolveClassNameRuntime-B6vKNL5y.js.map} +1 -1
- package/dist/server.js +87 -17
- package/dist/server.js.map +1 -1
- package/dist/{shared-D4-AKGn6.mjs → shared-BfASWZo1.mjs} +4 -4
- package/dist/{shared-D4-AKGn6.mjs.map → shared-BfASWZo1.mjs.map} +1 -1
- package/dist/{shared-C9XQd8p_.cjs → shared-DY0kuBcN.cjs} +460 -162
- package/dist/shared-DY0kuBcN.cjs.map +1 -0
- package/dist/sheet-Biw_rI4_.js +1 -0
- package/dist/{config-TyjNpRrV.js → sheet-C6ymGhKV.js} +23 -2
- package/dist/sheet-C6ymGhKV.js.map +1 -0
- package/dist/sheet-D_grHnaJ.js +7 -0
- package/dist/sheet-D_grHnaJ.js.map +1 -0
- package/dist/{sidecar-CZTYX2vA.mjs → sidecar-cCzTDkzg.mjs} +3 -3
- package/dist/{sidecar-CZTYX2vA.mjs.map → sidecar-cCzTDkzg.mjs.map} +1 -1
- package/dist/{style-CmXHCPF4.js → style-CRs-vfY1.js} +12 -12
- package/dist/style-CRs-vfY1.js.map +1 -0
- package/dist/{env-C8TRVSyb.js → styleStore-D1IEmq1v.js} +435 -63
- package/dist/styleStore-D1IEmq1v.js.map +1 -0
- package/dist/styleStore-HI4V2puu.js +45 -0
- package/dist/styleStore-HI4V2puu.js.map +1 -0
- package/dist/{token-DMrBbat8.js → token-BX5jRxMb.js} +2 -2
- package/dist/{token-DMrBbat8.js.map → token-BX5jRxMb.js.map} +1 -1
- package/dist/{trace-C7EzEj2Q.js → trace-DdFJPELS.js} +3 -3
- package/dist/{trace-C7EzEj2Q.js.map → trace-DdFJPELS.js.map} +1 -1
- package/dist/{trace-DzCntvK4.js → trace-uHVvnYiw.js} +2 -2
- package/dist/{trace-DzCntvK4.js.map → trace-uHVvnYiw.js.map} +1 -1
- package/dist/{transform-CSZMklMb.js → transform-BZ4jPwy3.js} +2 -2
- package/dist/{transform-CSZMklMb.js.map → transform-BZ4jPwy3.js.map} +1 -1
- package/dist/types/atomic/className.d.ts +2 -2
- package/dist/types/atomic/utils/selector.d.ts +2 -1
- package/dist/types/builder/data/const.d.ts +1 -0
- package/dist/types/builder/data/data.d.ts +1 -1
- package/dist/types/builder/data/state.d.ts +1 -0
- package/dist/types/builder/selector_override.d.ts +1 -1
- package/dist/types/builder/selector_override_core.d.ts +2 -0
- package/dist/types/builder/types/alias.d.ts +2 -2
- package/dist/types/compiler/extract/types.d.ts +7 -1
- package/dist/types/compiler/transform/extract/chain/extract_chain.d.ts +2 -0
- package/dist/types/compiler/utils/constants.d.ts +1 -0
- package/dist/types/config/config/css.d.ts +2 -1
- package/dist/types/config/configure.d.ts +2 -0
- package/dist/types/config/document.d.ts +3 -0
- package/dist/types/css/globalSheet.d.ts +24 -0
- package/dist/types/css/index.d.ts +4 -1
- package/dist/types/css/sheet.d.ts +3 -2
- package/dist/types/entry/rsc_dev/css.d.ts +1 -0
- package/dist/types/runtime/rsc/constants.d.ts +2 -0
- package/dist/types/runtime/rsc/dev.d.ts +5 -0
- package/dist/types/runtime/rsc/getClassName.d.ts +3 -0
- package/dist/types/runtime/rsc/globalSheet.d.ts +22 -0
- package/dist/types/runtime/rsc/observer.d.ts +5 -0
- package/dist/types/runtime/rsc/styleStore.d.ts +2 -0
- package/dist/types/runtime/sheet/document.d.ts +3 -0
- package/dist/types/sheet/ordered.d.ts +4 -0
- package/dist/types/sheet/ordering.d.ts +15 -0
- package/dist/types/sheet/types.d.ts +7 -0
- package/dist/types/style/important.d.ts +2 -1
- package/dist/types/style/style.d.ts +2 -2
- package/dist/{utils-CoMwEfhG.mjs → utils-BO6Ix8t5.mjs} +4 -4
- package/dist/{utils-CoMwEfhG.mjs.map → utils-BO6Ix8t5.mjs.map} +1 -1
- package/dist/{utils-B7QcJ-Yw.js → utils-CB70kIh6.js} +3 -3
- package/dist/{utils-B7QcJ-Yw.js.map → utils-CB70kIh6.js.map} +1 -1
- package/dist/{utils-BYpkJ-uE.mjs → utils-EG9gh2g3.mjs} +3 -3
- package/dist/{utils-BYpkJ-uE.mjs.map → utils-EG9gh2g3.mjs.map} +1 -1
- package/dist/{utils-D4KMqCu2.js → utils-sG7IWYP6.js} +1089 -646
- package/dist/utils-sG7IWYP6.js.map +1 -0
- package/dist/utils.js +3 -3
- package/dist/{value-yd2SZ1XQ.js → value-BhyWGLkf.js} +16 -9
- package/dist/value-BhyWGLkf.js.map +1 -0
- package/dist/{webpack-B6z1UHh9.mjs → webpack-WXAJ3IYn.mjs} +5 -5
- package/dist/{webpack-B6z1UHh9.mjs.map → webpack-WXAJ3IYn.mjs.map} +1 -1
- package/entry/dev/sheet.ts +4 -2
- package/entry/rsc_dev/css.ts +2 -0
- package/jsx/rsc/jsx_dev_runtime.ts +11 -2
- package/jsx/rsc/jsx_runtime.ts +14 -3
- package/package.json +16 -1
- package/plugin/nextjs/loader.ts +18 -2
- package/runtime/core/elementMarker.ts +9 -3
- package/runtime/rsc/constants.ts +3 -0
- package/runtime/rsc/dev.ts +31 -15
- package/runtime/rsc/getClassName.ts +6 -0
- package/runtime/rsc/globalSheet.ts +130 -0
- package/runtime/rsc/observer.ts +118 -15
- package/runtime/rsc/styleStore.ts +12 -36
- package/runtime/sheet/document.ts +28 -0
- package/runtime/sheet/global-prod.ts +3 -5
- package/runtime/sheet/global.ts +3 -5
- package/runtime/sheet/rule.ts +4 -2
- package/runtime/sheet/rules.ts +3 -0
- package/sheet/dev/dev_sort.ts +5 -1
- package/sheet/dev/index.ts +23 -3
- package/sheet/ordered.ts +188 -0
- package/sheet/ordering.ts +138 -0
- package/sheet/prod.ts +17 -5
- package/sheet/types.ts +4 -0
- package/style/important.ts +3 -1
- package/style/style.ts +1 -1
- package/utils/trace.ts +1 -0
- package/dist/className-yhJCGT0F.js.map +0 -1
- package/dist/combine-CC9bY-hu.js.map +0 -1
- package/dist/compiler-Ct5xGIeu.mjs.map +0 -1
- package/dist/config-BiiMS4rU.js.map +0 -1
- package/dist/config-TyjNpRrV.js.map +0 -1
- package/dist/createTransformElement-BGznW-Mu.js +0 -34
- package/dist/createTransformElement-BGznW-Mu.js.map +0 -1
- package/dist/css-BhoclXaw.js.map +0 -1
- package/dist/css-IecKRNxs.js.map +0 -1
- package/dist/css-WaHZ6gxv.js.map +0 -1
- package/dist/data-BgZmL55Y.js.map +0 -1
- package/dist/debug-D-1hhd0G.js.map +0 -1
- package/dist/elementMarker-CJcfpKL1.js.map +0 -1
- package/dist/env-C8TRVSyb.js.map +0 -1
- package/dist/getClassName-CeoxISNW.js.map +0 -1
- package/dist/global-CWYOol4o.js +0 -14
- package/dist/global-CWYOol4o.js.map +0 -1
- package/dist/hash-DlXmmPPm.js.map +0 -1
- package/dist/jsx_runtime-CPojW0KD.js +0 -12
- package/dist/jsx_runtime-CPojW0KD.js.map +0 -1
- package/dist/rules-Dz-szpPu.js.map +0 -1
- package/dist/shared-C9XQd8p_.cjs.map +0 -1
- package/dist/sheet-LU89fcH_.js +0 -7
- package/dist/sheet-LU89fcH_.js.map +0 -1
- package/dist/style-CmXHCPF4.js.map +0 -1
- package/dist/styleStore-B0x4Ahpx.js +0 -60
- package/dist/styleStore-B0x4Ahpx.js.map +0 -1
- package/dist/styleStore-BrpgLNgc.js +0 -57
- package/dist/styleStore-BrpgLNgc.js.map +0 -1
- package/dist/utils-D4KMqCu2.js.map +0 -1
- package/dist/value-yd2SZ1XQ.js.map +0 -1
|
@@ -40,12 +40,18 @@ function symbol(name) {
|
|
|
40
40
|
}
|
|
41
41
|
//#endregion
|
|
42
42
|
//#region utils/global.ts
|
|
43
|
+
function getGlobalData(key) {
|
|
44
|
+
return globalThis[symbol(key)];
|
|
45
|
+
}
|
|
43
46
|
function globalData(key, data) {
|
|
44
47
|
const id = symbol(key);
|
|
45
48
|
const root = globalThis;
|
|
46
49
|
if (root[id] === void 0) assign(root, id, data());
|
|
47
50
|
return root[id];
|
|
48
51
|
}
|
|
52
|
+
function clearGlobalData(key) {
|
|
53
|
+
delete globalThis[symbol(key)];
|
|
54
|
+
}
|
|
49
55
|
function assign(target, id, value) {
|
|
50
56
|
Object.defineProperty(target, id, {
|
|
51
57
|
value,
|
|
@@ -72,12 +78,9 @@ function isStyleLayerEnabled(layer = CSS_CONFIG.layer) {
|
|
|
72
78
|
function isSheetLayerOption(value) {
|
|
73
79
|
return value === void 0 || typeof value === "boolean" || typeof value === "string" && /^\.?(?:--|-?[a-zA-Z_\u0080-\uFFFF])[\w\u0080-\uFFFF-]*(?:\.(?:--|-?[a-zA-Z_\u0080-\uFFFF])[\w\u0080-\uFFFF-]*)*$/.test(value);
|
|
74
80
|
}
|
|
75
|
-
function resolveSheetLayerOption(layer, namespace) {
|
|
76
|
-
if (typeof layer !== "string") return layer ? "
|
|
77
|
-
return { name: layer.startsWith(".") ? namespace ? namespace + layer : layer.slice(1) : layer };
|
|
78
|
-
}
|
|
79
|
-
function isSheetLayerEnabled(layer = CSS_CONFIG.layer) {
|
|
80
|
-
return typeof layer === "object" && (layer.sheet ?? false);
|
|
81
|
+
function resolveSheetLayerOption(layer, namespace, mainLayerEnabled = isStyleLayerEnabled()) {
|
|
82
|
+
if (typeof layer !== "string") return layer && mainLayerEnabled ? "style" : false;
|
|
83
|
+
return { name: layer.startsWith(".") ? mainLayerEnabled && namespace ? namespace + layer : layer.slice(1) : layer };
|
|
81
84
|
}
|
|
82
85
|
//#endregion
|
|
83
86
|
//#region config/utils.ts
|
|
@@ -110,6 +113,21 @@ const DEFAULT_DEBUG_CONFIG = {
|
|
|
110
113
|
};
|
|
111
114
|
const DEBUG_CONFIG = globalData("config.debug", () => ({ ...DEFAULT_DEBUG_CONFIG }));
|
|
112
115
|
//#endregion
|
|
116
|
+
//#region config/document.ts
|
|
117
|
+
const state$2 = globalData("config.document", () => ({
|
|
118
|
+
target: true,
|
|
119
|
+
listeners: /* @__PURE__ */ new Set()
|
|
120
|
+
}));
|
|
121
|
+
function getRuntimeDocument(documentOverride) {
|
|
122
|
+
if (state$2.target === false) return null;
|
|
123
|
+
if (state$2.target !== true) return state$2.target;
|
|
124
|
+
if (documentOverride) return documentOverride;
|
|
125
|
+
return typeof globalThis.document === "undefined" ? null : globalThis.document;
|
|
126
|
+
}
|
|
127
|
+
function onRuntimeDocumentChange(listener) {
|
|
128
|
+
state$2.listeners.add(listener);
|
|
129
|
+
}
|
|
130
|
+
//#endregion
|
|
113
131
|
//#region utils/hash.ts
|
|
114
132
|
function hashString(str) {
|
|
115
133
|
let hash = 2166136261;
|
|
@@ -124,6 +142,41 @@ function normalizeHashLength(length) {
|
|
|
124
142
|
function compareLayerPriority(p1, p2) {
|
|
125
143
|
return p1[0] - p2[0] || p1[1] - p2[1] || p1[2] - p2[2] || p1[3] - p2[3] || p1[4] - p2[4] || p1[5] - p2[5] || p1[6] - p2[6];
|
|
126
144
|
}
|
|
145
|
+
function createLayerNamePool() {
|
|
146
|
+
const lookup = /* @__PURE__ */ new Map();
|
|
147
|
+
const getLayerId = (priority) => {
|
|
148
|
+
const key = priority.join("|");
|
|
149
|
+
let name = lookup.get(key);
|
|
150
|
+
if (name) return name;
|
|
151
|
+
name = "p" + hashString(key);
|
|
152
|
+
lookup.set(key, name);
|
|
153
|
+
return name;
|
|
154
|
+
};
|
|
155
|
+
const getLayerName = (layerNamespace, priority) => {
|
|
156
|
+
const layerId = getLayerId(priority);
|
|
157
|
+
return layerNamespace ? layerNamespace + "." + layerId : layerId;
|
|
158
|
+
};
|
|
159
|
+
return {
|
|
160
|
+
getLayerName,
|
|
161
|
+
getLayerId
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function createLayerPool(layerNamespace) {
|
|
165
|
+
const namePool = createLayerNamePool();
|
|
166
|
+
const priorities = /* @__PURE__ */ new Map();
|
|
167
|
+
const getName = (priority) => {
|
|
168
|
+
const key = priority.join("|");
|
|
169
|
+
if (!priorities.has(key)) priorities.set(key, priority);
|
|
170
|
+
return namePool.getLayerName(layerNamespace, priority);
|
|
171
|
+
};
|
|
172
|
+
const getNames = () => {
|
|
173
|
+
return Array.from(priorities.values()).sort(compareLayerPriority).map((priority) => namePool.getLayerName(layerNamespace, priority));
|
|
174
|
+
};
|
|
175
|
+
return {
|
|
176
|
+
getName,
|
|
177
|
+
getNames
|
|
178
|
+
};
|
|
179
|
+
}
|
|
127
180
|
function flattenCssLayers(layers, layerNames) {
|
|
128
181
|
const names = typeof layerNames === "string" ? [layerNames] : layerNames;
|
|
129
182
|
return [...new Set(layers.flatMap((layer) => layer === "$layer" ? names.filter((name) => !layers.includes(name)) : layer).filter(Boolean))];
|
|
@@ -182,6 +235,108 @@ function createCssCollector() {
|
|
|
182
235
|
}
|
|
183
236
|
};
|
|
184
237
|
}
|
|
238
|
+
function getSheetRulePriority(priority) {
|
|
239
|
+
return priority ?? LayerDefaultPriority;
|
|
240
|
+
}
|
|
241
|
+
function getSheetRuleLayerPriority(priority, important) {
|
|
242
|
+
const resolved = getSheetRulePriority(priority);
|
|
243
|
+
return important ? [
|
|
244
|
+
-resolved[0],
|
|
245
|
+
-resolved[1],
|
|
246
|
+
-resolved[2],
|
|
247
|
+
-resolved[3],
|
|
248
|
+
-resolved[4],
|
|
249
|
+
-resolved[5],
|
|
250
|
+
-resolved[6]
|
|
251
|
+
] : resolved;
|
|
252
|
+
}
|
|
253
|
+
//#endregion
|
|
254
|
+
//#region sheet/ordering.ts
|
|
255
|
+
function sheetRuleLayer(rule, config = CSS_CONFIG) {
|
|
256
|
+
const mainEnabled = isStyleLayerEnabled(config.layer);
|
|
257
|
+
let layer = rule.layer ?? "style";
|
|
258
|
+
if (layer === "style" && !mainEnabled) layer = false;
|
|
259
|
+
if (rule.sheet && rule.important && !rule.importantNative && layer !== false) return { name: (typeof layer === "object" ? layer.name : config.layerNamespace || "css") + ".important" };
|
|
260
|
+
return layer;
|
|
261
|
+
}
|
|
262
|
+
function sheetRuleGroup(rule, config = CSS_CONFIG) {
|
|
263
|
+
if (rule.globalSheet) return "global:" + rule.globalSheet.id;
|
|
264
|
+
return rule.sheet && sheetRuleLayer(rule, config) === false ? "local-unlayered" : "regular";
|
|
265
|
+
}
|
|
266
|
+
function compareSheetGroups(a, b) {
|
|
267
|
+
const region = (rule) => rule.globalSheet ? rule.globalSheet.order <= 0 ? 0 : 2 : 1;
|
|
268
|
+
const order = region(a) - region(b);
|
|
269
|
+
if (order) return order;
|
|
270
|
+
if (a.globalSheet && b.globalSheet) return a.globalSheet.order - b.globalSheet.order;
|
|
271
|
+
return 0;
|
|
272
|
+
}
|
|
273
|
+
function compareSheetRules(a, b, config = CSS_CONFIG) {
|
|
274
|
+
const layerRank = (rule) => {
|
|
275
|
+
const layer = sheetRuleLayer(rule, config);
|
|
276
|
+
const main = config.layerNamespace || "css";
|
|
277
|
+
return layer === false ? 2 : layer === "style" || typeof layer === "object" && layer.name === main ? 0 : 1;
|
|
278
|
+
};
|
|
279
|
+
return layerRank(a) - layerRank(b) || compareLayerPriority(getSheetRulePriority(a.priority), getSheetRulePriority(b.priority));
|
|
280
|
+
}
|
|
281
|
+
/** Stable group sort: equal global orders keep the first-discovered sheet first. */
|
|
282
|
+
function orderSheetRules(rules, config = CSS_CONFIG) {
|
|
283
|
+
const groups = /* @__PURE__ */ new Map();
|
|
284
|
+
for (const rule of rules) {
|
|
285
|
+
const key = sheetRuleGroup(rule, config);
|
|
286
|
+
const group = groups.get(key) ?? [];
|
|
287
|
+
group.push(rule);
|
|
288
|
+
groups.set(key, group);
|
|
289
|
+
}
|
|
290
|
+
return [...groups.entries()].sort(([ak, a], [bk, b]) => compareSheetGroups(a[0], b[0]) || (!a[0].globalSheet && !b[0].globalSheet ? Number(ak === "local-unlayered") - Number(bk === "local-unlayered") : 0)).flatMap(([, group]) => group.slice().sort((a, b) => compareSheetRules(a, b, config)));
|
|
291
|
+
}
|
|
292
|
+
/** Reserve each parent's first child for managed important declarations. */
|
|
293
|
+
function sheetLayerOrder(names, config = CSS_CONFIG, reservedParents = names) {
|
|
294
|
+
const roots = [];
|
|
295
|
+
const children = /* @__PURE__ */ new Map();
|
|
296
|
+
const add = (name) => {
|
|
297
|
+
const parts = name.split(".");
|
|
298
|
+
if (!roots.includes(parts[0])) roots.push(parts[0]);
|
|
299
|
+
for (let i = 1; i < parts.length; i++) {
|
|
300
|
+
const parent = parts.slice(0, i).join(".");
|
|
301
|
+
const child = parts.slice(0, i + 1).join(".");
|
|
302
|
+
const list = children.get(parent) ?? [];
|
|
303
|
+
if (!list.includes(child)) list.push(child);
|
|
304
|
+
children.set(parent, list);
|
|
305
|
+
}
|
|
306
|
+
if (!name.endsWith(".important") && reservedParents.includes(name)) children.set(name, children.get(name) ?? []);
|
|
307
|
+
};
|
|
308
|
+
for (const name of [...(config.layers ?? CSS_CONFIG_DEFAULT.layers ?? []).filter((name) => name !== "$layer"), ...names]) add(name);
|
|
309
|
+
const declarations = [getLayerOrderCss((config.layers ?? CSS_CONFIG_DEFAULT.layers ?? []).map((name) => name === "$layer" ? name : name.split(".")[0]), roots)];
|
|
310
|
+
for (const [parent, list] of children) {
|
|
311
|
+
if (parent.endsWith(".important")) continue;
|
|
312
|
+
declarations.push("@layer " + [...new Set([parent + ".important", ...list])].join(", ") + ";");
|
|
313
|
+
}
|
|
314
|
+
return declarations.filter(Boolean).join("\n");
|
|
315
|
+
}
|
|
316
|
+
function layerNameForRule(rule, config, mode, pool) {
|
|
317
|
+
const layer = sheetRuleLayer(rule, config);
|
|
318
|
+
return typeof layer === "object" ? layer.name : layer === false ? null : layer === "sheet" ? (config.layerNamespace || "css") + ".sheet" : mode === "layer" ? pool.getName(getSheetRuleLayerPriority(rule.priority, rule.important)) : config.layerNamespace || "css";
|
|
319
|
+
}
|
|
320
|
+
/** Build only ordering declarations; runtime flushing need not serialize rule bodies. */
|
|
321
|
+
function sheetOrderingPreamble(rules, config = CSS_CONFIG, mode = "sort") {
|
|
322
|
+
const pool = createLayerPool(config.layerNamespace || "css");
|
|
323
|
+
const names = /* @__PURE__ */ new Set();
|
|
324
|
+
for (const rule of orderSheetRules(rules, config)) {
|
|
325
|
+
const name = layerNameForRule(rule, config, mode, pool);
|
|
326
|
+
if (name) names.add(name);
|
|
327
|
+
}
|
|
328
|
+
const priorities = pool.getNames();
|
|
329
|
+
const named = [...names].filter((name) => !priorities.includes(name));
|
|
330
|
+
return sheetLayerOrder([...priorities, ...named], config, named);
|
|
331
|
+
}
|
|
332
|
+
function serializeOrderedRules(rules, config = CSS_CONFIG, mode = "sort") {
|
|
333
|
+
const pool = createLayerPool(config.layerNamespace || "css");
|
|
334
|
+
const rendered = orderSheetRules(rules, config).map((rule) => {
|
|
335
|
+
const name = layerNameForRule(rule, config, mode, pool);
|
|
336
|
+
return name ? getLayerBlockCss(name, rule.css) : rule.css;
|
|
337
|
+
});
|
|
338
|
+
return [sheetOrderingPreamble(rules, config, mode), ...rendered].filter(Boolean).join("\n");
|
|
339
|
+
}
|
|
185
340
|
const STYLE_IMPORT_PATH = "@fluentic/style";
|
|
186
341
|
const STYLE_CSS_IMPORT_PATH = "@fluentic/style/css";
|
|
187
342
|
const STYLE_DIALECT_IMPORT_PATH = "@fluentic/style/dialect";
|
|
@@ -222,46 +377,26 @@ const DEBUG_SOURCE_CONTENT_VAR = "_styleDebugSourceContent";
|
|
|
222
377
|
//#endregion
|
|
223
378
|
//#region compiler/extract/extract.ts
|
|
224
379
|
function extractCss(items, args) {
|
|
225
|
-
return getExtractedCssItems(items, args);
|
|
226
|
-
}
|
|
227
|
-
function getExtractedCssItems(items, args) {
|
|
228
|
-
const sortedItems = items.slice().sort((a, b) => compareLayerPriority(a.priority, b.priority));
|
|
229
380
|
const seen = /* @__PURE__ */ new Set();
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
381
|
+
const unique = items.filter((item) => {
|
|
382
|
+
const key = JSON.stringify([
|
|
383
|
+
item.globalSheet?.id,
|
|
384
|
+
item.globalSheet?.order,
|
|
385
|
+
item.sheet,
|
|
386
|
+
item.layer,
|
|
387
|
+
item.importantNative,
|
|
388
|
+
item.css
|
|
389
|
+
]);
|
|
390
|
+
if (seen.has(key)) return false;
|
|
234
391
|
seen.add(key);
|
|
235
|
-
|
|
236
|
-
}
|
|
237
|
-
if (!
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
const styleItems = [];
|
|
244
|
-
const sheetItems = /* @__PURE__ */ new Map();
|
|
245
|
-
const unlayeredItems = [];
|
|
246
|
-
for (let i = 0, len = css.length; i < len; i++) {
|
|
247
|
-
const item = css[i];
|
|
248
|
-
if (item.layer === "sheet" || typeof item.layer === "object") {
|
|
249
|
-
const name = typeof item.layer === "object" ? item.layer.name : sheetLayerName;
|
|
250
|
-
const rules = sheetItems.get(name) ?? [];
|
|
251
|
-
rules.push(item.css);
|
|
252
|
-
sheetItems.set(name, rules);
|
|
253
|
-
} else if (item.layer === false || !styleLayer) unlayeredItems.push(item.css);
|
|
254
|
-
else styleItems.push(item.css);
|
|
255
|
-
}
|
|
256
|
-
const styleLayerName = [...sheetItems.keys()].some((name) => name.startsWith(layerNamespace + ".")) && layerNamespace ? layerNamespace + ".style" : layerNamespace;
|
|
257
|
-
const layerNames = [styleItems.length ? styleLayerName : "", ...sheetItems.keys()].filter(Boolean);
|
|
258
|
-
const output = [];
|
|
259
|
-
const layerOrder = getLayerOrderCss(layers, layerNames);
|
|
260
|
-
if (layerOrder) output.push(layerOrder);
|
|
261
|
-
if (styleItems.length) output.push(getLayerBlockCss(styleLayerName, "\n" + styleItems.join("\n") + "\n"));
|
|
262
|
-
for (const [name, rules] of sheetItems) output.push(getLayerBlockCss(name, "\n" + rules.join("\n") + "\n"));
|
|
263
|
-
output.push(...unlayeredItems);
|
|
264
|
-
return output.join("\n");
|
|
392
|
+
return true;
|
|
393
|
+
});
|
|
394
|
+
if (!unique.length) return "";
|
|
395
|
+
return serializeOrderedRules(unique, {
|
|
396
|
+
layer: args.layer ?? DEFAULT_CONFIG.layer ?? true,
|
|
397
|
+
layers: args.layers ?? DEFAULT_CONFIG.layers,
|
|
398
|
+
layerNamespace: args.layerNamespace ?? DEFAULT_CONFIG.layerNamespace
|
|
399
|
+
});
|
|
265
400
|
}
|
|
266
401
|
//#endregion
|
|
267
402
|
//#region compiler/utils/path.ts
|
|
@@ -486,7 +621,7 @@ function babelTransform(args) {
|
|
|
486
621
|
error.stack = void 0;
|
|
487
622
|
throw error;
|
|
488
623
|
}
|
|
489
|
-
if (!result ||
|
|
624
|
+
if (!result || result.code == null) return null;
|
|
490
625
|
return {
|
|
491
626
|
code: result.code,
|
|
492
627
|
sourcemap: result.map ? JSON.stringify(result.map) : null
|
|
@@ -610,6 +745,7 @@ const BUILDER_SCOPE_ID = symbol("builder.scopeId");
|
|
|
610
745
|
const BUILDER_SCOPE = symbol("builder.scope");
|
|
611
746
|
const BUILDER_SELECTOR = symbol("builder.selector");
|
|
612
747
|
const BUILDER_SHEET_OPTIONS = symbol("builder.sheetOptions");
|
|
748
|
+
const GLOBAL_SHEET_SELECTOR_ANCHOR = "\0global";
|
|
613
749
|
const SHEET_SELECTOR_ANCHOR = "\0sheet";
|
|
614
750
|
//#endregion
|
|
615
751
|
//#region utils/object.ts
|
|
@@ -720,7 +856,7 @@ function createStackFrameLine(frame) {
|
|
|
720
856
|
}
|
|
721
857
|
function isInternalCallsite(filePath) {
|
|
722
858
|
const normalized = filePath.replace(/\\/g, "/");
|
|
723
|
-
return normalized.startsWith("node:") || normalized.startsWith("internal/") || normalized.includes("/node_modules/") || normalized.includes("/packages/style/dist/") || normalized.includes("/packages/style/builder/") || normalized.includes("/packages/style/runtime/") || normalized.includes("/packages/style/utils/trace.");
|
|
859
|
+
return normalized.startsWith("node:") || normalized.startsWith("internal/") || normalized.includes("/node_modules/") || normalized.includes("/packages/style/dist/") || normalized.includes("/packages/style/builder/") || normalized.includes("/packages/style/css/") || normalized.includes("/packages/style/runtime/") || normalized.includes("/packages/style/utils/trace.");
|
|
724
860
|
}
|
|
725
861
|
function traceError(message, options = {}) {
|
|
726
862
|
const error = new Error(message || "");
|
|
@@ -1471,7 +1607,9 @@ function getIdentifierSafeHashValue(hash) {
|
|
|
1471
1607
|
//#endregion
|
|
1472
1608
|
//#region atomic/utils/selector.ts
|
|
1473
1609
|
function getSelectorText$1(selector) {
|
|
1474
|
-
|
|
1610
|
+
const text = Array.isArray(selector) ? selector[0] : selector;
|
|
1611
|
+
if (text.startsWith("\0global")) return text.slice(text.indexOf("\0", 7) + 1);
|
|
1612
|
+
return stripSheetSelectorAnchor(text);
|
|
1475
1613
|
}
|
|
1476
1614
|
function getSelectorHash(selector) {
|
|
1477
1615
|
return Array.isArray(selector) ? selector.join("|") : selector;
|
|
@@ -1483,14 +1621,15 @@ function getSelectorPriority$1(selector) {
|
|
|
1483
1621
|
function hasSheetSelectorAnchor(selector) {
|
|
1484
1622
|
return (selector ? Array.isArray(selector) ? selector[0] : selector : "").startsWith(SHEET_SELECTOR_ANCHOR);
|
|
1485
1623
|
}
|
|
1486
|
-
function
|
|
1624
|
+
function getSheetSelectorSpecificity(selector) {
|
|
1487
1625
|
const text = selector ? Array.isArray(selector) ? selector[0] : selector : "";
|
|
1488
1626
|
if (!text.startsWith("\0sheet:")) return null;
|
|
1489
1627
|
const end = text.indexOf("\0", 6);
|
|
1490
1628
|
if (end < 0) return null;
|
|
1491
1629
|
const [weightValue] = text.slice(7, end).split(":");
|
|
1630
|
+
if (!weightValue) return null;
|
|
1492
1631
|
const weight = Number(weightValue);
|
|
1493
|
-
return Number.isInteger(weight) && weight
|
|
1632
|
+
return Number.isInteger(weight) && weight >= 0 ? weight : null;
|
|
1494
1633
|
}
|
|
1495
1634
|
function stripSheetSelectorAnchor(selector) {
|
|
1496
1635
|
if (!selector.startsWith("\0sheet")) return selector;
|
|
@@ -1500,12 +1639,16 @@ function stripSheetSelectorAnchor(selector) {
|
|
|
1500
1639
|
}
|
|
1501
1640
|
return selector.slice(6);
|
|
1502
1641
|
}
|
|
1642
|
+
function hasGlobalSheetSelectorAnchor(selector) {
|
|
1643
|
+
return (selector ? Array.isArray(selector) ? selector[0] : selector : "").startsWith(GLOBAL_SHEET_SELECTOR_ANCHOR);
|
|
1644
|
+
}
|
|
1503
1645
|
//#endregion
|
|
1504
1646
|
//#region atomic/className.ts
|
|
1505
|
-
function getAtomicClassName(property, priority, important, value, selector, parentSelector, atRule, callsite, localClassName, debugClassName, classNameFormat, transformClassName, transformClassNameFormat, sheetClassNameFormat = null, hashLength = null) {
|
|
1647
|
+
function getAtomicClassName(property, priority, important, value, selector, parentSelector, atRule, callsite, localClassName, debugClassName, classNameFormat, transformClassName, transformClassNameFormat, sheetClassNameFormat = null, hashLength = null, importantNative = false) {
|
|
1506
1648
|
let hash = property;
|
|
1507
1649
|
hash += "\n" + (priority || "");
|
|
1508
1650
|
if (important) hash += "\nimportant";
|
|
1651
|
+
if (importantNative) hash += "\nnative-important";
|
|
1509
1652
|
hash += "\n" + value;
|
|
1510
1653
|
hash += "\n" + (selector ? getSelectorHash(selector) : "");
|
|
1511
1654
|
hash += "\n" + (parentSelector ? getSelectorHash(parentSelector) : "");
|
|
@@ -1536,10 +1679,11 @@ function getClassNameHashLength(options) {
|
|
|
1536
1679
|
if (options.debugClassName && options.isDev) return options.devHashLength ?? options.cssHashLength ?? 5;
|
|
1537
1680
|
return options.cssHashLength ?? 7;
|
|
1538
1681
|
}
|
|
1539
|
-
function getClassNameDedupe(property, priority, important, selector, parentSelector, atRule) {
|
|
1682
|
+
function getClassNameDedupe(property, priority, important, selector, parentSelector, atRule, importantNative = false) {
|
|
1540
1683
|
let hash = property;
|
|
1541
1684
|
hash += "\n" + (priority || "");
|
|
1542
1685
|
if (important) hash += "\nimportant";
|
|
1686
|
+
if (importantNative) hash += "\nnative-important";
|
|
1543
1687
|
hash += "\n" + (selector ? getSelectorHash(selector) : "");
|
|
1544
1688
|
hash += "\n" + (parentSelector ? getSelectorHash(parentSelector) : "");
|
|
1545
1689
|
hash += "\n" + (atRule ? atRule.map(getSelectorHash).join("\n") : "");
|
|
@@ -1619,8 +1763,8 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1619
1763
|
value = scopeItem.value;
|
|
1620
1764
|
weight = scopeItem.weight;
|
|
1621
1765
|
important = scopeItem.important;
|
|
1622
|
-
dedupe = getClassNameDedupe(scopeItem.property, weight, important, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule);
|
|
1623
|
-
className = getAtomicClassName(scopeItem.property, weight, important, value, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule, itemCallsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, scopeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null, CSS_CONFIG.sheetClassNameFormat ?? null);
|
|
1766
|
+
dedupe = getClassNameDedupe(scopeItem.property, weight, important, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule, scopeItem.importantNative);
|
|
1767
|
+
className = getAtomicClassName(scopeItem.property, weight, important, value, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule, itemCallsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, scopeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null, CSS_CONFIG.sheetClassNameFormat ?? null, null, scopeItem.importantNative);
|
|
1624
1768
|
scopeItem.dedupe = dedupe;
|
|
1625
1769
|
scopeItem.className = className;
|
|
1626
1770
|
scopeItem.callsite = itemCallsite;
|
|
@@ -1659,6 +1803,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1659
1803
|
property: overrideItem.property,
|
|
1660
1804
|
weight: overrideItem.weight,
|
|
1661
1805
|
important: overrideItem.important,
|
|
1806
|
+
importantNative: overrideItem.importantNative,
|
|
1662
1807
|
value: overrideItem.value,
|
|
1663
1808
|
transformClassName: overrideItem.transformClassName,
|
|
1664
1809
|
token: overrideItem.token,
|
|
@@ -1672,8 +1817,8 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1672
1817
|
value = scopeItem.value;
|
|
1673
1818
|
weight = scopeItem.weight;
|
|
1674
1819
|
important = scopeItem.important;
|
|
1675
|
-
dedupe = getClassNameDedupe(scopeItem.property, weight, important, scopeItem.selector, parentSelector, scopeItem.atRule);
|
|
1676
|
-
className = getAtomicClassName(scopeItem.property, weight, important, value, scopeItem.selector, parentSelector, scopeItem.atRule, scopeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, scopeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null, CSS_CONFIG.sheetClassNameFormat ?? null);
|
|
1820
|
+
dedupe = getClassNameDedupe(scopeItem.property, weight, important, scopeItem.selector, parentSelector, scopeItem.atRule, scopeItem.importantNative);
|
|
1821
|
+
className = getAtomicClassName(scopeItem.property, weight, important, value, scopeItem.selector, parentSelector, scopeItem.atRule, scopeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, scopeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null, CSS_CONFIG.sheetClassNameFormat ?? null, null, scopeItem.importantNative);
|
|
1677
1822
|
scopeItem.dedupe = dedupe;
|
|
1678
1823
|
scopeItem.className = className;
|
|
1679
1824
|
const lookupKey = getScopeLookupKey(slotId, dedupe);
|
|
@@ -1833,10 +1978,11 @@ function shouldAppendCssPx(property) {
|
|
|
1833
1978
|
//#endregion
|
|
1834
1979
|
//#region style/important.ts
|
|
1835
1980
|
const STYLE_IMPORTANT = symbol("style.important");
|
|
1836
|
-
function importantValue(value) {
|
|
1981
|
+
function importantValue(value, native = false) {
|
|
1837
1982
|
return {
|
|
1838
1983
|
[STYLE_IMPORTANT]: true,
|
|
1839
|
-
value
|
|
1984
|
+
value,
|
|
1985
|
+
native
|
|
1840
1986
|
};
|
|
1841
1987
|
}
|
|
1842
1988
|
function isStyleImportantValue(value) {
|
|
@@ -1893,6 +2039,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1893
2039
|
let value;
|
|
1894
2040
|
let weight;
|
|
1895
2041
|
let important;
|
|
2042
|
+
let importantNative;
|
|
1896
2043
|
let itemCallsite;
|
|
1897
2044
|
let className;
|
|
1898
2045
|
let dedupe;
|
|
@@ -1934,7 +2081,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1934
2081
|
}
|
|
1935
2082
|
} else for (const property in style) {
|
|
1936
2083
|
valueRaw = style[property];
|
|
1937
|
-
[valueRaw, weight, important] = unwrapAuthoredStyleValue(valueRaw);
|
|
2084
|
+
[valueRaw, weight, important, importantNative] = unwrapAuthoredStyleValue(valueRaw);
|
|
1938
2085
|
const sourceType = source[BUILDER_TYPE];
|
|
1939
2086
|
checkImportantUsage(valueRaw, important, sourceType === 9 || sourceType === 8);
|
|
1940
2087
|
transformClassName = null;
|
|
@@ -1957,6 +2104,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1957
2104
|
property,
|
|
1958
2105
|
weight,
|
|
1959
2106
|
important,
|
|
2107
|
+
importantNative,
|
|
1960
2108
|
value,
|
|
1961
2109
|
transformClassName,
|
|
1962
2110
|
variable: ref ? [3, ref] : variableName && token ? [
|
|
@@ -2019,8 +2167,8 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
2019
2167
|
value = runtimeItem.value;
|
|
2020
2168
|
weight = runtimeItem.weight;
|
|
2021
2169
|
important = runtimeItem.important;
|
|
2022
|
-
dedupe = getClassNameDedupe(runtimeItem.property, weight, important, runtimeItem.selector, null, runtimeItem.atRule);
|
|
2023
|
-
className = getAtomicClassName(runtimeItem.property, weight, important, value, runtimeItem.selector, null, runtimeItem.atRule, runtimeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, runtimeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null, CSS_CONFIG.sheetClassNameFormat ?? null);
|
|
2170
|
+
dedupe = getClassNameDedupe(runtimeItem.property, weight, important, runtimeItem.selector, null, runtimeItem.atRule, runtimeItem.importantNative);
|
|
2171
|
+
className = getAtomicClassName(runtimeItem.property, weight, important, value, runtimeItem.selector, null, runtimeItem.atRule, runtimeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, runtimeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null, CSS_CONFIG.sheetClassNameFormat ?? null, null, runtimeItem.importantNative);
|
|
2024
2172
|
runtimeItem.dedupe = dedupe;
|
|
2025
2173
|
runtimeItem.className = className;
|
|
2026
2174
|
lookupIndex = lookup[dedupe];
|
|
@@ -2032,9 +2180,11 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
2032
2180
|
function unwrapAuthoredStyleValue(value) {
|
|
2033
2181
|
let weight = null;
|
|
2034
2182
|
let important = false;
|
|
2183
|
+
let native = false;
|
|
2035
2184
|
while (true) {
|
|
2036
2185
|
if (isStyleImportantValue(value)) {
|
|
2037
2186
|
important = true;
|
|
2187
|
+
native ||= value.native === true;
|
|
2038
2188
|
value = value.value;
|
|
2039
2189
|
continue;
|
|
2040
2190
|
}
|
|
@@ -2048,7 +2198,8 @@ function unwrapAuthoredStyleValue(value) {
|
|
|
2048
2198
|
return [
|
|
2049
2199
|
value,
|
|
2050
2200
|
weight,
|
|
2051
|
-
important
|
|
2201
|
+
important,
|
|
2202
|
+
native
|
|
2052
2203
|
];
|
|
2053
2204
|
}
|
|
2054
2205
|
function checkImportantUsage(value, important, isSheet) {
|
|
@@ -2134,9 +2285,9 @@ function assertManualSelectorSyntax(selector) {
|
|
|
2134
2285
|
if (ampersandIndex === 0 && ampersandSelector && /^\s/.test(ampersandSelector)) throw new Error("selector cannot have whitespace after \"&\"; omit \"&\" for descendant selectors");
|
|
2135
2286
|
}
|
|
2136
2287
|
function setSheetSelectorOptions(selector, options) {
|
|
2137
|
-
if (options.
|
|
2288
|
+
if (options.specificity === void 0 && options.layer === void 0) return selector;
|
|
2138
2289
|
const text = Array.isArray(selector) ? selector[0] : selector;
|
|
2139
|
-
const weighted = SHEET_SELECTOR_ANCHOR + (":" + (options.
|
|
2290
|
+
const weighted = SHEET_SELECTOR_ANCHOR + (":" + (options.specificity ?? "") + ":" + (typeof options.layer === "string" ? JSON.stringify(options.layer) : options.layer === void 0 ? "" : options.layer ? "1" : "0")) + "\0" + text.slice(6);
|
|
2140
2291
|
return Array.isArray(selector) ? [weighted, selector[1]] : weighted;
|
|
2141
2292
|
}
|
|
2142
2293
|
function normalizeManualSelector(selector, assertManualSelector) {
|
|
@@ -2148,6 +2299,13 @@ function normalizeManualSelector(selector, assertManualSelector) {
|
|
|
2148
2299
|
}
|
|
2149
2300
|
return [SHEET_SELECTOR_ANCHOR + (value.startsWith("&") ? value.slice(1) : " " + value)];
|
|
2150
2301
|
}
|
|
2302
|
+
/** Convert a normalized explicit selector into an unscoped sheet selector. */
|
|
2303
|
+
function setGlobalSheetSelectorOptions(selector, options) {
|
|
2304
|
+
const suffix = (Array.isArray(selector) ? selector[0] : selector).slice(6);
|
|
2305
|
+
if (!suffix.startsWith(" ") || !suffix.trim()) throw new Error("createGlobalSheet requires explicit selectors without an ampersand anchor");
|
|
2306
|
+
const global = GLOBAL_SHEET_SELECTOR_ANCHOR + JSON.stringify(options.layer ?? null) + "\0" + suffix.trimStart();
|
|
2307
|
+
return Array.isArray(selector) ? [global, selector[1]] : global;
|
|
2308
|
+
}
|
|
2151
2309
|
//#endregion
|
|
2152
2310
|
//#region builder/selector_override.ts
|
|
2153
2311
|
function normalizeManualSelectors(input) {
|
|
@@ -3173,63 +3331,19 @@ function buildFontPaletteValuesCss(format, name, id, descriptors, tokens, tokenL
|
|
|
3173
3331
|
};
|
|
3174
3332
|
}
|
|
3175
3333
|
createIdCounter("fontPaletteValues");
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
const KEYFRAMES_AT_RULE = "keyframes";
|
|
3179
|
-
const formatKeyFramesName = createAtRuleNameFormatter("keyframes[-(name)]-$hash");
|
|
3180
|
-
function buildKeyframesCss(format, name, id, frames, tokens, tokenLookup, tokenNameFormat) {
|
|
3181
|
-
name = formatKeyFramesName(format, id, { name });
|
|
3182
|
-
let css = `@${KEYFRAMES_AT_RULE} ${name} {`;
|
|
3183
|
-
for (const selector in frames) {
|
|
3184
|
-
const frame = frames[selector];
|
|
3185
|
-
if (!frame) continue;
|
|
3186
|
-
css += selector + "{";
|
|
3187
|
-
css += buildAtRuleDeclarationCss(frame, tokens, tokenLookup, tokenNameFormat, false);
|
|
3188
|
-
css += "}";
|
|
3189
|
-
}
|
|
3190
|
-
css += "}";
|
|
3191
|
-
return {
|
|
3192
|
-
name,
|
|
3193
|
-
css
|
|
3194
|
-
};
|
|
3195
|
-
}
|
|
3196
|
-
//#endregion
|
|
3197
|
-
//#region css/keyframes.ts
|
|
3198
|
-
const idCounter$2 = createIdCounter("keyframes");
|
|
3199
|
-
function createKeyframes(frames, stableId) {
|
|
3200
|
-
return createNamedAtRuleRef({
|
|
3201
|
-
format: CSS_EXTRA_CONFIG.namedRuleFormat.keyframes,
|
|
3202
|
-
buildCss: buildKeyframesCss,
|
|
3203
|
-
value: frames,
|
|
3204
|
-
idCounter: idCounter$2,
|
|
3205
|
-
stableId
|
|
3206
|
-
});
|
|
3334
|
+
function appendStyleTag(document, tag) {
|
|
3335
|
+
(document.head || document.getElementsByTagName("head")[0] || document.documentElement).appendChild(tag);
|
|
3207
3336
|
}
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
const
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
return
|
|
3216
|
-
name,
|
|
3217
|
-
css
|
|
3218
|
-
};
|
|
3219
|
-
}
|
|
3220
|
-
createIdCounter("positionTry");
|
|
3221
|
-
//#endregion
|
|
3222
|
-
//#region atomic/atRule/property.ts
|
|
3223
|
-
const PROPERTY_AT_RULE = "property";
|
|
3224
|
-
const formatPropertyName = createAtRuleNameFormatter("[-(name)]-$hash", "--");
|
|
3225
|
-
function buildPropertyCss(format, name, id, descriptors, tokens, tokenLookup, tokenNameFormat) {
|
|
3226
|
-
name = formatPropertyName(format, id, { name });
|
|
3227
|
-
return {
|
|
3228
|
-
css: buildNamedAtRuleCss(PROPERTY_AT_RULE, name, descriptors, tokens, tokenLookup, tokenNameFormat),
|
|
3229
|
-
name
|
|
3230
|
-
};
|
|
3337
|
+
function getFirstCssSheetTag(head) {
|
|
3338
|
+
const nodes = head.childNodes;
|
|
3339
|
+
for (let i = 0, len = nodes.length; i < len; i++) {
|
|
3340
|
+
const node = nodes[i];
|
|
3341
|
+
if (typeof node.getAttribute !== "function") continue;
|
|
3342
|
+
if (node.getAttribute("data-css-sheet")) return node;
|
|
3343
|
+
}
|
|
3344
|
+
return null;
|
|
3231
3345
|
}
|
|
3232
|
-
|
|
3346
|
+
globalData("sheet.ordered.refreshers", () => /* @__PURE__ */ new Set());
|
|
3233
3347
|
//#endregion
|
|
3234
3348
|
//#region sheet/utils/sourcemap.ts
|
|
3235
3349
|
const VLQ_BASE_SHIFT = 5;
|
|
@@ -3238,6 +3352,45 @@ const VLQ_BASE_MASK = VLQ_BASE - 1;
|
|
|
3238
3352
|
const VLQ_CONTINUATION_BIT = VLQ_BASE;
|
|
3239
3353
|
const BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
3240
3354
|
const SOURCE_URL_PREFIX = "source://";
|
|
3355
|
+
function createSourceMapComment$1(rules) {
|
|
3356
|
+
const sources = [];
|
|
3357
|
+
const sourceLookup = Object.create(null);
|
|
3358
|
+
let generatedLine = 0;
|
|
3359
|
+
let previousSource = 0;
|
|
3360
|
+
let previousOriginalLine = 0;
|
|
3361
|
+
let previousOriginalColumn = 0;
|
|
3362
|
+
const mappingLines = [];
|
|
3363
|
+
for (let i = 0, len = rules.length; i < len; i++) {
|
|
3364
|
+
const rule = rules[i];
|
|
3365
|
+
const sourceData = rule.source;
|
|
3366
|
+
let mapping = "";
|
|
3367
|
+
if (sourceData) {
|
|
3368
|
+
const source = getSource(sources, sourceLookup, getSourceMapSourceUrl(sourceData), sourceData.sourceContent);
|
|
3369
|
+
const originalLine = Math.max(sourceData.line - 1, 0);
|
|
3370
|
+
const originalColumn = Math.max(sourceData.column - 1, 0);
|
|
3371
|
+
mapping += encodeVlq(0);
|
|
3372
|
+
mapping += encodeVlq(source.sourceIndex - previousSource);
|
|
3373
|
+
mapping += encodeVlq(originalLine - previousOriginalLine);
|
|
3374
|
+
mapping += encodeVlq(originalColumn - previousOriginalColumn);
|
|
3375
|
+
previousSource = source.sourceIndex;
|
|
3376
|
+
previousOriginalLine = originalLine;
|
|
3377
|
+
previousOriginalColumn = originalColumn;
|
|
3378
|
+
}
|
|
3379
|
+
mappingLines[generatedLine] = mapping;
|
|
3380
|
+
const lineCount = getLineCount(rule.css);
|
|
3381
|
+
for (let j = 1; j < lineCount; j++) mappingLines[generatedLine + j] = "";
|
|
3382
|
+
generatedLine += lineCount;
|
|
3383
|
+
}
|
|
3384
|
+
if (!sources.length) return "";
|
|
3385
|
+
const data = {
|
|
3386
|
+
version: 3,
|
|
3387
|
+
sources: sources.map((source) => source.filePath),
|
|
3388
|
+
sourcesContent: sources.some((source) => source.sourceContent !== void 0) ? sources.map((source) => source.sourceContent ?? null) : void 0,
|
|
3389
|
+
names: [],
|
|
3390
|
+
mappings: mappingLines.join(";")
|
|
3391
|
+
};
|
|
3392
|
+
return "/*# sourceMappingURL=data:application/json;charset=utf-8;base64," + encodeBase64(JSON.stringify(data)) + " */";
|
|
3393
|
+
}
|
|
3241
3394
|
function encodeBase64(text) {
|
|
3242
3395
|
const bytes = new TextEncoder().encode(text);
|
|
3243
3396
|
let binary = "";
|
|
@@ -3338,8 +3491,21 @@ function normalizeRuleCallsite(callsite) {
|
|
|
3338
3491
|
sourceUrl: callsite.sourceUrl ? normalizeCallsiteSourceUrl(callsite.sourceUrl) : callsite.sourceUrl
|
|
3339
3492
|
};
|
|
3340
3493
|
}
|
|
3494
|
+
function getSourcemapRuleCallsite(rule) {
|
|
3495
|
+
return getRuleCallsite(rule.callsite, rule.debug, rule.debugField);
|
|
3496
|
+
}
|
|
3341
3497
|
globalData("sheet.dev.sourcemapTags", () => []);
|
|
3342
3498
|
globalData("sheet.dev.sheets", () => /* @__PURE__ */ new Set());
|
|
3499
|
+
//#endregion
|
|
3500
|
+
//#region runtime/sheet/document.ts
|
|
3501
|
+
const GLOBAL_KEY = "runtime.sheet.global";
|
|
3502
|
+
const state$1 = globalData("runtime.sheet.document", () => ({ document: getRuntimeDocument() }));
|
|
3503
|
+
function resetSheet() {
|
|
3504
|
+
getGlobalData(GLOBAL_KEY)?.destroy?.();
|
|
3505
|
+
clearGlobalData(GLOBAL_KEY);
|
|
3506
|
+
state$1.document = getRuntimeDocument();
|
|
3507
|
+
}
|
|
3508
|
+
onRuntimeDocumentChange(resetSheet);
|
|
3343
3509
|
globalData("runtime.combinedStyle.targets", () => /* @__PURE__ */ new WeakMap());
|
|
3344
3510
|
//#endregion
|
|
3345
3511
|
//#region runtime/core/cache/resolvedItem.ts
|
|
@@ -3637,10 +3803,10 @@ function buildAtomicRule(className, property, value, important, selector, parent
|
|
|
3637
3803
|
const cssProp = getCssPropertyName(property);
|
|
3638
3804
|
const cssValue = getCssPropertyValue(property, value) + (important ? " !important" : "");
|
|
3639
3805
|
const escapedClass = escapeCssIdent(className);
|
|
3640
|
-
const
|
|
3641
|
-
const classSelector =
|
|
3806
|
+
const specificity = hasSheetSelectorAnchor(selector) ? getSheetSelectorSpecificity(selector) ?? 1 : 1;
|
|
3807
|
+
const classSelector = specificity === 0 ? `:where(.${escapedClass})` : Array(specificity).fill("." + escapedClass).join("");
|
|
3642
3808
|
const itemSelector = selector ? getSelectorText$1(selector) : "";
|
|
3643
|
-
let selectorStr = classSelector + itemSelector;
|
|
3809
|
+
let selectorStr = hasGlobalSheetSelectorAnchor(selector) ? itemSelector : classSelector + itemSelector;
|
|
3644
3810
|
if (parentSelector) {
|
|
3645
3811
|
const parentWhere = `:where(${"." + escapeCssIdent(getScopeClassName(className, scopeClassNameFormat)) + getSelectorText$1(parentSelector)})`;
|
|
3646
3812
|
selectorStr = classSelector + parentWhere + itemSelector + "," + parentWhere + " " + selectorStr;
|
|
@@ -3720,8 +3886,71 @@ function stripGenericThemePrefix(value) {
|
|
|
3720
3886
|
function isGeneratedNameHash(value) {
|
|
3721
3887
|
return /^[a-z0-9]{7}$/.test(value) && /\d/.test(value);
|
|
3722
3888
|
}
|
|
3889
|
+
//#endregion
|
|
3890
|
+
//#region atomic/atRule/keyframes.ts
|
|
3891
|
+
const KEYFRAMES_AT_RULE = "keyframes";
|
|
3892
|
+
const formatKeyFramesName = createAtRuleNameFormatter("keyframes[-(name)]-$hash");
|
|
3893
|
+
function buildKeyframesCss(format, name, id, frames, tokens, tokenLookup, tokenNameFormat) {
|
|
3894
|
+
name = formatKeyFramesName(format, id, { name });
|
|
3895
|
+
let css = `@${KEYFRAMES_AT_RULE} ${name} {`;
|
|
3896
|
+
for (const selector in frames) {
|
|
3897
|
+
const frame = frames[selector];
|
|
3898
|
+
if (!frame) continue;
|
|
3899
|
+
css += selector + "{";
|
|
3900
|
+
css += buildAtRuleDeclarationCss(frame, tokens, tokenLookup, tokenNameFormat, false);
|
|
3901
|
+
css += "}";
|
|
3902
|
+
}
|
|
3903
|
+
css += "}";
|
|
3904
|
+
return {
|
|
3905
|
+
name,
|
|
3906
|
+
css
|
|
3907
|
+
};
|
|
3908
|
+
}
|
|
3909
|
+
//#endregion
|
|
3910
|
+
//#region css/keyframes.ts
|
|
3911
|
+
const idCounter$2 = createIdCounter("keyframes");
|
|
3912
|
+
function createKeyframes(frames, stableId) {
|
|
3913
|
+
return createNamedAtRuleRef({
|
|
3914
|
+
format: CSS_EXTRA_CONFIG.namedRuleFormat.keyframes,
|
|
3915
|
+
buildCss: buildKeyframesCss,
|
|
3916
|
+
value: frames,
|
|
3917
|
+
idCounter: idCounter$2,
|
|
3918
|
+
stableId
|
|
3919
|
+
});
|
|
3920
|
+
}
|
|
3921
|
+
//#endregion
|
|
3922
|
+
//#region atomic/atRule/positionTry.ts
|
|
3923
|
+
const POSITION_TRY_AT_RULE = "position-try";
|
|
3924
|
+
const formatPositionTryName = createAtRuleNameFormatter("position-try[-(name)]-$hash", "--");
|
|
3925
|
+
function buildPositionTryCss(format, name, id, descriptors, tokens, tokenLookup, tokenNameFormat) {
|
|
3926
|
+
name = formatPositionTryName(format, id, { name });
|
|
3927
|
+
const css = buildNamedAtRuleCss(POSITION_TRY_AT_RULE, name, descriptors, tokens, tokenLookup, tokenNameFormat);
|
|
3928
|
+
return {
|
|
3929
|
+
name,
|
|
3930
|
+
css
|
|
3931
|
+
};
|
|
3932
|
+
}
|
|
3933
|
+
createIdCounter("positionTry");
|
|
3934
|
+
//#endregion
|
|
3935
|
+
//#region atomic/atRule/property.ts
|
|
3936
|
+
const PROPERTY_AT_RULE = "property";
|
|
3937
|
+
const formatPropertyName = createAtRuleNameFormatter("[-(name)]-$hash", "--");
|
|
3938
|
+
function buildPropertyCss(format, name, id, descriptors, tokens, tokenLookup, tokenNameFormat) {
|
|
3939
|
+
name = formatPropertyName(format, id, { name });
|
|
3940
|
+
return {
|
|
3941
|
+
css: buildNamedAtRuleCss(PROPERTY_AT_RULE, name, descriptors, tokens, tokenLookup, tokenNameFormat),
|
|
3942
|
+
name
|
|
3943
|
+
};
|
|
3944
|
+
}
|
|
3945
|
+
createIdCounter("property");
|
|
3723
3946
|
createNameFormatter(["name"]);
|
|
3724
|
-
|
|
3947
|
+
//#endregion
|
|
3948
|
+
//#region runtime/core/elementMarker.ts
|
|
3949
|
+
const ELEMENT_MARKER_SHEET = globalData("runtime.elementMarkerSheet", () => ({ sheet: null }));
|
|
3950
|
+
onRuntimeDocumentChange(() => {
|
|
3951
|
+
ELEMENT_MARKER_SHEET.sheet?.sheet.destroy?.();
|
|
3952
|
+
ELEMENT_MARKER_SHEET.sheet = null;
|
|
3953
|
+
});
|
|
3725
3954
|
//#endregion
|
|
3726
3955
|
//#region style/keyframes.ts
|
|
3727
3956
|
function transformKeyframes(frames, transform) {
|
|
@@ -3753,7 +3982,7 @@ function createStyleFn(args) {
|
|
|
3753
3982
|
const fnWeight = (value, weight) => {
|
|
3754
3983
|
return weightValue(value, weight);
|
|
3755
3984
|
};
|
|
3756
|
-
const fnImportant = (value) => importantValue(value);
|
|
3985
|
+
const fnImportant = (value, native) => importantValue(value, native);
|
|
3757
3986
|
const fnRaw = (style) => style;
|
|
3758
3987
|
const fnPlain = (style) => style;
|
|
3759
3988
|
const fnKeyframes = ((frames, stableId) => createStyleKeyframes(frames, transform ?? null, stableId));
|
|
@@ -4511,7 +4740,10 @@ function evaluateCall(node, scope) {
|
|
|
4511
4740
|
if (node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.property.type === "Identifier" && node.callee.property.name === "important" && node.callee.object.type === "Identifier" && scope.styleNames?.has(node.callee.object.name)) {
|
|
4512
4741
|
const value = evaluateNode(node.arguments[0], scope);
|
|
4513
4742
|
if (!value.ok) return value;
|
|
4514
|
-
|
|
4743
|
+
const native = node.arguments[1] ? evaluateNode(node.arguments[1], scope) : evalOk(false);
|
|
4744
|
+
if (!native.ok) return native;
|
|
4745
|
+
if (typeof native.value !== "boolean") return evalFail("style.important second argument must be a boolean");
|
|
4746
|
+
return evalOk(importantValue(value.value, native.value));
|
|
4515
4747
|
}
|
|
4516
4748
|
if (node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.property.type === "Identifier" && (node.callee.property.name === "raw" || node.callee.property.name === "plain") && node.callee.object.type === "Identifier" && scope.styleNames?.has(node.callee.object.name)) return evaluateNode(node.arguments[0], scope);
|
|
4517
4749
|
return evalFail(`Cannot statically evaluate: ${node.type}`);
|
|
@@ -5213,6 +5445,15 @@ function createDebugPlugin(args) {
|
|
|
5213
5445
|
});
|
|
5214
5446
|
},
|
|
5215
5447
|
CallExpression(path, state) {
|
|
5448
|
+
if (path.node.callee.type === "Identifier") {
|
|
5449
|
+
const imported = state.imports.get(path.node.callee.name);
|
|
5450
|
+
if (imported?.source === "@fluentic/style/css" && imported.name === "createGlobalSheet" && !hasDebugArgument(path.node.arguments)) {
|
|
5451
|
+
const debug = buildDebugDataObject(t, path.node, state.fileId, getSourceUrlId(t, state), sourceContent ? getSourceContentId(t, state) : null);
|
|
5452
|
+
if (!path.getFunctionParent()) debug.properties.push(t.objectProperty(t.identifier("globalModule"), t.stringLiteral(state.filePath)));
|
|
5453
|
+
if (!path.node.arguments.length) path.node.arguments.push(t.arrayExpression([]));
|
|
5454
|
+
path.node.arguments.push(debug);
|
|
5455
|
+
}
|
|
5456
|
+
}
|
|
5216
5457
|
annotateThemeCall(path.node, state, t);
|
|
5217
5458
|
annotateThemeCallsite(t, path, state, sourceContent);
|
|
5218
5459
|
if (!state.styleNames.size) return;
|
|
@@ -6118,12 +6359,23 @@ function compileSheetChain(chain, fileId, scope, cssConfig, options) {
|
|
|
6118
6359
|
const items = [];
|
|
6119
6360
|
const rules = [];
|
|
6120
6361
|
const hasOptions = chain.baseArgs.length === 2;
|
|
6121
|
-
const sheetOptions = hasOptions ? evaluateCreateSheetOptions(chain.baseArgs[0], scope) : {};
|
|
6362
|
+
const sheetOptions = hasOptions ? evaluateCreateSheetOptions(chain.baseArgs[0], scope, chain.global) : {};
|
|
6122
6363
|
if (!sheetOptions) return null;
|
|
6364
|
+
if (chain.global) {
|
|
6365
|
+
if (sheetOptions.specificity !== void 0) throw new Error("createGlobalSheet does not support specificity");
|
|
6366
|
+
sheetOptions.global = true;
|
|
6367
|
+
}
|
|
6123
6368
|
const sheetItems = chain.baseArgs[hasOptions ? 1 : 0];
|
|
6124
6369
|
if (sheetItems && !compileSheetItemsArg(sheetItems, fileId, scope, cssConfig, options, items, rules, sheetOptions)) return null;
|
|
6125
|
-
const sheetLayer = sheetOptions.layer ??
|
|
6126
|
-
for (let i = 0, len = rules.length; i < len; i++)
|
|
6370
|
+
const sheetLayer = sheetOptions.layer ?? false;
|
|
6371
|
+
for (let i = 0, len = rules.length; i < len; i++) {
|
|
6372
|
+
rules[i].layer = resolveSheetLayerOption(sheetLayer, options.css?.layerNamespace ?? DEFAULT_CONFIG.layerNamespace ?? "", isStyleLayerEnabled(options.css?.layer ?? DEFAULT_CONFIG.layer));
|
|
6373
|
+
rules[i].sheet = true;
|
|
6374
|
+
if (chain.global) rules[i].globalSheet = {
|
|
6375
|
+
id: chain.sheetId ?? fileId,
|
|
6376
|
+
order: sheetOptions.order ?? 0
|
|
6377
|
+
};
|
|
6378
|
+
}
|
|
6127
6379
|
return {
|
|
6128
6380
|
type: "sheet",
|
|
6129
6381
|
items,
|
|
@@ -6131,17 +6383,17 @@ function compileSheetChain(chain, fileId, scope, cssConfig, options) {
|
|
|
6131
6383
|
sheetOptions
|
|
6132
6384
|
};
|
|
6133
6385
|
}
|
|
6134
|
-
function evaluateCreateSheetOptions(node, scope) {
|
|
6386
|
+
function evaluateCreateSheetOptions(node, scope, global = false) {
|
|
6135
6387
|
const result = evaluateNode(node, scope);
|
|
6136
6388
|
if (!result.ok || !result.value || typeof result.value !== "object" || Array.isArray(result.value)) return null;
|
|
6137
6389
|
const value = result.value;
|
|
6138
|
-
if (
|
|
6139
|
-
|
|
6140
|
-
if (value.
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
|
|
6390
|
+
if (hasGlobalRuntimeValue(value)) return null;
|
|
6391
|
+
const allowed = global ? ["layer", "order"] : ["layer", "specificity"];
|
|
6392
|
+
if (Object.keys(value).some((key) => !allowed.includes(key))) throw new Error(global ? "createGlobalSheet only supports layer and order" : "createSheet only supports layer and specificity");
|
|
6393
|
+
if (!isSheetLayerOption(value.layer)) throw new Error("invalid sheet layer");
|
|
6394
|
+
if (value.specificity !== void 0 && (!Number.isInteger(value.specificity) || value.specificity < 0)) throw new Error("specificity must be a non-negative integer");
|
|
6395
|
+
if (value.order !== void 0 && (typeof value.order !== "number" || !Number.isFinite(value.order))) throw new Error("order must be a finite number");
|
|
6396
|
+
return value;
|
|
6145
6397
|
}
|
|
6146
6398
|
function compileSheetItemsArg(node, fileId, scope, cssConfig, options, items, rules, sheetOptions) {
|
|
6147
6399
|
if (node.type === "ArrayExpression") {
|
|
@@ -6153,7 +6405,9 @@ function compileSheetItemsArg(node, fileId, scope, cssConfig, options, items, ru
|
|
|
6153
6405
|
return true;
|
|
6154
6406
|
}
|
|
6155
6407
|
const tokenOverride = evaluateNode(node, scope);
|
|
6408
|
+
if (tokenOverride.ok && !tokenOverride.value) return true;
|
|
6156
6409
|
if (tokenOverride.ok && isStyleTokenOverrideData(tokenOverride.value)) {
|
|
6410
|
+
if (sheetOptions.global) throw new Error("createGlobalSheet requires token overrides inside an explicit selector");
|
|
6157
6411
|
addCompiledTokenItem(getStyleTokenId(tokenOverride.value), tokenOverride.value, getCompiledRuntimeValue(tokenOverride.value) ?? node, items);
|
|
6158
6412
|
return true;
|
|
6159
6413
|
}
|
|
@@ -6162,6 +6416,7 @@ function compileSheetItemsArg(node, fileId, scope, cssConfig, options, items, ru
|
|
|
6162
6416
|
const item = tokenOverride.value[i];
|
|
6163
6417
|
if (!item) continue;
|
|
6164
6418
|
if (!isStyleTokenOverrideData(item)) return false;
|
|
6419
|
+
if (sheetOptions.global) throw new Error("createGlobalSheet requires token overrides inside an explicit selector");
|
|
6165
6420
|
addCompiledTokenItem(getStyleTokenId(item), item, getCompiledRuntimeValue(item) ?? null, items);
|
|
6166
6421
|
}
|
|
6167
6422
|
return true;
|
|
@@ -6175,10 +6430,16 @@ function compileSheetItemsArg(node, fileId, scope, cssConfig, options, items, ru
|
|
|
6175
6430
|
}
|
|
6176
6431
|
function compileSelectorOverrideChain(chain, selectors, fileId, scope, cssConfig, transform, styleNames, options, items, rules, sheetOptions) {
|
|
6177
6432
|
if (chain.baseArgs.length === 0 || chain.baseArgs.length > 2) return false;
|
|
6433
|
+
if (sheetOptions.global) {
|
|
6434
|
+
if ([...chain.baseArgs, ...chain.methods.flatMap((method) => method.args)].some((arg) => {
|
|
6435
|
+
const result = evaluateNode(arg, scope);
|
|
6436
|
+
return !result.ok || hasGlobalRuntimeValue(result.value);
|
|
6437
|
+
})) return false;
|
|
6438
|
+
}
|
|
6178
6439
|
const selectorArg = evaluateNode(chain.baseArgs[0], scope);
|
|
6179
6440
|
if (!selectorArg.ok) return false;
|
|
6180
6441
|
const manualSelectors = normalizeManualSelectors(Array.isArray(selectorArg.value) ? selectorArg.value.map(String) : String(selectorArg.value ?? ""));
|
|
6181
|
-
for (let i = 0, len = manualSelectors.length; i < len; i++) if (!compileSelectorOverrideInto(chain, selectors, fileId, scope, cssConfig, transform, styleNames, options, items, rules, setSheetSelectorOptions(manualSelectors[i], sheetOptions))) return false;
|
|
6442
|
+
for (let i = 0, len = manualSelectors.length; i < len; i++) if (!compileSelectorOverrideInto(chain, selectors, fileId, scope, cssConfig, transform, styleNames, options, items, rules, sheetOptions.global ? setGlobalSheetSelectorOptions(manualSelectors[i], sheetOptions) : setSheetSelectorOptions(manualSelectors[i], sheetOptions))) return false;
|
|
6182
6443
|
return true;
|
|
6183
6444
|
}
|
|
6184
6445
|
function compileSelectorOverrideInto(chain, selectors, fileId, scope, cssConfig, transform, styleNames, options, items, rules, selectorPrefix) {
|
|
@@ -6386,7 +6647,7 @@ function decorateClassNameStyle(style, className) {
|
|
|
6386
6647
|
}
|
|
6387
6648
|
function decorateClassNameValue(value, className) {
|
|
6388
6649
|
if (isClassNameValue(value)) return value;
|
|
6389
|
-
if (isStyleImportantValue(value)) return importantValue(decorateClassNameValue(value.value, className));
|
|
6650
|
+
if (isStyleImportantValue(value)) return importantValue(decorateClassNameValue(value.value, className), value.native);
|
|
6390
6651
|
if (isStyleWeightValue(value)) return weightValue(decorateClassNameValue(value.value, className), value.weight);
|
|
6391
6652
|
return classNameValue(value, className);
|
|
6392
6653
|
}
|
|
@@ -6990,6 +7251,7 @@ function addSlotOverrideDataItems(value, parentSelector, atRules, fileId, items,
|
|
|
6990
7251
|
property: overrideItem.property,
|
|
6991
7252
|
weight: overrideItem.weight,
|
|
6992
7253
|
important: overrideItem.important,
|
|
7254
|
+
importantNative: overrideItem.importantNative,
|
|
6993
7255
|
value: overrideItem.value,
|
|
6994
7256
|
variable: overrideItem.variable,
|
|
6995
7257
|
token: overrideItem.token,
|
|
@@ -7041,8 +7303,8 @@ function addRuntimeScopeItem(sourceItem, parentSelector, atRules, fileId, items,
|
|
|
7041
7303
|
const itemAtRules = mergeAtRules(atRules, sourceItem.atRule);
|
|
7042
7304
|
const traceCallsite = callsiteOverride ?? sourceItem.callsite;
|
|
7043
7305
|
const valueStr = String(value ?? "");
|
|
7044
|
-
const dedupe = getClassNameDedupe(sourceItem.property, weight, important, sourceItem.selector, itemParentSelector, itemAtRules);
|
|
7045
|
-
const className = getAtomicClassName(sourceItem.property, weight, important, valueStr, sourceItem.selector, itemParentSelector, itemAtRules, traceCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, sourceItem.transformClassName ?? null, cssConfig.transformClassNameFormat, cssConfig.sheetClassNameFormat, cssConfig.hashLength);
|
|
7306
|
+
const dedupe = getClassNameDedupe(sourceItem.property, weight, important, sourceItem.selector, itemParentSelector, itemAtRules, sourceItem.importantNative);
|
|
7307
|
+
const className = getAtomicClassName(sourceItem.property, weight, important, valueStr, sourceItem.selector, itemParentSelector, itemAtRules, traceCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, sourceItem.transformClassName ?? null, cssConfig.transformClassNameFormat, cssConfig.sheetClassNameFormat, cssConfig.hashLength, sourceItem.importantNative);
|
|
7046
7308
|
const item = createCompiledItem(4, sourceItem.slotId, dedupe, className, !!itemParentSelector);
|
|
7047
7309
|
items.push(item);
|
|
7048
7310
|
const css = buildAtomicRule(className, sourceItem.property, valueStr, important, sourceItem.selector, itemParentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
@@ -7053,6 +7315,7 @@ function addRuntimeScopeItem(sourceItem, parentSelector, atRules, fileId, items,
|
|
|
7053
7315
|
css,
|
|
7054
7316
|
priority: layerPriority,
|
|
7055
7317
|
important,
|
|
7318
|
+
importantNative: sourceItem.importantNative,
|
|
7056
7319
|
trace: traceCallsite ? {
|
|
7057
7320
|
filePath: traceCallsite.filePath ?? fileId,
|
|
7058
7321
|
line: traceCallsite.line,
|
|
@@ -7119,9 +7382,9 @@ function addRuntimeStyleItem(sourceItem, selector, parentSelector, atRules, file
|
|
|
7119
7382
|
const runtimeValue = variable?.[0] === 1 ? getCompiledRuntimeValue(variable[2]) : void 0;
|
|
7120
7383
|
const shouldUseVariable = !!variable && (variable[0] !== 1 || !!sourceItem.token || !!runtimeValue);
|
|
7121
7384
|
const valueStr = variable?.[0] === 1 && !shouldUseVariable ? String(variable[2] ?? "") : String(value ?? "");
|
|
7122
|
-
const dedupe = getClassNameDedupe(sourceItem.property, weight, important, itemSelector, parentSelector, itemAtRules);
|
|
7385
|
+
const dedupe = getClassNameDedupe(sourceItem.property, weight, important, itemSelector, parentSelector, itemAtRules, sourceItem.importantNative);
|
|
7123
7386
|
const traceCallsite = callsiteOverride ?? sourceItem.callsite;
|
|
7124
|
-
const className = getAtomicClassName(sourceItem.property, weight, important, valueStr, itemSelector, parentSelector, itemAtRules, traceCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, sourceItem.transformClassName ?? null, cssConfig.transformClassNameFormat, cssConfig.sheetClassNameFormat, cssConfig.hashLength);
|
|
7387
|
+
const className = getAtomicClassName(sourceItem.property, weight, important, valueStr, itemSelector, parentSelector, itemAtRules, traceCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, sourceItem.transformClassName ?? null, cssConfig.transformClassNameFormat, cssConfig.sheetClassNameFormat, cssConfig.hashLength, sourceItem.importantNative);
|
|
7125
7388
|
const item = createCompiledItem(type, slotId, dedupe, className, !!parentSelector);
|
|
7126
7389
|
item.sourceTrace = getRuntimeStyleItemSourceTrace(sourceItem, fileId);
|
|
7127
7390
|
if (type !== 4 && variable && shouldUseVariable) {
|
|
@@ -7137,6 +7400,7 @@ function addRuntimeStyleItem(sourceItem, selector, parentSelector, atRules, file
|
|
|
7137
7400
|
css,
|
|
7138
7401
|
priority: layerPriority,
|
|
7139
7402
|
important,
|
|
7403
|
+
importantNative: sourceItem.importantNative,
|
|
7140
7404
|
trace: traceCallsite ? {
|
|
7141
7405
|
filePath: traceCallsite.filePath ?? fileId,
|
|
7142
7406
|
line: traceCallsite.line,
|
|
@@ -7203,9 +7467,10 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
7203
7467
|
const rawValue = styleObj[property];
|
|
7204
7468
|
let weight = null;
|
|
7205
7469
|
let important = false;
|
|
7470
|
+
let importantNative = false;
|
|
7206
7471
|
let value = rawValue;
|
|
7207
7472
|
let transformClassName = null;
|
|
7208
|
-
[value, weight, important] = unwrapStaticStyleValue(value);
|
|
7473
|
+
[value, weight, important, importantNative] = unwrapStaticStyleValue(value);
|
|
7209
7474
|
if (isClassNameValue(value)) {
|
|
7210
7475
|
transformClassName = value.className;
|
|
7211
7476
|
value = value.value;
|
|
@@ -7228,8 +7493,8 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
7228
7493
|
const shouldUseVariable = !!(token || runtimeValue);
|
|
7229
7494
|
const variableName = shouldUseVariable && propertyLoc && propertyLoc.variable !== false ? getLocalVarName(cssConfig.runtimeMode === "rsc-dev" ? fileId : propertyLoc.filePath ?? fileId, cssConfig.runtimeMode === "rsc-dev" ? propertyLoc.variableLine ?? propertyLoc.line : propertyLoc.line, cssConfig.runtimeMode === "rsc-dev" ? propertyLoc.variableColumn ?? propertyLoc.column : propertyLoc.column, cssConfig.tokenNameFormat) : null;
|
|
7230
7495
|
const valueStr = variableName ? token ? getCssVarRawFallback(variableName, getTokenVar(token, cssConfig.tokenNameFormat)) : `var(${variableName})` : token ? getTokenVar(token, cssConfig.tokenNameFormat) : String(value);
|
|
7231
|
-
const dedupe = getClassNameDedupe(property, weight, important, selector, parentSelector, atRules);
|
|
7232
|
-
const className = getAtomicClassName(property, weight, important, valueStr, selector, parentSelector, atRules, propertyCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, transformClassName, cssConfig.transformClassNameFormat, cssConfig.sheetClassNameFormat, cssConfig.hashLength);
|
|
7496
|
+
const dedupe = getClassNameDedupe(property, weight, important, selector, parentSelector, atRules, importantNative);
|
|
7497
|
+
const className = getAtomicClassName(property, weight, important, valueStr, selector, parentSelector, atRules, propertyCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, transformClassName, cssConfig.transformClassNameFormat, cssConfig.sheetClassNameFormat, cssConfig.hashLength, importantNative);
|
|
7233
7498
|
const item = createCompiledItem(type, slotId, dedupe, className, !!parentSelector);
|
|
7234
7499
|
item.sourceTrace = propertyCallsite ? {
|
|
7235
7500
|
property,
|
|
@@ -7262,6 +7527,7 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
7262
7527
|
css,
|
|
7263
7528
|
priority: layerPriority,
|
|
7264
7529
|
important,
|
|
7530
|
+
importantNative,
|
|
7265
7531
|
trace: propertyCallsite ? {
|
|
7266
7532
|
filePath: propertyCallsite.filePath ?? fileId,
|
|
7267
7533
|
line: propertyCallsite.line,
|
|
@@ -7287,9 +7553,11 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
7287
7553
|
function unwrapStaticStyleValue(value) {
|
|
7288
7554
|
let weight = null;
|
|
7289
7555
|
let important = false;
|
|
7556
|
+
let native = false;
|
|
7290
7557
|
while (true) {
|
|
7291
7558
|
if (isStyleImportantValue(value)) {
|
|
7292
7559
|
important = true;
|
|
7560
|
+
native ||= value.native === true;
|
|
7293
7561
|
value = value.value;
|
|
7294
7562
|
continue;
|
|
7295
7563
|
}
|
|
@@ -7303,7 +7571,8 @@ function unwrapStaticStyleValue(value) {
|
|
|
7303
7571
|
return [
|
|
7304
7572
|
value,
|
|
7305
7573
|
weight,
|
|
7306
|
-
important
|
|
7574
|
+
important,
|
|
7575
|
+
native
|
|
7307
7576
|
];
|
|
7308
7577
|
}
|
|
7309
7578
|
function throwIfRequiredStaticStyleValue(result) {
|
|
@@ -7360,6 +7629,13 @@ function getCompiledRuntimeValue(value) {
|
|
|
7360
7629
|
if (!value || typeof value !== "object") return void 0;
|
|
7361
7630
|
return value[COMPILED_RUNTIME_VALUE];
|
|
7362
7631
|
}
|
|
7632
|
+
function hasGlobalRuntimeValue(value, seen = /* @__PURE__ */ new Set()) {
|
|
7633
|
+
if (!value || typeof value !== "object" || isStyleTokenData(value) || isAtRuleRef(value)) return false;
|
|
7634
|
+
if (getCompiledRuntimeValue(value)) return true;
|
|
7635
|
+
if (seen.has(value)) return false;
|
|
7636
|
+
seen.add(value);
|
|
7637
|
+
return Object.values(value).some((item) => hasGlobalRuntimeValue(item, seen));
|
|
7638
|
+
}
|
|
7363
7639
|
//#endregion
|
|
7364
7640
|
//#region compiler/transform/evaluator/tracer.ts
|
|
7365
7641
|
const CACHE_TYPE = "transform-trace";
|
|
@@ -7836,7 +8112,9 @@ function isCompilerHandledImport(source, name) {
|
|
|
7836
8112
|
"createTheme",
|
|
7837
8113
|
"createToken",
|
|
7838
8114
|
"createTokens",
|
|
7839
|
-
"createValues"
|
|
8115
|
+
"createValues",
|
|
8116
|
+
"createSheet",
|
|
8117
|
+
"createGlobalSheet"
|
|
7840
8118
|
].includes(name);
|
|
7841
8119
|
}
|
|
7842
8120
|
//#endregion
|
|
@@ -7865,7 +8143,7 @@ function buildSheetOptions(t, chain) {
|
|
|
7865
8143
|
const options = chain.sheetOptions ?? {};
|
|
7866
8144
|
const properties = [];
|
|
7867
8145
|
if (options.layer !== void 0) properties.push(t.objectProperty(t.identifier("layer"), typeof options.layer === "string" ? t.stringLiteral(options.layer) : t.booleanLiteral(options.layer)));
|
|
7868
|
-
if (options.
|
|
8146
|
+
if (options.specificity !== void 0) properties.push(t.objectProperty(t.identifier("specificity"), t.numericLiteral(options.specificity)));
|
|
7869
8147
|
return t.objectExpression(properties);
|
|
7870
8148
|
}
|
|
7871
8149
|
function buildStyleMergeArgs(t, chain, state, options) {
|
|
@@ -8299,7 +8577,7 @@ function createExtractPlugin(args) {
|
|
|
8299
8577
|
state.styleNames.add(spec.local.name);
|
|
8300
8578
|
state.styleMetas.set(spec.local.name, meta);
|
|
8301
8579
|
}
|
|
8302
|
-
if (sourceName === "@fluentic/style/css" && imported === "createSheet") state.sheetNames.add(spec.local.name);
|
|
8580
|
+
if (sourceName === "@fluentic/style/css" && (imported === "createSheet" || imported === "createGlobalSheet")) state.sheetNames.add(spec.local.name);
|
|
8303
8581
|
});
|
|
8304
8582
|
},
|
|
8305
8583
|
VariableDeclaration(path, state) {
|
|
@@ -8355,6 +8633,8 @@ function createExtractPlugin(args) {
|
|
|
8355
8633
|
if (!state.styleNames.size && !state.sheetNames.size) return;
|
|
8356
8634
|
const chain = extractStyleChain(path.node, state.styleNames, state.sheetNames);
|
|
8357
8635
|
if (!chain) return;
|
|
8636
|
+
chain.global = chain.kind === "sheet" && state.imports.get(chain.rootName)?.name === "createGlobalSheet";
|
|
8637
|
+
if (chain.global) chain.sheetId = state.fileId + ":" + path.node.start;
|
|
8358
8638
|
if (chain.kind === "slot" && path.parent.type === "CallExpression" && path.parent.callee === path.node) throw path.buildCodeFrameError("Direct invocation `style.slot(...)()` is not allowed. Assign the slot to a variable first, then call it through that binding.");
|
|
8359
8639
|
const scope = getEvalScope(state);
|
|
8360
8640
|
const loc = path.node.loc?.start;
|
|
@@ -8376,6 +8656,12 @@ function createExtractPlugin(args) {
|
|
|
8376
8656
|
state.collector.add(rule);
|
|
8377
8657
|
});
|
|
8378
8658
|
if (mode === "collect") return;
|
|
8659
|
+
if (chain.global) {
|
|
8660
|
+
if (path.parentPath.isExpressionStatement()) path.parentPath.remove();
|
|
8661
|
+
else path.replaceWith(t.unaryExpression("void", t.numericLiteral(0)));
|
|
8662
|
+
path.skip();
|
|
8663
|
+
return;
|
|
8664
|
+
}
|
|
8379
8665
|
const replacement = createChainReplacement({
|
|
8380
8666
|
t,
|
|
8381
8667
|
path,
|
|
@@ -8430,23 +8716,35 @@ function checkCompiledImportantUsage(result, options, report) {
|
|
|
8430
8716
|
if (hasOutsideSheet && options.outsideSheet) report(options.outsideSheet, "style.important(...) outside createSheet is discouraged. Prefer style.weight(...) for Fluentic style priority.");
|
|
8431
8717
|
}
|
|
8432
8718
|
function pruneUnusedStyleInputDeclarations(path, state) {
|
|
8433
|
-
|
|
8434
|
-
|
|
8435
|
-
|
|
8436
|
-
|
|
8437
|
-
|
|
8438
|
-
|
|
8439
|
-
|
|
8440
|
-
|
|
8441
|
-
|
|
8442
|
-
|
|
8443
|
-
|
|
8444
|
-
|
|
8445
|
-
|
|
8719
|
+
const dependencies = /* @__PURE__ */ new Set();
|
|
8720
|
+
let changed;
|
|
8721
|
+
do {
|
|
8722
|
+
changed = false;
|
|
8723
|
+
path.scope.crawl();
|
|
8724
|
+
path.traverse({ VariableDeclarator(declaratorPath) {
|
|
8725
|
+
const node = declaratorPath.node;
|
|
8726
|
+
if (declaratorPath.parentPath?.parentPath?.isExportNamedDeclaration()) return;
|
|
8727
|
+
if (node.id.type !== "Identifier") return;
|
|
8728
|
+
const binding = declaratorPath.scope.getBinding(node.id.name);
|
|
8729
|
+
if (!binding || !binding.constant || binding.referencePaths.length) return;
|
|
8730
|
+
if (!isStyleInputCall(node.init, state) && !(dependencies.has(node) && declaratorPath.get("init").isPure())) return;
|
|
8731
|
+
declaratorPath.get("init").traverse({ ReferencedIdentifier(reference) {
|
|
8732
|
+
const dependency = reference.scope.getBinding(reference.node.name);
|
|
8733
|
+
if (dependency?.path.isVariableDeclarator()) dependencies.add(dependency.path.node);
|
|
8734
|
+
} });
|
|
8735
|
+
const declarationPath = declaratorPath.parentPath;
|
|
8736
|
+
if (!declarationPath?.isVariableDeclaration()) return;
|
|
8737
|
+
if (declarationPath.node.declarations.length > 1) declaratorPath.remove();
|
|
8738
|
+
else declarationPath.remove();
|
|
8739
|
+
changed = true;
|
|
8740
|
+
} });
|
|
8741
|
+
} while (changed);
|
|
8446
8742
|
path.scope.crawl();
|
|
8447
8743
|
}
|
|
8448
8744
|
function isStyleInputCall(node, state) {
|
|
8449
8745
|
if (!node || node.type !== "CallExpression") return false;
|
|
8746
|
+
const selectorChain = extractStyleChain(node, state.styleNames, state.sheetNames);
|
|
8747
|
+
if (selectorChain?.kind === "selector") return selectorChain.baseArgs.every((arg) => evaluateNode(arg, getEvalScope(state)).ok) && selectorChain.methods.every((method) => method.args.every((arg) => evaluateNode(arg, getEvalScope(state)).ok));
|
|
8450
8748
|
const callee = node.callee;
|
|
8451
8749
|
if (callee.type !== "MemberExpression" || callee.computed) return false;
|
|
8452
8750
|
if (callee.object.type !== "Identifier") return false;
|
|
@@ -9510,4 +9808,4 @@ Object.defineProperty(exports, "writeParcelVirtualRuntimeFile", {
|
|
|
9510
9808
|
}
|
|
9511
9809
|
});
|
|
9512
9810
|
|
|
9513
|
-
//# sourceMappingURL=shared-
|
|
9811
|
+
//# sourceMappingURL=shared-DY0kuBcN.cjs.map
|