@fluentic/style 0.1.0-beta.13 → 0.1.0-beta.14
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 +10 -0
- package/README.md +3 -2
- package/atomic/token.ts +10 -1
- package/builder/extract/token.ts +10 -0
- package/compiler/transform/evaluator/evaluator.ts +83 -9
- package/compiler/transform/evaluator/tracer.ts +4 -0
- package/compiler/transform/extract/plugin.ts +30 -4
- package/compiler/transform/extract/utils/imports.ts +5 -1
- package/compiler/transform/extract/utils/replacement.ts +15 -3
- package/compiler/transform/extract/utils/state.ts +2 -0
- package/compiler/transform/extract/utils/token.ts +107 -0
- package/compiler/utils/constants.ts +1 -0
- package/dialect/namedTokens.ts +13 -8
- package/dist/{combine-yuoQ_qpx.js → combine-CC9bY-hu.js} +2 -2
- package/dist/{combine-yuoQ_qpx.js.map → combine-CC9bY-hu.js.map} +1 -1
- package/dist/compiler/index.mjs +1 -1
- package/dist/{compiler-BEHxZYjz.mjs → compiler-Ct5xGIeu.mjs} +164 -24
- package/dist/compiler-Ct5xGIeu.mjs.map +1 -0
- package/dist/config/index.js +2 -2
- package/dist/{config-DggQEE-4.js → config-BiiMS4rU.js} +3 -3
- package/dist/{config-DggQEE-4.js.map → config-BiiMS4rU.js.map} +1 -1
- package/dist/{config-B5nEd-TV.js → config-CCgsVvyR.js} +2 -2
- package/dist/{config-B5nEd-TV.js.map → config-CCgsVvyR.js.map} +1 -1
- package/dist/{config-BWGBkVrM.js → config-DZKR6gH1.js} +4 -4
- package/dist/{config-BWGBkVrM.js.map → config-DZKR6gH1.js.map} +1 -1
- package/dist/{config-Bqe8Y-4_.js → config-TyjNpRrV.js} +2 -2
- package/dist/{config-Bqe8Y-4_.js.map → config-TyjNpRrV.js.map} +1 -1
- package/dist/{createTransformElement-B2jSnugo.js → createTransformElement-BGznW-Mu.js} +2 -2
- package/dist/{createTransformElement-B2jSnugo.js.map → createTransformElement-BGznW-Mu.js.map} +1 -1
- package/dist/{css-CGMAis1n.js → css-BhoclXaw.js} +5 -5
- package/dist/{css-CGMAis1n.js.map → css-BhoclXaw.js.map} +1 -1
- package/dist/{css-p_5ZNny_.js → css-IecKRNxs.js} +11 -11
- package/dist/{css-p_5ZNny_.js.map → css-IecKRNxs.js.map} +1 -1
- package/dist/{css-BQRIvzwZ.js → css-WaHZ6gxv.js} +6 -2
- package/dist/css-WaHZ6gxv.js.map +1 -0
- package/dist/css.js +1 -1
- package/dist/{css_extra-DuVzUIYx.js → css_extra-DDeJc2Cu.js} +2 -2
- package/dist/{css_extra-DuVzUIYx.js.map → css_extra-DDeJc2Cu.js.map} +1 -1
- package/dist/{data-QXDBLlWs.js → data-BgZmL55Y.js} +7 -8
- package/dist/{data-QXDBLlWs.js.map → data-BgZmL55Y.js.map} +1 -1
- package/dist/{debug-CkgcZDaX.js → debug-D-1hhd0G.js} +27 -3
- package/dist/debug-D-1hhd0G.js.map +1 -0
- package/dist/dev/rsc.js +6 -6
- package/dist/{dev-DocaGP3_.js → dev-CBRbVaeq.js} +6 -7
- package/dist/{dev-DocaGP3_.js.map → dev-CBRbVaeq.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-DZjd1NuA.js → elementMarker-CJcfpKL1.js} +5 -6
- package/dist/{elementMarker-DZjd1NuA.js.map → elementMarker-CJcfpKL1.js.map} +1 -1
- 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 +2 -2
- 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/css.js +2 -2
- package/dist/entry/prod/extract.js +10 -1
- package/dist/entry/prod/extract.js.map +1 -1
- package/dist/entry/prod.js +2 -2
- 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 +2 -2
- package/dist/entry/rsc-dev/dev.js +5 -5
- package/dist/entry/rsc-dev/jsx-dev-runtime.js +2 -2
- package/dist/entry/rsc-dev/jsx-runtime.js +2 -2
- package/dist/entry/rsc-dev.js +5 -5
- package/dist/entry/rsc-prod/css.js +2 -2
- package/dist/entry/rsc-prod.js +12 -3
- package/dist/entry/rsc-prod.js.map +1 -1
- package/dist/{env-DJyXPJ9q.js → env-C8TRVSyb.js} +5 -1
- package/dist/env-C8TRVSyb.js.map +1 -0
- package/dist/getClassName-9CsXbNls.js.map +1 -1
- package/dist/{getClassName-BB_L7U_v.js → getClassName-BNe3Ycyy.js} +4 -5
- package/dist/{getClassName-BB_L7U_v.js.map → getClassName-BNe3Ycyy.js.map} +1 -1
- package/dist/{getClassName-BIqt1S41.js → getClassName-CeoxISNW.js} +4 -4
- package/dist/{getClassName-BIqt1S41.js.map → getClassName-CeoxISNW.js.map} +1 -1
- package/dist/getClassName-DtkplEIt.js.map +1 -1
- package/dist/{global-CBQGormL.js → global-CWYOol4o.js} +2 -2
- package/dist/{global-CBQGormL.js.map → global-CWYOol4o.js.map} +1 -1
- package/dist/global-UOHFwqHN.js +33 -0
- package/dist/global-UOHFwqHN.js.map +1 -0
- package/dist/{debug-0iaVEC7z.js → hash-DlXmmPPm.js} +167 -5
- package/dist/hash-DlXmmPPm.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 +1 -1
- package/dist/jsx/jsx-runtime.js +1 -1
- package/dist/jsx/jsx-runtime.server.js +1 -1
- package/dist/{jsx-BCufpzdb.js → jsx-8TwYuvgM.js} +4 -4
- package/dist/{jsx-BCufpzdb.js.map → jsx-8TwYuvgM.js.map} +1 -1
- package/dist/{jsx_runtime-Bu_A8mr4.js → jsx_runtime-CPojW0KD.js} +2 -2
- package/dist/{jsx_runtime-Bu_A8mr4.js.map → jsx_runtime-CPojW0KD.js.map} +1 -1
- package/dist/{loader-vMHuD1zT.mjs → loader-BVebGteg.mjs} +3 -3
- package/dist/{loader-vMHuD1zT.mjs.map → loader-BVebGteg.mjs.map} +1 -1
- package/dist/{misc-9EGKYkZo.mjs → misc-Bs2DgdG7.mjs} +2 -2
- package/dist/{misc-9EGKYkZo.mjs.map → misc-Bs2DgdG7.mjs.map} +1 -1
- package/dist/{namedTokens-DnpyC5XT.js → namedTokens-CwniouKk.js} +13 -9
- package/dist/namedTokens-CwniouKk.js.map +1 -0
- package/dist/plugin/farm/index.mjs +3 -3
- package/dist/plugin/nextjs/index.mjs +4 -4
- package/dist/plugin/nextjs/loader.mjs +4 -4
- 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-DVB7n6V-.mjs → registry-D1n78rd7.mjs} +2 -2
- package/dist/{registry-DVB7n6V-.mjs.map → registry-D1n78rd7.mjs.map} +1 -1
- package/dist/{resolveClassNameRuntime-DvH6j_4N.js → resolveClassNameRuntime-BJcykzdl.js} +2 -2
- package/dist/{resolveClassNameRuntime-DvH6j_4N.js.map → resolveClassNameRuntime-BJcykzdl.js.map} +1 -1
- package/dist/{rules-znG9bsKI.js → rules-Dz-szpPu.js} +7 -8
- package/dist/{rules-znG9bsKI.js.map → rules-Dz-szpPu.js.map} +1 -1
- package/dist/server.js +13 -13
- package/dist/{shared-DaEDCb8I.cjs → shared-C9XQd8p_.cjs} +164 -24
- package/dist/shared-C9XQd8p_.cjs.map +1 -0
- package/dist/{shared-O-5Fcsxa.mjs → shared-D4-AKGn6.mjs} +4 -4
- package/dist/{shared-O-5Fcsxa.mjs.map → shared-D4-AKGn6.mjs.map} +1 -1
- package/dist/sheet-LU89fcH_.js +7 -0
- package/dist/{sheet-SlZRjOmw.js.map → sheet-LU89fcH_.js.map} +1 -1
- package/dist/{sidecar-DiYLwXbk.mjs → sidecar-CZTYX2vA.mjs} +3 -3
- package/dist/{sidecar-DiYLwXbk.mjs.map → sidecar-CZTYX2vA.mjs.map} +1 -1
- package/dist/{style-CtXEZqgx.js → style-CmXHCPF4.js} +10 -11
- package/dist/{style-CtXEZqgx.js.map → style-CmXHCPF4.js.map} +1 -1
- package/dist/{styleStore-CBan0gHQ.js → styleStore-B0x4Ahpx.js} +5 -5
- package/dist/{styleStore-CBan0gHQ.js.map → styleStore-B0x4Ahpx.js.map} +1 -1
- package/dist/{styleStore-BImBZdt6.js → styleStore-BrpgLNgc.js} +2 -2
- package/dist/{styleStore-BImBZdt6.js.map → styleStore-BrpgLNgc.js.map} +1 -1
- package/dist/{token-DyLO6Hnf.js → token-DMrBbat8.js} +5 -33
- package/dist/token-DMrBbat8.js.map +1 -0
- package/dist/{trace-C1_6fM21.js → trace-C7EzEj2Q.js} +3 -3
- package/dist/{trace-C1_6fM21.js.map → trace-C7EzEj2Q.js.map} +1 -1
- package/dist/{trace-Bsh-Kkg_.js → trace-DzCntvK4.js} +2 -2
- package/dist/{trace-Bsh-Kkg_.js.map → trace-DzCntvK4.js.map} +1 -1
- package/dist/{transform-8TIMiF5A.js → transform-CSZMklMb.js} +2 -2
- package/dist/{transform-8TIMiF5A.js.map → transform-CSZMklMb.js.map} +1 -1
- package/dist/types/builder/data/merge/utils.d.ts +6 -1
- package/dist/types/builder/data/state.d.ts +16 -2
- package/dist/types/builder/extract/token.d.ts +6 -1
- package/dist/types/builder/style_fns.d.ts +1 -1
- package/dist/types/builder/utils.d.ts +1 -1
- package/dist/types/compiler/transform/evaluator/evaluator.d.ts +18 -1
- package/dist/types/compiler/transform/extract/utils/replacement.d.ts +2 -0
- package/dist/types/compiler/transform/extract/utils/state.d.ts +1 -0
- package/dist/types/compiler/transform/extract/utils/token.d.ts +3 -0
- package/dist/types/compiler/transform/utils/selector.d.ts +1 -1
- package/dist/types/compiler/utils/constants.d.ts +1 -0
- package/dist/types/compiler/utils/import_source.d.ts +8 -2
- package/dist/types/plugin/bundler/farm/plugin.d.ts +8 -2
- package/dist/types/presets/tailwind/selectors.d.ts +24 -24
- package/dist/types/presets/tailwind/theme.d.ts +361 -361
- package/dist/types/runtime/core/cache/itemWithResolver.d.ts +1 -1
- package/dist/types/runtime/core/cache/stateItem.d.ts +8 -2
- package/dist/types/runtime/types.d.ts +4 -1
- package/dist/types/selector/presets/default.d.ts +28 -28
- package/dist/types/selector/presets/minimal.d.ts +10 -10
- package/dist/types/selector/selector.d.ts +15 -2
- package/dist/types/style/style.d.ts +93 -93
- package/dist/{utils-DoKJnvxk.js → utils-B7QcJ-Yw.js} +3 -3
- package/dist/{utils-DoKJnvxk.js.map → utils-B7QcJ-Yw.js.map} +1 -1
- package/dist/{utils-Bjh9pO87.mjs → utils-BYpkJ-uE.mjs} +3 -3
- package/dist/{utils-Bjh9pO87.mjs.map → utils-BYpkJ-uE.mjs.map} +1 -1
- package/dist/{utils-BBN9msTv.mjs → utils-CoMwEfhG.mjs} +4 -4
- package/dist/{utils-BBN9msTv.mjs.map → utils-CoMwEfhG.mjs.map} +1 -1
- package/dist/{utils-10MTZOuB.js → utils-D4KMqCu2.js} +7 -2
- package/dist/utils-D4KMqCu2.js.map +1 -0
- package/dist/utils.js +3 -3
- package/dist/{value-Dg6ALjjj.js → value-yd2SZ1XQ.js} +37 -3
- package/dist/value-yd2SZ1XQ.js.map +1 -0
- package/dist/{webpack-C1j49Psk.mjs → webpack-B6z1UHh9.mjs} +5 -5
- package/dist/{webpack-C1j49Psk.mjs.map → webpack-B6z1UHh9.mjs.map} +1 -1
- package/package.json +5 -4
- package/runtime/extract/getClassName.ts +1 -1
- package/style/token.ts +2 -0
- package/dist/compiler-BEHxZYjz.mjs.map +0 -1
- package/dist/css-BQRIvzwZ.js.map +0 -1
- package/dist/css-D7eTqvMH.js +0 -57
- package/dist/css-D7eTqvMH.js.map +0 -1
- package/dist/debug-0iaVEC7z.js.map +0 -1
- package/dist/debug-CkgcZDaX.js.map +0 -1
- package/dist/env-DJyXPJ9q.js.map +0 -1
- package/dist/hash-Cr-LCWDt.js +0 -166
- package/dist/hash-Cr-LCWDt.js.map +0 -1
- package/dist/namedTokens-DnpyC5XT.js.map +0 -1
- package/dist/shared-DaEDCb8I.cjs.map +0 -1
- package/dist/sheet-SlZRjOmw.js +0 -7
- package/dist/token-DyLO6Hnf.js.map +0 -1
- package/dist/utils-10MTZOuB.js.map +0 -1
- package/dist/value-Dg6ALjjj.js.map +0 -1
|
@@ -257,6 +257,7 @@ const FN_CREATE_EXTRACTED_SHEET = "createExtractedSheet";
|
|
|
257
257
|
const FN_CREATE_EXTRACTED_SLOT = "createExtractedSlot";
|
|
258
258
|
const FN_CREATE_EXTRACTED_SCOPE = "createExtractedScope";
|
|
259
259
|
const FN_CREATE_EXTRACTED_TOKEN = "createExtractedToken";
|
|
260
|
+
const FN_CREATE_EXTRACTED_VALUES = "createExtractedValues";
|
|
260
261
|
const FN_CREATE_EXTRACTED_THEME = "createExtractedTheme";
|
|
261
262
|
const FN_CREATE_EXTRACTED_STYLE_MERGE = "createExtractedStyleMerge";
|
|
262
263
|
const FN_WITH_TOKENS = "withTokens";
|
|
@@ -697,6 +698,9 @@ function getStyleTokenId(token) {
|
|
|
697
698
|
function getStyleTokenName(token) {
|
|
698
699
|
return token[TOKEN_NAME] ?? null;
|
|
699
700
|
}
|
|
701
|
+
function getStyleTokenVarName(token) {
|
|
702
|
+
return token[TOKEN_VAR_NAME] ?? null;
|
|
703
|
+
}
|
|
700
704
|
//#endregion
|
|
701
705
|
//#region builder/token/name.ts
|
|
702
706
|
function getStyleTokenNameFromId(id) {
|
|
@@ -756,12 +760,14 @@ function createStyleTokenOverride(token, value, debug) {
|
|
|
756
760
|
[TOKEN_ID]: getStyleTokenId(token),
|
|
757
761
|
[TOKEN_OVERRIDE]: true,
|
|
758
762
|
[TOKEN_NAME]: getStyleTokenName(token),
|
|
763
|
+
[TOKEN_VAR_NAME]: token[TOKEN_VAR_NAME] ?? null,
|
|
759
764
|
value: value.value,
|
|
760
765
|
ref: value
|
|
761
766
|
} : {
|
|
762
767
|
[TOKEN_ID]: getStyleTokenId(token),
|
|
763
768
|
[TOKEN_OVERRIDE]: true,
|
|
764
769
|
[TOKEN_NAME]: getStyleTokenName(token),
|
|
770
|
+
[TOKEN_VAR_NAME]: token[TOKEN_VAR_NAME] ?? null,
|
|
765
771
|
value,
|
|
766
772
|
ref: null
|
|
767
773
|
};
|
|
@@ -1595,6 +1601,8 @@ function escapeCssValue(value) {
|
|
|
1595
1601
|
}
|
|
1596
1602
|
const formatTokenName = createNameFormatter(["name"]);
|
|
1597
1603
|
function getTokenVarName(token, format) {
|
|
1604
|
+
const explicitName = getStyleTokenVarName(token);
|
|
1605
|
+
if (explicitName) return explicitName;
|
|
1598
1606
|
const id = getStyleTokenId(token);
|
|
1599
1607
|
const debugName = getStyleTokenName(token);
|
|
1600
1608
|
return "--" + formatTokenName(format || "token[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name: debugName });
|
|
@@ -3845,8 +3853,9 @@ function appendExtractedStyleTuples(target, source) {
|
|
|
3845
3853
|
//#region dialect/namedTokens.ts
|
|
3846
3854
|
const ROOT = Symbol("fluentic.namedTokens.root");
|
|
3847
3855
|
function createNamedToken(id, value) {
|
|
3848
|
-
const
|
|
3849
|
-
token
|
|
3856
|
+
const tokenId = createNamedTokenId(id);
|
|
3857
|
+
const token = createStyleToken(value, tokenId);
|
|
3858
|
+
token[TOKEN_VAR_NAME] = "--token-" + tokenId;
|
|
3850
3859
|
return token;
|
|
3851
3860
|
}
|
|
3852
3861
|
function createNamedTokens(namespace, values) {
|
|
@@ -3858,7 +3867,10 @@ function createNamedTokens(namespace, values) {
|
|
|
3858
3867
|
}, []);
|
|
3859
3868
|
}
|
|
3860
3869
|
function createNamedTokenId(id) {
|
|
3861
|
-
return
|
|
3870
|
+
return id.split(".").map(encodeNamedTokenSegment).join("-");
|
|
3871
|
+
}
|
|
3872
|
+
function encodeNamedTokenSegment(segment) {
|
|
3873
|
+
return segment.replace(/[^a-zA-Z0-9]/gu, (char) => "_x" + char.codePointAt(0).toString(16) + "_");
|
|
3862
3874
|
}
|
|
3863
3875
|
function createNamedTokenProxy(root, path) {
|
|
3864
3876
|
return new Proxy(noop, {
|
|
@@ -3880,11 +3892,13 @@ function createNamedTokenProxy(root, path) {
|
|
|
3880
3892
|
});
|
|
3881
3893
|
}
|
|
3882
3894
|
function getNamedTokenAtPath(root, path) {
|
|
3883
|
-
const key =
|
|
3895
|
+
const key = JSON.stringify(path);
|
|
3884
3896
|
const cached = root.cache.get(key);
|
|
3885
3897
|
if (cached) return cached;
|
|
3886
3898
|
const value = getValueAtPath(root.values, path);
|
|
3887
|
-
const
|
|
3899
|
+
const id = root.namespace.split(".").concat(path).map(encodeNamedTokenSegment).join("-");
|
|
3900
|
+
const token = createStyleToken(value, id);
|
|
3901
|
+
token[TOKEN_VAR_NAME] = "--token-" + id;
|
|
3888
3902
|
root.cache.set(key, token);
|
|
3889
3903
|
return token;
|
|
3890
3904
|
}
|
|
@@ -3921,6 +3935,7 @@ function exposeStyleValue(value) {
|
|
|
3921
3935
|
//#region compiler/transform/evaluator/evaluator.ts
|
|
3922
3936
|
const STYLE_IMPORT_PATHS = new Set(IMPORT_PATHS);
|
|
3923
3937
|
const COMPILED_RUNTIME_VALUE = Symbol();
|
|
3938
|
+
const COMPILED_TOKEN_REFERENCE = Symbol();
|
|
3924
3939
|
const COMPILED_STYLE_OBJECT_LOCATIONS = Symbol();
|
|
3925
3940
|
const COMPILED_TOKEN_FACTORY = Symbol();
|
|
3926
3941
|
function evalOk(value) {
|
|
@@ -3943,11 +3958,11 @@ function evaluateNode(node, scope) {
|
|
|
3943
3958
|
case "BooleanLiteral": return evalOk(node.value);
|
|
3944
3959
|
case "NullLiteral": return evalOk(null);
|
|
3945
3960
|
case "TemplateLiteral": return evaluateTemplate(node, scope);
|
|
3946
|
-
case "Identifier": return evaluateIdentifier(node, scope);
|
|
3947
|
-
case "MemberExpression": return evaluateMember(node, scope);
|
|
3961
|
+
case "Identifier": return referenceResult(evaluateIdentifier(node, scope), node, scope);
|
|
3962
|
+
case "MemberExpression": return referenceResult(evaluateMember(node, scope), node, scope);
|
|
3948
3963
|
case "ObjectExpression": return evaluateObject(node, scope);
|
|
3949
3964
|
case "ArrayExpression": return evaluateArray(node, scope);
|
|
3950
|
-
case "CallExpression": return evaluateCall(node, scope);
|
|
3965
|
+
case "CallExpression": return referenceCallResult(evaluateCall(node, scope), node, scope);
|
|
3951
3966
|
case "BinaryExpression": return evaluateBinary(node, scope);
|
|
3952
3967
|
case "UnaryExpression": return evaluateUnary(node, scope);
|
|
3953
3968
|
case "ParenthesizedExpression":
|
|
@@ -4271,7 +4286,7 @@ function evaluateCall(node, scope) {
|
|
|
4271
4286
|
if (imp && STYLE_IMPORT_PATHS.has(imp.source) && imp.name === "getToken") {
|
|
4272
4287
|
const value = evaluateNode(node.arguments[0], scope);
|
|
4273
4288
|
if (!value.ok) return value;
|
|
4274
|
-
if (isStyleTokenData(value.value)) return evalOk(getTokenVar(value.value, CSS_CONFIG.tokenNameFormat || null));
|
|
4289
|
+
if (isStyleTokenData(value.value)) return evalOk(getTokenVar(value.value, scope.tokenNameFormat === void 0 ? CSS_CONFIG.tokenNameFormat || null : scope.tokenNameFormat));
|
|
4275
4290
|
return evalOk(value.value);
|
|
4276
4291
|
}
|
|
4277
4292
|
if (imp && imp.source === "@fluentic/style/utils" && imp.name === "exposeStyle") {
|
|
@@ -4309,7 +4324,7 @@ function evaluateCall(node, scope) {
|
|
|
4309
4324
|
if (!provide.ok) return provide;
|
|
4310
4325
|
return evalOk(createCompiledTokenOverride(target, provide.value, node));
|
|
4311
4326
|
}
|
|
4312
|
-
return evalOk(withRuntimeValue(node, target));
|
|
4327
|
+
return referenceResult(evalOk(withRuntimeValue(node, target)), node, scope);
|
|
4313
4328
|
}
|
|
4314
4329
|
}
|
|
4315
4330
|
if (node.callee.type === "MemberExpression") {
|
|
@@ -4327,7 +4342,7 @@ function evaluateCall(node, scope) {
|
|
|
4327
4342
|
if (!stableId.ok) return stableId;
|
|
4328
4343
|
const stable = stableId.value ?? createCompiledAtRuleStableId(scope, node.loc?.start, frames.value);
|
|
4329
4344
|
const meta = scope.styleMetas?.get(node.callee.object.name);
|
|
4330
|
-
const transformedFrames = transformKeyframes(frames.value, meta?.transform ?? scope.styleTransform ?? null);
|
|
4345
|
+
const transformedFrames = transformKeyframes(frames.value, (meta?.mode === "StyleObject" ? meta.transform : null) ?? scope.styleTransform ?? null);
|
|
4331
4346
|
const format = CSS_EXTRA_CONFIG.namedRuleFormat.keyframes ?? null;
|
|
4332
4347
|
return evalOk(createCompiledAtRuleRef({
|
|
4333
4348
|
value: formatKeyFramesName(format, stable.id, { name: stable.name }),
|
|
@@ -4383,6 +4398,7 @@ function createCompiledTokenOverride(token, value, runtimeValue) {
|
|
|
4383
4398
|
[TOKEN_ID]: getStyleTokenId(token),
|
|
4384
4399
|
[TOKEN_OVERRIDE]: true,
|
|
4385
4400
|
[TOKEN_NAME]: getStyleTokenName(token),
|
|
4401
|
+
[TOKEN_VAR_NAME]: token[TOKEN_VAR_NAME] ?? null,
|
|
4386
4402
|
value: value.value,
|
|
4387
4403
|
ref: value
|
|
4388
4404
|
});
|
|
@@ -4390,6 +4406,7 @@ function createCompiledTokenOverride(token, value, runtimeValue) {
|
|
|
4390
4406
|
[TOKEN_ID]: getStyleTokenId(token),
|
|
4391
4407
|
[TOKEN_OVERRIDE]: true,
|
|
4392
4408
|
[TOKEN_NAME]: getStyleTokenName(token),
|
|
4409
|
+
[TOKEN_VAR_NAME]: token[TOKEN_VAR_NAME] ?? null,
|
|
4393
4410
|
value,
|
|
4394
4411
|
ref: null
|
|
4395
4412
|
});
|
|
@@ -4448,6 +4465,7 @@ function assignCompiledTokenRecord(target, value, scope, loc, runtimeValue, stab
|
|
|
4448
4465
|
}
|
|
4449
4466
|
}
|
|
4450
4467
|
function createCompiledValues(values, scope, loc, runtimeValue, stableId, isNumber) {
|
|
4468
|
+
if (!values.length) throw new Error("[Style.values] NO_VALUES");
|
|
4451
4469
|
const tokens = /* @__PURE__ */ new Map();
|
|
4452
4470
|
const groupName = getStyleTokenNameFromId(stableId);
|
|
4453
4471
|
for (let i = 0, len = values.length; i < len; i++) {
|
|
@@ -4464,7 +4482,7 @@ function parseCompiledValue(value, isNumber) {
|
|
|
4464
4482
|
value = String(value).split(/[;|]/)[0].trim();
|
|
4465
4483
|
if (!isNumber) return value;
|
|
4466
4484
|
const number = Number(value);
|
|
4467
|
-
if (!Number.isFinite(number))
|
|
4485
|
+
if (!Number.isFinite(number)) throw new Error(`[Style.values] INVALID_NUMBER_VALUE: ${String(value)}`);
|
|
4468
4486
|
return number;
|
|
4469
4487
|
}
|
|
4470
4488
|
function isCompiledTokenFactory(value) {
|
|
@@ -4512,9 +4530,14 @@ function sanitizeTokenDebugName(value) {
|
|
|
4512
4530
|
return value.replace(/[^a-zA-Z0-9_-]+/g, "-").replace(/^-+|-+$/g, "") || null;
|
|
4513
4531
|
}
|
|
4514
4532
|
function withRuntimeValue(runtimeValue, token) {
|
|
4533
|
+
if (typeof token === "function") return new Proxy(token, { get(target, key) {
|
|
4534
|
+
if (key === COMPILED_RUNTIME_VALUE) return runtimeValue;
|
|
4535
|
+
return Reflect.get(target, key);
|
|
4536
|
+
} });
|
|
4515
4537
|
return Object.assign({}, token, {
|
|
4516
4538
|
[TOKEN_ID]: token[TOKEN_ID],
|
|
4517
4539
|
[TOKEN_NAME]: token[TOKEN_NAME] ?? null,
|
|
4540
|
+
[TOKEN_VAR_NAME]: token[TOKEN_VAR_NAME] ?? null,
|
|
4518
4541
|
[COMPILED_RUNTIME_VALUE]: runtimeValue
|
|
4519
4542
|
});
|
|
4520
4543
|
}
|
|
@@ -4545,6 +4568,34 @@ function evaluateUnary(node, scope) {
|
|
|
4545
4568
|
default: return evalFail(`Unsupported unary operator: ${node.operator}`);
|
|
4546
4569
|
}
|
|
4547
4570
|
}
|
|
4571
|
+
function referenceResult(result, expression, scope) {
|
|
4572
|
+
if (!result.ok) return result;
|
|
4573
|
+
return evalOk(referenceValue(result.value, expression, scope));
|
|
4574
|
+
}
|
|
4575
|
+
function referenceValue(value, expression, scope, nested = false) {
|
|
4576
|
+
if (isStyleTokenData(value) || isStyleTokenOverrideData(value)) {
|
|
4577
|
+
if (nested && value[COMPILED_TOKEN_REFERENCE]?.filePath === scope.filePath) return value;
|
|
4578
|
+
const reference = {
|
|
4579
|
+
expression,
|
|
4580
|
+
filePath: scope.filePath
|
|
4581
|
+
};
|
|
4582
|
+
if (typeof value === "function") return new Proxy(value, { get(target, key) {
|
|
4583
|
+
if (key === COMPILED_TOKEN_REFERENCE) return reference;
|
|
4584
|
+
return Reflect.get(target, key);
|
|
4585
|
+
} });
|
|
4586
|
+
return Object.assign(withRuntimeValue(value[COMPILED_RUNTIME_VALUE] ?? expression, value), { [COMPILED_TOKEN_REFERENCE]: reference });
|
|
4587
|
+
}
|
|
4588
|
+
if (!value || typeof value !== "object" || isCompiledTokenFactory(value)) return value;
|
|
4589
|
+
if (Object.getOwnPropertySymbols(value).some((key) => key !== COMPILED_STYLE_OBJECT_LOCATIONS)) return value;
|
|
4590
|
+
const result = Object.defineProperties(Array.isArray(value) ? [] : {}, Object.getOwnPropertyDescriptors(value));
|
|
4591
|
+
for (const key of Object.keys(value)) result[key] = referenceValue(value[key], BabelCore.types.memberExpression(expression, BabelCore.types.stringLiteral(key), true), scope, true);
|
|
4592
|
+
return result;
|
|
4593
|
+
}
|
|
4594
|
+
function referenceCallResult(result, node, scope) {
|
|
4595
|
+
const imp = node.callee.type === "Identifier" ? scope.imports.get(node.callee.name) : void 0;
|
|
4596
|
+
if (imp && STYLE_IMPORT_PATHS.has(imp.source)) return result;
|
|
4597
|
+
return result.ok && (isStyleTokenData(result.value) || isStyleTokenOverrideData(result.value)) ? referenceResult(result, node, scope) : result;
|
|
4598
|
+
}
|
|
4548
4599
|
//#endregion
|
|
4549
4600
|
//#region compiler/transform/syntax/isStaticStyleValue.ts
|
|
4550
4601
|
function isStaticStyleValue(value) {
|
|
@@ -7338,12 +7389,15 @@ function parseAndExtractModule(projectDir, filePath, content, babel, resolveImpo
|
|
|
7338
7389
|
if (spec.type !== "ExportSpecifier") continue;
|
|
7339
7390
|
const local = spec.local.name;
|
|
7340
7391
|
const exported = spec.exported.type === "Identifier" ? spec.exported.name : spec.exported.value;
|
|
7341
|
-
if (stmt.source)
|
|
7342
|
-
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
|
-
|
|
7392
|
+
if (stmt.source) {
|
|
7393
|
+
imports.set(exported, {
|
|
7394
|
+
source: stmt.source.value,
|
|
7395
|
+
name: local
|
|
7396
|
+
});
|
|
7397
|
+
rawBindings.set(exported, t.identifier(exported));
|
|
7398
|
+
} else if (rawBindings.has(local)) rawBindings.set(exported, rawBindings.get(local));
|
|
7346
7399
|
else if (bindings.has(local)) bindings.set(exported, bindings.get(local));
|
|
7400
|
+
else if (imports.has(local)) rawBindings.set(exported, t.identifier(local));
|
|
7347
7401
|
}
|
|
7348
7402
|
continue;
|
|
7349
7403
|
}
|
|
@@ -7356,6 +7410,7 @@ function parseAndExtractModule(projectDir, filePath, content, babel, resolveImpo
|
|
|
7356
7410
|
if (stmt.type === "ExportDefaultDeclaration") rawBindings.set("default", stmt.declaration);
|
|
7357
7411
|
}
|
|
7358
7412
|
const scope = {
|
|
7413
|
+
tokenNameFormat: options.css?.tokenNameFormat ?? null,
|
|
7359
7414
|
bindings,
|
|
7360
7415
|
imports,
|
|
7361
7416
|
styleNames,
|
|
@@ -7663,7 +7718,12 @@ function isExtractRuntimeImportSpecifier(spec) {
|
|
|
7663
7718
|
return EXTRACT_RUNTIME_IMPORT_NAMES.has(imported);
|
|
7664
7719
|
}
|
|
7665
7720
|
function isCompilerHandledImport(source, name) {
|
|
7666
|
-
return IMPORT_PATHS.includes(source) &&
|
|
7721
|
+
return IMPORT_PATHS.includes(source) && [
|
|
7722
|
+
"createTheme",
|
|
7723
|
+
"createToken",
|
|
7724
|
+
"createTokens",
|
|
7725
|
+
"createValues"
|
|
7726
|
+
].includes(name);
|
|
7667
7727
|
}
|
|
7668
7728
|
//#endregion
|
|
7669
7729
|
//#region compiler/transform/extract/utils/replacement.ts
|
|
@@ -7802,7 +7862,11 @@ function buildAtRuleRefExpression(t, ref, state) {
|
|
|
7802
7862
|
}
|
|
7803
7863
|
function buildVariableValueExpression(t, value, state, item, options) {
|
|
7804
7864
|
if (isStyleTokenData(value)) {
|
|
7805
|
-
|
|
7865
|
+
const reference = value[COMPILED_TOKEN_REFERENCE];
|
|
7866
|
+
if (reference?.filePath === state.filePath) {
|
|
7867
|
+
const runtimeToken = options.getRuntimeToken?.(item, reference.expression);
|
|
7868
|
+
if (runtimeToken) return runtimeToken;
|
|
7869
|
+
}
|
|
7806
7870
|
return buildExtractedTokenExpression(t, value, state);
|
|
7807
7871
|
}
|
|
7808
7872
|
const valueNode = item.valueNode;
|
|
@@ -7810,7 +7874,9 @@ function buildVariableValueExpression(t, value, state, item, options) {
|
|
|
7810
7874
|
if (runtimeToken) return runtimeToken;
|
|
7811
7875
|
return valueNode ? t.cloneNode(valueNode) : literalExpression(t, value);
|
|
7812
7876
|
}
|
|
7813
|
-
function buildExtractedTokenExpression(t, token, state) {
|
|
7877
|
+
function buildExtractedTokenExpression(t, token, state, preserveReference = true) {
|
|
7878
|
+
const reference = token[COMPILED_TOKEN_REFERENCE];
|
|
7879
|
+
if (preserveReference && reference?.filePath === state.filePath) return t.cloneNode(reference.expression, true);
|
|
7814
7880
|
state.usedHelpers.add(FN_CREATE_EXTRACTED_TOKEN);
|
|
7815
7881
|
const tokenNameFormat = state.options.css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat ?? null;
|
|
7816
7882
|
return t.callExpression(t.identifier(FN_CREATE_EXTRACTED_TOKEN), [
|
|
@@ -7822,6 +7888,8 @@ function buildExtractedTokenExpression(t, token, state) {
|
|
|
7822
7888
|
]);
|
|
7823
7889
|
}
|
|
7824
7890
|
function buildExtractedTokenOverrideExpression(t, token, state) {
|
|
7891
|
+
const reference = token[COMPILED_TOKEN_REFERENCE];
|
|
7892
|
+
if (reference?.filePath === state.filePath) return t.cloneNode(reference.expression, true);
|
|
7825
7893
|
state.usedHelpers.add(FN_CREATE_EXTRACTED_TOKEN);
|
|
7826
7894
|
const tokenNameFormat = state.options.css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat ?? null;
|
|
7827
7895
|
const extractedToken = t.callExpression(t.identifier(FN_CREATE_EXTRACTED_TOKEN), [
|
|
@@ -7838,7 +7906,7 @@ function literalExpression(t, value) {
|
|
|
7838
7906
|
if (typeof value === "number") return t.numericLiteral(value);
|
|
7839
7907
|
if (typeof value === "boolean") return t.booleanLiteral(value);
|
|
7840
7908
|
if (value === null || value === void 0) return t.nullLiteral();
|
|
7841
|
-
return t.
|
|
7909
|
+
return t.valueToNode(value);
|
|
7842
7910
|
}
|
|
7843
7911
|
//#endregion
|
|
7844
7912
|
//#region compiler/transform/extract/utils/slot.ts
|
|
@@ -7957,7 +8025,8 @@ function getEvalScope(state) {
|
|
|
7957
8025
|
sheetNames: state.sheetNames,
|
|
7958
8026
|
styleMetas: state.styleMetas,
|
|
7959
8027
|
bindingNodes: state.bindingNodes,
|
|
7960
|
-
runtimeMode: state.runtimeMode
|
|
8028
|
+
runtimeMode: state.runtimeMode,
|
|
8029
|
+
tokenNameFormat: state.options.css?.tokenNameFormat ?? null
|
|
7961
8030
|
};
|
|
7962
8031
|
}
|
|
7963
8032
|
//#endregion
|
|
@@ -8003,6 +8072,62 @@ function compileThemeCall(path, state, opts) {
|
|
|
8003
8072
|
};
|
|
8004
8073
|
}
|
|
8005
8074
|
//#endregion
|
|
8075
|
+
//#region compiler/transform/extract/utils/token.ts
|
|
8076
|
+
function compileTokenFactory(node, state, t) {
|
|
8077
|
+
if (node.callee.type !== "Identifier") return null;
|
|
8078
|
+
const imp = state.imports.get(node.callee.name);
|
|
8079
|
+
if (!imp || !IMPORT_PATHS.includes(imp.source)) return null;
|
|
8080
|
+
if (![
|
|
8081
|
+
"createToken",
|
|
8082
|
+
"createTokens",
|
|
8083
|
+
"createValues"
|
|
8084
|
+
].includes(imp.name)) return null;
|
|
8085
|
+
const inputValue = evaluateNode(node.arguments[0], getEvalScope(state));
|
|
8086
|
+
if (inputValue.ok && hasUnresolvedValue(inputValue.value)) throw new Error(`Cannot extract ${imp.name}: factory inputs must be statically resolvable`);
|
|
8087
|
+
const result = evaluateNode(node, getEvalScope(state));
|
|
8088
|
+
if (!result.ok) throw new Error(`Cannot extract ${imp.name}: ${result.reason}`);
|
|
8089
|
+
if (isCompiledTokenFactory(result.value)) {
|
|
8090
|
+
state.usedHelpers.add(FN_CREATE_EXTRACTED_VALUES);
|
|
8091
|
+
const expression = t.callExpression(t.identifier(FN_CREATE_EXTRACTED_VALUES), [t.arrayExpression([...result.value.tokens].map(([key, token]) => t.arrayExpression([t.valueToNode(key), buildExtractedTokenExpression(t, token, state, false)])))]);
|
|
8092
|
+
t.addComment(expression, "leading", "#__PURE__");
|
|
8093
|
+
return expression;
|
|
8094
|
+
}
|
|
8095
|
+
const input = node.arguments[0];
|
|
8096
|
+
if (imp.name === "createToken") return buildGroup(result.value, input);
|
|
8097
|
+
const raw = evaluateNode(input, getEvalScope(state));
|
|
8098
|
+
const array = raw.ok && Array.isArray(raw.value) ? raw.value : null;
|
|
8099
|
+
if (array) return t.objectExpression(Object.entries(result.value).map(([key, token]) => {
|
|
8100
|
+
let index = array.length - 1;
|
|
8101
|
+
while (index >= 0 && String(array[index]) !== key) index--;
|
|
8102
|
+
return t.objectProperty(t.stringLiteral(key), buildGroup(token, member(input, String(index))), key === "__proto__");
|
|
8103
|
+
}));
|
|
8104
|
+
return buildGroup(result.value, input);
|
|
8105
|
+
function buildGroup(value, source) {
|
|
8106
|
+
if (isStyleTokenData(value)) {
|
|
8107
|
+
const expression = buildExtractedTokenExpression(t, value, state, false);
|
|
8108
|
+
if (!value.ref) expression.arguments[1] = t.cloneNode(source, true);
|
|
8109
|
+
t.addComment(expression, "leading", "#__PURE__");
|
|
8110
|
+
return expression;
|
|
8111
|
+
}
|
|
8112
|
+
if (!value || typeof value !== "object") throw new Error(`Invalid ${imp.name} token group`);
|
|
8113
|
+
return t.objectExpression(Object.entries(value).map(([key, child]) => t.objectProperty(t.stringLiteral(key), buildGroup(child, member(source, key)), key === "__proto__")));
|
|
8114
|
+
}
|
|
8115
|
+
function member(source, key) {
|
|
8116
|
+
if (source.type === "ObjectExpression") for (let index = source.properties.length - 1; index >= 0; index--) {
|
|
8117
|
+
const property = source.properties[index];
|
|
8118
|
+
if (property.type !== "ObjectProperty" || property.computed) break;
|
|
8119
|
+
if (getObjectPropertyKey$1(property) === key) return property.value;
|
|
8120
|
+
}
|
|
8121
|
+
if (source.type === "ArrayExpression" && !source.elements.some((item) => item?.type === "SpreadElement") && source.elements[Number(key)] && t.isExpression(source.elements[Number(key)])) return source.elements[Number(key)];
|
|
8122
|
+
return t.memberExpression(t.cloneNode(source, true), t.stringLiteral(key), true);
|
|
8123
|
+
}
|
|
8124
|
+
}
|
|
8125
|
+
function hasUnresolvedValue(value) {
|
|
8126
|
+
if (!value || typeof value !== "object" || isStyleTokenData(value)) return false;
|
|
8127
|
+
if (value[COMPILED_RUNTIME_VALUE]) return true;
|
|
8128
|
+
return Object.values(value).some(hasUnresolvedValue);
|
|
8129
|
+
}
|
|
8130
|
+
//#endregion
|
|
8006
8131
|
//#region compiler/transform/extract/plugin.ts
|
|
8007
8132
|
function createExtractPlugin(args) {
|
|
8008
8133
|
const { options } = args;
|
|
@@ -8011,6 +8136,7 @@ function createExtractPlugin(args) {
|
|
|
8011
8136
|
const { types: t } = babel;
|
|
8012
8137
|
return {
|
|
8013
8138
|
pre() {
|
|
8139
|
+
this.tokenFactoryReplacements = /* @__PURE__ */ new Map();
|
|
8014
8140
|
this.styleNames = /* @__PURE__ */ new Set();
|
|
8015
8141
|
this.sheetNames = /* @__PURE__ */ new Set();
|
|
8016
8142
|
this.styleMetas = /* @__PURE__ */ new Map();
|
|
@@ -8095,6 +8221,12 @@ function createExtractPlugin(args) {
|
|
|
8095
8221
|
state.bindings.set(name, evaluateEnumDeclaration(path.node, scope));
|
|
8096
8222
|
},
|
|
8097
8223
|
CallExpression(path, state) {
|
|
8224
|
+
if (mode === "extract") try {
|
|
8225
|
+
const tokenFactory = compileTokenFactory(path.node, state, t);
|
|
8226
|
+
if (tokenFactory) state.tokenFactoryReplacements.set(path.node, tokenFactory);
|
|
8227
|
+
} catch (error) {
|
|
8228
|
+
throw path.buildCodeFrameError(error instanceof Error ? error.message : String(error));
|
|
8229
|
+
}
|
|
8098
8230
|
if (path.parent.type === "MemberExpression" && !path.parent.computed) return;
|
|
8099
8231
|
const theme = compileThemeCall(path, state, options);
|
|
8100
8232
|
if (theme) {
|
|
@@ -8151,6 +8283,13 @@ function createExtractPlugin(args) {
|
|
|
8151
8283
|
},
|
|
8152
8284
|
Program: { exit(path, state) {
|
|
8153
8285
|
if (mode === "collect") return;
|
|
8286
|
+
path.traverse({ CallExpression(factoryPath) {
|
|
8287
|
+
const replacement = state.tokenFactoryReplacements.get(factoryPath.node);
|
|
8288
|
+
if (!replacement) return;
|
|
8289
|
+
factoryPath.replaceWith(replacement);
|
|
8290
|
+
factoryPath.skip();
|
|
8291
|
+
state.needsExtractImport = true;
|
|
8292
|
+
} });
|
|
8154
8293
|
pruneUnusedStyleInputDeclarations(path, state);
|
|
8155
8294
|
pruneUnusedStyleImports(path, state);
|
|
8156
8295
|
if (!state.needsExtractImport) return;
|
|
@@ -8251,7 +8390,8 @@ function createRuntimeTokenCollector(args) {
|
|
|
8251
8390
|
return {
|
|
8252
8391
|
overrides,
|
|
8253
8392
|
addOverride(item) {
|
|
8254
|
-
|
|
8393
|
+
const reference = item.value[COMPILED_TOKEN_REFERENCE];
|
|
8394
|
+
overrides.push(args.t.cloneNode(reference?.filePath === args.state.filePath ? reference.expression : item.valueNode, true));
|
|
8255
8395
|
},
|
|
8256
8396
|
add(item, valueNode) {
|
|
8257
8397
|
if (canHoistRuntimeValue(args.path, valueNode)) return null;
|
|
@@ -8565,4 +8705,4 @@ const CssPropPresets = {
|
|
|
8565
8705
|
//#endregion
|
|
8566
8706
|
export { getDefaultSourcemapUrl as a, getStyleFnMeta as c, babelTransform as d, extractCss as f, createCompilerCache as g, globalData as h, CompilerRuntimeMode as i, isPromiseLike as l, SIDECAR_URL_GLOBAL_SYMBOL as m, createCompiler as n, normalizeSourcemapSourcePath as o, compareLayerPriority as p, getStyleRuntimeImportPath as r, normalizePath as s, CssPropPresets as t, babelPlugin as u };
|
|
8567
8707
|
|
|
8568
|
-
//# sourceMappingURL=compiler-
|
|
8708
|
+
//# sourceMappingURL=compiler-Ct5xGIeu.mjs.map
|