@fluentic/style 0.1.0-beta.14 → 0.1.0-beta.15
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 +12 -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-DZKR6gH1.js → config-BF-mxuPk.js} +4 -4
- package/dist/{config-DZKR6gH1.js.map → config-BF-mxuPk.js.map} +1 -1
- package/dist/{config-BiiMS4rU.js → config-B_OQYZSm.js} +25 -4
- package/dist/config-B_OQYZSm.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-IecKRNxs.js → css-RohOR3Vq.js} +112 -73
- package/dist/css-RohOR3Vq.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-CuzJtAR_.js} +2 -2
- package/dist/css_extra-CuzJtAR_.js.map +1 -0
- package/dist/{data-BgZmL55Y.js → data-Bw3Xod5J.js} +28 -19
- package/dist/data-Bw3Xod5J.js.map +1 -0
- package/dist/{debug-D-1hhd0G.js → debug-CVO3xx4C.js} +6 -9
- package/dist/debug-CVO3xx4C.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-BnQXPLQB.js} +6 -6
- package/dist/{dev-CBRbVaeq.js.map → dev-BnQXPLQB.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-BrHXg161.js} +334 -53
- package/dist/elementMarker-BrHXg161.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-D6daex-9.js} +64 -19
- package/dist/env-D6daex-9.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-m5DOkMFQ.js} +4 -4
- package/dist/{getClassName-BNe3Ycyy.js.map → getClassName-m5DOkMFQ.js.map} +1 -1
- package/dist/{global-UOHFwqHN.js → global-DeIYtcdl.js} +5 -2
- package/dist/{global-UOHFwqHN.js.map → global-DeIYtcdl.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-DCJkLls_.js} +4 -4
- package/dist/hash-DCJkLls_.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-CvloSSpb.js} +4 -4
- package/dist/{jsx-8TwYuvgM.js.map → jsx-CvloSSpb.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-DwgmUMBM.js} +2 -2
- package/dist/{namedTokens-CwniouKk.js.map → namedTokens-DwgmUMBM.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-B-5idGtZ.js +9 -0
- package/dist/sheet-B-5idGtZ.js.map +1 -0
- package/dist/{config-TyjNpRrV.js → sheet-C6ymGhKV.js} +23 -2
- package/dist/sheet-C6ymGhKV.js.map +1 -0
- package/dist/sheet-D4f9KYPf.js +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-a6ccye6R.js} +12 -12
- package/dist/style-a6ccye6R.js.map +1 -0
- package/dist/styleStore-Ceoaqa5U.js +45 -0
- package/dist/styleStore-Ceoaqa5U.js.map +1 -0
- package/dist/{env-C8TRVSyb.js → styleStore-D1IEmq1v.js} +435 -63
- package/dist/styleStore-D1IEmq1v.js.map +1 -0
- package/dist/{token-DMrBbat8.js → token-Ci73NE6h.js} +2 -2
- package/dist/{token-DMrBbat8.js.map → token-Ci73NE6h.js.map} +1 -1
- package/dist/{trace-C7EzEj2Q.js → trace-DDsvwdF0.js} +3 -3
- package/dist/{trace-C7EzEj2Q.js.map → trace-DDsvwdF0.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-BkxIouPX.js} +2 -2
- package/dist/{transform-CSZMklMb.js.map → transform-BkxIouPX.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-B-ThmbY-.js} +16 -9
- package/dist/value-B-ThmbY-.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 -1
- 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 +1 -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
|
@@ -1,20 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
function hasOwn(target, field) {
|
|
3
|
-
return Object.prototype.hasOwnProperty.call(target, field);
|
|
4
|
-
}
|
|
5
|
-
//#endregion
|
|
1
|
+
import { Fragment, cache, cloneElement, createElement } from "react";
|
|
6
2
|
//#region utils/symbol.ts
|
|
7
3
|
function symbol(name) {
|
|
8
4
|
return Symbol.for(`@fluentic/style.${name}`);
|
|
9
5
|
}
|
|
10
6
|
//#endregion
|
|
7
|
+
//#region builder/data/const.ts
|
|
8
|
+
const BUILDER_TYPE = symbol("builder.type");
|
|
9
|
+
const BUILDER_STATE = symbol("builder.state");
|
|
10
|
+
const BUILDER_CALLSITE = symbol("builder.callsite");
|
|
11
|
+
const BUILDER_SLOT_ID = symbol("builder.slotId");
|
|
12
|
+
const BUILDER_SCOPE_ID = symbol("builder.scopeId");
|
|
13
|
+
const BUILDER_SCOPE = symbol("builder.scope");
|
|
14
|
+
symbol("builder.selector");
|
|
15
|
+
const BUILDER_SHEET_OPTIONS = symbol("builder.sheetOptions");
|
|
16
|
+
const GLOBAL_SHEET_SELECTOR_ANCHOR = "\0global";
|
|
17
|
+
const SHEET_SELECTOR_ANCHOR = "\0sheet";
|
|
18
|
+
//#endregion
|
|
11
19
|
//#region utils/global.ts
|
|
20
|
+
function getGlobalData(key) {
|
|
21
|
+
return globalThis[symbol(key)];
|
|
22
|
+
}
|
|
12
23
|
function globalData(key, data) {
|
|
13
24
|
const id = symbol(key);
|
|
14
25
|
const root = globalThis;
|
|
15
26
|
if (root[id] === void 0) assign(root, id, data());
|
|
16
27
|
return root[id];
|
|
17
28
|
}
|
|
29
|
+
function clearGlobalData(key) {
|
|
30
|
+
delete globalThis[symbol(key)];
|
|
31
|
+
}
|
|
18
32
|
function assign(target, id, value) {
|
|
19
33
|
Object.defineProperty(target, id, {
|
|
20
34
|
value,
|
|
@@ -24,24 +38,6 @@ function assign(target, id, value) {
|
|
|
24
38
|
});
|
|
25
39
|
}
|
|
26
40
|
//#endregion
|
|
27
|
-
//#region config/config/css.ts
|
|
28
|
-
const CSS_CONFIG_DEFAULT = {
|
|
29
|
-
layer: true,
|
|
30
|
-
layers: ["$layer"],
|
|
31
|
-
layerNamespace: "css"
|
|
32
|
-
};
|
|
33
|
-
const CSS_CONFIG = globalData("config.css", () => ({ ...CSS_CONFIG_DEFAULT }));
|
|
34
|
-
function isStyleLayerEnabled(layer = CSS_CONFIG.layer) {
|
|
35
|
-
return typeof layer === "boolean" ? layer : layer.style ?? true;
|
|
36
|
-
}
|
|
37
|
-
function resolveSheetLayerOption(layer, namespace) {
|
|
38
|
-
if (typeof layer !== "string") return layer ? "sheet" : false;
|
|
39
|
-
return { name: layer.startsWith(".") ? namespace ? namespace + layer : layer.slice(1) : layer };
|
|
40
|
-
}
|
|
41
|
-
function isSheetLayerEnabled(layer = CSS_CONFIG.layer) {
|
|
42
|
-
return typeof layer === "object" && (layer.sheet ?? false);
|
|
43
|
-
}
|
|
44
|
-
//#endregion
|
|
45
41
|
//#region utils/hash.ts
|
|
46
42
|
function hashString(str) {
|
|
47
43
|
let hash = 2166136261;
|
|
@@ -52,6 +48,11 @@ function normalizeHashLength(length) {
|
|
|
52
48
|
return Number.isFinite(length) ? Math.max(1, Math.floor(length)) : 7;
|
|
53
49
|
}
|
|
54
50
|
//#endregion
|
|
51
|
+
//#region utils/object.ts
|
|
52
|
+
function hasOwn(target, field) {
|
|
53
|
+
return Object.prototype.hasOwnProperty.call(target, field);
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
55
56
|
//#region config/config/debug.ts
|
|
56
57
|
const DEFAULT_DEBUG_CONFIG = {
|
|
57
58
|
isDebugClassNameEnabled: false,
|
|
@@ -99,46 +100,71 @@ const DEV_CONFIG = globalData("config.dev", () => ({ ...DEV_CONFIG_DEFAULT }));
|
|
|
99
100
|
globalData("config.dev.plugin", () => ({ config: null }));
|
|
100
101
|
globalData("config.dev.base", () => ({ config: null }));
|
|
101
102
|
globalData("config.dev.utils", () => ({ config: null }));
|
|
103
|
+
function normalizeCallsiteSourceUrl(source) {
|
|
104
|
+
let filePath = source.trim();
|
|
105
|
+
try {
|
|
106
|
+
filePath = decodeURI(filePath);
|
|
107
|
+
} catch {}
|
|
108
|
+
if (filePath.startsWith("source:///at ") || filePath.startsWith("source:///at%20")) filePath = filePath.slice(10);
|
|
109
|
+
const strayAtMatch = filePath.match(/(?:^|\/)at\s+([a-zA-Z][a-zA-Z\d+.-]*:\/\/.+|\/.+)$/);
|
|
110
|
+
return strayAtMatch ? strayAtMatch[1] : filePath.replace(/^at\s+/, "");
|
|
111
|
+
}
|
|
112
|
+
function getDebugFieldLoc(debug, field) {
|
|
113
|
+
const loc = debug?.fields?.[field];
|
|
114
|
+
if (!loc) return null;
|
|
115
|
+
if (Array.isArray(loc)) return loc;
|
|
116
|
+
return loc[DEV_CONFIG.sourcemapLocationMode === "value" ? 1 : 0] ?? loc[0] ?? loc[1] ?? null;
|
|
117
|
+
}
|
|
102
118
|
//#endregion
|
|
103
|
-
//#region
|
|
104
|
-
function
|
|
105
|
-
|
|
106
|
-
for (let i = 0; i < ident.length; i++) {
|
|
107
|
-
const char = ident.charAt(i);
|
|
108
|
-
const code = ident.charCodeAt(i);
|
|
109
|
-
const nextCode = ident.charCodeAt(i + 1);
|
|
110
|
-
if (code === 0) {
|
|
111
|
-
result += "�";
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
if (code >= 1 && code <= 31 || code === 127 || i === 0 && code >= 48 && code <= 57 || i === 1 && code >= 48 && code <= 57 && ident.charCodeAt(0) === 45) {
|
|
115
|
-
result += "\\" + code.toString(16) + " ";
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
if (i === 0 && code === 45 && ident.length === 1) {
|
|
119
|
-
result += "\\-";
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
|
-
if (code >= 55296 && code <= 56319 && nextCode >= 56320 && nextCode <= 57343) {
|
|
123
|
-
result += char + ident.charAt(++i);
|
|
124
|
-
continue;
|
|
125
|
-
}
|
|
126
|
-
if (code >= 128 || code === 45 || code === 95 || code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122) {
|
|
127
|
-
result += char;
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
130
|
-
result += "\\" + char;
|
|
131
|
-
}
|
|
132
|
-
return result;
|
|
119
|
+
//#region builder/data/is.ts
|
|
120
|
+
function getSlotId(data) {
|
|
121
|
+
return data[BUILDER_SLOT_ID];
|
|
133
122
|
}
|
|
134
|
-
function
|
|
135
|
-
return
|
|
123
|
+
function getScopeTargetSlotId(data) {
|
|
124
|
+
return data[BUILDER_SCOPE_ID];
|
|
125
|
+
}
|
|
126
|
+
function getScopeTargetScope(data) {
|
|
127
|
+
return data[BUILDER_SCOPE];
|
|
128
|
+
}
|
|
129
|
+
function isStyleData(value) {
|
|
130
|
+
return getBuilderType(value) === 1;
|
|
131
|
+
}
|
|
132
|
+
function isSlotData(value) {
|
|
133
|
+
return getBuilderType(value) === 2;
|
|
134
|
+
}
|
|
135
|
+
function isSlotOverrideData(value) {
|
|
136
|
+
return getBuilderType(value) === 3;
|
|
137
|
+
}
|
|
138
|
+
function isSheetData(value) {
|
|
139
|
+
return getBuilderType(value) === 9;
|
|
140
|
+
}
|
|
141
|
+
function isScopeData(value) {
|
|
142
|
+
return getBuilderType(value) === 4;
|
|
143
|
+
}
|
|
144
|
+
function isScopeTargetData(value) {
|
|
145
|
+
return getBuilderType(value) === 5;
|
|
146
|
+
}
|
|
147
|
+
function isThemeData(value) {
|
|
148
|
+
return getBuilderType(value) === 6;
|
|
149
|
+
}
|
|
150
|
+
function getBuilderType(value) {
|
|
151
|
+
if (!value || typeof value !== "object" && typeof value !== "function") return null;
|
|
152
|
+
return value[BUILDER_TYPE];
|
|
136
153
|
}
|
|
137
154
|
//#endregion
|
|
138
|
-
//#region
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
155
|
+
//#region config/config/css.ts
|
|
156
|
+
const CSS_CONFIG_DEFAULT = {
|
|
157
|
+
layer: true,
|
|
158
|
+
layers: ["$layer"],
|
|
159
|
+
layerNamespace: "css"
|
|
160
|
+
};
|
|
161
|
+
const CSS_CONFIG = globalData("config.css", () => ({ ...CSS_CONFIG_DEFAULT }));
|
|
162
|
+
function isStyleLayerEnabled(layer = CSS_CONFIG.layer) {
|
|
163
|
+
return typeof layer === "boolean" ? layer : layer.style ?? true;
|
|
164
|
+
}
|
|
165
|
+
function resolveSheetLayerOption(layer, namespace, mainLayerEnabled = isStyleLayerEnabled()) {
|
|
166
|
+
if (typeof layer !== "string") return layer && mainLayerEnabled ? "style" : false;
|
|
167
|
+
return { name: layer.startsWith(".") ? mainLayerEnabled && namespace ? namespace + layer : layer.slice(1) : layer };
|
|
142
168
|
}
|
|
143
169
|
//#endregion
|
|
144
170
|
//#region atomic/utils/format.ts
|
|
@@ -247,6 +273,103 @@ function formatTokenValue(value, maxLength, truncate) {
|
|
|
247
273
|
if (!Number.isFinite(maxLength) || maxLength < 0 || value.length <= maxLength) return value;
|
|
248
274
|
return truncate ? value.slice(0, maxLength) : null;
|
|
249
275
|
}
|
|
276
|
+
createNameFormatter([
|
|
277
|
+
"atRule",
|
|
278
|
+
"scopeSelector",
|
|
279
|
+
"property",
|
|
280
|
+
"selector",
|
|
281
|
+
"value"
|
|
282
|
+
]);
|
|
283
|
+
createNameFormatter(["className"]);
|
|
284
|
+
//#endregion
|
|
285
|
+
//#region atomic/utils/cssIdent.ts
|
|
286
|
+
function escapeCssIdent(ident) {
|
|
287
|
+
let result = "";
|
|
288
|
+
for (let i = 0; i < ident.length; i++) {
|
|
289
|
+
const char = ident.charAt(i);
|
|
290
|
+
const code = ident.charCodeAt(i);
|
|
291
|
+
const nextCode = ident.charCodeAt(i + 1);
|
|
292
|
+
if (code === 0) {
|
|
293
|
+
result += "�";
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
if (code >= 1 && code <= 31 || code === 127 || i === 0 && code >= 48 && code <= 57 || i === 1 && code >= 48 && code <= 57 && ident.charCodeAt(0) === 45) {
|
|
297
|
+
result += "\\" + code.toString(16) + " ";
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
if (i === 0 && code === 45 && ident.length === 1) {
|
|
301
|
+
result += "\\-";
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
if (code >= 55296 && code <= 56319 && nextCode >= 56320 && nextCode <= 57343) {
|
|
305
|
+
result += char + ident.charAt(++i);
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
if (code >= 128 || code === 45 || code === 95 || code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122) {
|
|
309
|
+
result += char;
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
result += "\\" + char;
|
|
313
|
+
}
|
|
314
|
+
return result;
|
|
315
|
+
}
|
|
316
|
+
function sanitizeCssIdentName(value, fallback = "") {
|
|
317
|
+
return value.replace(/[^a-zA-Z0-9_-]+/g, "-").replace(/^-+|-+$/g, "") || fallback;
|
|
318
|
+
}
|
|
319
|
+
function sanitizeDebugName(value) {
|
|
320
|
+
if (!value) return "";
|
|
321
|
+
return sanitizeCssIdentName(value.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), "");
|
|
322
|
+
}
|
|
323
|
+
new Set([
|
|
324
|
+
"align-content",
|
|
325
|
+
"align-items",
|
|
326
|
+
"align-self",
|
|
327
|
+
"background-repeat",
|
|
328
|
+
"background-size",
|
|
329
|
+
"border-collapse",
|
|
330
|
+
"border-style",
|
|
331
|
+
"box-sizing",
|
|
332
|
+
"clear",
|
|
333
|
+
"cursor",
|
|
334
|
+
"display",
|
|
335
|
+
"flex-direction",
|
|
336
|
+
"flex-wrap",
|
|
337
|
+
"float",
|
|
338
|
+
"font-weight",
|
|
339
|
+
"font-style",
|
|
340
|
+
"justify-content",
|
|
341
|
+
"justify-items",
|
|
342
|
+
"justify-self",
|
|
343
|
+
"list-style-position",
|
|
344
|
+
"list-style-type",
|
|
345
|
+
"object-fit",
|
|
346
|
+
"object-position",
|
|
347
|
+
"overflow",
|
|
348
|
+
"overflow-x",
|
|
349
|
+
"overflow-y",
|
|
350
|
+
"pointer-events",
|
|
351
|
+
"place-content",
|
|
352
|
+
"place-items",
|
|
353
|
+
"place-self",
|
|
354
|
+
"position",
|
|
355
|
+
"resize",
|
|
356
|
+
"table-layout",
|
|
357
|
+
"text-align",
|
|
358
|
+
"text-decoration-line",
|
|
359
|
+
"text-transform",
|
|
360
|
+
"user-select",
|
|
361
|
+
"vertical-align",
|
|
362
|
+
"visibility",
|
|
363
|
+
"white-space"
|
|
364
|
+
]);
|
|
365
|
+
new Set(["font-weight"]);
|
|
366
|
+
function getScopeClassName(className, scopeClassNameFormat) {
|
|
367
|
+
return formatScopeClassName$1(scopeClassNameFormat || "-(className)", { className });
|
|
368
|
+
}
|
|
369
|
+
function formatScopeClassName$1(format, info) {
|
|
370
|
+
if (typeof format === "function") return format(info);
|
|
371
|
+
return format.replace(/\[|\]/g, "").replace(/\(className\)/g, info.className);
|
|
372
|
+
}
|
|
250
373
|
//#endregion
|
|
251
374
|
//#region atomic/utils/hash.ts
|
|
252
375
|
function getIdentifierSafeHash(value, startLength = 7) {
|
|
@@ -258,77 +381,239 @@ function getIdentifierSafeHashValue(hash) {
|
|
|
258
381
|
if (first < 48 || first > 57) return hash;
|
|
259
382
|
return String.fromCharCode(97 + first - 48) + hash.slice(1);
|
|
260
383
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
const
|
|
265
|
-
|
|
384
|
+
//#endregion
|
|
385
|
+
//#region atomic/utils/selector.ts
|
|
386
|
+
function getSelectorText$1(selector) {
|
|
387
|
+
const text = Array.isArray(selector) ? selector[0] : selector;
|
|
388
|
+
if (text.startsWith("\0global")) return text.slice(text.indexOf("\0", 7) + 1);
|
|
389
|
+
return stripSheetSelectorAnchor(text);
|
|
266
390
|
}
|
|
267
|
-
function
|
|
268
|
-
|
|
391
|
+
function getSelectorPriority$1(selector) {
|
|
392
|
+
if (!selector) return 0;
|
|
393
|
+
return Array.isArray(selector) ? selector[1] : 0;
|
|
269
394
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
const CHECK_CONFIG_DEFAULT = {};
|
|
273
|
-
globalData("config.check", () => ({ ...CHECK_CONFIG_DEFAULT }));
|
|
274
|
-
globalData("config.build", () => ({ current: null }));
|
|
275
|
-
//#endregion
|
|
276
|
-
//#region atomic/layer/layer.ts
|
|
277
|
-
function compareLayerPriority(p1, p2) {
|
|
278
|
-
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];
|
|
395
|
+
function hasSheetSelectorAnchor(selector) {
|
|
396
|
+
return (selector ? Array.isArray(selector) ? selector[0] : selector : "").startsWith(SHEET_SELECTOR_ANCHOR);
|
|
279
397
|
}
|
|
280
|
-
function
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
};
|
|
290
|
-
const getLayerName = (layerNamespace, priority) => {
|
|
291
|
-
const layerId = getLayerId(priority);
|
|
292
|
-
return layerNamespace ? layerNamespace + "." + layerId : layerId;
|
|
293
|
-
};
|
|
294
|
-
return {
|
|
295
|
-
getLayerName,
|
|
296
|
-
getLayerId
|
|
297
|
-
};
|
|
398
|
+
function getSheetSelectorSpecificity(selector) {
|
|
399
|
+
const text = selector ? Array.isArray(selector) ? selector[0] : selector : "";
|
|
400
|
+
if (!text.startsWith("\0sheet:")) return null;
|
|
401
|
+
const end = text.indexOf("\0", 6);
|
|
402
|
+
if (end < 0) return null;
|
|
403
|
+
const [weightValue] = text.slice(7, end).split(":");
|
|
404
|
+
if (!weightValue) return null;
|
|
405
|
+
const weight = Number(weightValue);
|
|
406
|
+
return Number.isInteger(weight) && weight >= 0 ? weight : null;
|
|
298
407
|
}
|
|
299
|
-
function
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
};
|
|
307
|
-
const getNames = () => {
|
|
308
|
-
return Array.from(priorities.values()).sort(compareLayerPriority).map((priority) => namePool.getLayerName(layerNamespace, priority));
|
|
309
|
-
};
|
|
310
|
-
return {
|
|
311
|
-
getName,
|
|
312
|
-
getNames
|
|
313
|
-
};
|
|
408
|
+
function stripSheetSelectorAnchor(selector) {
|
|
409
|
+
if (!selector.startsWith("\0sheet")) return selector;
|
|
410
|
+
if (selector.startsWith("\0sheet:")) {
|
|
411
|
+
const end = selector.indexOf("\0", 6);
|
|
412
|
+
if (end >= 0) return selector.slice(end + 1);
|
|
413
|
+
}
|
|
414
|
+
return selector.slice(6);
|
|
314
415
|
}
|
|
315
|
-
function
|
|
316
|
-
|
|
317
|
-
return [...new Set(layers.flatMap((layer) => layer === "$layer" ? names.filter((name) => !layers.includes(name)) : layer).filter(Boolean))];
|
|
416
|
+
function hasGlobalSheetSelectorAnchor(selector) {
|
|
417
|
+
return (selector ? Array.isArray(selector) ? selector[0] : selector : "").startsWith(GLOBAL_SHEET_SELECTOR_ANCHOR);
|
|
318
418
|
}
|
|
319
419
|
//#endregion
|
|
320
|
-
//#region
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
420
|
+
//#region builder/token/symbols.ts
|
|
421
|
+
const TOKEN_ID = symbol("style:token");
|
|
422
|
+
const TOKEN_OVERRIDE = symbol("style:token.override");
|
|
423
|
+
const TOKEN_NAME = symbol("style:token.name");
|
|
424
|
+
const TOKEN_VAR_NAME = symbol("style:token.varName");
|
|
425
|
+
//#endregion
|
|
426
|
+
//#region builder/token/data.ts
|
|
427
|
+
function isStyleTokenData(value) {
|
|
428
|
+
return !!value && typeof value[TOKEN_ID] === "string" && value[TOKEN_OVERRIDE] !== true;
|
|
429
|
+
}
|
|
430
|
+
function isStyleTokenOverrideData(value) {
|
|
431
|
+
return !!value && typeof value[TOKEN_ID] === "string" && value[TOKEN_OVERRIDE] === true;
|
|
432
|
+
}
|
|
433
|
+
function getStyleTokenId(token) {
|
|
434
|
+
return token[TOKEN_ID];
|
|
435
|
+
}
|
|
436
|
+
function getStyleTokenName(token) {
|
|
437
|
+
return token[TOKEN_NAME] ?? null;
|
|
438
|
+
}
|
|
439
|
+
function getStyleTokenVarName(token) {
|
|
440
|
+
return token[TOKEN_VAR_NAME] ?? null;
|
|
441
|
+
}
|
|
442
|
+
symbol("style:token.debug");
|
|
443
|
+
globalData("style.token.idCounter", () => ({ value: 0 }));
|
|
444
|
+
//#endregion
|
|
445
|
+
//#region atomic/utils/cssVar.ts
|
|
446
|
+
function getCssVar(varName, value) {
|
|
447
|
+
return "var(" + varName + ", " + escapeCssValue(value) + ")";
|
|
448
|
+
}
|
|
449
|
+
function getCssVarRawFallback(varName, fallbackCss) {
|
|
450
|
+
return "var(" + varName + ", " + fallbackCss + ")";
|
|
451
|
+
}
|
|
452
|
+
function escapeCssValue(value) {
|
|
453
|
+
if (!value) return "";
|
|
454
|
+
return value.trim().replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/'/g, "\\'").replace(/;/g, "\\;");
|
|
455
|
+
}
|
|
456
|
+
const formatTokenName = createNameFormatter(["name"]);
|
|
457
|
+
function getTokenVarName(token, format) {
|
|
458
|
+
const explicitName = getStyleTokenVarName(token);
|
|
459
|
+
if (explicitName) return explicitName;
|
|
460
|
+
const id = getStyleTokenId(token);
|
|
461
|
+
const debugName = getStyleTokenName(token);
|
|
462
|
+
return "--" + formatTokenName(format || "token[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name: debugName });
|
|
463
|
+
}
|
|
464
|
+
function getTokenVar(token, format) {
|
|
465
|
+
return getTokenVarFallback(token, format);
|
|
466
|
+
}
|
|
467
|
+
function getTokenOverrideValue(token, format) {
|
|
468
|
+
return token.ref ? getTokenVar(token.ref, format) : token.value;
|
|
469
|
+
}
|
|
470
|
+
function getTokenVarFallback(token, tokenNameFormat) {
|
|
471
|
+
const varName = getTokenVarName(token, tokenNameFormat);
|
|
472
|
+
if (token.ref) return getCssVarRawFallback(varName, getTokenVarFallback(token.ref, tokenNameFormat));
|
|
473
|
+
return getCssVar(varName, String(token.value ?? ""));
|
|
474
|
+
}
|
|
475
|
+
//#endregion
|
|
476
|
+
//#region atomic/value/unitless.ts
|
|
477
|
+
const UnitlessProperties = [
|
|
478
|
+
"animationIterationCount",
|
|
479
|
+
"aspectRatio",
|
|
480
|
+
"borderImageOutset",
|
|
481
|
+
"borderImageSlice",
|
|
482
|
+
"borderImageWidth",
|
|
483
|
+
"boxFlex",
|
|
484
|
+
"boxFlexGroup",
|
|
485
|
+
"boxOrdinalGroup",
|
|
486
|
+
"columnCount",
|
|
487
|
+
"columns",
|
|
488
|
+
"fillOpacity",
|
|
489
|
+
"flex",
|
|
490
|
+
"flexGrow",
|
|
491
|
+
"flexNegative",
|
|
492
|
+
"flexOrder",
|
|
493
|
+
"flexPositive",
|
|
494
|
+
"flexShrink",
|
|
495
|
+
"floodOpacity",
|
|
496
|
+
"fontWeight",
|
|
497
|
+
"gridArea",
|
|
498
|
+
"gridColumn",
|
|
499
|
+
"gridColumnEnd",
|
|
500
|
+
"gridColumnSpan",
|
|
501
|
+
"gridColumnStart",
|
|
502
|
+
"gridRow",
|
|
503
|
+
"gridRowEnd",
|
|
504
|
+
"gridRowSpan",
|
|
505
|
+
"gridRowStart",
|
|
506
|
+
"imageOrientation",
|
|
507
|
+
"lineClamp",
|
|
508
|
+
"lineHeight",
|
|
509
|
+
"opacity",
|
|
510
|
+
"order",
|
|
511
|
+
"orphans",
|
|
512
|
+
"scale",
|
|
513
|
+
"stopOpacity",
|
|
514
|
+
"strokeDasharray",
|
|
515
|
+
"strokeDashoffset",
|
|
516
|
+
"strokeMiterlimit",
|
|
517
|
+
"strokeOpacity",
|
|
518
|
+
"strokeWidth",
|
|
519
|
+
"tabSize",
|
|
520
|
+
"widows",
|
|
521
|
+
"zIndex",
|
|
522
|
+
"zoom"
|
|
523
|
+
];
|
|
524
|
+
//#endregion
|
|
525
|
+
//#region atomic/value/value.ts
|
|
526
|
+
const CSS_NUMBER_VALUE = /^-?(\d+\.?\d*|\.\d+)$/;
|
|
527
|
+
const UNITLESS = new Set(UnitlessProperties);
|
|
528
|
+
function getCssPropertyValue(property, value) {
|
|
529
|
+
if (!value || !shouldAppendCssPx(property)) return value;
|
|
530
|
+
if (CSS_NUMBER_VALUE.test(value)) return value + "px";
|
|
531
|
+
return value;
|
|
532
|
+
}
|
|
533
|
+
function shouldAppendCssPx(property) {
|
|
534
|
+
return !UNITLESS.has(property);
|
|
535
|
+
}
|
|
536
|
+
//#endregion
|
|
537
|
+
//#region config/config/check.ts
|
|
538
|
+
const CHECK_CONFIG_DEFAULT = {};
|
|
539
|
+
globalData("config.check", () => ({ ...CHECK_CONFIG_DEFAULT }));
|
|
540
|
+
symbol("style.important");
|
|
541
|
+
symbol("transform.classNameValue");
|
|
542
|
+
symbol("atRule.ref");
|
|
543
|
+
symbol("style.weight");
|
|
544
|
+
globalData("config.build", () => ({ current: null }));
|
|
545
|
+
//#endregion
|
|
546
|
+
//#region config/document.ts
|
|
547
|
+
const state$1 = globalData("config.document", () => ({
|
|
548
|
+
target: true,
|
|
549
|
+
listeners: /* @__PURE__ */ new Set()
|
|
550
|
+
}));
|
|
551
|
+
function getRuntimeDocument(documentOverride) {
|
|
552
|
+
if (state$1.target === false) return null;
|
|
553
|
+
if (state$1.target !== true) return state$1.target;
|
|
554
|
+
if (documentOverride) return documentOverride;
|
|
555
|
+
return typeof globalThis.document === "undefined" ? null : globalThis.document;
|
|
556
|
+
}
|
|
557
|
+
function onRuntimeDocumentChange(listener) {
|
|
558
|
+
state$1.listeners.add(listener);
|
|
559
|
+
}
|
|
560
|
+
//#endregion
|
|
561
|
+
//#region atomic/layer/layer.ts
|
|
562
|
+
function compareLayerPriority(p1, p2) {
|
|
563
|
+
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];
|
|
564
|
+
}
|
|
565
|
+
function createLayerNamePool() {
|
|
566
|
+
const lookup = /* @__PURE__ */ new Map();
|
|
567
|
+
const getLayerId = (priority) => {
|
|
568
|
+
const key = priority.join("|");
|
|
569
|
+
let name = lookup.get(key);
|
|
570
|
+
if (name) return name;
|
|
571
|
+
name = "p" + hashString(key);
|
|
572
|
+
lookup.set(key, name);
|
|
573
|
+
return name;
|
|
574
|
+
};
|
|
575
|
+
const getLayerName = (layerNamespace, priority) => {
|
|
576
|
+
const layerId = getLayerId(priority);
|
|
577
|
+
return layerNamespace ? layerNamespace + "." + layerId : layerId;
|
|
578
|
+
};
|
|
579
|
+
return {
|
|
580
|
+
getLayerName,
|
|
581
|
+
getLayerId
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
function createLayerPool(layerNamespace) {
|
|
585
|
+
const namePool = createLayerNamePool();
|
|
586
|
+
const priorities = /* @__PURE__ */ new Map();
|
|
587
|
+
const getName = (priority) => {
|
|
588
|
+
const key = priority.join("|");
|
|
589
|
+
if (!priorities.has(key)) priorities.set(key, priority);
|
|
590
|
+
return namePool.getLayerName(layerNamespace, priority);
|
|
591
|
+
};
|
|
592
|
+
const getNames = () => {
|
|
593
|
+
return Array.from(priorities.values()).sort(compareLayerPriority).map((priority) => namePool.getLayerName(layerNamespace, priority));
|
|
594
|
+
};
|
|
595
|
+
return {
|
|
596
|
+
getName,
|
|
597
|
+
getNames
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
function flattenCssLayers(layers, layerNames) {
|
|
601
|
+
const names = typeof layerNames === "string" ? [layerNames] : layerNames;
|
|
602
|
+
return [...new Set(layers.flatMap((layer) => layer === "$layer" ? names.filter((name) => !layers.includes(name)) : layer).filter(Boolean))];
|
|
603
|
+
}
|
|
604
|
+
//#endregion
|
|
605
|
+
//#region atomic/layer/types.ts
|
|
606
|
+
const LayerDefaultPriority = [
|
|
607
|
+
0,
|
|
608
|
+
0,
|
|
609
|
+
0,
|
|
610
|
+
0,
|
|
611
|
+
0,
|
|
612
|
+
0,
|
|
613
|
+
0
|
|
614
|
+
];
|
|
615
|
+
const LayerMediaPriorities = {
|
|
616
|
+
base: 0,
|
|
332
617
|
media: 1,
|
|
333
618
|
priorityMedia: 2
|
|
334
619
|
};
|
|
@@ -354,6 +639,127 @@ function getLayerBlockCss(layerName, css) {
|
|
|
354
639
|
return "@layer " + layerName + " {" + css + "}";
|
|
355
640
|
}
|
|
356
641
|
//#endregion
|
|
642
|
+
//#region sheet/utils/layer.ts
|
|
643
|
+
function createSheetLayerState() {
|
|
644
|
+
return createLayerPool(getStyleLayerName());
|
|
645
|
+
}
|
|
646
|
+
function getSheetRulePriority(priority) {
|
|
647
|
+
return priority ?? LayerDefaultPriority;
|
|
648
|
+
}
|
|
649
|
+
function getSheetRuleLayerPriority(priority, important) {
|
|
650
|
+
const resolved = getSheetRulePriority(priority);
|
|
651
|
+
return important ? [
|
|
652
|
+
-resolved[0],
|
|
653
|
+
-resolved[1],
|
|
654
|
+
-resolved[2],
|
|
655
|
+
-resolved[3],
|
|
656
|
+
-resolved[4],
|
|
657
|
+
-resolved[5],
|
|
658
|
+
-resolved[6]
|
|
659
|
+
] : resolved;
|
|
660
|
+
}
|
|
661
|
+
function getStyleLayerName() {
|
|
662
|
+
return CSS_CONFIG.layerNamespace || "css";
|
|
663
|
+
}
|
|
664
|
+
function getSheetLayerName() {
|
|
665
|
+
return getStyleLayerName() + ".sheet";
|
|
666
|
+
}
|
|
667
|
+
function getSheetLayerNames(layerState, hasSheetLayer, namedLayers = /* @__PURE__ */ new Set()) {
|
|
668
|
+
const names = layerState.getNames();
|
|
669
|
+
return [...new Set([
|
|
670
|
+
...names,
|
|
671
|
+
...hasSheetLayer ? [getSheetLayerName()] : [],
|
|
672
|
+
...namedLayers
|
|
673
|
+
])];
|
|
674
|
+
}
|
|
675
|
+
//#endregion
|
|
676
|
+
//#region sheet/ordering.ts
|
|
677
|
+
function sheetRuleLayer(rule, config = CSS_CONFIG) {
|
|
678
|
+
const mainEnabled = isStyleLayerEnabled(config.layer);
|
|
679
|
+
let layer = rule.layer ?? "style";
|
|
680
|
+
if (layer === "style" && !mainEnabled) layer = false;
|
|
681
|
+
if (rule.sheet && rule.important && !rule.importantNative && layer !== false) return { name: (typeof layer === "object" ? layer.name : config.layerNamespace || "css") + ".important" };
|
|
682
|
+
return layer;
|
|
683
|
+
}
|
|
684
|
+
function sheetRuleGroup(rule, config = CSS_CONFIG) {
|
|
685
|
+
if (rule.globalSheet) return "global:" + rule.globalSheet.id;
|
|
686
|
+
return rule.sheet && sheetRuleLayer(rule, config) === false ? "local-unlayered" : "regular";
|
|
687
|
+
}
|
|
688
|
+
function compareSheetGroups(a, b) {
|
|
689
|
+
const region = (rule) => rule.globalSheet ? rule.globalSheet.order <= 0 ? 0 : 2 : 1;
|
|
690
|
+
const order = region(a) - region(b);
|
|
691
|
+
if (order) return order;
|
|
692
|
+
if (a.globalSheet && b.globalSheet) return a.globalSheet.order - b.globalSheet.order;
|
|
693
|
+
return 0;
|
|
694
|
+
}
|
|
695
|
+
function compareSheetRules(a, b, config = CSS_CONFIG) {
|
|
696
|
+
const layerRank = (rule) => {
|
|
697
|
+
const layer = sheetRuleLayer(rule, config);
|
|
698
|
+
const main = config.layerNamespace || "css";
|
|
699
|
+
return layer === false ? 2 : layer === "style" || typeof layer === "object" && layer.name === main ? 0 : 1;
|
|
700
|
+
};
|
|
701
|
+
return layerRank(a) - layerRank(b) || compareLayerPriority(getSheetRulePriority(a.priority), getSheetRulePriority(b.priority));
|
|
702
|
+
}
|
|
703
|
+
/** Stable group sort: equal global orders keep the first-discovered sheet first. */
|
|
704
|
+
function orderSheetRules(rules, config = CSS_CONFIG) {
|
|
705
|
+
const groups = /* @__PURE__ */ new Map();
|
|
706
|
+
for (const rule of rules) {
|
|
707
|
+
const key = sheetRuleGroup(rule, config);
|
|
708
|
+
const group = groups.get(key) ?? [];
|
|
709
|
+
group.push(rule);
|
|
710
|
+
groups.set(key, group);
|
|
711
|
+
}
|
|
712
|
+
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)));
|
|
713
|
+
}
|
|
714
|
+
/** Reserve each parent's first child for managed important declarations. */
|
|
715
|
+
function sheetLayerOrder(names, config = CSS_CONFIG, reservedParents = names) {
|
|
716
|
+
const roots = [];
|
|
717
|
+
const children = /* @__PURE__ */ new Map();
|
|
718
|
+
const add = (name) => {
|
|
719
|
+
const parts = name.split(".");
|
|
720
|
+
if (!roots.includes(parts[0])) roots.push(parts[0]);
|
|
721
|
+
for (let i = 1; i < parts.length; i++) {
|
|
722
|
+
const parent = parts.slice(0, i).join(".");
|
|
723
|
+
const child = parts.slice(0, i + 1).join(".");
|
|
724
|
+
const list = children.get(parent) ?? [];
|
|
725
|
+
if (!list.includes(child)) list.push(child);
|
|
726
|
+
children.set(parent, list);
|
|
727
|
+
}
|
|
728
|
+
if (!name.endsWith(".important") && reservedParents.includes(name)) children.set(name, children.get(name) ?? []);
|
|
729
|
+
};
|
|
730
|
+
for (const name of [...(config.layers ?? CSS_CONFIG_DEFAULT.layers ?? []).filter((name) => name !== "$layer"), ...names]) add(name);
|
|
731
|
+
const declarations = [getLayerOrderCss((config.layers ?? CSS_CONFIG_DEFAULT.layers ?? []).map((name) => name === "$layer" ? name : name.split(".")[0]), roots)];
|
|
732
|
+
for (const [parent, list] of children) {
|
|
733
|
+
if (parent.endsWith(".important")) continue;
|
|
734
|
+
declarations.push("@layer " + [...new Set([parent + ".important", ...list])].join(", ") + ";");
|
|
735
|
+
}
|
|
736
|
+
return declarations.filter(Boolean).join("\n");
|
|
737
|
+
}
|
|
738
|
+
function layerNameForRule(rule, config, mode, pool) {
|
|
739
|
+
const layer = sheetRuleLayer(rule, config);
|
|
740
|
+
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";
|
|
741
|
+
}
|
|
742
|
+
/** Build only ordering declarations; runtime flushing need not serialize rule bodies. */
|
|
743
|
+
function sheetOrderingPreamble(rules, config = CSS_CONFIG, mode = "sort") {
|
|
744
|
+
const pool = createLayerPool(config.layerNamespace || "css");
|
|
745
|
+
const names = /* @__PURE__ */ new Set();
|
|
746
|
+
for (const rule of orderSheetRules(rules, config)) {
|
|
747
|
+
const name = layerNameForRule(rule, config, mode, pool);
|
|
748
|
+
if (name) names.add(name);
|
|
749
|
+
}
|
|
750
|
+
const priorities = pool.getNames();
|
|
751
|
+
const named = [...names].filter((name) => !priorities.includes(name));
|
|
752
|
+
return sheetLayerOrder([...priorities, ...named], config, named);
|
|
753
|
+
}
|
|
754
|
+
function serializeOrderedRules(rules, config = CSS_CONFIG, mode = "sort") {
|
|
755
|
+
const pool = createLayerPool(config.layerNamespace || "css");
|
|
756
|
+
const rendered = orderSheetRules(rules, config).map((rule) => {
|
|
757
|
+
const name = layerNameForRule(rule, config, mode, pool);
|
|
758
|
+
return name ? getLayerBlockCss(name, rule.css) : rule.css;
|
|
759
|
+
});
|
|
760
|
+
return [sheetOrderingPreamble(rules, config, mode), ...rendered].filter(Boolean).join("\n");
|
|
761
|
+
}
|
|
762
|
+
//#endregion
|
|
357
763
|
//#region sheet/utils/dom.ts
|
|
358
764
|
function resolveDocument(documentOverride) {
|
|
359
765
|
if (documentOverride !== void 0) return documentOverride;
|
|
@@ -392,38 +798,166 @@ function getFirstCssSheetTag(head) {
|
|
|
392
798
|
return null;
|
|
393
799
|
}
|
|
394
800
|
//#endregion
|
|
395
|
-
//#region sheet/
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
const
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
801
|
+
//#region sheet/ordered.ts
|
|
802
|
+
const refreshers = globalData("sheet.ordered.refreshers", () => /* @__PURE__ */ new Set());
|
|
803
|
+
/** Keep whole global sheets together; move DOM groups without rebuilding unrelated rules. */
|
|
804
|
+
function createOrderedSheet(create, options, dev) {
|
|
805
|
+
const document = resolveDocument(options.document);
|
|
806
|
+
if (!document) return create(options);
|
|
807
|
+
const groups = /* @__PURE__ */ new Map();
|
|
808
|
+
const owners = /* @__PURE__ */ new Map();
|
|
809
|
+
const direct = [];
|
|
810
|
+
const seen = /* @__PURE__ */ new Set();
|
|
811
|
+
let activeLayers = CSS_CONFIG.layers;
|
|
812
|
+
let enabled = false;
|
|
813
|
+
let header = null;
|
|
814
|
+
let serial = 0;
|
|
815
|
+
let dirty = false;
|
|
816
|
+
let mode = DEV_CONFIG.stylePriorityMode;
|
|
817
|
+
const pending = /* @__PURE__ */ new Set();
|
|
818
|
+
const regular = getGroup("regular");
|
|
819
|
+
const refresh = () => {
|
|
820
|
+
dirty = true;
|
|
821
|
+
flush();
|
|
822
|
+
};
|
|
823
|
+
if (dev) refreshers.add(refresh);
|
|
824
|
+
function getGroup(name) {
|
|
825
|
+
const previous = groups.get(name);
|
|
826
|
+
if (previous) return previous;
|
|
827
|
+
const tagName = name === "regular" ? options.tagName : (options.tagName ? options.tagName + " " : "") + "ordered-" + ++serial;
|
|
828
|
+
const group = {
|
|
829
|
+
name,
|
|
830
|
+
tagName,
|
|
831
|
+
rules: [],
|
|
832
|
+
sheet: create({
|
|
833
|
+
...options,
|
|
834
|
+
tagName
|
|
835
|
+
})
|
|
836
|
+
};
|
|
837
|
+
group.sheet.updateLayers(activeLayers ?? []);
|
|
838
|
+
groups.set(name, group);
|
|
839
|
+
return group;
|
|
840
|
+
}
|
|
841
|
+
function route(rule) {
|
|
842
|
+
return {
|
|
843
|
+
...rule,
|
|
844
|
+
layer: sheetRuleLayer(rule)
|
|
845
|
+
};
|
|
846
|
+
}
|
|
847
|
+
function insert(rule) {
|
|
848
|
+
const item = typeof rule === "string" ? { css: rule } : rule;
|
|
849
|
+
const key = sheetRuleGroup(item) + "\0" + (item.key ?? item.css);
|
|
850
|
+
if (seen.has(key)) return;
|
|
851
|
+
seen.add(key);
|
|
852
|
+
direct.push(item);
|
|
853
|
+
add(item);
|
|
854
|
+
}
|
|
855
|
+
function add(item) {
|
|
856
|
+
enabled ||= !!(item.sheet || item.globalSheet);
|
|
857
|
+
const group = getGroup(sheetRuleGroup(item));
|
|
858
|
+
const previous = group.rules[group.rules.length - 1];
|
|
859
|
+
group.rules.push(item);
|
|
860
|
+
if (enabled && previous && compareSheetRules(previous, item) > 0) pending.add(group);
|
|
861
|
+
if (!pending.has(group)) group.sheet.insert(route(item));
|
|
862
|
+
dirty = true;
|
|
863
|
+
}
|
|
864
|
+
function rebuild(group) {
|
|
865
|
+
pending.delete(group);
|
|
866
|
+
group.sheet.destroy?.();
|
|
867
|
+
group.sheet = create({
|
|
868
|
+
...options,
|
|
869
|
+
tagName: group.tagName
|
|
870
|
+
});
|
|
871
|
+
group.sheet.updateLayers(activeLayers ?? []);
|
|
872
|
+
group.rules.sort((a, b) => compareSheetRules(a, b));
|
|
873
|
+
for (const rule of group.rules) group.sheet.insert(route(rule));
|
|
874
|
+
group.sheet.flush();
|
|
875
|
+
dirty = true;
|
|
876
|
+
}
|
|
877
|
+
function collectTags() {
|
|
878
|
+
const lookup = new Map([...groups.values()].map((group) => [group.tagName ?? "", group]));
|
|
879
|
+
const result = /* @__PURE__ */ new Map();
|
|
880
|
+
const head = document.head || document.documentElement;
|
|
881
|
+
for (const node of Array.from(head.childNodes)) {
|
|
882
|
+
if (typeof node.getAttribute !== "function") continue;
|
|
883
|
+
const match = node.getAttribute("data-css-sheet")?.match(/^(?:(.*) )?(?:layers|rules(?: .*)?)$/);
|
|
884
|
+
const group = match && lookup.get(match[1] ?? "");
|
|
885
|
+
if (!group) continue;
|
|
886
|
+
const list = result.get(group) ?? [];
|
|
887
|
+
list.push(node);
|
|
888
|
+
result.set(group, list);
|
|
889
|
+
}
|
|
890
|
+
return result;
|
|
891
|
+
}
|
|
892
|
+
function flush() {
|
|
893
|
+
if (dev && mode !== DEV_CONFIG.stylePriorityMode) {
|
|
894
|
+
mode = DEV_CONFIG.stylePriorityMode;
|
|
895
|
+
dirty = true;
|
|
896
|
+
}
|
|
897
|
+
for (const group of pending) rebuild(group);
|
|
898
|
+
pending.clear();
|
|
899
|
+
for (const group of groups.values()) group.sheet.flush();
|
|
900
|
+
if (!enabled || !dirty) return;
|
|
901
|
+
const config = {
|
|
902
|
+
...CSS_CONFIG,
|
|
903
|
+
layers: activeLayers ? [...activeLayers] : void 0
|
|
904
|
+
};
|
|
905
|
+
const order = sheetOrderingPreamble([...groups.values()].flatMap((group) => group.rules), config, dev ? DEV_CONFIG.stylePriorityMode : "layer");
|
|
906
|
+
const head = document.head || document.documentElement;
|
|
907
|
+
const groupTags = collectTags();
|
|
908
|
+
if (!header) {
|
|
909
|
+
header = createStyleTag(document, (options.tagName ? options.tagName + " " : "") + "ordering", options.nonce);
|
|
910
|
+
const first = groupTags.get(regular)?.[0];
|
|
911
|
+
if (first) head.insertBefore(header, first);
|
|
912
|
+
else head.appendChild(header);
|
|
913
|
+
}
|
|
914
|
+
if (header.textContent !== order) header.textContent = order;
|
|
915
|
+
const sorted = [...groups.values()].sort((a, b) => {
|
|
916
|
+
const ar = a.rules[0] ?? { css: "" };
|
|
917
|
+
const br = b.rules[0] ?? { css: "" };
|
|
918
|
+
return compareSheetGroups(ar, br) || (!ar.globalSheet && !br.globalSheet ? Number(a.name === "local-unlayered") - Number(b.name === "local-unlayered") : 0);
|
|
919
|
+
});
|
|
920
|
+
let previous = header;
|
|
921
|
+
for (const group of sorted) for (const tag of groupTags.get(group) ?? []) {
|
|
922
|
+
if (previous.nextSibling !== tag) {
|
|
923
|
+
const oldSheet = tag.sheet;
|
|
924
|
+
const css = oldSheet ? Array.from(oldSheet.cssRules).map((rule) => rule.cssText) : [];
|
|
925
|
+
head.insertBefore(tag, previous.nextSibling);
|
|
926
|
+
if (oldSheet && tag.sheet !== oldSheet && css.length && !tag.sheet?.cssRules.length) for (const rule of css) tag.sheet?.insertRule(rule, tag.sheet.cssRules.length);
|
|
927
|
+
}
|
|
928
|
+
previous = tag;
|
|
929
|
+
}
|
|
930
|
+
dirty = false;
|
|
931
|
+
}
|
|
932
|
+
return {
|
|
933
|
+
insert,
|
|
934
|
+
flush,
|
|
935
|
+
updateLayers(layers) {
|
|
936
|
+
if (activeLayers?.length === layers.length && layers.every((name, index) => activeLayers[index] === name)) return;
|
|
937
|
+
activeLayers = [...layers];
|
|
938
|
+
for (const group of groups.values()) group.sheet.updateLayers(layers);
|
|
939
|
+
dirty = true;
|
|
940
|
+
},
|
|
941
|
+
replaceRules(owner, rules) {
|
|
942
|
+
const previous = owners.get(owner) ?? [];
|
|
943
|
+
owners.set(owner, rules);
|
|
944
|
+
enabled = true;
|
|
945
|
+
const affected = new Set([...previous, ...rules].map((rule) => sheetRuleGroup(rule)));
|
|
946
|
+
const all = [...direct, ...[...owners.values()].flat()];
|
|
947
|
+
for (const name of affected) {
|
|
948
|
+
const group = getGroup(name);
|
|
949
|
+
group.rules = all.filter((rule) => sheetRuleGroup(rule) === name);
|
|
950
|
+
rebuild(group);
|
|
951
|
+
}
|
|
952
|
+
flush();
|
|
953
|
+
},
|
|
954
|
+
destroy() {
|
|
955
|
+
refreshers.delete(refresh);
|
|
956
|
+
for (const group of groups.values()) group.sheet.destroy?.();
|
|
957
|
+
if (header?.parentNode) header.parentNode.removeChild(header);
|
|
958
|
+
groups.clear();
|
|
959
|
+
}
|
|
960
|
+
};
|
|
427
961
|
}
|
|
428
962
|
//#endregion
|
|
429
963
|
//#region sheet/utils/noop.ts
|
|
@@ -441,23 +975,6 @@ function normalizeRule(rule) {
|
|
|
441
975
|
return typeof rule === "string" ? rule : rule.css;
|
|
442
976
|
}
|
|
443
977
|
//#endregion
|
|
444
|
-
//#region utils/trace.ts
|
|
445
|
-
function normalizeCallsiteSourceUrl(source) {
|
|
446
|
-
let filePath = source.trim();
|
|
447
|
-
try {
|
|
448
|
-
filePath = decodeURI(filePath);
|
|
449
|
-
} catch {}
|
|
450
|
-
if (filePath.startsWith("source:///at ") || filePath.startsWith("source:///at%20")) filePath = filePath.slice(10);
|
|
451
|
-
const strayAtMatch = filePath.match(/(?:^|\/)at\s+([a-zA-Z][a-zA-Z\d+.-]*:\/\/.+|\/.+)$/);
|
|
452
|
-
return strayAtMatch ? strayAtMatch[1] : filePath.replace(/^at\s+/, "");
|
|
453
|
-
}
|
|
454
|
-
function getDebugFieldLoc(debug, field) {
|
|
455
|
-
const loc = debug?.fields?.[field];
|
|
456
|
-
if (!loc) return null;
|
|
457
|
-
if (Array.isArray(loc)) return loc;
|
|
458
|
-
return loc[DEV_CONFIG.sourcemapLocationMode === "value" ? 1 : 0] ?? loc[0] ?? loc[1] ?? null;
|
|
459
|
-
}
|
|
460
|
-
//#endregion
|
|
461
978
|
//#region sheet/utils/sourcemap.ts
|
|
462
979
|
const VLQ_BASE_SHIFT = 5;
|
|
463
980
|
const VLQ_BASE = 1 << VLQ_BASE_SHIFT;
|
|
@@ -889,7 +1406,7 @@ function ensureGroup(groups, priority, layer) {
|
|
|
889
1406
|
return group;
|
|
890
1407
|
}
|
|
891
1408
|
function getLayerRank(layer) {
|
|
892
|
-
return layer === "style" ? 0 : layer === "sheet" || typeof layer === "object" ? 1 : 2;
|
|
1409
|
+
return layer === "style" || typeof layer === "object" && layer.name === getStyleLayerName() ? 0 : layer === "sheet" || typeof layer === "object" ? 1 : 2;
|
|
893
1410
|
}
|
|
894
1411
|
function createGroupTag(document, groups, group, options) {
|
|
895
1412
|
const previous = getPreviousTag(groups, group, options.previous);
|
|
@@ -932,6 +1449,9 @@ function getPriorityKey(priority) {
|
|
|
932
1449
|
//#region sheet/dev/index.ts
|
|
933
1450
|
const DEV_SHEETS = globalData("sheet.dev.sheets", () => /* @__PURE__ */ new Set());
|
|
934
1451
|
function createDevSheet(options = {}) {
|
|
1452
|
+
return createOrderedSheet(createDevSheetBase, options, true);
|
|
1453
|
+
}
|
|
1454
|
+
function createDevSheetBase(options = {}) {
|
|
935
1455
|
let activeMode = DEV_CONFIG.stylePriorityMode;
|
|
936
1456
|
let active = createDevSheetForMode(activeMode, options);
|
|
937
1457
|
let activeLayers = CSS_CONFIG.layers ?? CSS_CONFIG_DEFAULT.layers ?? [];
|
|
@@ -951,6 +1471,15 @@ function createDevSheet(options = {}) {
|
|
|
951
1471
|
rules.push(rule);
|
|
952
1472
|
active.insert(rule);
|
|
953
1473
|
},
|
|
1474
|
+
replaceRules(owner, next) {
|
|
1475
|
+
const group = rules.find((rule) => typeof rule === "object" && "owner" in rule && rule.owner === owner);
|
|
1476
|
+
if (group && typeof group === "object" && "owner" in group) group.rules = next;
|
|
1477
|
+
else rules.push({
|
|
1478
|
+
owner,
|
|
1479
|
+
rules: next
|
|
1480
|
+
});
|
|
1481
|
+
rebuild();
|
|
1482
|
+
},
|
|
954
1483
|
flush() {
|
|
955
1484
|
ensureActiveMode();
|
|
956
1485
|
active.flush();
|
|
@@ -970,7 +1499,11 @@ function createDevSheet(options = {}) {
|
|
|
970
1499
|
removeDevSheetTags(options.document, options.tagName);
|
|
971
1500
|
active = createDevSheetForMode(activeMode, options);
|
|
972
1501
|
active.updateLayers(activeLayers);
|
|
973
|
-
for (let i = 0, len = rules.length; i < len; i++)
|
|
1502
|
+
for (let i = 0, len = rules.length; i < len; i++) {
|
|
1503
|
+
const rule = rules[i];
|
|
1504
|
+
if (typeof rule === "object" && "owner" in rule) for (const item of rule.rules) active.insert(item);
|
|
1505
|
+
else active.insert(rule);
|
|
1506
|
+
}
|
|
974
1507
|
active.flush();
|
|
975
1508
|
}
|
|
976
1509
|
}
|
|
@@ -996,213 +1529,23 @@ function removeDevSheetTags(documentOverride, tagName) {
|
|
|
996
1529
|
pruneDevSourcemapTags();
|
|
997
1530
|
}
|
|
998
1531
|
function matchesDevSheetTag(sheetName, tagName) {
|
|
999
|
-
if (tagName)
|
|
1532
|
+
if (tagName) {
|
|
1533
|
+
if (sheetName === tagName) return true;
|
|
1534
|
+
if (!sheetName.startsWith(tagName + " ")) return false;
|
|
1535
|
+
sheetName = sheetName.slice(tagName.length + 1);
|
|
1536
|
+
}
|
|
1000
1537
|
return sheetName === "layers" || sheetName === "rules" || sheetName.startsWith("rules ");
|
|
1001
1538
|
}
|
|
1002
1539
|
//#endregion
|
|
1003
|
-
//#region runtime/sheet/
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
}
|
|
1011
|
-
//#endregion
|
|
1012
|
-
//#region runtime/core/elementMarkerData.ts
|
|
1013
|
-
function splitElementMarkerStyleProp(styleProp) {
|
|
1014
|
-
if (isElementDebugData(styleProp)) return {
|
|
1015
|
-
debug: styleProp,
|
|
1016
|
-
styleProp: void 0
|
|
1017
|
-
};
|
|
1018
|
-
if (!Array.isArray(styleProp) || !isElementDebugData(styleProp[0])) return {
|
|
1019
|
-
debug: void 0,
|
|
1020
|
-
styleProp
|
|
1021
|
-
};
|
|
1022
|
-
return {
|
|
1023
|
-
debug: styleProp[0],
|
|
1024
|
-
styleProp: styleProp.length > 2 ? styleProp.slice(1) : styleProp[1]
|
|
1025
|
-
};
|
|
1026
|
-
}
|
|
1027
|
-
function isElementDebugData(value) {
|
|
1028
|
-
if (!value || typeof value !== "object") return false;
|
|
1029
|
-
return value.$$elementDebug === true;
|
|
1030
|
-
}
|
|
1031
|
-
//#endregion
|
|
1032
|
-
//#region runtime/core/elementMarker.ts
|
|
1033
|
-
const ELEMENT_MARKER_SHEET = globalData("runtime.elementMarkerSheet", () => ({ sheet: null }));
|
|
1034
|
-
function createElementMarkerClassName(debug) {
|
|
1035
|
-
if (!DEV_CONFIG.isDev || !DEV_CONFIG.isElementClassNameEnabled) return null;
|
|
1036
|
-
const marker = createElementMarkerRuleFromDebug(debug);
|
|
1037
|
-
if (!marker) return null;
|
|
1038
|
-
insertElementMarkerSheetRule(marker.rule);
|
|
1039
|
-
return marker.className;
|
|
1040
|
-
}
|
|
1041
|
-
function insertElementMarkerSheetRule(rule, documentOverride) {
|
|
1042
|
-
const document = documentOverride ?? (typeof globalThis.document === "undefined" ? null : globalThis.document);
|
|
1043
|
-
if (!document) return;
|
|
1044
|
-
const className = getElementMarkerClassNameFromRule(rule);
|
|
1045
|
-
if (!className) return;
|
|
1046
|
-
const sheet = getElementMarkerSheet(document);
|
|
1047
|
-
sheet.classNames.add(className);
|
|
1048
|
-
sheet.sheet.insert(rule);
|
|
1049
|
-
sheet.sheet.flush();
|
|
1050
|
-
}
|
|
1051
|
-
function createElementMarkerRuleFromDebug(debug) {
|
|
1052
|
-
const callsite = getElementCallsite(debug);
|
|
1053
|
-
if (!callsite) return null;
|
|
1054
|
-
const className = getElementClassName(debug?.label, getElementCallsiteId(callsite), CSS_CONFIG.elementClassNameFormat || null);
|
|
1055
|
-
return {
|
|
1056
|
-
className,
|
|
1057
|
-
rule: createElementMarkerRule(className, callsite)
|
|
1058
|
-
};
|
|
1059
|
-
}
|
|
1060
|
-
function isElementMarkerRule(rule) {
|
|
1061
|
-
return typeof rule.key === "string" && rule.key.startsWith("element-marker:");
|
|
1062
|
-
}
|
|
1063
|
-
function getElementMarkerClassNameFromRule(rule) {
|
|
1064
|
-
if (!isElementMarkerRule(rule)) return null;
|
|
1065
|
-
return rule.key.slice(15) || null;
|
|
1066
|
-
}
|
|
1067
|
-
function getElementMarkerSheet(document) {
|
|
1068
|
-
const current = ELEMENT_MARKER_SHEET.sheet;
|
|
1069
|
-
if (current?.document === document) return current;
|
|
1070
|
-
const sheet = {
|
|
1071
|
-
document,
|
|
1072
|
-
sheet: createDevSheet({
|
|
1073
|
-
document,
|
|
1074
|
-
tagName: "element-marker",
|
|
1075
|
-
top: true
|
|
1076
|
-
}),
|
|
1077
|
-
classNames: /* @__PURE__ */ new Set()
|
|
1078
|
-
};
|
|
1079
|
-
ELEMENT_MARKER_SHEET.sheet = sheet;
|
|
1080
|
-
return sheet;
|
|
1081
|
-
}
|
|
1082
|
-
function getElementCallsite(debug) {
|
|
1083
|
-
if (debug) return {
|
|
1084
|
-
filePath: debug.sourceUrl,
|
|
1085
|
-
sourceUrl: debug.sourceUrl,
|
|
1086
|
-
sourceContent: debug.code,
|
|
1087
|
-
line: debug.loc[0],
|
|
1088
|
-
column: debug.loc[1]
|
|
1089
|
-
};
|
|
1090
|
-
return null;
|
|
1091
|
-
}
|
|
1092
|
-
function getElementCallsiteId(callsite) {
|
|
1093
|
-
return `${callsite.filePath}\n${callsite.line}:${callsite.column}`;
|
|
1094
|
-
}
|
|
1095
|
-
//#endregion
|
|
1096
|
-
//#region runtime/core/createTransformElement.ts
|
|
1097
|
-
function createTransformElement(getClassName) {
|
|
1098
|
-
return ({ type, props }) => {
|
|
1099
|
-
if (!props || typeof type !== "string") return {
|
|
1100
|
-
type,
|
|
1101
|
-
props
|
|
1102
|
-
};
|
|
1103
|
-
if (!hasOwn(props, "css")) return {
|
|
1104
|
-
type,
|
|
1105
|
-
props
|
|
1106
|
-
};
|
|
1107
|
-
const { css, ...rest } = props;
|
|
1108
|
-
if (!css) return {
|
|
1109
|
-
type,
|
|
1110
|
-
props: rest
|
|
1111
|
-
};
|
|
1112
|
-
const marker = splitElementMarkerStyleProp(css);
|
|
1113
|
-
if (marker.styleProp) Object.assign(rest, getClassName(marker.styleProp, rest));
|
|
1114
|
-
prependClassName(rest, createElementMarkerClassName(marker.debug));
|
|
1115
|
-
return {
|
|
1116
|
-
type,
|
|
1117
|
-
props: rest
|
|
1118
|
-
};
|
|
1119
|
-
};
|
|
1120
|
-
}
|
|
1121
|
-
function prependClassName(props, className) {
|
|
1122
|
-
if (!className) return;
|
|
1123
|
-
props.className = props.className ? `${className} ${props.className}` : className;
|
|
1124
|
-
}
|
|
1125
|
-
//#endregion
|
|
1126
|
-
//#region builder/data/const.ts
|
|
1127
|
-
const BUILDER_TYPE = symbol("builder.type");
|
|
1128
|
-
const BUILDER_STATE = symbol("builder.state");
|
|
1129
|
-
const BUILDER_CALLSITE = symbol("builder.callsite");
|
|
1130
|
-
const BUILDER_SLOT_ID = symbol("builder.slotId");
|
|
1131
|
-
const BUILDER_SCOPE_ID = symbol("builder.scopeId");
|
|
1132
|
-
const BUILDER_SCOPE = symbol("builder.scope");
|
|
1133
|
-
symbol("builder.selector");
|
|
1134
|
-
const BUILDER_SHEET_OPTIONS = symbol("builder.sheetOptions");
|
|
1135
|
-
const SHEET_SELECTOR_ANCHOR = "\0sheet";
|
|
1136
|
-
//#endregion
|
|
1137
|
-
//#region builder/data/is.ts
|
|
1138
|
-
function getSlotId(data) {
|
|
1139
|
-
return data[BUILDER_SLOT_ID];
|
|
1140
|
-
}
|
|
1141
|
-
function getScopeTargetSlotId(data) {
|
|
1142
|
-
return data[BUILDER_SCOPE_ID];
|
|
1143
|
-
}
|
|
1144
|
-
function getScopeTargetScope(data) {
|
|
1145
|
-
return data[BUILDER_SCOPE];
|
|
1146
|
-
}
|
|
1147
|
-
function isStyleData(value) {
|
|
1148
|
-
return getBuilderType(value) === 1;
|
|
1149
|
-
}
|
|
1150
|
-
function isSlotData(value) {
|
|
1151
|
-
return getBuilderType(value) === 2;
|
|
1152
|
-
}
|
|
1153
|
-
function isSlotOverrideData(value) {
|
|
1154
|
-
return getBuilderType(value) === 3;
|
|
1155
|
-
}
|
|
1156
|
-
function isSheetData(value) {
|
|
1157
|
-
return getBuilderType(value) === 9;
|
|
1158
|
-
}
|
|
1159
|
-
function isScopeData(value) {
|
|
1160
|
-
return getBuilderType(value) === 4;
|
|
1161
|
-
}
|
|
1162
|
-
function isScopeTargetData(value) {
|
|
1163
|
-
return getBuilderType(value) === 5;
|
|
1164
|
-
}
|
|
1165
|
-
function isThemeData(value) {
|
|
1166
|
-
return getBuilderType(value) === 6;
|
|
1167
|
-
}
|
|
1168
|
-
function getBuilderType(value) {
|
|
1169
|
-
if (!value || typeof value !== "object" && typeof value !== "function") return null;
|
|
1170
|
-
return value[BUILDER_TYPE];
|
|
1171
|
-
}
|
|
1172
|
-
//#endregion
|
|
1173
|
-
//#region builder/extract/withTokens.ts
|
|
1174
|
-
const tokenBoundData = /* @__PURE__ */ new WeakMap();
|
|
1175
|
-
function isExtractedTokenBoundData(value) {
|
|
1176
|
-
return !!value && (typeof value === "object" || typeof value === "function") && tokenBoundData.has(value);
|
|
1177
|
-
}
|
|
1178
|
-
function getExtractedTokenBoundData(value) {
|
|
1179
|
-
return tokenBoundData.get(value);
|
|
1180
|
-
}
|
|
1181
|
-
//#endregion
|
|
1182
|
-
//#region builder/token/symbols.ts
|
|
1183
|
-
const TOKEN_ID = symbol("style:token");
|
|
1184
|
-
const TOKEN_OVERRIDE = symbol("style:token.override");
|
|
1185
|
-
const TOKEN_NAME = symbol("style:token.name");
|
|
1186
|
-
const TOKEN_VAR_NAME = symbol("style:token.varName");
|
|
1187
|
-
//#endregion
|
|
1188
|
-
//#region builder/token/data.ts
|
|
1189
|
-
function isStyleTokenData(value) {
|
|
1190
|
-
return !!value && typeof value[TOKEN_ID] === "string" && value[TOKEN_OVERRIDE] !== true;
|
|
1191
|
-
}
|
|
1192
|
-
function isStyleTokenOverrideData(value) {
|
|
1193
|
-
return !!value && typeof value[TOKEN_ID] === "string" && value[TOKEN_OVERRIDE] === true;
|
|
1194
|
-
}
|
|
1195
|
-
function getStyleTokenId(token) {
|
|
1196
|
-
return token[TOKEN_ID];
|
|
1197
|
-
}
|
|
1198
|
-
function getStyleTokenName(token) {
|
|
1199
|
-
return token[TOKEN_NAME] ?? null;
|
|
1540
|
+
//#region runtime/sheet/document.ts
|
|
1541
|
+
const GLOBAL_KEY$1 = "runtime.sheet.global";
|
|
1542
|
+
const state = globalData("runtime.sheet.document", () => ({ document: getRuntimeDocument() }));
|
|
1543
|
+
function resetSheet() {
|
|
1544
|
+
getGlobalData(GLOBAL_KEY$1)?.destroy?.();
|
|
1545
|
+
clearGlobalData(GLOBAL_KEY$1);
|
|
1546
|
+
state.document = getRuntimeDocument();
|
|
1200
1547
|
}
|
|
1201
|
-
|
|
1202
|
-
return token[TOKEN_VAR_NAME] ?? null;
|
|
1203
|
-
}
|
|
1204
|
-
symbol("style:token.debug");
|
|
1205
|
-
globalData("style.token.idCounter", () => ({ value: 0 }));
|
|
1548
|
+
onRuntimeDocumentChange(resetSheet);
|
|
1206
1549
|
//#endregion
|
|
1207
1550
|
//#region runtime/core/combinedStyle.ts
|
|
1208
1551
|
const targets = globalData("runtime.combinedStyle.targets", () => /* @__PURE__ */ new WeakMap());
|
|
@@ -1374,17 +1717,46 @@ function resolveItems(data, scopes) {
|
|
|
1374
1717
|
return items;
|
|
1375
1718
|
}
|
|
1376
1719
|
function getScopeParentItem(className) {
|
|
1377
|
-
const parentClassName = formatScopeClassName
|
|
1720
|
+
const parentClassName = formatScopeClassName(className);
|
|
1378
1721
|
return [parentClassName, parentClassName];
|
|
1379
1722
|
}
|
|
1380
|
-
function formatScopeClassName
|
|
1381
|
-
const format = CSS_CONFIG.scopeClassNameFormat;
|
|
1382
|
-
if (!format) return "-" + className;
|
|
1383
|
-
if (typeof format === "function") return format({ className });
|
|
1384
|
-
return format.replace(/\[|\]/g, "").replace(/\(className\)/g, className);
|
|
1723
|
+
function formatScopeClassName(className) {
|
|
1724
|
+
const format = CSS_CONFIG.scopeClassNameFormat;
|
|
1725
|
+
if (!format) return "-" + className;
|
|
1726
|
+
if (typeof format === "function") return format({ className });
|
|
1727
|
+
return format.replace(/\[|\]/g, "").replace(/\(className\)/g, className);
|
|
1728
|
+
}
|
|
1729
|
+
function isExtractedScopeParentMarker$1(value) {
|
|
1730
|
+
return value === 1 || value === true;
|
|
1731
|
+
}
|
|
1732
|
+
//#endregion
|
|
1733
|
+
//#region builder/extract/withTokens.ts
|
|
1734
|
+
const tokenBoundData = /* @__PURE__ */ new WeakMap();
|
|
1735
|
+
function isExtractedTokenBoundData(value) {
|
|
1736
|
+
return !!value && (typeof value === "object" || typeof value === "function") && tokenBoundData.has(value);
|
|
1737
|
+
}
|
|
1738
|
+
function getExtractedTokenBoundData(value) {
|
|
1739
|
+
return tokenBoundData.get(value);
|
|
1740
|
+
}
|
|
1741
|
+
//#endregion
|
|
1742
|
+
//#region runtime/core/elementMarkerData.ts
|
|
1743
|
+
function splitElementMarkerStyleProp(styleProp) {
|
|
1744
|
+
if (isElementDebugData(styleProp)) return {
|
|
1745
|
+
debug: styleProp,
|
|
1746
|
+
styleProp: void 0
|
|
1747
|
+
};
|
|
1748
|
+
if (!Array.isArray(styleProp) || !isElementDebugData(styleProp[0])) return {
|
|
1749
|
+
debug: void 0,
|
|
1750
|
+
styleProp
|
|
1751
|
+
};
|
|
1752
|
+
return {
|
|
1753
|
+
debug: styleProp[0],
|
|
1754
|
+
styleProp: styleProp.length > 2 ? styleProp.slice(1) : styleProp[1]
|
|
1755
|
+
};
|
|
1385
1756
|
}
|
|
1386
|
-
function
|
|
1387
|
-
|
|
1757
|
+
function isElementDebugData(value) {
|
|
1758
|
+
if (!value || typeof value !== "object") return false;
|
|
1759
|
+
return value.$$elementDebug === true;
|
|
1388
1760
|
}
|
|
1389
1761
|
//#endregion
|
|
1390
1762
|
//#region runtime/core/cache/itemWithResolver.ts
|
|
@@ -1445,37 +1817,6 @@ function createCacheValue() {
|
|
|
1445
1817
|
};
|
|
1446
1818
|
}
|
|
1447
1819
|
//#endregion
|
|
1448
|
-
//#region atomic/utils/cssVar.ts
|
|
1449
|
-
function getCssVar(varName, value) {
|
|
1450
|
-
return "var(" + varName + ", " + escapeCssValue(value) + ")";
|
|
1451
|
-
}
|
|
1452
|
-
function getCssVarRawFallback(varName, fallbackCss) {
|
|
1453
|
-
return "var(" + varName + ", " + fallbackCss + ")";
|
|
1454
|
-
}
|
|
1455
|
-
function escapeCssValue(value) {
|
|
1456
|
-
if (!value) return "";
|
|
1457
|
-
return value.trim().replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/'/g, "\\'").replace(/;/g, "\\;");
|
|
1458
|
-
}
|
|
1459
|
-
const formatTokenName = createNameFormatter(["name"]);
|
|
1460
|
-
function getTokenVarName(token, format) {
|
|
1461
|
-
const explicitName = getStyleTokenVarName(token);
|
|
1462
|
-
if (explicitName) return explicitName;
|
|
1463
|
-
const id = getStyleTokenId(token);
|
|
1464
|
-
const debugName = getStyleTokenName(token);
|
|
1465
|
-
return "--" + formatTokenName(format || "token[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name: debugName });
|
|
1466
|
-
}
|
|
1467
|
-
function getTokenVar(token, format) {
|
|
1468
|
-
return getTokenVarFallback(token, format);
|
|
1469
|
-
}
|
|
1470
|
-
function getTokenOverrideValue(token, format) {
|
|
1471
|
-
return token.ref ? getTokenVar(token.ref, format) : token.value;
|
|
1472
|
-
}
|
|
1473
|
-
function getTokenVarFallback(token, tokenNameFormat) {
|
|
1474
|
-
const varName = getTokenVarName(token, tokenNameFormat);
|
|
1475
|
-
if (token.ref) return getCssVarRawFallback(varName, getTokenVarFallback(token.ref, tokenNameFormat));
|
|
1476
|
-
return getCssVar(varName, String(token.value ?? ""));
|
|
1477
|
-
}
|
|
1478
|
-
//#endregion
|
|
1479
1820
|
//#region runtime/core/cache/stateItem.ts
|
|
1480
1821
|
function getStateItemDedupe(item) {
|
|
1481
1822
|
if (Array.isArray(item)) {
|
|
@@ -1786,65 +2127,6 @@ function getBoundTokens(item, bindings) {
|
|
|
1786
2127
|
return tokens;
|
|
1787
2128
|
}
|
|
1788
2129
|
//#endregion
|
|
1789
|
-
//#region runtime/core/className.ts
|
|
1790
|
-
function mergeClassName(className) {
|
|
1791
|
-
if (!className) return void 0;
|
|
1792
|
-
if (!Array.isArray(className)) return className;
|
|
1793
|
-
let nextClassName = "";
|
|
1794
|
-
const stack = [className];
|
|
1795
|
-
while (stack.length) {
|
|
1796
|
-
const item = stack.pop();
|
|
1797
|
-
if (!item) continue;
|
|
1798
|
-
if (Array.isArray(item)) for (let index = item.length - 1; index >= 0; index--) stack.push(item[index]);
|
|
1799
|
-
else nextClassName = nextClassName ? `${nextClassName} ${item}` : item;
|
|
1800
|
-
}
|
|
1801
|
-
return nextClassName || void 0;
|
|
1802
|
-
}
|
|
1803
|
-
function mergeStyle(style) {
|
|
1804
|
-
if (!style) return void 0;
|
|
1805
|
-
if (!Array.isArray(style)) return style;
|
|
1806
|
-
const nextStyle = {};
|
|
1807
|
-
const stack = [style];
|
|
1808
|
-
while (stack.length) {
|
|
1809
|
-
const item = stack.pop();
|
|
1810
|
-
if (!item) continue;
|
|
1811
|
-
if (Array.isArray(item)) for (let index = item.length - 1; index >= 0; index--) stack.push(item[index]);
|
|
1812
|
-
else Object.assign(nextStyle, item);
|
|
1813
|
-
}
|
|
1814
|
-
return nextStyle;
|
|
1815
|
-
}
|
|
1816
|
-
function mergeResolvedClassName(result, resolvedClassName) {
|
|
1817
|
-
if (!resolvedClassName) return;
|
|
1818
|
-
result.className = result.className ? result.className + " " + resolvedClassName : resolvedClassName;
|
|
1819
|
-
}
|
|
1820
|
-
function mergeResolvedStyle(result, resolvedStyle) {
|
|
1821
|
-
if (!resolvedStyle) return;
|
|
1822
|
-
result.style = result.style ? Object.assign({}, resolvedStyle, result.style) : resolvedStyle;
|
|
1823
|
-
}
|
|
1824
|
-
function createClassNameResult(props = {}) {
|
|
1825
|
-
return {
|
|
1826
|
-
className: props.className ? mergeClassName(props.className) : void 0,
|
|
1827
|
-
style: props.style ? mergeStyle(props.style) : void 0
|
|
1828
|
-
};
|
|
1829
|
-
}
|
|
1830
|
-
function finishClassNameResult(result) {
|
|
1831
|
-
return result.className || result.style ? result : {};
|
|
1832
|
-
}
|
|
1833
|
-
//#endregion
|
|
1834
|
-
//#region runtime/core/resolveClassNameRuntime.ts
|
|
1835
|
-
function resolveClassNameRuntime(styleProp, props = {}) {
|
|
1836
|
-
const result = createClassNameResult(props);
|
|
1837
|
-
const resolved = resolveStylePropRuntime(styleProp);
|
|
1838
|
-
if (resolved) {
|
|
1839
|
-
mergeResolvedClassName(result, resolved.result.className);
|
|
1840
|
-
mergeResolvedStyle(result, resolved.result.style);
|
|
1841
|
-
}
|
|
1842
|
-
return {
|
|
1843
|
-
result: finishClassNameResult(result),
|
|
1844
|
-
items: resolved?.items ?? []
|
|
1845
|
-
};
|
|
1846
|
-
}
|
|
1847
|
-
//#endregion
|
|
1848
2130
|
//#region atomic/property/types.ts
|
|
1849
2131
|
const LONGHAND = LayerPropertyPriorities.longhand;
|
|
1850
2132
|
const SHORTHAND = LayerPropertyPriorities.shorthand;
|
|
@@ -2184,164 +2466,67 @@ const text = {
|
|
|
2184
2466
|
textDecorationLine: LONGHAND,
|
|
2185
2467
|
textDecorationSkip: LONGHAND,
|
|
2186
2468
|
textDecorationSkipInk: LONGHAND,
|
|
2187
|
-
textDecorationStyle: LONGHAND,
|
|
2188
|
-
textDecorationThickness: LONGHAND,
|
|
2189
|
-
textEmphasis: SHORTHAND,
|
|
2190
|
-
textEmphasisColor: LONGHAND,
|
|
2191
|
-
textEmphasisPosition: LONGHAND,
|
|
2192
|
-
textEmphasisStyle: LONGHAND
|
|
2193
|
-
};
|
|
2194
|
-
const transition = {
|
|
2195
|
-
transition: SHORTHAND,
|
|
2196
|
-
transitionBehavior: LONGHAND,
|
|
2197
|
-
transitionDelay: LONGHAND,
|
|
2198
|
-
transitionDuration: LONGHAND,
|
|
2199
|
-
transitionProperty: LONGHAND,
|
|
2200
|
-
transitionTimingFunction: LONGHAND
|
|
2201
|
-
};
|
|
2202
|
-
const viewTimeline = {
|
|
2203
|
-
viewTimeline: SHORTHAND,
|
|
2204
|
-
viewTimelineAxis: LONGHAND,
|
|
2205
|
-
viewTimelineInset: LONGHAND,
|
|
2206
|
-
viewTimelineName: LONGHAND
|
|
2207
|
-
};
|
|
2208
|
-
const whiteSpace = {
|
|
2209
|
-
whiteSpace: SHORTHAND,
|
|
2210
|
-
whiteSpaceCollapse: LONGHAND
|
|
2211
|
-
};
|
|
2212
|
-
//#endregion
|
|
2213
|
-
//#region atomic/property/presets.ts
|
|
2214
|
-
const DefaultPropertyTypes = {
|
|
2215
|
-
...animation,
|
|
2216
|
-
...background,
|
|
2217
|
-
...border,
|
|
2218
|
-
...columns,
|
|
2219
|
-
...containIntrinsicSize,
|
|
2220
|
-
...container,
|
|
2221
|
-
...flex,
|
|
2222
|
-
...font,
|
|
2223
|
-
...gap,
|
|
2224
|
-
...grid,
|
|
2225
|
-
...inset,
|
|
2226
|
-
...listStyle,
|
|
2227
|
-
...margin,
|
|
2228
|
-
...mask,
|
|
2229
|
-
...offset,
|
|
2230
|
-
...outline,
|
|
2231
|
-
...overflow,
|
|
2232
|
-
...overscrollBehavior,
|
|
2233
|
-
...padding,
|
|
2234
|
-
...place,
|
|
2235
|
-
...scrollMargin,
|
|
2236
|
-
...scrollPadding,
|
|
2237
|
-
...scrollTimeline,
|
|
2238
|
-
...text,
|
|
2239
|
-
...transition,
|
|
2240
|
-
...viewTimeline,
|
|
2241
|
-
...whiteSpace
|
|
2242
|
-
};
|
|
2243
|
-
function getPropertyPriority(property) {
|
|
2244
|
-
return DefaultPropertyTypes[property] ?? 0;
|
|
2245
|
-
}
|
|
2246
|
-
function getCssPropertyName(property) {
|
|
2247
|
-
return property.replace(/^(webkit|moz|ms|o)([A-Z])/g, (_, prefix, c) => `-${prefix}-${c.toLowerCase()}`).replace(/[A-Z]/g, (c) => "-" + c.toLowerCase());
|
|
2248
|
-
}
|
|
2249
|
-
function getScopeClassName(className, scopeClassNameFormat) {
|
|
2250
|
-
return formatScopeClassName(scopeClassNameFormat || "-(className)", { className });
|
|
2251
|
-
}
|
|
2252
|
-
function formatScopeClassName(format, info) {
|
|
2253
|
-
if (typeof format === "function") return format(info);
|
|
2254
|
-
return format.replace(/\[|\]/g, "").replace(/\(className\)/g, info.className);
|
|
2255
|
-
}
|
|
2256
|
-
//#endregion
|
|
2257
|
-
//#region atomic/utils/selector.ts
|
|
2258
|
-
function getSelectorText(selector) {
|
|
2259
|
-
return stripSheetSelectorAnchor(Array.isArray(selector) ? selector[0] : selector);
|
|
2260
|
-
}
|
|
2261
|
-
function getSelectorPriority(selector) {
|
|
2262
|
-
if (!selector) return 0;
|
|
2263
|
-
return Array.isArray(selector) ? selector[1] : 0;
|
|
2264
|
-
}
|
|
2265
|
-
function hasSheetSelectorAnchor(selector) {
|
|
2266
|
-
return (selector ? Array.isArray(selector) ? selector[0] : selector : "").startsWith(SHEET_SELECTOR_ANCHOR);
|
|
2267
|
-
}
|
|
2268
|
-
function getSheetSelectorWeight(selector) {
|
|
2269
|
-
const text = selector ? Array.isArray(selector) ? selector[0] : selector : "";
|
|
2270
|
-
if (!text.startsWith("\0sheet:")) return null;
|
|
2271
|
-
const end = text.indexOf("\0", 6);
|
|
2272
|
-
if (end < 0) return null;
|
|
2273
|
-
const [weightValue] = text.slice(7, end).split(":");
|
|
2274
|
-
const weight = Number(weightValue);
|
|
2275
|
-
return Number.isInteger(weight) && weight > 0 ? weight : null;
|
|
2276
|
-
}
|
|
2277
|
-
function stripSheetSelectorAnchor(selector) {
|
|
2278
|
-
if (!selector.startsWith("\0sheet")) return selector;
|
|
2279
|
-
if (selector.startsWith("\0sheet:")) {
|
|
2280
|
-
const end = selector.indexOf("\0", 6);
|
|
2281
|
-
if (end >= 0) return selector.slice(end + 1);
|
|
2282
|
-
}
|
|
2283
|
-
return selector.slice(6);
|
|
2284
|
-
}
|
|
2285
|
-
//#endregion
|
|
2286
|
-
//#region atomic/value/unitless.ts
|
|
2287
|
-
const UnitlessProperties = [
|
|
2288
|
-
"animationIterationCount",
|
|
2289
|
-
"aspectRatio",
|
|
2290
|
-
"borderImageOutset",
|
|
2291
|
-
"borderImageSlice",
|
|
2292
|
-
"borderImageWidth",
|
|
2293
|
-
"boxFlex",
|
|
2294
|
-
"boxFlexGroup",
|
|
2295
|
-
"boxOrdinalGroup",
|
|
2296
|
-
"columnCount",
|
|
2297
|
-
"columns",
|
|
2298
|
-
"fillOpacity",
|
|
2299
|
-
"flex",
|
|
2300
|
-
"flexGrow",
|
|
2301
|
-
"flexNegative",
|
|
2302
|
-
"flexOrder",
|
|
2303
|
-
"flexPositive",
|
|
2304
|
-
"flexShrink",
|
|
2305
|
-
"floodOpacity",
|
|
2306
|
-
"fontWeight",
|
|
2307
|
-
"gridArea",
|
|
2308
|
-
"gridColumn",
|
|
2309
|
-
"gridColumnEnd",
|
|
2310
|
-
"gridColumnSpan",
|
|
2311
|
-
"gridColumnStart",
|
|
2312
|
-
"gridRow",
|
|
2313
|
-
"gridRowEnd",
|
|
2314
|
-
"gridRowSpan",
|
|
2315
|
-
"gridRowStart",
|
|
2316
|
-
"imageOrientation",
|
|
2317
|
-
"lineClamp",
|
|
2318
|
-
"lineHeight",
|
|
2319
|
-
"opacity",
|
|
2320
|
-
"order",
|
|
2321
|
-
"orphans",
|
|
2322
|
-
"scale",
|
|
2323
|
-
"stopOpacity",
|
|
2324
|
-
"strokeDasharray",
|
|
2325
|
-
"strokeDashoffset",
|
|
2326
|
-
"strokeMiterlimit",
|
|
2327
|
-
"strokeOpacity",
|
|
2328
|
-
"strokeWidth",
|
|
2329
|
-
"tabSize",
|
|
2330
|
-
"widows",
|
|
2331
|
-
"zIndex",
|
|
2332
|
-
"zoom"
|
|
2333
|
-
];
|
|
2469
|
+
textDecorationStyle: LONGHAND,
|
|
2470
|
+
textDecorationThickness: LONGHAND,
|
|
2471
|
+
textEmphasis: SHORTHAND,
|
|
2472
|
+
textEmphasisColor: LONGHAND,
|
|
2473
|
+
textEmphasisPosition: LONGHAND,
|
|
2474
|
+
textEmphasisStyle: LONGHAND
|
|
2475
|
+
};
|
|
2476
|
+
const transition = {
|
|
2477
|
+
transition: SHORTHAND,
|
|
2478
|
+
transitionBehavior: LONGHAND,
|
|
2479
|
+
transitionDelay: LONGHAND,
|
|
2480
|
+
transitionDuration: LONGHAND,
|
|
2481
|
+
transitionProperty: LONGHAND,
|
|
2482
|
+
transitionTimingFunction: LONGHAND
|
|
2483
|
+
};
|
|
2484
|
+
const viewTimeline = {
|
|
2485
|
+
viewTimeline: SHORTHAND,
|
|
2486
|
+
viewTimelineAxis: LONGHAND,
|
|
2487
|
+
viewTimelineInset: LONGHAND,
|
|
2488
|
+
viewTimelineName: LONGHAND
|
|
2489
|
+
};
|
|
2490
|
+
const whiteSpace = {
|
|
2491
|
+
whiteSpace: SHORTHAND,
|
|
2492
|
+
whiteSpaceCollapse: LONGHAND
|
|
2493
|
+
};
|
|
2334
2494
|
//#endregion
|
|
2335
|
-
//#region atomic/
|
|
2336
|
-
const
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2495
|
+
//#region atomic/property/presets.ts
|
|
2496
|
+
const DefaultPropertyTypes = {
|
|
2497
|
+
...animation,
|
|
2498
|
+
...background,
|
|
2499
|
+
...border,
|
|
2500
|
+
...columns,
|
|
2501
|
+
...containIntrinsicSize,
|
|
2502
|
+
...container,
|
|
2503
|
+
...flex,
|
|
2504
|
+
...font,
|
|
2505
|
+
...gap,
|
|
2506
|
+
...grid,
|
|
2507
|
+
...inset,
|
|
2508
|
+
...listStyle,
|
|
2509
|
+
...margin,
|
|
2510
|
+
...mask,
|
|
2511
|
+
...offset,
|
|
2512
|
+
...outline,
|
|
2513
|
+
...overflow,
|
|
2514
|
+
...overscrollBehavior,
|
|
2515
|
+
...padding,
|
|
2516
|
+
...place,
|
|
2517
|
+
...scrollMargin,
|
|
2518
|
+
...scrollPadding,
|
|
2519
|
+
...scrollTimeline,
|
|
2520
|
+
...text,
|
|
2521
|
+
...transition,
|
|
2522
|
+
...viewTimeline,
|
|
2523
|
+
...whiteSpace
|
|
2524
|
+
};
|
|
2525
|
+
function getPropertyPriority(property) {
|
|
2526
|
+
return DefaultPropertyTypes[property] ?? 0;
|
|
2342
2527
|
}
|
|
2343
|
-
function
|
|
2344
|
-
return
|
|
2528
|
+
function getCssPropertyName(property) {
|
|
2529
|
+
return property.replace(/^(webkit|moz|ms|o)([A-Z])/g, (_, prefix, c) => `-${prefix}-${c.toLowerCase()}`).replace(/[A-Z]/g, (c) => "-" + c.toLowerCase());
|
|
2345
2530
|
}
|
|
2346
2531
|
//#endregion
|
|
2347
2532
|
//#region atomic/rule.ts
|
|
@@ -2349,21 +2534,21 @@ function buildAtomicRule(className, property, value, important, selector, parent
|
|
|
2349
2534
|
const cssProp = getCssPropertyName(property);
|
|
2350
2535
|
const cssValue = getCssPropertyValue(property, value) + (important ? " !important" : "");
|
|
2351
2536
|
const escapedClass = escapeCssIdent(className);
|
|
2352
|
-
const
|
|
2353
|
-
const classSelector =
|
|
2354
|
-
const itemSelector = selector ? getSelectorText(selector) : "";
|
|
2355
|
-
let selectorStr = classSelector + itemSelector;
|
|
2537
|
+
const specificity = hasSheetSelectorAnchor(selector) ? getSheetSelectorSpecificity(selector) ?? 1 : 1;
|
|
2538
|
+
const classSelector = specificity === 0 ? `:where(.${escapedClass})` : Array(specificity).fill("." + escapedClass).join("");
|
|
2539
|
+
const itemSelector = selector ? getSelectorText$1(selector) : "";
|
|
2540
|
+
let selectorStr = hasGlobalSheetSelectorAnchor(selector) ? itemSelector : classSelector + itemSelector;
|
|
2356
2541
|
if (parentSelector) {
|
|
2357
|
-
const parentWhere = `:where(${"." + escapeCssIdent(getScopeClassName(className, scopeClassNameFormat)) + getSelectorText(parentSelector)})`;
|
|
2542
|
+
const parentWhere = `:where(${"." + escapeCssIdent(getScopeClassName(className, scopeClassNameFormat)) + getSelectorText$1(parentSelector)})`;
|
|
2358
2543
|
selectorStr = classSelector + parentWhere + itemSelector + "," + parentWhere + " " + selectorStr;
|
|
2359
2544
|
}
|
|
2360
2545
|
let rule = `${selectorStr}{${cssProp}: ${cssValue}}`;
|
|
2361
|
-
if (atRules) for (let i = atRules.length - 1; i >= 0; i--) rule = `${getSelectorText(atRules[i])}{${rule}}`;
|
|
2546
|
+
if (atRules) for (let i = atRules.length - 1; i >= 0; i--) rule = `${getSelectorText$1(atRules[i])}{${rule}}`;
|
|
2362
2547
|
return rule;
|
|
2363
2548
|
}
|
|
2364
2549
|
function getAtomicRuleLayerPriority(property, priority, selector, parentSelector, atRules, isScopeRule = false) {
|
|
2365
|
-
const selectorPriority = getSelectorPriority(selector);
|
|
2366
|
-
const parentSelectorPriority = getSelectorPriority(parentSelector);
|
|
2550
|
+
const selectorPriority = getSelectorPriority$1(selector);
|
|
2551
|
+
const parentSelectorPriority = getSelectorPriority$1(parentSelector);
|
|
2367
2552
|
const atRulePriority = getAtRulePriority(atRules);
|
|
2368
2553
|
return [
|
|
2369
2554
|
priority ?? 0,
|
|
@@ -2392,7 +2577,7 @@ function getParentSelectorPriority(parentSelector, priority) {
|
|
|
2392
2577
|
function getAtRulePriority(atRules) {
|
|
2393
2578
|
if (!atRules?.length) return 0;
|
|
2394
2579
|
let priority = 0;
|
|
2395
|
-
for (let i = 0, len = atRules.length; i < len; i++) priority = Math.max(priority, getSelectorPriority(atRules[i]));
|
|
2580
|
+
for (let i = 0, len = atRules.length; i < len; i++) priority = Math.max(priority, getSelectorPriority$1(atRules[i]));
|
|
2396
2581
|
return priority;
|
|
2397
2582
|
}
|
|
2398
2583
|
//#endregion
|
|
@@ -2409,6 +2594,8 @@ function createRuntimeSheetRules(item, sheetOptions = null) {
|
|
|
2409
2594
|
dedupe: runtimeItem.dedupe,
|
|
2410
2595
|
priority: layerPriority,
|
|
2411
2596
|
important: runtimeItem.important,
|
|
2597
|
+
importantNative: runtimeItem.importantNative,
|
|
2598
|
+
sheet: !!sheetOptions,
|
|
2412
2599
|
layer: getRuntimeRuleLayer(sheetOptions),
|
|
2413
2600
|
css: ruleCss,
|
|
2414
2601
|
callsite: runtimeItem.callsite,
|
|
@@ -2427,7 +2614,7 @@ function createRuntimeSheetRules(item, sheetOptions = null) {
|
|
|
2427
2614
|
}
|
|
2428
2615
|
function getRuntimeRuleLayer(sheetOptions) {
|
|
2429
2616
|
if (!sheetOptions) return "style";
|
|
2430
|
-
return resolveSheetLayerOption(sheetOptions.layer ??
|
|
2617
|
+
return resolveSheetLayerOption(sheetOptions.layer ?? false, CSS_CONFIG.layerNamespace || "css");
|
|
2431
2618
|
}
|
|
2432
2619
|
createNameFormatter(["name"]);
|
|
2433
2620
|
function getThemeRuleCss(className, tokens, tokenNameFormat) {
|
|
@@ -2493,16 +2680,21 @@ function createSheetRulePayload(rule) {
|
|
|
2493
2680
|
debugField: rule.debugField || null,
|
|
2494
2681
|
priority: rule.priority,
|
|
2495
2682
|
important: rule.important,
|
|
2683
|
+
importantNative: rule.importantNative,
|
|
2684
|
+
sheet: rule.sheet,
|
|
2685
|
+
globalSheet: rule.globalSheet,
|
|
2496
2686
|
layer: rule.layer
|
|
2497
2687
|
};
|
|
2498
2688
|
}
|
|
2499
2689
|
//#endregion
|
|
2500
|
-
//#region runtime/rsc/constants.ts
|
|
2501
|
-
const ELEMENT_CSS_DATA_ATTR = "data-css-dev";
|
|
2502
|
-
//#endregion
|
|
2503
2690
|
//#region runtime/env.ts
|
|
2504
2691
|
const IS_SERVER_RUNTIME = typeof window === "undefined";
|
|
2505
2692
|
//#endregion
|
|
2693
|
+
//#region runtime/rsc/constants.ts
|
|
2694
|
+
const GLOBAL_SEED_ATTR = "data-css-global-seed-dev";
|
|
2695
|
+
const GLOBAL_RULES_ATTR = "data-css-global-rules-dev";
|
|
2696
|
+
const ELEMENT_CSS_DATA_ATTR = "data-css-dev";
|
|
2697
|
+
//#endregion
|
|
2506
2698
|
//#region runtime/rsc/styleStore.ts
|
|
2507
2699
|
const GLOBAL_KEY = "runtime.rsc.styleStore";
|
|
2508
2700
|
function addRscStyleRules(rules) {
|
|
@@ -2517,6 +2709,12 @@ function addRscStyleRules(rules) {
|
|
|
2517
2709
|
}
|
|
2518
2710
|
store.counter += 1;
|
|
2519
2711
|
}
|
|
2712
|
+
function getRscStyleRules() {
|
|
2713
|
+
return getGlobalData(GLOBAL_KEY)?.rules ?? [];
|
|
2714
|
+
}
|
|
2715
|
+
function serializeRscRules(rules) {
|
|
2716
|
+
return serializeOrderedRules(rules, CSS_CONFIG, DEV_CONFIG.stylePriorityMode);
|
|
2717
|
+
}
|
|
2520
2718
|
function getRscStyleStore() {
|
|
2521
2719
|
return globalData(GLOBAL_KEY, () => ({
|
|
2522
2720
|
counter: 0,
|
|
@@ -2526,6 +2724,248 @@ function getRscStyleStore() {
|
|
|
2526
2724
|
}));
|
|
2527
2725
|
}
|
|
2528
2726
|
//#endregion
|
|
2727
|
+
//#region runtime/rsc/globalSheet.ts
|
|
2728
|
+
const seedComponent = globalData("runtime.rsc.global.seedComponent", () => ({ current: null }));
|
|
2729
|
+
const modules = globalData("runtime.rsc.global.modules", () => /* @__PURE__ */ new Map());
|
|
2730
|
+
const requestRegistry = globalData("runtime.rsc.global.request", () => cache(() => /* @__PURE__ */ new Map()));
|
|
2731
|
+
const delivered = globalData("runtime.rsc.global.delivered", () => cache(() => /* @__PURE__ */ new Map()));
|
|
2732
|
+
function getGlobalRuleBatches() {
|
|
2733
|
+
return [...modules, ...requestRegistry()].map(([owner, rules]) => ({
|
|
2734
|
+
owner,
|
|
2735
|
+
revision: hashString(JSON.stringify(rules)),
|
|
2736
|
+
rules
|
|
2737
|
+
}));
|
|
2738
|
+
}
|
|
2739
|
+
function serializeGlobalRuleBatches(batches) {
|
|
2740
|
+
return JSON.stringify(batches).replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
2741
|
+
}
|
|
2742
|
+
function GlobalSheetPayload() {
|
|
2743
|
+
const cursor = delivered();
|
|
2744
|
+
return renderGlobalRuleBatches(getGlobalRuleBatches().filter((batch) => {
|
|
2745
|
+
if (cursor.get(batch.owner) === batch.revision) return false;
|
|
2746
|
+
cursor.set(batch.owner, batch.revision);
|
|
2747
|
+
return true;
|
|
2748
|
+
}));
|
|
2749
|
+
}
|
|
2750
|
+
function renderGlobalRuleBatches(batches) {
|
|
2751
|
+
if (!batches.length) return null;
|
|
2752
|
+
const payload = serializeGlobalRuleBatches(batches);
|
|
2753
|
+
const current = new Map(getGlobalRuleBatches().map((batch) => [batch.owner, batch]));
|
|
2754
|
+
for (const batch of batches) current.set(batch.owner, batch);
|
|
2755
|
+
const allBatches = [...current.values()];
|
|
2756
|
+
const css = serializeRscRules([...getRscStyleRules(), ...allBatches.flatMap((batch) => batch.rules)]);
|
|
2757
|
+
const id = hashString(payload + css);
|
|
2758
|
+
return createElement(Fragment, null, seedComponent.current ? createElement(seedComponent.current, {
|
|
2759
|
+
globalRules: allBatches,
|
|
2760
|
+
seedOnly: true
|
|
2761
|
+
}) : null, createElement("style", {
|
|
2762
|
+
[GLOBAL_SEED_ATTR]: id,
|
|
2763
|
+
href: "fluentic-global-" + id,
|
|
2764
|
+
precedence: "default",
|
|
2765
|
+
dangerouslySetInnerHTML: { __html: css.replace(/<\/style/gi, "<\\/style") },
|
|
2766
|
+
suppressHydrationWarning: true
|
|
2767
|
+
}), createElement("script", {
|
|
2768
|
+
type: "application/json",
|
|
2769
|
+
async: true,
|
|
2770
|
+
[GLOBAL_RULES_ATTR]: id,
|
|
2771
|
+
dangerouslySetInnerHTML: { __html: payload },
|
|
2772
|
+
suppressHydrationWarning: true
|
|
2773
|
+
}));
|
|
2774
|
+
}
|
|
2775
|
+
function withGlobalSheetPayload(element, type) {
|
|
2776
|
+
if (!IS_SERVER_RUNTIME || !DEV_CONFIG.isDev || typeof type === "string" && [
|
|
2777
|
+
"html",
|
|
2778
|
+
"head",
|
|
2779
|
+
"style",
|
|
2780
|
+
"script",
|
|
2781
|
+
"meta",
|
|
2782
|
+
"link",
|
|
2783
|
+
"title"
|
|
2784
|
+
].includes(type)) return element;
|
|
2785
|
+
if (typeof type === "string" && !modules.size && !requestRegistry().size) return element;
|
|
2786
|
+
if (type === "body") {
|
|
2787
|
+
const props = element.props;
|
|
2788
|
+
return cloneElement(element, {}, createElement(GlobalSheetPayload), props.children);
|
|
2789
|
+
}
|
|
2790
|
+
return createElement(Fragment, element.key == null ? null : { key: element.key }, typeof type === "string" ? createElement(GlobalSheetPayload) : element, typeof type === "string" ? element : createElement(GlobalSheetPayload));
|
|
2791
|
+
}
|
|
2792
|
+
const formatElementClassName = createNameFormatter(["name"]);
|
|
2793
|
+
function getElementClassName(label, id, elementClassNameFormat) {
|
|
2794
|
+
const name = sanitizeDebugName(label) || null;
|
|
2795
|
+
const hash = getIdentifierSafeHash(id, DEV_CONFIG.hashLength ?? CSS_CONFIG.hashLength ?? 5);
|
|
2796
|
+
return formatElementClassName(elementClassNameFormat || "@(name)", hash, { name });
|
|
2797
|
+
}
|
|
2798
|
+
function getElementMarkerRuleCss(className) {
|
|
2799
|
+
return `.${escapeCssIdent(className)}{--fluentic-element-marker:0}`;
|
|
2800
|
+
}
|
|
2801
|
+
//#endregion
|
|
2802
|
+
//#region runtime/sheet/element.ts
|
|
2803
|
+
function createElementMarkerRule(className, callsite) {
|
|
2804
|
+
return {
|
|
2805
|
+
key: `element-marker:${className}`,
|
|
2806
|
+
css: getElementMarkerRuleCss(className),
|
|
2807
|
+
callsite
|
|
2808
|
+
};
|
|
2809
|
+
}
|
|
2810
|
+
//#endregion
|
|
2811
|
+
//#region runtime/core/elementMarker.ts
|
|
2812
|
+
const ELEMENT_MARKER_SHEET = globalData("runtime.elementMarkerSheet", () => ({ sheet: null }));
|
|
2813
|
+
function createElementMarkerClassName(debug) {
|
|
2814
|
+
if (!DEV_CONFIG.isDev || !DEV_CONFIG.isElementClassNameEnabled) return null;
|
|
2815
|
+
const marker = createElementMarkerRuleFromDebug(debug);
|
|
2816
|
+
if (!marker) return null;
|
|
2817
|
+
insertElementMarkerSheetRule(marker.rule);
|
|
2818
|
+
return marker.className;
|
|
2819
|
+
}
|
|
2820
|
+
function insertElementMarkerSheetRule(rule, documentOverride) {
|
|
2821
|
+
const document = getRuntimeDocument(documentOverride);
|
|
2822
|
+
if (!document) return;
|
|
2823
|
+
const className = getElementMarkerClassNameFromRule(rule);
|
|
2824
|
+
if (!className) return;
|
|
2825
|
+
const sheet = getElementMarkerSheet(document);
|
|
2826
|
+
sheet.classNames.add(className);
|
|
2827
|
+
sheet.sheet.insert(rule);
|
|
2828
|
+
sheet.sheet.flush();
|
|
2829
|
+
}
|
|
2830
|
+
function createElementMarkerRuleFromDebug(debug) {
|
|
2831
|
+
const callsite = getElementCallsite(debug);
|
|
2832
|
+
if (!callsite) return null;
|
|
2833
|
+
const className = getElementClassName(debug?.label, getElementCallsiteId(callsite), CSS_CONFIG.elementClassNameFormat || null);
|
|
2834
|
+
return {
|
|
2835
|
+
className,
|
|
2836
|
+
rule: createElementMarkerRule(className, callsite)
|
|
2837
|
+
};
|
|
2838
|
+
}
|
|
2839
|
+
function isElementMarkerRule(rule) {
|
|
2840
|
+
return typeof rule.key === "string" && rule.key.startsWith("element-marker:");
|
|
2841
|
+
}
|
|
2842
|
+
function getElementMarkerClassNameFromRule(rule) {
|
|
2843
|
+
if (!isElementMarkerRule(rule)) return null;
|
|
2844
|
+
return rule.key.slice(15) || null;
|
|
2845
|
+
}
|
|
2846
|
+
function getElementMarkerSheet(document) {
|
|
2847
|
+
const current = ELEMENT_MARKER_SHEET.sheet;
|
|
2848
|
+
if (current?.document === document) return current;
|
|
2849
|
+
current?.sheet.destroy?.();
|
|
2850
|
+
const sheet = {
|
|
2851
|
+
document,
|
|
2852
|
+
sheet: createDevSheet({
|
|
2853
|
+
document,
|
|
2854
|
+
tagName: "element-marker",
|
|
2855
|
+
top: true
|
|
2856
|
+
}),
|
|
2857
|
+
classNames: /* @__PURE__ */ new Set()
|
|
2858
|
+
};
|
|
2859
|
+
ELEMENT_MARKER_SHEET.sheet = sheet;
|
|
2860
|
+
return sheet;
|
|
2861
|
+
}
|
|
2862
|
+
onRuntimeDocumentChange(() => {
|
|
2863
|
+
ELEMENT_MARKER_SHEET.sheet?.sheet.destroy?.();
|
|
2864
|
+
ELEMENT_MARKER_SHEET.sheet = null;
|
|
2865
|
+
});
|
|
2866
|
+
function getElementCallsite(debug) {
|
|
2867
|
+
if (debug) return {
|
|
2868
|
+
filePath: debug.sourceUrl,
|
|
2869
|
+
sourceUrl: debug.sourceUrl,
|
|
2870
|
+
sourceContent: debug.code,
|
|
2871
|
+
line: debug.loc[0],
|
|
2872
|
+
column: debug.loc[1]
|
|
2873
|
+
};
|
|
2874
|
+
return null;
|
|
2875
|
+
}
|
|
2876
|
+
function getElementCallsiteId(callsite) {
|
|
2877
|
+
return `${callsite.filePath}\n${callsite.line}:${callsite.column}`;
|
|
2878
|
+
}
|
|
2879
|
+
//#endregion
|
|
2880
|
+
//#region runtime/core/createTransformElement.ts
|
|
2881
|
+
function createTransformElement(getClassName) {
|
|
2882
|
+
return ({ type, props }) => {
|
|
2883
|
+
if (!props || typeof type !== "string") return {
|
|
2884
|
+
type,
|
|
2885
|
+
props
|
|
2886
|
+
};
|
|
2887
|
+
if (!hasOwn(props, "css")) return {
|
|
2888
|
+
type,
|
|
2889
|
+
props
|
|
2890
|
+
};
|
|
2891
|
+
const { css, ...rest } = props;
|
|
2892
|
+
if (!css) return {
|
|
2893
|
+
type,
|
|
2894
|
+
props: rest
|
|
2895
|
+
};
|
|
2896
|
+
const marker = splitElementMarkerStyleProp(css);
|
|
2897
|
+
if (marker.styleProp) Object.assign(rest, getClassName(marker.styleProp, rest));
|
|
2898
|
+
prependClassName(rest, createElementMarkerClassName(marker.debug));
|
|
2899
|
+
return {
|
|
2900
|
+
type,
|
|
2901
|
+
props: rest
|
|
2902
|
+
};
|
|
2903
|
+
};
|
|
2904
|
+
}
|
|
2905
|
+
function prependClassName(props, className) {
|
|
2906
|
+
if (!className) return;
|
|
2907
|
+
props.className = props.className ? `${className} ${props.className}` : className;
|
|
2908
|
+
}
|
|
2909
|
+
//#endregion
|
|
2910
|
+
//#region runtime/core/className.ts
|
|
2911
|
+
function mergeClassName(className) {
|
|
2912
|
+
if (!className) return void 0;
|
|
2913
|
+
if (!Array.isArray(className)) return className;
|
|
2914
|
+
let nextClassName = "";
|
|
2915
|
+
const stack = [className];
|
|
2916
|
+
while (stack.length) {
|
|
2917
|
+
const item = stack.pop();
|
|
2918
|
+
if (!item) continue;
|
|
2919
|
+
if (Array.isArray(item)) for (let index = item.length - 1; index >= 0; index--) stack.push(item[index]);
|
|
2920
|
+
else nextClassName = nextClassName ? `${nextClassName} ${item}` : item;
|
|
2921
|
+
}
|
|
2922
|
+
return nextClassName || void 0;
|
|
2923
|
+
}
|
|
2924
|
+
function mergeStyle(style) {
|
|
2925
|
+
if (!style) return void 0;
|
|
2926
|
+
if (!Array.isArray(style)) return style;
|
|
2927
|
+
const nextStyle = {};
|
|
2928
|
+
const stack = [style];
|
|
2929
|
+
while (stack.length) {
|
|
2930
|
+
const item = stack.pop();
|
|
2931
|
+
if (!item) continue;
|
|
2932
|
+
if (Array.isArray(item)) for (let index = item.length - 1; index >= 0; index--) stack.push(item[index]);
|
|
2933
|
+
else Object.assign(nextStyle, item);
|
|
2934
|
+
}
|
|
2935
|
+
return nextStyle;
|
|
2936
|
+
}
|
|
2937
|
+
function mergeResolvedClassName(result, resolvedClassName) {
|
|
2938
|
+
if (!resolvedClassName) return;
|
|
2939
|
+
result.className = result.className ? result.className + " " + resolvedClassName : resolvedClassName;
|
|
2940
|
+
}
|
|
2941
|
+
function mergeResolvedStyle(result, resolvedStyle) {
|
|
2942
|
+
if (!resolvedStyle) return;
|
|
2943
|
+
result.style = result.style ? Object.assign({}, resolvedStyle, result.style) : resolvedStyle;
|
|
2944
|
+
}
|
|
2945
|
+
function createClassNameResult(props = {}) {
|
|
2946
|
+
return {
|
|
2947
|
+
className: props.className ? mergeClassName(props.className) : void 0,
|
|
2948
|
+
style: props.style ? mergeStyle(props.style) : void 0
|
|
2949
|
+
};
|
|
2950
|
+
}
|
|
2951
|
+
function finishClassNameResult(result) {
|
|
2952
|
+
return result.className || result.style ? result : {};
|
|
2953
|
+
}
|
|
2954
|
+
//#endregion
|
|
2955
|
+
//#region runtime/core/resolveClassNameRuntime.ts
|
|
2956
|
+
function resolveClassNameRuntime(styleProp, props = {}) {
|
|
2957
|
+
const result = createClassNameResult(props);
|
|
2958
|
+
const resolved = resolveStylePropRuntime(styleProp);
|
|
2959
|
+
if (resolved) {
|
|
2960
|
+
mergeResolvedClassName(result, resolved.result.className);
|
|
2961
|
+
mergeResolvedStyle(result, resolved.result.style);
|
|
2962
|
+
}
|
|
2963
|
+
return {
|
|
2964
|
+
result: finishClassNameResult(result),
|
|
2965
|
+
items: resolved?.items ?? []
|
|
2966
|
+
};
|
|
2967
|
+
}
|
|
2968
|
+
//#endregion
|
|
2529
2969
|
//#region runtime/rsc/getClassName.ts
|
|
2530
2970
|
function getClassName(styleProp, props = {}) {
|
|
2531
2971
|
const marker = splitElementMarkerStyleProp(styleProp);
|
|
@@ -2552,6 +2992,9 @@ function createRscStylePayloadRule(rule) {
|
|
|
2552
2992
|
css: rule.css,
|
|
2553
2993
|
priority: rule.priority,
|
|
2554
2994
|
important: rule.important,
|
|
2995
|
+
importantNative: rule.importantNative,
|
|
2996
|
+
sheet: rule.sheet,
|
|
2997
|
+
globalSheet: rule.globalSheet,
|
|
2555
2998
|
layer: rule.layer,
|
|
2556
2999
|
callsite: isElementMarkerRule(rule) ? rule.callsite : void 0,
|
|
2557
3000
|
debug: rule.debug ? createRscDebugPayload(rule.debug, rule.debugField) : void 0,
|
|
@@ -2604,6 +3047,6 @@ function createJsx(fn, transformElement) {
|
|
|
2604
3047
|
};
|
|
2605
3048
|
}
|
|
2606
3049
|
//#endregion
|
|
2607
|
-
export { transformElement as a, wrapFragment as i, createJsxDEV as n, wrapCreateElement as r, createJsx as t };
|
|
3050
|
+
export { transformElement as a, wrapFragment as i, createJsxDEV as n, withGlobalSheetPayload as o, wrapCreateElement as r, createJsx as t };
|
|
2608
3051
|
|
|
2609
|
-
//# sourceMappingURL=utils-
|
|
3052
|
+
//# sourceMappingURL=utils-sG7IWYP6.js.map
|