@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
|
@@ -103,12 +103,18 @@ function symbol(name) {
|
|
|
103
103
|
}
|
|
104
104
|
//#endregion
|
|
105
105
|
//#region utils/global.ts
|
|
106
|
+
function getGlobalData(key) {
|
|
107
|
+
return globalThis[symbol(key)];
|
|
108
|
+
}
|
|
106
109
|
function globalData(key, data) {
|
|
107
110
|
const id = symbol(key);
|
|
108
111
|
const root = globalThis;
|
|
109
112
|
if (root[id] === void 0) assign(root, id, data());
|
|
110
113
|
return root[id];
|
|
111
114
|
}
|
|
115
|
+
function clearGlobalData(key) {
|
|
116
|
+
delete globalThis[symbol(key)];
|
|
117
|
+
}
|
|
112
118
|
function assign(target, id, value) {
|
|
113
119
|
Object.defineProperty(target, id, {
|
|
114
120
|
value,
|
|
@@ -118,10 +124,6 @@ function assign(target, id, value) {
|
|
|
118
124
|
});
|
|
119
125
|
}
|
|
120
126
|
//#endregion
|
|
121
|
-
//#region config/config/check.ts
|
|
122
|
-
const CHECK_CONFIG_DEFAULT = {};
|
|
123
|
-
const CHECK_CONFIG = globalData("config.check", () => ({ ...CHECK_CONFIG_DEFAULT }));
|
|
124
|
-
//#endregion
|
|
125
127
|
//#region config/config/css.ts
|
|
126
128
|
const CSS_CONFIG_DEFAULT = {
|
|
127
129
|
layer: true,
|
|
@@ -135,14 +137,15 @@ function isStyleLayerEnabled(layer = CSS_CONFIG.layer) {
|
|
|
135
137
|
function isSheetLayerOption(value) {
|
|
136
138
|
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);
|
|
137
139
|
}
|
|
138
|
-
function resolveSheetLayerOption(layer, namespace) {
|
|
139
|
-
if (typeof layer !== "string") return layer ? "
|
|
140
|
-
return { name: layer.startsWith(".") ? namespace ? namespace + layer : layer.slice(1) : layer };
|
|
141
|
-
}
|
|
142
|
-
function isSheetLayerEnabled(layer = CSS_CONFIG.layer) {
|
|
143
|
-
return typeof layer === "object" && (layer.sheet ?? false);
|
|
140
|
+
function resolveSheetLayerOption(layer, namespace, mainLayerEnabled = isStyleLayerEnabled()) {
|
|
141
|
+
if (typeof layer !== "string") return layer && mainLayerEnabled ? "style" : false;
|
|
142
|
+
return { name: layer.startsWith(".") ? mainLayerEnabled && namespace ? namespace + layer : layer.slice(1) : layer };
|
|
144
143
|
}
|
|
145
144
|
//#endregion
|
|
145
|
+
//#region config/config/check.ts
|
|
146
|
+
const CHECK_CONFIG_DEFAULT = {};
|
|
147
|
+
const CHECK_CONFIG = globalData("config.check", () => ({ ...CHECK_CONFIG_DEFAULT }));
|
|
148
|
+
//#endregion
|
|
146
149
|
//#region config/utils.ts
|
|
147
150
|
const SIDECAR_URL_GLOBAL_SYMBOL = "FLUENTIC_STYLE_SIDECAR_URL";
|
|
148
151
|
function getCacheTTL(cache) {
|
|
@@ -173,6 +176,21 @@ const DEFAULT_DEBUG_CONFIG = {
|
|
|
173
176
|
};
|
|
174
177
|
const DEBUG_CONFIG = globalData("config.debug", () => ({ ...DEFAULT_DEBUG_CONFIG }));
|
|
175
178
|
//#endregion
|
|
179
|
+
//#region config/document.ts
|
|
180
|
+
const state$1 = globalData("config.document", () => ({
|
|
181
|
+
target: true,
|
|
182
|
+
listeners: /* @__PURE__ */ new Set()
|
|
183
|
+
}));
|
|
184
|
+
function getRuntimeDocument(documentOverride) {
|
|
185
|
+
if (state$1.target === false) return null;
|
|
186
|
+
if (state$1.target !== true) return state$1.target;
|
|
187
|
+
if (documentOverride) return documentOverride;
|
|
188
|
+
return typeof globalThis.document === "undefined" ? null : globalThis.document;
|
|
189
|
+
}
|
|
190
|
+
function onRuntimeDocumentChange(listener) {
|
|
191
|
+
state$1.listeners.add(listener);
|
|
192
|
+
}
|
|
193
|
+
//#endregion
|
|
176
194
|
//#region utils/hash.ts
|
|
177
195
|
function hashString(str) {
|
|
178
196
|
let hash = 2166136261;
|
|
@@ -187,6 +205,41 @@ function normalizeHashLength(length) {
|
|
|
187
205
|
function compareLayerPriority(p1, p2) {
|
|
188
206
|
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];
|
|
189
207
|
}
|
|
208
|
+
function createLayerNamePool() {
|
|
209
|
+
const lookup = /* @__PURE__ */ new Map();
|
|
210
|
+
const getLayerId = (priority) => {
|
|
211
|
+
const key = priority.join("|");
|
|
212
|
+
let name = lookup.get(key);
|
|
213
|
+
if (name) return name;
|
|
214
|
+
name = "p" + hashString(key);
|
|
215
|
+
lookup.set(key, name);
|
|
216
|
+
return name;
|
|
217
|
+
};
|
|
218
|
+
const getLayerName = (layerNamespace, priority) => {
|
|
219
|
+
const layerId = getLayerId(priority);
|
|
220
|
+
return layerNamespace ? layerNamespace + "." + layerId : layerId;
|
|
221
|
+
};
|
|
222
|
+
return {
|
|
223
|
+
getLayerName,
|
|
224
|
+
getLayerId
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
function createLayerPool(layerNamespace) {
|
|
228
|
+
const namePool = createLayerNamePool();
|
|
229
|
+
const priorities = /* @__PURE__ */ new Map();
|
|
230
|
+
const getName = (priority) => {
|
|
231
|
+
const key = priority.join("|");
|
|
232
|
+
if (!priorities.has(key)) priorities.set(key, priority);
|
|
233
|
+
return namePool.getLayerName(layerNamespace, priority);
|
|
234
|
+
};
|
|
235
|
+
const getNames = () => {
|
|
236
|
+
return Array.from(priorities.values()).sort(compareLayerPriority).map((priority) => namePool.getLayerName(layerNamespace, priority));
|
|
237
|
+
};
|
|
238
|
+
return {
|
|
239
|
+
getName,
|
|
240
|
+
getNames
|
|
241
|
+
};
|
|
242
|
+
}
|
|
190
243
|
function flattenCssLayers(layers, layerNames) {
|
|
191
244
|
const names = typeof layerNames === "string" ? [layerNames] : layerNames;
|
|
192
245
|
return [...new Set(layers.flatMap((layer) => layer === "$layer" ? names.filter((name) => !layers.includes(name)) : layer).filter(Boolean))];
|
|
@@ -226,6 +279,108 @@ function getLayerOrderCss(layers, layerNames) {
|
|
|
226
279
|
function getLayerBlockCss(layerName, css) {
|
|
227
280
|
return "@layer " + layerName + " {" + css + "}";
|
|
228
281
|
}
|
|
282
|
+
function getSheetRulePriority(priority) {
|
|
283
|
+
return priority ?? LayerDefaultPriority;
|
|
284
|
+
}
|
|
285
|
+
function getSheetRuleLayerPriority(priority, important) {
|
|
286
|
+
const resolved = getSheetRulePriority(priority);
|
|
287
|
+
return important ? [
|
|
288
|
+
-resolved[0],
|
|
289
|
+
-resolved[1],
|
|
290
|
+
-resolved[2],
|
|
291
|
+
-resolved[3],
|
|
292
|
+
-resolved[4],
|
|
293
|
+
-resolved[5],
|
|
294
|
+
-resolved[6]
|
|
295
|
+
] : resolved;
|
|
296
|
+
}
|
|
297
|
+
//#endregion
|
|
298
|
+
//#region sheet/ordering.ts
|
|
299
|
+
function sheetRuleLayer(rule, config = CSS_CONFIG) {
|
|
300
|
+
const mainEnabled = isStyleLayerEnabled(config.layer);
|
|
301
|
+
let layer = rule.layer ?? "style";
|
|
302
|
+
if (layer === "style" && !mainEnabled) layer = false;
|
|
303
|
+
if (rule.sheet && rule.important && !rule.importantNative && layer !== false) return { name: (typeof layer === "object" ? layer.name : config.layerNamespace || "css") + ".important" };
|
|
304
|
+
return layer;
|
|
305
|
+
}
|
|
306
|
+
function sheetRuleGroup(rule, config = CSS_CONFIG) {
|
|
307
|
+
if (rule.globalSheet) return "global:" + rule.globalSheet.id;
|
|
308
|
+
return rule.sheet && sheetRuleLayer(rule, config) === false ? "local-unlayered" : "regular";
|
|
309
|
+
}
|
|
310
|
+
function compareSheetGroups(a, b) {
|
|
311
|
+
const region = (rule) => rule.globalSheet ? rule.globalSheet.order <= 0 ? 0 : 2 : 1;
|
|
312
|
+
const order = region(a) - region(b);
|
|
313
|
+
if (order) return order;
|
|
314
|
+
if (a.globalSheet && b.globalSheet) return a.globalSheet.order - b.globalSheet.order;
|
|
315
|
+
return 0;
|
|
316
|
+
}
|
|
317
|
+
function compareSheetRules(a, b, config = CSS_CONFIG) {
|
|
318
|
+
const layerRank = (rule) => {
|
|
319
|
+
const layer = sheetRuleLayer(rule, config);
|
|
320
|
+
const main = config.layerNamespace || "css";
|
|
321
|
+
return layer === false ? 2 : layer === "style" || typeof layer === "object" && layer.name === main ? 0 : 1;
|
|
322
|
+
};
|
|
323
|
+
return layerRank(a) - layerRank(b) || compareLayerPriority(getSheetRulePriority(a.priority), getSheetRulePriority(b.priority));
|
|
324
|
+
}
|
|
325
|
+
/** Stable group sort: equal global orders keep the first-discovered sheet first. */
|
|
326
|
+
function orderSheetRules(rules, config = CSS_CONFIG) {
|
|
327
|
+
const groups = /* @__PURE__ */ new Map();
|
|
328
|
+
for (const rule of rules) {
|
|
329
|
+
const key = sheetRuleGroup(rule, config);
|
|
330
|
+
const group = groups.get(key) ?? [];
|
|
331
|
+
group.push(rule);
|
|
332
|
+
groups.set(key, group);
|
|
333
|
+
}
|
|
334
|
+
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)));
|
|
335
|
+
}
|
|
336
|
+
/** Reserve each parent's first child for managed important declarations. */
|
|
337
|
+
function sheetLayerOrder(names, config = CSS_CONFIG, reservedParents = names) {
|
|
338
|
+
const roots = [];
|
|
339
|
+
const children = /* @__PURE__ */ new Map();
|
|
340
|
+
const add = (name) => {
|
|
341
|
+
const parts = name.split(".");
|
|
342
|
+
if (!roots.includes(parts[0])) roots.push(parts[0]);
|
|
343
|
+
for (let i = 1; i < parts.length; i++) {
|
|
344
|
+
const parent = parts.slice(0, i).join(".");
|
|
345
|
+
const child = parts.slice(0, i + 1).join(".");
|
|
346
|
+
const list = children.get(parent) ?? [];
|
|
347
|
+
if (!list.includes(child)) list.push(child);
|
|
348
|
+
children.set(parent, list);
|
|
349
|
+
}
|
|
350
|
+
if (!name.endsWith(".important") && reservedParents.includes(name)) children.set(name, children.get(name) ?? []);
|
|
351
|
+
};
|
|
352
|
+
for (const name of [...(config.layers ?? CSS_CONFIG_DEFAULT.layers ?? []).filter((name) => name !== "$layer"), ...names]) add(name);
|
|
353
|
+
const declarations = [getLayerOrderCss((config.layers ?? CSS_CONFIG_DEFAULT.layers ?? []).map((name) => name === "$layer" ? name : name.split(".")[0]), roots)];
|
|
354
|
+
for (const [parent, list] of children) {
|
|
355
|
+
if (parent.endsWith(".important")) continue;
|
|
356
|
+
declarations.push("@layer " + [...new Set([parent + ".important", ...list])].join(", ") + ";");
|
|
357
|
+
}
|
|
358
|
+
return declarations.filter(Boolean).join("\n");
|
|
359
|
+
}
|
|
360
|
+
function layerNameForRule(rule, config, mode, pool) {
|
|
361
|
+
const layer = sheetRuleLayer(rule, config);
|
|
362
|
+
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";
|
|
363
|
+
}
|
|
364
|
+
/** Build only ordering declarations; runtime flushing need not serialize rule bodies. */
|
|
365
|
+
function sheetOrderingPreamble(rules, config = CSS_CONFIG, mode = "sort") {
|
|
366
|
+
const pool = createLayerPool(config.layerNamespace || "css");
|
|
367
|
+
const names = /* @__PURE__ */ new Set();
|
|
368
|
+
for (const rule of orderSheetRules(rules, config)) {
|
|
369
|
+
const name = layerNameForRule(rule, config, mode, pool);
|
|
370
|
+
if (name) names.add(name);
|
|
371
|
+
}
|
|
372
|
+
const priorities = pool.getNames();
|
|
373
|
+
const named = [...names].filter((name) => !priorities.includes(name));
|
|
374
|
+
return sheetLayerOrder([...priorities, ...named], config, named);
|
|
375
|
+
}
|
|
376
|
+
function serializeOrderedRules(rules, config = CSS_CONFIG, mode = "sort") {
|
|
377
|
+
const pool = createLayerPool(config.layerNamespace || "css");
|
|
378
|
+
const rendered = orderSheetRules(rules, config).map((rule) => {
|
|
379
|
+
const name = layerNameForRule(rule, config, mode, pool);
|
|
380
|
+
return name ? getLayerBlockCss(name, rule.css) : rule.css;
|
|
381
|
+
});
|
|
382
|
+
return [sheetOrderingPreamble(rules, config, mode), ...rendered].filter(Boolean).join("\n");
|
|
383
|
+
}
|
|
229
384
|
const STYLE_IMPORT_PATH = "@fluentic/style";
|
|
230
385
|
const STYLE_CSS_IMPORT_PATH = "@fluentic/style/css";
|
|
231
386
|
const STYLE_DIALECT_IMPORT_PATH = "@fluentic/style/dialect";
|
|
@@ -266,46 +421,26 @@ const DEBUG_SOURCE_CONTENT_VAR = "_styleDebugSourceContent";
|
|
|
266
421
|
//#endregion
|
|
267
422
|
//#region compiler/extract/extract.ts
|
|
268
423
|
function extractCss(items, args) {
|
|
269
|
-
return getExtractedCssItems(items, args);
|
|
270
|
-
}
|
|
271
|
-
function getExtractedCssItems(items, args) {
|
|
272
|
-
const sortedItems = items.slice().sort((a, b) => compareLayerPriority(a.priority, b.priority));
|
|
273
424
|
const seen = /* @__PURE__ */ new Set();
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
425
|
+
const unique = items.filter((item) => {
|
|
426
|
+
const key = JSON.stringify([
|
|
427
|
+
item.globalSheet?.id,
|
|
428
|
+
item.globalSheet?.order,
|
|
429
|
+
item.sheet,
|
|
430
|
+
item.layer,
|
|
431
|
+
item.importantNative,
|
|
432
|
+
item.css
|
|
433
|
+
]);
|
|
434
|
+
if (seen.has(key)) return false;
|
|
278
435
|
seen.add(key);
|
|
279
|
-
|
|
280
|
-
}
|
|
281
|
-
if (!
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
const styleItems = [];
|
|
288
|
-
const sheetItems = /* @__PURE__ */ new Map();
|
|
289
|
-
const unlayeredItems = [];
|
|
290
|
-
for (let i = 0, len = css.length; i < len; i++) {
|
|
291
|
-
const item = css[i];
|
|
292
|
-
if (item.layer === "sheet" || typeof item.layer === "object") {
|
|
293
|
-
const name = typeof item.layer === "object" ? item.layer.name : sheetLayerName;
|
|
294
|
-
const rules = sheetItems.get(name) ?? [];
|
|
295
|
-
rules.push(item.css);
|
|
296
|
-
sheetItems.set(name, rules);
|
|
297
|
-
} else if (item.layer === false || !styleLayer) unlayeredItems.push(item.css);
|
|
298
|
-
else styleItems.push(item.css);
|
|
299
|
-
}
|
|
300
|
-
const styleLayerName = [...sheetItems.keys()].some((name) => name.startsWith(layerNamespace + ".")) && layerNamespace ? layerNamespace + ".style" : layerNamespace;
|
|
301
|
-
const layerNames = [styleItems.length ? styleLayerName : "", ...sheetItems.keys()].filter(Boolean);
|
|
302
|
-
const output = [];
|
|
303
|
-
const layerOrder = getLayerOrderCss(layers, layerNames);
|
|
304
|
-
if (layerOrder) output.push(layerOrder);
|
|
305
|
-
if (styleItems.length) output.push(getLayerBlockCss(styleLayerName, "\n" + styleItems.join("\n") + "\n"));
|
|
306
|
-
for (const [name, rules] of sheetItems) output.push(getLayerBlockCss(name, "\n" + rules.join("\n") + "\n"));
|
|
307
|
-
output.push(...unlayeredItems);
|
|
308
|
-
return output.join("\n");
|
|
436
|
+
return true;
|
|
437
|
+
});
|
|
438
|
+
if (!unique.length) return "";
|
|
439
|
+
return serializeOrderedRules(unique, {
|
|
440
|
+
layer: args.layer ?? DEFAULT_CONFIG.layer ?? true,
|
|
441
|
+
layers: args.layers ?? DEFAULT_CONFIG.layers,
|
|
442
|
+
layerNamespace: args.layerNamespace ?? DEFAULT_CONFIG.layerNamespace
|
|
443
|
+
});
|
|
309
444
|
}
|
|
310
445
|
//#endregion
|
|
311
446
|
//#region compiler/transform/utils/babel.ts
|
|
@@ -332,7 +467,7 @@ function babelTransform(args) {
|
|
|
332
467
|
error.stack = void 0;
|
|
333
468
|
throw error;
|
|
334
469
|
}
|
|
335
|
-
if (!result ||
|
|
470
|
+
if (!result || result.code == null) return null;
|
|
336
471
|
return {
|
|
337
472
|
code: result.code,
|
|
338
473
|
sourcemap: result.map ? JSON.stringify(result.map) : null
|
|
@@ -456,6 +591,7 @@ const BUILDER_SCOPE_ID = symbol("builder.scopeId");
|
|
|
456
591
|
const BUILDER_SCOPE = symbol("builder.scope");
|
|
457
592
|
const BUILDER_SELECTOR = symbol("builder.selector");
|
|
458
593
|
const BUILDER_SHEET_OPTIONS = symbol("builder.sheetOptions");
|
|
594
|
+
const GLOBAL_SHEET_SELECTOR_ANCHOR = "\0global";
|
|
459
595
|
const SHEET_SELECTOR_ANCHOR = "\0sheet";
|
|
460
596
|
//#endregion
|
|
461
597
|
//#region utils/object.ts
|
|
@@ -569,7 +705,7 @@ function createStackFrameLine(frame) {
|
|
|
569
705
|
}
|
|
570
706
|
function isInternalCallsite(filePath) {
|
|
571
707
|
const normalized = filePath.replace(/\\/g, "/");
|
|
572
|
-
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.");
|
|
708
|
+
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.");
|
|
573
709
|
}
|
|
574
710
|
function traceError(message, options = {}) {
|
|
575
711
|
const error = new Error(message || "");
|
|
@@ -1320,7 +1456,9 @@ function getIdentifierSafeHashValue(hash) {
|
|
|
1320
1456
|
//#endregion
|
|
1321
1457
|
//#region atomic/utils/selector.ts
|
|
1322
1458
|
function getSelectorText$1(selector) {
|
|
1323
|
-
|
|
1459
|
+
const text = Array.isArray(selector) ? selector[0] : selector;
|
|
1460
|
+
if (text.startsWith("\0global")) return text.slice(text.indexOf("\0", 7) + 1);
|
|
1461
|
+
return stripSheetSelectorAnchor(text);
|
|
1324
1462
|
}
|
|
1325
1463
|
function getSelectorHash(selector) {
|
|
1326
1464
|
return Array.isArray(selector) ? selector.join("|") : selector;
|
|
@@ -1332,14 +1470,15 @@ function getSelectorPriority$1(selector) {
|
|
|
1332
1470
|
function hasSheetSelectorAnchor(selector) {
|
|
1333
1471
|
return (selector ? Array.isArray(selector) ? selector[0] : selector : "").startsWith(SHEET_SELECTOR_ANCHOR);
|
|
1334
1472
|
}
|
|
1335
|
-
function
|
|
1473
|
+
function getSheetSelectorSpecificity(selector) {
|
|
1336
1474
|
const text = selector ? Array.isArray(selector) ? selector[0] : selector : "";
|
|
1337
1475
|
if (!text.startsWith("\0sheet:")) return null;
|
|
1338
1476
|
const end = text.indexOf("\0", 6);
|
|
1339
1477
|
if (end < 0) return null;
|
|
1340
1478
|
const [weightValue] = text.slice(7, end).split(":");
|
|
1479
|
+
if (!weightValue) return null;
|
|
1341
1480
|
const weight = Number(weightValue);
|
|
1342
|
-
return Number.isInteger(weight) && weight
|
|
1481
|
+
return Number.isInteger(weight) && weight >= 0 ? weight : null;
|
|
1343
1482
|
}
|
|
1344
1483
|
function stripSheetSelectorAnchor(selector) {
|
|
1345
1484
|
if (!selector.startsWith("\0sheet")) return selector;
|
|
@@ -1349,12 +1488,16 @@ function stripSheetSelectorAnchor(selector) {
|
|
|
1349
1488
|
}
|
|
1350
1489
|
return selector.slice(6);
|
|
1351
1490
|
}
|
|
1491
|
+
function hasGlobalSheetSelectorAnchor(selector) {
|
|
1492
|
+
return (selector ? Array.isArray(selector) ? selector[0] : selector : "").startsWith(GLOBAL_SHEET_SELECTOR_ANCHOR);
|
|
1493
|
+
}
|
|
1352
1494
|
//#endregion
|
|
1353
1495
|
//#region atomic/className.ts
|
|
1354
|
-
function getAtomicClassName(property, priority, important, value, selector, parentSelector, atRule, callsite, localClassName, debugClassName, classNameFormat, transformClassName, transformClassNameFormat, sheetClassNameFormat = null, hashLength = null) {
|
|
1496
|
+
function getAtomicClassName(property, priority, important, value, selector, parentSelector, atRule, callsite, localClassName, debugClassName, classNameFormat, transformClassName, transformClassNameFormat, sheetClassNameFormat = null, hashLength = null, importantNative = false) {
|
|
1355
1497
|
let hash = property;
|
|
1356
1498
|
hash += "\n" + (priority || "");
|
|
1357
1499
|
if (important) hash += "\nimportant";
|
|
1500
|
+
if (importantNative) hash += "\nnative-important";
|
|
1358
1501
|
hash += "\n" + value;
|
|
1359
1502
|
hash += "\n" + (selector ? getSelectorHash(selector) : "");
|
|
1360
1503
|
hash += "\n" + (parentSelector ? getSelectorHash(parentSelector) : "");
|
|
@@ -1385,10 +1528,11 @@ function getClassNameHashLength(options) {
|
|
|
1385
1528
|
if (options.debugClassName && options.isDev) return options.devHashLength ?? options.cssHashLength ?? 5;
|
|
1386
1529
|
return options.cssHashLength ?? 7;
|
|
1387
1530
|
}
|
|
1388
|
-
function getClassNameDedupe(property, priority, important, selector, parentSelector, atRule) {
|
|
1531
|
+
function getClassNameDedupe(property, priority, important, selector, parentSelector, atRule, importantNative = false) {
|
|
1389
1532
|
let hash = property;
|
|
1390
1533
|
hash += "\n" + (priority || "");
|
|
1391
1534
|
if (important) hash += "\nimportant";
|
|
1535
|
+
if (importantNative) hash += "\nnative-important";
|
|
1392
1536
|
hash += "\n" + (selector ? getSelectorHash(selector) : "");
|
|
1393
1537
|
hash += "\n" + (parentSelector ? getSelectorHash(parentSelector) : "");
|
|
1394
1538
|
hash += "\n" + (atRule ? atRule.map(getSelectorHash).join("\n") : "");
|
|
@@ -1468,8 +1612,8 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1468
1612
|
value = scopeItem.value;
|
|
1469
1613
|
weight = scopeItem.weight;
|
|
1470
1614
|
important = scopeItem.important;
|
|
1471
|
-
dedupe = getClassNameDedupe(scopeItem.property, weight, important, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule);
|
|
1472
|
-
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);
|
|
1615
|
+
dedupe = getClassNameDedupe(scopeItem.property, weight, important, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule, scopeItem.importantNative);
|
|
1616
|
+
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);
|
|
1473
1617
|
scopeItem.dedupe = dedupe;
|
|
1474
1618
|
scopeItem.className = className;
|
|
1475
1619
|
scopeItem.callsite = itemCallsite;
|
|
@@ -1508,6 +1652,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1508
1652
|
property: overrideItem.property,
|
|
1509
1653
|
weight: overrideItem.weight,
|
|
1510
1654
|
important: overrideItem.important,
|
|
1655
|
+
importantNative: overrideItem.importantNative,
|
|
1511
1656
|
value: overrideItem.value,
|
|
1512
1657
|
transformClassName: overrideItem.transformClassName,
|
|
1513
1658
|
token: overrideItem.token,
|
|
@@ -1521,8 +1666,8 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1521
1666
|
value = scopeItem.value;
|
|
1522
1667
|
weight = scopeItem.weight;
|
|
1523
1668
|
important = scopeItem.important;
|
|
1524
|
-
dedupe = getClassNameDedupe(scopeItem.property, weight, important, scopeItem.selector, parentSelector, scopeItem.atRule);
|
|
1525
|
-
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);
|
|
1669
|
+
dedupe = getClassNameDedupe(scopeItem.property, weight, important, scopeItem.selector, parentSelector, scopeItem.atRule, scopeItem.importantNative);
|
|
1670
|
+
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);
|
|
1526
1671
|
scopeItem.dedupe = dedupe;
|
|
1527
1672
|
scopeItem.className = className;
|
|
1528
1673
|
const lookupKey = getScopeLookupKey(slotId, dedupe);
|
|
@@ -1682,10 +1827,11 @@ function shouldAppendCssPx(property) {
|
|
|
1682
1827
|
//#endregion
|
|
1683
1828
|
//#region style/important.ts
|
|
1684
1829
|
const STYLE_IMPORTANT = symbol("style.important");
|
|
1685
|
-
function importantValue(value) {
|
|
1830
|
+
function importantValue(value, native = false) {
|
|
1686
1831
|
return {
|
|
1687
1832
|
[STYLE_IMPORTANT]: true,
|
|
1688
|
-
value
|
|
1833
|
+
value,
|
|
1834
|
+
native
|
|
1689
1835
|
};
|
|
1690
1836
|
}
|
|
1691
1837
|
function isStyleImportantValue(value) {
|
|
@@ -1742,6 +1888,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1742
1888
|
let value;
|
|
1743
1889
|
let weight;
|
|
1744
1890
|
let important;
|
|
1891
|
+
let importantNative;
|
|
1745
1892
|
let itemCallsite;
|
|
1746
1893
|
let className;
|
|
1747
1894
|
let dedupe;
|
|
@@ -1783,7 +1930,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1783
1930
|
}
|
|
1784
1931
|
} else for (const property in style) {
|
|
1785
1932
|
valueRaw = style[property];
|
|
1786
|
-
[valueRaw, weight, important] = unwrapAuthoredStyleValue(valueRaw);
|
|
1933
|
+
[valueRaw, weight, important, importantNative] = unwrapAuthoredStyleValue(valueRaw);
|
|
1787
1934
|
const sourceType = source[BUILDER_TYPE];
|
|
1788
1935
|
checkImportantUsage(valueRaw, important, sourceType === 9 || sourceType === 8);
|
|
1789
1936
|
transformClassName = null;
|
|
@@ -1806,6 +1953,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1806
1953
|
property,
|
|
1807
1954
|
weight,
|
|
1808
1955
|
important,
|
|
1956
|
+
importantNative,
|
|
1809
1957
|
value,
|
|
1810
1958
|
transformClassName,
|
|
1811
1959
|
variable: ref ? [3, ref] : variableName && token ? [
|
|
@@ -1868,8 +2016,8 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1868
2016
|
value = runtimeItem.value;
|
|
1869
2017
|
weight = runtimeItem.weight;
|
|
1870
2018
|
important = runtimeItem.important;
|
|
1871
|
-
dedupe = getClassNameDedupe(runtimeItem.property, weight, important, runtimeItem.selector, null, runtimeItem.atRule);
|
|
1872
|
-
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);
|
|
2019
|
+
dedupe = getClassNameDedupe(runtimeItem.property, weight, important, runtimeItem.selector, null, runtimeItem.atRule, runtimeItem.importantNative);
|
|
2020
|
+
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);
|
|
1873
2021
|
runtimeItem.dedupe = dedupe;
|
|
1874
2022
|
runtimeItem.className = className;
|
|
1875
2023
|
lookupIndex = lookup[dedupe];
|
|
@@ -1881,9 +2029,11 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1881
2029
|
function unwrapAuthoredStyleValue(value) {
|
|
1882
2030
|
let weight = null;
|
|
1883
2031
|
let important = false;
|
|
2032
|
+
let native = false;
|
|
1884
2033
|
while (true) {
|
|
1885
2034
|
if (isStyleImportantValue(value)) {
|
|
1886
2035
|
important = true;
|
|
2036
|
+
native ||= value.native === true;
|
|
1887
2037
|
value = value.value;
|
|
1888
2038
|
continue;
|
|
1889
2039
|
}
|
|
@@ -1897,7 +2047,8 @@ function unwrapAuthoredStyleValue(value) {
|
|
|
1897
2047
|
return [
|
|
1898
2048
|
value,
|
|
1899
2049
|
weight,
|
|
1900
|
-
important
|
|
2050
|
+
important,
|
|
2051
|
+
native
|
|
1901
2052
|
];
|
|
1902
2053
|
}
|
|
1903
2054
|
function checkImportantUsage(value, important, isSheet) {
|
|
@@ -1983,9 +2134,9 @@ function assertManualSelectorSyntax(selector) {
|
|
|
1983
2134
|
if (ampersandIndex === 0 && ampersandSelector && /^\s/.test(ampersandSelector)) throw new Error("selector cannot have whitespace after \"&\"; omit \"&\" for descendant selectors");
|
|
1984
2135
|
}
|
|
1985
2136
|
function setSheetSelectorOptions(selector, options) {
|
|
1986
|
-
if (options.
|
|
2137
|
+
if (options.specificity === void 0 && options.layer === void 0) return selector;
|
|
1987
2138
|
const text = Array.isArray(selector) ? selector[0] : selector;
|
|
1988
|
-
const weighted = SHEET_SELECTOR_ANCHOR + (":" + (options.
|
|
2139
|
+
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);
|
|
1989
2140
|
return Array.isArray(selector) ? [weighted, selector[1]] : weighted;
|
|
1990
2141
|
}
|
|
1991
2142
|
function normalizeManualSelector(selector, assertManualSelector) {
|
|
@@ -1997,6 +2148,13 @@ function normalizeManualSelector(selector, assertManualSelector) {
|
|
|
1997
2148
|
}
|
|
1998
2149
|
return [SHEET_SELECTOR_ANCHOR + (value.startsWith("&") ? value.slice(1) : " " + value)];
|
|
1999
2150
|
}
|
|
2151
|
+
/** Convert a normalized explicit selector into an unscoped sheet selector. */
|
|
2152
|
+
function setGlobalSheetSelectorOptions(selector, options) {
|
|
2153
|
+
const suffix = (Array.isArray(selector) ? selector[0] : selector).slice(6);
|
|
2154
|
+
if (!suffix.startsWith(" ") || !suffix.trim()) throw new Error("createGlobalSheet requires explicit selectors without an ampersand anchor");
|
|
2155
|
+
const global = GLOBAL_SHEET_SELECTOR_ANCHOR + JSON.stringify(options.layer ?? null) + "\0" + suffix.trimStart();
|
|
2156
|
+
return Array.isArray(selector) ? [global, selector[1]] : global;
|
|
2157
|
+
}
|
|
2000
2158
|
//#endregion
|
|
2001
2159
|
//#region builder/selector_override.ts
|
|
2002
2160
|
function normalizeManualSelectors(input) {
|
|
@@ -3022,63 +3180,19 @@ function buildFontPaletteValuesCss(format, name, id, descriptors, tokens, tokenL
|
|
|
3022
3180
|
};
|
|
3023
3181
|
}
|
|
3024
3182
|
createIdCounter("fontPaletteValues");
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
const KEYFRAMES_AT_RULE = "keyframes";
|
|
3028
|
-
const formatKeyFramesName = createAtRuleNameFormatter("keyframes[-(name)]-$hash");
|
|
3029
|
-
function buildKeyframesCss(format, name, id, frames, tokens, tokenLookup, tokenNameFormat) {
|
|
3030
|
-
name = formatKeyFramesName(format, id, { name });
|
|
3031
|
-
let css = `@${KEYFRAMES_AT_RULE} ${name} {`;
|
|
3032
|
-
for (const selector in frames) {
|
|
3033
|
-
const frame = frames[selector];
|
|
3034
|
-
if (!frame) continue;
|
|
3035
|
-
css += selector + "{";
|
|
3036
|
-
css += buildAtRuleDeclarationCss(frame, tokens, tokenLookup, tokenNameFormat, false);
|
|
3037
|
-
css += "}";
|
|
3038
|
-
}
|
|
3039
|
-
css += "}";
|
|
3040
|
-
return {
|
|
3041
|
-
name,
|
|
3042
|
-
css
|
|
3043
|
-
};
|
|
3183
|
+
function appendStyleTag(document, tag) {
|
|
3184
|
+
(document.head || document.getElementsByTagName("head")[0] || document.documentElement).appendChild(tag);
|
|
3044
3185
|
}
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
idCounter: idCounter$2,
|
|
3054
|
-
stableId
|
|
3055
|
-
});
|
|
3056
|
-
}
|
|
3057
|
-
//#endregion
|
|
3058
|
-
//#region atomic/atRule/positionTry.ts
|
|
3059
|
-
const POSITION_TRY_AT_RULE = "position-try";
|
|
3060
|
-
const formatPositionTryName = createAtRuleNameFormatter("position-try[-(name)]-$hash", "--");
|
|
3061
|
-
function buildPositionTryCss(format, name, id, descriptors, tokens, tokenLookup, tokenNameFormat) {
|
|
3062
|
-
name = formatPositionTryName(format, id, { name });
|
|
3063
|
-
const css = buildNamedAtRuleCss(POSITION_TRY_AT_RULE, name, descriptors, tokens, tokenLookup, tokenNameFormat);
|
|
3064
|
-
return {
|
|
3065
|
-
name,
|
|
3066
|
-
css
|
|
3067
|
-
};
|
|
3068
|
-
}
|
|
3069
|
-
createIdCounter("positionTry");
|
|
3070
|
-
//#endregion
|
|
3071
|
-
//#region atomic/atRule/property.ts
|
|
3072
|
-
const PROPERTY_AT_RULE = "property";
|
|
3073
|
-
const formatPropertyName = createAtRuleNameFormatter("[-(name)]-$hash", "--");
|
|
3074
|
-
function buildPropertyCss(format, name, id, descriptors, tokens, tokenLookup, tokenNameFormat) {
|
|
3075
|
-
name = formatPropertyName(format, id, { name });
|
|
3076
|
-
return {
|
|
3077
|
-
css: buildNamedAtRuleCss(PROPERTY_AT_RULE, name, descriptors, tokens, tokenLookup, tokenNameFormat),
|
|
3078
|
-
name
|
|
3079
|
-
};
|
|
3186
|
+
function getFirstCssSheetTag(head) {
|
|
3187
|
+
const nodes = head.childNodes;
|
|
3188
|
+
for (let i = 0, len = nodes.length; i < len; i++) {
|
|
3189
|
+
const node = nodes[i];
|
|
3190
|
+
if (typeof node.getAttribute !== "function") continue;
|
|
3191
|
+
if (node.getAttribute("data-css-sheet")) return node;
|
|
3192
|
+
}
|
|
3193
|
+
return null;
|
|
3080
3194
|
}
|
|
3081
|
-
|
|
3195
|
+
globalData("sheet.ordered.refreshers", () => /* @__PURE__ */ new Set());
|
|
3082
3196
|
//#endregion
|
|
3083
3197
|
//#region sheet/utils/sourcemap.ts
|
|
3084
3198
|
const VLQ_BASE_SHIFT = 5;
|
|
@@ -3087,6 +3201,45 @@ const VLQ_BASE_MASK = VLQ_BASE - 1;
|
|
|
3087
3201
|
const VLQ_CONTINUATION_BIT = VLQ_BASE;
|
|
3088
3202
|
const BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
3089
3203
|
const SOURCE_URL_PREFIX = "source://";
|
|
3204
|
+
function createSourceMapComment$1(rules) {
|
|
3205
|
+
const sources = [];
|
|
3206
|
+
const sourceLookup = Object.create(null);
|
|
3207
|
+
let generatedLine = 0;
|
|
3208
|
+
let previousSource = 0;
|
|
3209
|
+
let previousOriginalLine = 0;
|
|
3210
|
+
let previousOriginalColumn = 0;
|
|
3211
|
+
const mappingLines = [];
|
|
3212
|
+
for (let i = 0, len = rules.length; i < len; i++) {
|
|
3213
|
+
const rule = rules[i];
|
|
3214
|
+
const sourceData = rule.source;
|
|
3215
|
+
let mapping = "";
|
|
3216
|
+
if (sourceData) {
|
|
3217
|
+
const source = getSource(sources, sourceLookup, getSourceMapSourceUrl(sourceData), sourceData.sourceContent);
|
|
3218
|
+
const originalLine = Math.max(sourceData.line - 1, 0);
|
|
3219
|
+
const originalColumn = Math.max(sourceData.column - 1, 0);
|
|
3220
|
+
mapping += encodeVlq(0);
|
|
3221
|
+
mapping += encodeVlq(source.sourceIndex - previousSource);
|
|
3222
|
+
mapping += encodeVlq(originalLine - previousOriginalLine);
|
|
3223
|
+
mapping += encodeVlq(originalColumn - previousOriginalColumn);
|
|
3224
|
+
previousSource = source.sourceIndex;
|
|
3225
|
+
previousOriginalLine = originalLine;
|
|
3226
|
+
previousOriginalColumn = originalColumn;
|
|
3227
|
+
}
|
|
3228
|
+
mappingLines[generatedLine] = mapping;
|
|
3229
|
+
const lineCount = getLineCount(rule.css);
|
|
3230
|
+
for (let j = 1; j < lineCount; j++) mappingLines[generatedLine + j] = "";
|
|
3231
|
+
generatedLine += lineCount;
|
|
3232
|
+
}
|
|
3233
|
+
if (!sources.length) return "";
|
|
3234
|
+
const data = {
|
|
3235
|
+
version: 3,
|
|
3236
|
+
sources: sources.map((source) => source.filePath),
|
|
3237
|
+
sourcesContent: sources.some((source) => source.sourceContent !== void 0) ? sources.map((source) => source.sourceContent ?? null) : void 0,
|
|
3238
|
+
names: [],
|
|
3239
|
+
mappings: mappingLines.join(";")
|
|
3240
|
+
};
|
|
3241
|
+
return "/*# sourceMappingURL=data:application/json;charset=utf-8;base64," + encodeBase64(JSON.stringify(data)) + " */";
|
|
3242
|
+
}
|
|
3090
3243
|
function encodeBase64(text) {
|
|
3091
3244
|
const bytes = new TextEncoder().encode(text);
|
|
3092
3245
|
let binary = "";
|
|
@@ -3187,8 +3340,21 @@ function normalizeRuleCallsite(callsite) {
|
|
|
3187
3340
|
sourceUrl: callsite.sourceUrl ? normalizeCallsiteSourceUrl(callsite.sourceUrl) : callsite.sourceUrl
|
|
3188
3341
|
};
|
|
3189
3342
|
}
|
|
3343
|
+
function getSourcemapRuleCallsite(rule) {
|
|
3344
|
+
return getRuleCallsite(rule.callsite, rule.debug, rule.debugField);
|
|
3345
|
+
}
|
|
3190
3346
|
globalData("sheet.dev.sourcemapTags", () => []);
|
|
3191
3347
|
globalData("sheet.dev.sheets", () => /* @__PURE__ */ new Set());
|
|
3348
|
+
//#endregion
|
|
3349
|
+
//#region runtime/sheet/document.ts
|
|
3350
|
+
const GLOBAL_KEY = "runtime.sheet.global";
|
|
3351
|
+
const state = globalData("runtime.sheet.document", () => ({ document: getRuntimeDocument() }));
|
|
3352
|
+
function resetSheet() {
|
|
3353
|
+
getGlobalData(GLOBAL_KEY)?.destroy?.();
|
|
3354
|
+
clearGlobalData(GLOBAL_KEY);
|
|
3355
|
+
state.document = getRuntimeDocument();
|
|
3356
|
+
}
|
|
3357
|
+
onRuntimeDocumentChange(resetSheet);
|
|
3192
3358
|
globalData("runtime.combinedStyle.targets", () => /* @__PURE__ */ new WeakMap());
|
|
3193
3359
|
//#endregion
|
|
3194
3360
|
//#region runtime/core/cache/resolvedItem.ts
|
|
@@ -3486,10 +3652,10 @@ function buildAtomicRule(className, property, value, important, selector, parent
|
|
|
3486
3652
|
const cssProp = getCssPropertyName(property);
|
|
3487
3653
|
const cssValue = getCssPropertyValue(property, value) + (important ? " !important" : "");
|
|
3488
3654
|
const escapedClass = escapeCssIdent(className);
|
|
3489
|
-
const
|
|
3490
|
-
const classSelector =
|
|
3655
|
+
const specificity = hasSheetSelectorAnchor(selector) ? getSheetSelectorSpecificity(selector) ?? 1 : 1;
|
|
3656
|
+
const classSelector = specificity === 0 ? `:where(.${escapedClass})` : Array(specificity).fill("." + escapedClass).join("");
|
|
3491
3657
|
const itemSelector = selector ? getSelectorText$1(selector) : "";
|
|
3492
|
-
let selectorStr = classSelector + itemSelector;
|
|
3658
|
+
let selectorStr = hasGlobalSheetSelectorAnchor(selector) ? itemSelector : classSelector + itemSelector;
|
|
3493
3659
|
if (parentSelector) {
|
|
3494
3660
|
const parentWhere = `:where(${"." + escapeCssIdent(getScopeClassName(className, scopeClassNameFormat)) + getSelectorText$1(parentSelector)})`;
|
|
3495
3661
|
selectorStr = classSelector + parentWhere + itemSelector + "," + parentWhere + " " + selectorStr;
|
|
@@ -3569,8 +3735,71 @@ function stripGenericThemePrefix(value) {
|
|
|
3569
3735
|
function isGeneratedNameHash(value) {
|
|
3570
3736
|
return /^[a-z0-9]{7}$/.test(value) && /\d/.test(value);
|
|
3571
3737
|
}
|
|
3738
|
+
//#endregion
|
|
3739
|
+
//#region atomic/atRule/keyframes.ts
|
|
3740
|
+
const KEYFRAMES_AT_RULE = "keyframes";
|
|
3741
|
+
const formatKeyFramesName = createAtRuleNameFormatter("keyframes[-(name)]-$hash");
|
|
3742
|
+
function buildKeyframesCss(format, name, id, frames, tokens, tokenLookup, tokenNameFormat) {
|
|
3743
|
+
name = formatKeyFramesName(format, id, { name });
|
|
3744
|
+
let css = `@${KEYFRAMES_AT_RULE} ${name} {`;
|
|
3745
|
+
for (const selector in frames) {
|
|
3746
|
+
const frame = frames[selector];
|
|
3747
|
+
if (!frame) continue;
|
|
3748
|
+
css += selector + "{";
|
|
3749
|
+
css += buildAtRuleDeclarationCss(frame, tokens, tokenLookup, tokenNameFormat, false);
|
|
3750
|
+
css += "}";
|
|
3751
|
+
}
|
|
3752
|
+
css += "}";
|
|
3753
|
+
return {
|
|
3754
|
+
name,
|
|
3755
|
+
css
|
|
3756
|
+
};
|
|
3757
|
+
}
|
|
3758
|
+
//#endregion
|
|
3759
|
+
//#region css/keyframes.ts
|
|
3760
|
+
const idCounter$2 = createIdCounter("keyframes");
|
|
3761
|
+
function createKeyframes(frames, stableId) {
|
|
3762
|
+
return createNamedAtRuleRef({
|
|
3763
|
+
format: CSS_EXTRA_CONFIG.namedRuleFormat.keyframes,
|
|
3764
|
+
buildCss: buildKeyframesCss,
|
|
3765
|
+
value: frames,
|
|
3766
|
+
idCounter: idCounter$2,
|
|
3767
|
+
stableId
|
|
3768
|
+
});
|
|
3769
|
+
}
|
|
3770
|
+
//#endregion
|
|
3771
|
+
//#region atomic/atRule/positionTry.ts
|
|
3772
|
+
const POSITION_TRY_AT_RULE = "position-try";
|
|
3773
|
+
const formatPositionTryName = createAtRuleNameFormatter("position-try[-(name)]-$hash", "--");
|
|
3774
|
+
function buildPositionTryCss(format, name, id, descriptors, tokens, tokenLookup, tokenNameFormat) {
|
|
3775
|
+
name = formatPositionTryName(format, id, { name });
|
|
3776
|
+
const css = buildNamedAtRuleCss(POSITION_TRY_AT_RULE, name, descriptors, tokens, tokenLookup, tokenNameFormat);
|
|
3777
|
+
return {
|
|
3778
|
+
name,
|
|
3779
|
+
css
|
|
3780
|
+
};
|
|
3781
|
+
}
|
|
3782
|
+
createIdCounter("positionTry");
|
|
3783
|
+
//#endregion
|
|
3784
|
+
//#region atomic/atRule/property.ts
|
|
3785
|
+
const PROPERTY_AT_RULE = "property";
|
|
3786
|
+
const formatPropertyName = createAtRuleNameFormatter("[-(name)]-$hash", "--");
|
|
3787
|
+
function buildPropertyCss(format, name, id, descriptors, tokens, tokenLookup, tokenNameFormat) {
|
|
3788
|
+
name = formatPropertyName(format, id, { name });
|
|
3789
|
+
return {
|
|
3790
|
+
css: buildNamedAtRuleCss(PROPERTY_AT_RULE, name, descriptors, tokens, tokenLookup, tokenNameFormat),
|
|
3791
|
+
name
|
|
3792
|
+
};
|
|
3793
|
+
}
|
|
3794
|
+
createIdCounter("property");
|
|
3572
3795
|
createNameFormatter(["name"]);
|
|
3573
|
-
|
|
3796
|
+
//#endregion
|
|
3797
|
+
//#region runtime/core/elementMarker.ts
|
|
3798
|
+
const ELEMENT_MARKER_SHEET = globalData("runtime.elementMarkerSheet", () => ({ sheet: null }));
|
|
3799
|
+
onRuntimeDocumentChange(() => {
|
|
3800
|
+
ELEMENT_MARKER_SHEET.sheet?.sheet.destroy?.();
|
|
3801
|
+
ELEMENT_MARKER_SHEET.sheet = null;
|
|
3802
|
+
});
|
|
3574
3803
|
//#endregion
|
|
3575
3804
|
//#region style/keyframes.ts
|
|
3576
3805
|
function transformKeyframes(frames, transform) {
|
|
@@ -3602,7 +3831,7 @@ function createStyleFn(args) {
|
|
|
3602
3831
|
const fnWeight = (value, weight) => {
|
|
3603
3832
|
return weightValue(value, weight);
|
|
3604
3833
|
};
|
|
3605
|
-
const fnImportant = (value) => importantValue(value);
|
|
3834
|
+
const fnImportant = (value, native) => importantValue(value, native);
|
|
3606
3835
|
const fnRaw = (style) => style;
|
|
3607
3836
|
const fnPlain = (style) => style;
|
|
3608
3837
|
const fnKeyframes = ((frames, stableId) => createStyleKeyframes(frames, transform ?? null, stableId));
|
|
@@ -4360,7 +4589,10 @@ function evaluateCall(node, scope) {
|
|
|
4360
4589
|
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)) {
|
|
4361
4590
|
const value = evaluateNode(node.arguments[0], scope);
|
|
4362
4591
|
if (!value.ok) return value;
|
|
4363
|
-
|
|
4592
|
+
const native = node.arguments[1] ? evaluateNode(node.arguments[1], scope) : evalOk(false);
|
|
4593
|
+
if (!native.ok) return native;
|
|
4594
|
+
if (typeof native.value !== "boolean") return evalFail("style.important second argument must be a boolean");
|
|
4595
|
+
return evalOk(importantValue(value.value, native.value));
|
|
4364
4596
|
}
|
|
4365
4597
|
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);
|
|
4366
4598
|
return evalFail(`Cannot statically evaluate: ${node.type}`);
|
|
@@ -5090,6 +5322,15 @@ function createDebugPlugin(args) {
|
|
|
5090
5322
|
});
|
|
5091
5323
|
},
|
|
5092
5324
|
CallExpression(path, state) {
|
|
5325
|
+
if (path.node.callee.type === "Identifier") {
|
|
5326
|
+
const imported = state.imports.get(path.node.callee.name);
|
|
5327
|
+
if (imported?.source === "@fluentic/style/css" && imported.name === "createGlobalSheet" && !hasDebugArgument(path.node.arguments)) {
|
|
5328
|
+
const debug = buildDebugDataObject(t, path.node, state.fileId, getSourceUrlId(t, state), sourceContent ? getSourceContentId(t, state) : null);
|
|
5329
|
+
if (!path.getFunctionParent()) debug.properties.push(t.objectProperty(t.identifier("globalModule"), t.stringLiteral(state.filePath)));
|
|
5330
|
+
if (!path.node.arguments.length) path.node.arguments.push(t.arrayExpression([]));
|
|
5331
|
+
path.node.arguments.push(debug);
|
|
5332
|
+
}
|
|
5333
|
+
}
|
|
5093
5334
|
annotateThemeCall(path.node, state, t);
|
|
5094
5335
|
annotateThemeCallsite(t, path, state, sourceContent);
|
|
5095
5336
|
if (!state.styleNames.size) return;
|
|
@@ -6004,12 +6245,23 @@ function compileSheetChain(chain, fileId, scope, cssConfig, options) {
|
|
|
6004
6245
|
const items = [];
|
|
6005
6246
|
const rules = [];
|
|
6006
6247
|
const hasOptions = chain.baseArgs.length === 2;
|
|
6007
|
-
const sheetOptions = hasOptions ? evaluateCreateSheetOptions(chain.baseArgs[0], scope) : {};
|
|
6248
|
+
const sheetOptions = hasOptions ? evaluateCreateSheetOptions(chain.baseArgs[0], scope, chain.global) : {};
|
|
6008
6249
|
if (!sheetOptions) return null;
|
|
6250
|
+
if (chain.global) {
|
|
6251
|
+
if (sheetOptions.specificity !== void 0) throw new Error("createGlobalSheet does not support specificity");
|
|
6252
|
+
sheetOptions.global = true;
|
|
6253
|
+
}
|
|
6009
6254
|
const sheetItems = chain.baseArgs[hasOptions ? 1 : 0];
|
|
6010
6255
|
if (sheetItems && !compileSheetItemsArg(sheetItems, fileId, scope, cssConfig, options, items, rules, sheetOptions)) return null;
|
|
6011
|
-
const sheetLayer = sheetOptions.layer ??
|
|
6012
|
-
for (let i = 0, len = rules.length; i < len; i++)
|
|
6256
|
+
const sheetLayer = sheetOptions.layer ?? false;
|
|
6257
|
+
for (let i = 0, len = rules.length; i < len; i++) {
|
|
6258
|
+
rules[i].layer = resolveSheetLayerOption(sheetLayer, options.css?.layerNamespace ?? DEFAULT_CONFIG.layerNamespace ?? "", isStyleLayerEnabled(options.css?.layer ?? DEFAULT_CONFIG.layer));
|
|
6259
|
+
rules[i].sheet = true;
|
|
6260
|
+
if (chain.global) rules[i].globalSheet = {
|
|
6261
|
+
id: chain.sheetId ?? fileId,
|
|
6262
|
+
order: sheetOptions.order ?? 0
|
|
6263
|
+
};
|
|
6264
|
+
}
|
|
6013
6265
|
return {
|
|
6014
6266
|
type: "sheet",
|
|
6015
6267
|
items,
|
|
@@ -6017,17 +6269,17 @@ function compileSheetChain(chain, fileId, scope, cssConfig, options) {
|
|
|
6017
6269
|
sheetOptions
|
|
6018
6270
|
};
|
|
6019
6271
|
}
|
|
6020
|
-
function evaluateCreateSheetOptions(node, scope) {
|
|
6272
|
+
function evaluateCreateSheetOptions(node, scope, global = false) {
|
|
6021
6273
|
const result = evaluateNode(node, scope);
|
|
6022
6274
|
if (!result.ok || !result.value || typeof result.value !== "object" || Array.isArray(result.value)) return null;
|
|
6023
6275
|
const value = result.value;
|
|
6024
|
-
if (
|
|
6025
|
-
|
|
6026
|
-
if (value.
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6276
|
+
if (hasGlobalRuntimeValue(value)) return null;
|
|
6277
|
+
const allowed = global ? ["layer", "order"] : ["layer", "specificity"];
|
|
6278
|
+
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");
|
|
6279
|
+
if (!isSheetLayerOption(value.layer)) throw new Error("invalid sheet layer");
|
|
6280
|
+
if (value.specificity !== void 0 && (!Number.isInteger(value.specificity) || value.specificity < 0)) throw new Error("specificity must be a non-negative integer");
|
|
6281
|
+
if (value.order !== void 0 && (typeof value.order !== "number" || !Number.isFinite(value.order))) throw new Error("order must be a finite number");
|
|
6282
|
+
return value;
|
|
6031
6283
|
}
|
|
6032
6284
|
function compileSheetItemsArg(node, fileId, scope, cssConfig, options, items, rules, sheetOptions) {
|
|
6033
6285
|
if (node.type === "ArrayExpression") {
|
|
@@ -6039,7 +6291,9 @@ function compileSheetItemsArg(node, fileId, scope, cssConfig, options, items, ru
|
|
|
6039
6291
|
return true;
|
|
6040
6292
|
}
|
|
6041
6293
|
const tokenOverride = evaluateNode(node, scope);
|
|
6294
|
+
if (tokenOverride.ok && !tokenOverride.value) return true;
|
|
6042
6295
|
if (tokenOverride.ok && isStyleTokenOverrideData(tokenOverride.value)) {
|
|
6296
|
+
if (sheetOptions.global) throw new Error("createGlobalSheet requires token overrides inside an explicit selector");
|
|
6043
6297
|
addCompiledTokenItem(getStyleTokenId(tokenOverride.value), tokenOverride.value, getCompiledRuntimeValue(tokenOverride.value) ?? node, items);
|
|
6044
6298
|
return true;
|
|
6045
6299
|
}
|
|
@@ -6048,6 +6302,7 @@ function compileSheetItemsArg(node, fileId, scope, cssConfig, options, items, ru
|
|
|
6048
6302
|
const item = tokenOverride.value[i];
|
|
6049
6303
|
if (!item) continue;
|
|
6050
6304
|
if (!isStyleTokenOverrideData(item)) return false;
|
|
6305
|
+
if (sheetOptions.global) throw new Error("createGlobalSheet requires token overrides inside an explicit selector");
|
|
6051
6306
|
addCompiledTokenItem(getStyleTokenId(item), item, getCompiledRuntimeValue(item) ?? null, items);
|
|
6052
6307
|
}
|
|
6053
6308
|
return true;
|
|
@@ -6061,10 +6316,16 @@ function compileSheetItemsArg(node, fileId, scope, cssConfig, options, items, ru
|
|
|
6061
6316
|
}
|
|
6062
6317
|
function compileSelectorOverrideChain(chain, selectors, fileId, scope, cssConfig, transform, styleNames, options, items, rules, sheetOptions) {
|
|
6063
6318
|
if (chain.baseArgs.length === 0 || chain.baseArgs.length > 2) return false;
|
|
6319
|
+
if (sheetOptions.global) {
|
|
6320
|
+
if ([...chain.baseArgs, ...chain.methods.flatMap((method) => method.args)].some((arg) => {
|
|
6321
|
+
const result = evaluateNode(arg, scope);
|
|
6322
|
+
return !result.ok || hasGlobalRuntimeValue(result.value);
|
|
6323
|
+
})) return false;
|
|
6324
|
+
}
|
|
6064
6325
|
const selectorArg = evaluateNode(chain.baseArgs[0], scope);
|
|
6065
6326
|
if (!selectorArg.ok) return false;
|
|
6066
6327
|
const manualSelectors = normalizeManualSelectors(Array.isArray(selectorArg.value) ? selectorArg.value.map(String) : String(selectorArg.value ?? ""));
|
|
6067
|
-
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;
|
|
6328
|
+
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;
|
|
6068
6329
|
return true;
|
|
6069
6330
|
}
|
|
6070
6331
|
function compileSelectorOverrideInto(chain, selectors, fileId, scope, cssConfig, transform, styleNames, options, items, rules, selectorPrefix) {
|
|
@@ -6272,7 +6533,7 @@ function decorateClassNameStyle(style, className) {
|
|
|
6272
6533
|
}
|
|
6273
6534
|
function decorateClassNameValue(value, className) {
|
|
6274
6535
|
if (isClassNameValue(value)) return value;
|
|
6275
|
-
if (isStyleImportantValue(value)) return importantValue(decorateClassNameValue(value.value, className));
|
|
6536
|
+
if (isStyleImportantValue(value)) return importantValue(decorateClassNameValue(value.value, className), value.native);
|
|
6276
6537
|
if (isStyleWeightValue(value)) return weightValue(decorateClassNameValue(value.value, className), value.weight);
|
|
6277
6538
|
return classNameValue(value, className);
|
|
6278
6539
|
}
|
|
@@ -6876,6 +7137,7 @@ function addSlotOverrideDataItems(value, parentSelector, atRules, fileId, items,
|
|
|
6876
7137
|
property: overrideItem.property,
|
|
6877
7138
|
weight: overrideItem.weight,
|
|
6878
7139
|
important: overrideItem.important,
|
|
7140
|
+
importantNative: overrideItem.importantNative,
|
|
6879
7141
|
value: overrideItem.value,
|
|
6880
7142
|
variable: overrideItem.variable,
|
|
6881
7143
|
token: overrideItem.token,
|
|
@@ -6927,8 +7189,8 @@ function addRuntimeScopeItem(sourceItem, parentSelector, atRules, fileId, items,
|
|
|
6927
7189
|
const itemAtRules = mergeAtRules(atRules, sourceItem.atRule);
|
|
6928
7190
|
const traceCallsite = callsiteOverride ?? sourceItem.callsite;
|
|
6929
7191
|
const valueStr = String(value ?? "");
|
|
6930
|
-
const dedupe = getClassNameDedupe(sourceItem.property, weight, important, sourceItem.selector, itemParentSelector, itemAtRules);
|
|
6931
|
-
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);
|
|
7192
|
+
const dedupe = getClassNameDedupe(sourceItem.property, weight, important, sourceItem.selector, itemParentSelector, itemAtRules, sourceItem.importantNative);
|
|
7193
|
+
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);
|
|
6932
7194
|
const item = createCompiledItem(4, sourceItem.slotId, dedupe, className, !!itemParentSelector);
|
|
6933
7195
|
items.push(item);
|
|
6934
7196
|
const css = buildAtomicRule(className, sourceItem.property, valueStr, important, sourceItem.selector, itemParentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
@@ -6939,6 +7201,7 @@ function addRuntimeScopeItem(sourceItem, parentSelector, atRules, fileId, items,
|
|
|
6939
7201
|
css,
|
|
6940
7202
|
priority: layerPriority,
|
|
6941
7203
|
important,
|
|
7204
|
+
importantNative: sourceItem.importantNative,
|
|
6942
7205
|
trace: traceCallsite ? {
|
|
6943
7206
|
filePath: traceCallsite.filePath ?? fileId,
|
|
6944
7207
|
line: traceCallsite.line,
|
|
@@ -7005,9 +7268,9 @@ function addRuntimeStyleItem(sourceItem, selector, parentSelector, atRules, file
|
|
|
7005
7268
|
const runtimeValue = variable?.[0] === 1 ? getCompiledRuntimeValue(variable[2]) : void 0;
|
|
7006
7269
|
const shouldUseVariable = !!variable && (variable[0] !== 1 || !!sourceItem.token || !!runtimeValue);
|
|
7007
7270
|
const valueStr = variable?.[0] === 1 && !shouldUseVariable ? String(variable[2] ?? "") : String(value ?? "");
|
|
7008
|
-
const dedupe = getClassNameDedupe(sourceItem.property, weight, important, itemSelector, parentSelector, itemAtRules);
|
|
7271
|
+
const dedupe = getClassNameDedupe(sourceItem.property, weight, important, itemSelector, parentSelector, itemAtRules, sourceItem.importantNative);
|
|
7009
7272
|
const traceCallsite = callsiteOverride ?? sourceItem.callsite;
|
|
7010
|
-
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);
|
|
7273
|
+
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);
|
|
7011
7274
|
const item = createCompiledItem(type, slotId, dedupe, className, !!parentSelector);
|
|
7012
7275
|
item.sourceTrace = getRuntimeStyleItemSourceTrace(sourceItem, fileId);
|
|
7013
7276
|
if (type !== 4 && variable && shouldUseVariable) {
|
|
@@ -7023,6 +7286,7 @@ function addRuntimeStyleItem(sourceItem, selector, parentSelector, atRules, file
|
|
|
7023
7286
|
css,
|
|
7024
7287
|
priority: layerPriority,
|
|
7025
7288
|
important,
|
|
7289
|
+
importantNative: sourceItem.importantNative,
|
|
7026
7290
|
trace: traceCallsite ? {
|
|
7027
7291
|
filePath: traceCallsite.filePath ?? fileId,
|
|
7028
7292
|
line: traceCallsite.line,
|
|
@@ -7089,9 +7353,10 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
7089
7353
|
const rawValue = styleObj[property];
|
|
7090
7354
|
let weight = null;
|
|
7091
7355
|
let important = false;
|
|
7356
|
+
let importantNative = false;
|
|
7092
7357
|
let value = rawValue;
|
|
7093
7358
|
let transformClassName = null;
|
|
7094
|
-
[value, weight, important] = unwrapStaticStyleValue(value);
|
|
7359
|
+
[value, weight, important, importantNative] = unwrapStaticStyleValue(value);
|
|
7095
7360
|
if (isClassNameValue(value)) {
|
|
7096
7361
|
transformClassName = value.className;
|
|
7097
7362
|
value = value.value;
|
|
@@ -7114,8 +7379,8 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
7114
7379
|
const shouldUseVariable = !!(token || runtimeValue);
|
|
7115
7380
|
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;
|
|
7116
7381
|
const valueStr = variableName ? token ? getCssVarRawFallback(variableName, getTokenVar(token, cssConfig.tokenNameFormat)) : `var(${variableName})` : token ? getTokenVar(token, cssConfig.tokenNameFormat) : String(value);
|
|
7117
|
-
const dedupe = getClassNameDedupe(property, weight, important, selector, parentSelector, atRules);
|
|
7118
|
-
const className = getAtomicClassName(property, weight, important, valueStr, selector, parentSelector, atRules, propertyCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, transformClassName, cssConfig.transformClassNameFormat, cssConfig.sheetClassNameFormat, cssConfig.hashLength);
|
|
7382
|
+
const dedupe = getClassNameDedupe(property, weight, important, selector, parentSelector, atRules, importantNative);
|
|
7383
|
+
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);
|
|
7119
7384
|
const item = createCompiledItem(type, slotId, dedupe, className, !!parentSelector);
|
|
7120
7385
|
item.sourceTrace = propertyCallsite ? {
|
|
7121
7386
|
property,
|
|
@@ -7148,6 +7413,7 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
7148
7413
|
css,
|
|
7149
7414
|
priority: layerPriority,
|
|
7150
7415
|
important,
|
|
7416
|
+
importantNative,
|
|
7151
7417
|
trace: propertyCallsite ? {
|
|
7152
7418
|
filePath: propertyCallsite.filePath ?? fileId,
|
|
7153
7419
|
line: propertyCallsite.line,
|
|
@@ -7173,9 +7439,11 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
7173
7439
|
function unwrapStaticStyleValue(value) {
|
|
7174
7440
|
let weight = null;
|
|
7175
7441
|
let important = false;
|
|
7442
|
+
let native = false;
|
|
7176
7443
|
while (true) {
|
|
7177
7444
|
if (isStyleImportantValue(value)) {
|
|
7178
7445
|
important = true;
|
|
7446
|
+
native ||= value.native === true;
|
|
7179
7447
|
value = value.value;
|
|
7180
7448
|
continue;
|
|
7181
7449
|
}
|
|
@@ -7189,7 +7457,8 @@ function unwrapStaticStyleValue(value) {
|
|
|
7189
7457
|
return [
|
|
7190
7458
|
value,
|
|
7191
7459
|
weight,
|
|
7192
|
-
important
|
|
7460
|
+
important,
|
|
7461
|
+
native
|
|
7193
7462
|
];
|
|
7194
7463
|
}
|
|
7195
7464
|
function throwIfRequiredStaticStyleValue(result) {
|
|
@@ -7246,6 +7515,13 @@ function getCompiledRuntimeValue(value) {
|
|
|
7246
7515
|
if (!value || typeof value !== "object") return void 0;
|
|
7247
7516
|
return value[COMPILED_RUNTIME_VALUE];
|
|
7248
7517
|
}
|
|
7518
|
+
function hasGlobalRuntimeValue(value, seen = /* @__PURE__ */ new Set()) {
|
|
7519
|
+
if (!value || typeof value !== "object" || isStyleTokenData(value) || isAtRuleRef(value)) return false;
|
|
7520
|
+
if (getCompiledRuntimeValue(value)) return true;
|
|
7521
|
+
if (seen.has(value)) return false;
|
|
7522
|
+
seen.add(value);
|
|
7523
|
+
return Object.values(value).some((item) => hasGlobalRuntimeValue(item, seen));
|
|
7524
|
+
}
|
|
7249
7525
|
//#endregion
|
|
7250
7526
|
//#region compiler/transform/evaluator/tracer.ts
|
|
7251
7527
|
const CACHE_TYPE = "transform-trace";
|
|
@@ -7722,7 +7998,9 @@ function isCompilerHandledImport(source, name) {
|
|
|
7722
7998
|
"createTheme",
|
|
7723
7999
|
"createToken",
|
|
7724
8000
|
"createTokens",
|
|
7725
|
-
"createValues"
|
|
8001
|
+
"createValues",
|
|
8002
|
+
"createSheet",
|
|
8003
|
+
"createGlobalSheet"
|
|
7726
8004
|
].includes(name);
|
|
7727
8005
|
}
|
|
7728
8006
|
//#endregion
|
|
@@ -7751,7 +8029,7 @@ function buildSheetOptions(t, chain) {
|
|
|
7751
8029
|
const options = chain.sheetOptions ?? {};
|
|
7752
8030
|
const properties = [];
|
|
7753
8031
|
if (options.layer !== void 0) properties.push(t.objectProperty(t.identifier("layer"), typeof options.layer === "string" ? t.stringLiteral(options.layer) : t.booleanLiteral(options.layer)));
|
|
7754
|
-
if (options.
|
|
8032
|
+
if (options.specificity !== void 0) properties.push(t.objectProperty(t.identifier("specificity"), t.numericLiteral(options.specificity)));
|
|
7755
8033
|
return t.objectExpression(properties);
|
|
7756
8034
|
}
|
|
7757
8035
|
function buildStyleMergeArgs(t, chain, state, options) {
|
|
@@ -8185,7 +8463,7 @@ function createExtractPlugin(args) {
|
|
|
8185
8463
|
state.styleNames.add(spec.local.name);
|
|
8186
8464
|
state.styleMetas.set(spec.local.name, meta);
|
|
8187
8465
|
}
|
|
8188
|
-
if (sourceName === "@fluentic/style/css" && imported === "createSheet") state.sheetNames.add(spec.local.name);
|
|
8466
|
+
if (sourceName === "@fluentic/style/css" && (imported === "createSheet" || imported === "createGlobalSheet")) state.sheetNames.add(spec.local.name);
|
|
8189
8467
|
});
|
|
8190
8468
|
},
|
|
8191
8469
|
VariableDeclaration(path, state) {
|
|
@@ -8241,6 +8519,8 @@ function createExtractPlugin(args) {
|
|
|
8241
8519
|
if (!state.styleNames.size && !state.sheetNames.size) return;
|
|
8242
8520
|
const chain = extractStyleChain(path.node, state.styleNames, state.sheetNames);
|
|
8243
8521
|
if (!chain) return;
|
|
8522
|
+
chain.global = chain.kind === "sheet" && state.imports.get(chain.rootName)?.name === "createGlobalSheet";
|
|
8523
|
+
if (chain.global) chain.sheetId = state.fileId + ":" + path.node.start;
|
|
8244
8524
|
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.");
|
|
8245
8525
|
const scope = getEvalScope(state);
|
|
8246
8526
|
const loc = path.node.loc?.start;
|
|
@@ -8262,6 +8542,12 @@ function createExtractPlugin(args) {
|
|
|
8262
8542
|
state.collector.add(rule);
|
|
8263
8543
|
});
|
|
8264
8544
|
if (mode === "collect") return;
|
|
8545
|
+
if (chain.global) {
|
|
8546
|
+
if (path.parentPath.isExpressionStatement()) path.parentPath.remove();
|
|
8547
|
+
else path.replaceWith(t.unaryExpression("void", t.numericLiteral(0)));
|
|
8548
|
+
path.skip();
|
|
8549
|
+
return;
|
|
8550
|
+
}
|
|
8265
8551
|
const replacement = createChainReplacement({
|
|
8266
8552
|
t,
|
|
8267
8553
|
path,
|
|
@@ -8316,23 +8602,35 @@ function checkCompiledImportantUsage(result, options, report) {
|
|
|
8316
8602
|
if (hasOutsideSheet && options.outsideSheet) report(options.outsideSheet, "style.important(...) outside createSheet is discouraged. Prefer style.weight(...) for Fluentic style priority.");
|
|
8317
8603
|
}
|
|
8318
8604
|
function pruneUnusedStyleInputDeclarations(path, state) {
|
|
8319
|
-
|
|
8320
|
-
|
|
8321
|
-
|
|
8322
|
-
|
|
8323
|
-
|
|
8324
|
-
|
|
8325
|
-
|
|
8326
|
-
|
|
8327
|
-
|
|
8328
|
-
|
|
8329
|
-
|
|
8330
|
-
|
|
8331
|
-
|
|
8605
|
+
const dependencies = /* @__PURE__ */ new Set();
|
|
8606
|
+
let changed;
|
|
8607
|
+
do {
|
|
8608
|
+
changed = false;
|
|
8609
|
+
path.scope.crawl();
|
|
8610
|
+
path.traverse({ VariableDeclarator(declaratorPath) {
|
|
8611
|
+
const node = declaratorPath.node;
|
|
8612
|
+
if (declaratorPath.parentPath?.parentPath?.isExportNamedDeclaration()) return;
|
|
8613
|
+
if (node.id.type !== "Identifier") return;
|
|
8614
|
+
const binding = declaratorPath.scope.getBinding(node.id.name);
|
|
8615
|
+
if (!binding || !binding.constant || binding.referencePaths.length) return;
|
|
8616
|
+
if (!isStyleInputCall(node.init, state) && !(dependencies.has(node) && declaratorPath.get("init").isPure())) return;
|
|
8617
|
+
declaratorPath.get("init").traverse({ ReferencedIdentifier(reference) {
|
|
8618
|
+
const dependency = reference.scope.getBinding(reference.node.name);
|
|
8619
|
+
if (dependency?.path.isVariableDeclarator()) dependencies.add(dependency.path.node);
|
|
8620
|
+
} });
|
|
8621
|
+
const declarationPath = declaratorPath.parentPath;
|
|
8622
|
+
if (!declarationPath?.isVariableDeclaration()) return;
|
|
8623
|
+
if (declarationPath.node.declarations.length > 1) declaratorPath.remove();
|
|
8624
|
+
else declarationPath.remove();
|
|
8625
|
+
changed = true;
|
|
8626
|
+
} });
|
|
8627
|
+
} while (changed);
|
|
8332
8628
|
path.scope.crawl();
|
|
8333
8629
|
}
|
|
8334
8630
|
function isStyleInputCall(node, state) {
|
|
8335
8631
|
if (!node || node.type !== "CallExpression") return false;
|
|
8632
|
+
const selectorChain = extractStyleChain(node, state.styleNames, state.sheetNames);
|
|
8633
|
+
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));
|
|
8336
8634
|
const callee = node.callee;
|
|
8337
8635
|
if (callee.type !== "MemberExpression" || callee.computed) return false;
|
|
8338
8636
|
if (callee.object.type !== "Identifier") return false;
|
|
@@ -8705,4 +9003,4 @@ const CssPropPresets = {
|
|
|
8705
9003
|
//#endregion
|
|
8706
9004
|
export { getDefaultSourcemapUrl as a, getStyleFnMeta as c, babelTransform as d, extractCss as f, createCompilerCache as g, globalData as h, CompilerRuntimeMode as i, isPromiseLike as l, SIDECAR_URL_GLOBAL_SYMBOL as m, createCompiler as n, normalizeSourcemapSourcePath as o, compareLayerPriority as p, getStyleRuntimeImportPath as r, normalizePath as s, CssPropPresets as t, babelPlugin as u };
|
|
8707
9005
|
|
|
8708
|
-
//# sourceMappingURL=compiler-
|
|
9006
|
+
//# sourceMappingURL=compiler-AOb_VaKQ.mjs.map
|