@tenphi/tasty 3.9.2 → 3.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{babel-Zs1Q03qt.d.ts → babel-DD7kdEFT.d.ts} +2 -2
- package/dist/chunks/{build-config-CUQVwdWF.js → build-config-z06WcSWq.js} +4 -4
- package/dist/chunks/{build-config-CUQVwdWF.js.map → build-config-z06WcSWq.js.map} +1 -1
- package/dist/chunks/{collector-B0LTHw6Z.js → collector-CSMFKWEi.js} +4 -4
- package/dist/chunks/{collector-B0LTHw6Z.js.map → collector-CSMFKWEi.js.map} +1 -1
- package/dist/chunks/{config-engine-C3pF9EK9.js → config-engine-BKgJcV_F.js} +3 -3
- package/dist/chunks/{config-engine-C3pF9EK9.js.map → config-engine-BKgJcV_F.js.map} +1 -1
- package/dist/chunks/{css-definitions-D_it4XZH.js → css-definitions-BLxYIG-s.js} +2 -2
- package/dist/chunks/{css-definitions-D_it4XZH.js.map → css-definitions-BLxYIG-s.js.map} +1 -1
- package/dist/chunks/{debug-CiiHDgmR.js → debug-vitwtcMP.js} +4 -4
- package/dist/chunks/{debug-CiiHDgmR.js.map → debug-vitwtcMP.js.map} +1 -1
- package/dist/chunks/{react-runtime-sH6r6Ajr.js → react-runtime-D9XQr5wn.js} +4 -4
- package/dist/chunks/{react-runtime-sH6r6Ajr.js.map → react-runtime-D9XQr5wn.js.map} +1 -1
- package/dist/chunks/{runtime-engine-BrRcOZwD.js → runtime-engine-BBxhRy60.js} +5 -5
- package/dist/chunks/{runtime-engine-BrRcOZwD.js.map → runtime-engine-BBxhRy60.js.map} +1 -1
- package/dist/chunks/{runtime-state-BTDqSYBk.js → runtime-state-D_N0OAuJ.js} +2 -2
- package/dist/chunks/{runtime-state-BTDqSYBk.js.map → runtime-state-D_N0OAuJ.js.map} +1 -1
- package/dist/chunks/{style-engine-C1ECBZxR.js → style-engine-DeE1gFDC.js} +110 -44
- package/dist/chunks/{style-engine-C1ECBZxR.js.map → style-engine-DeE1gFDC.js.map} +1 -1
- package/dist/chunks/{zero-engine-B6EnYcXY.js → zero-engine-CtaJCmco.js} +3 -3
- package/dist/chunks/{zero-engine-B6EnYcXY.js.map → zero-engine-CtaJCmco.js.map} +1 -1
- package/dist/{collector-hl5KNH7k.d.ts → collector-YpsMjV7T.d.ts} +2 -2
- package/dist/{config-DWL1ZYue.d.ts → config-BnZqyYG4.d.ts} +3 -3
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +6 -6
- package/dist/{index-D9N9GV24.d.ts → index-BLJLo9cl.d.ts} +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +7 -7
- package/dist/{merge-styles-C_oMoJVd.d.ts → merge-styles-CTDLIrO5.d.ts} +2 -2
- package/dist/ssr/astro.js +2 -2
- package/dist/ssr/index.d.ts +1 -1
- package/dist/ssr/index.js +2 -2
- package/dist/ssr/next-config.d.ts +1 -1
- package/dist/ssr/next-config.js +3 -3
- package/dist/ssr/next.d.ts +1 -1
- package/dist/ssr/next.js +3 -3
- package/dist/static/index.d.ts +2 -2
- package/dist/{types-jKZNpias.d.ts → types-vfRQhzRd.d.ts} +5 -5
- package/dist/zero/babel.d.ts +1 -1
- package/dist/zero/babel.js +4 -4
- package/dist/zero/index.d.ts +1 -1
- package/dist/zero/index.js +1 -1
- package/dist/zero/next.d.ts +1 -1
- package/docs/ai-agents.md +21 -2
- package/docs/dsl.md +4 -2
- package/docs/getting-started.md +13 -11
- package/docs/methodology.md +2 -2
- package/docs/pipeline.md +29 -8
- package/docs/plugins.md +1 -1
- package/docs/styles.md +23 -5
- package/docs/tasty-static.md +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { L as DEFAULT_PROPERTIES } from "./css-definitions-
|
|
1
|
+
import { L as DEFAULT_PROPERTIES } from "./css-definitions-BLxYIG-s.js";
|
|
2
2
|
//#region src/config-resources.ts
|
|
3
3
|
let runtimeConfig = null;
|
|
4
4
|
let globalFontFace = null;
|
|
@@ -124,4 +124,4 @@ function getRegisteredSSRCollector() {
|
|
|
124
124
|
//#endregion
|
|
125
125
|
export { resetConfigResources as _, getGlobalConfigTokens as a, getGlobalFunctions as c, mergeGlobalConfigTokens as d, mergeGlobalCounterStyles as f, mergeGlobalStyles as g, mergeGlobalProperties as h, getEffectiveProperties as i, getGlobalStyles as l, mergeGlobalFunctions as m, registerSSRCollectorGetter as n, getGlobalCounterStyles as o, mergeGlobalFontFaces as p, registerSSRCollectorGetterGlobal as r, getGlobalFontFaces as s, getRegisteredSSRCollector as t, getRuntimeConfigState as u, setRuntimeConfigState as v };
|
|
126
126
|
|
|
127
|
-
//# sourceMappingURL=runtime-state-
|
|
127
|
+
//# sourceMappingURL=runtime-state-D_N0OAuJ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-state-
|
|
1
|
+
{"version":3,"file":"runtime-state-D_N0OAuJ.js","names":[],"sources":["../../src/config-resources.ts","../../src/ssr/ssr-collector-ref.ts"],"sourcesContent":["/**\n * DOM-free storage for configured CSS resources shared by the browser runtime\n * and server collectors.\n *\n * Astro can evaluate middleware and application code in separate module\n * graphs, so resources used by SSR are mirrored on globalThis. Keeping this\n * state outside config.ts lets server-only entrypoints read it without loading\n * StyleInjector and the rest of the browser runtime.\n */\n\nimport type {\n CounterStyleDescriptors,\n FontFaceInput,\n FunctionDefinition,\n PropertyDefinition,\n} from './injector/types';\nimport { DEFAULT_PROPERTIES } from './properties/defaults';\nimport type { ConfigTokens, Styles } from './styles/types';\n\ninterface RuntimeConfigState {\n namePrefix?: string;\n nonce?: string;\n}\n\nlet runtimeConfig: RuntimeConfigState | null = null;\nlet globalFontFace: Record<string, FontFaceInput> | null = null;\nlet globalCounterStyle: Record<string, CounterStyleDescriptors> | null = null;\nlet globalFunction: Record<string, FunctionDefinition> | null = null;\nlet globalProperties: Record<string, PropertyDefinition> | null = null;\nlet globalConfigTokens: ConfigTokens | null = null;\nlet globalStyles: Record<string, Styles> | null = null;\n\nconst GTKEY_TOKENS = '__tasty_cfg_tokens__';\nconst GTKEY_FONT_FACE = '__tasty_cfg_font_face__';\nconst GTKEY_COUNTER_STYLE = '__tasty_cfg_counter_style__';\nconst GTKEY_FUNCTION = '__tasty_cfg_function__';\nconst GTKEY_PROPERTIES = '__tasty_cfg_properties__';\nconst GTKEY_GLOBAL_STYLES = '__tasty_cfg_global_styles__';\n\nfunction setOnGlobalThis(key: string, value: unknown): void {\n (globalThis as Record<string, unknown>)[key] = value;\n}\n\nfunction getFromGlobalThis<T>(key: string): T | undefined {\n return (globalThis as Record<string, unknown>)[key] as T | undefined;\n}\n\nexport function getRuntimeConfigState(): RuntimeConfigState | null {\n return runtimeConfig;\n}\n\nexport function setRuntimeConfigState(config: RuntimeConfigState): void {\n runtimeConfig = config;\n}\n\nexport function getEffectiveProperties(): Record<string, PropertyDefinition> {\n const properties =\n globalProperties ??\n getFromGlobalThis<Record<string, PropertyDefinition>>(GTKEY_PROPERTIES);\n return properties\n ? { ...DEFAULT_PROPERTIES, ...properties }\n : DEFAULT_PROPERTIES;\n}\n\nexport function getGlobalFontFaces(): Record<string, FontFaceInput> | null {\n return (\n globalFontFace ??\n getFromGlobalThis<Record<string, FontFaceInput>>(GTKEY_FONT_FACE) ??\n null\n );\n}\n\nexport function getGlobalCounterStyles(): Record<\n string,\n CounterStyleDescriptors\n> | null {\n return (\n globalCounterStyle ??\n getFromGlobalThis<Record<string, CounterStyleDescriptors>>(\n GTKEY_COUNTER_STYLE,\n ) ??\n null\n );\n}\n\nexport function getGlobalFunctions(): Record<\n string,\n FunctionDefinition\n> | null {\n return (\n globalFunction ??\n getFromGlobalThis<Record<string, FunctionDefinition>>(GTKEY_FUNCTION) ??\n null\n );\n}\n\nexport function getGlobalConfigTokens(): ConfigTokens | null {\n return (\n globalConfigTokens ?? getFromGlobalThis<ConfigTokens>(GTKEY_TOKENS) ?? null\n );\n}\n\nexport function getGlobalStyles(): Record<string, Styles> | null {\n return (\n globalStyles ??\n getFromGlobalThis<Record<string, Styles>>(GTKEY_GLOBAL_STYLES) ??\n null\n );\n}\n\nexport function mergeGlobalProperties(\n properties: Record<string, PropertyDefinition>,\n): void {\n globalProperties = {\n ...(globalProperties ?? getFromGlobalThis(GTKEY_PROPERTIES) ?? {}),\n ...properties,\n };\n setOnGlobalThis(GTKEY_PROPERTIES, globalProperties);\n}\n\nexport function mergeGlobalFontFaces(\n fontFaces: Record<string, FontFaceInput>,\n): void {\n globalFontFace = { ...(getGlobalFontFaces() ?? {}), ...fontFaces };\n setOnGlobalThis(GTKEY_FONT_FACE, globalFontFace);\n}\n\nexport function mergeGlobalCounterStyles(\n counterStyles: Record<string, CounterStyleDescriptors>,\n): void {\n globalCounterStyle = {\n ...(getGlobalCounterStyles() ?? {}),\n ...counterStyles,\n };\n setOnGlobalThis(GTKEY_COUNTER_STYLE, globalCounterStyle);\n}\n\nexport function mergeGlobalFunctions(\n functions: Record<string, FunctionDefinition>,\n): void {\n globalFunction = { ...(getGlobalFunctions() ?? {}), ...functions };\n setOnGlobalThis(GTKEY_FUNCTION, globalFunction);\n}\n\nexport function mergeGlobalConfigTokens(styles: ConfigTokens): void {\n globalConfigTokens = globalConfigTokens\n ? { ...globalConfigTokens, ...styles }\n : styles;\n setOnGlobalThis(GTKEY_TOKENS, globalConfigTokens);\n}\n\nexport function mergeGlobalStyles(styles: Record<string, Styles>): void {\n if (globalStyles) {\n for (const [selector, selectorStyles] of Object.entries(styles)) {\n globalStyles[selector] = globalStyles[selector]\n ? { ...globalStyles[selector], ...selectorStyles }\n : selectorStyles;\n }\n } else {\n globalStyles = { ...styles };\n }\n setOnGlobalThis(GTKEY_GLOBAL_STYLES, globalStyles);\n}\n\nexport function resetConfigResources(): void {\n runtimeConfig = null;\n globalProperties = null;\n globalFontFace = null;\n globalCounterStyle = null;\n globalFunction = null;\n globalConfigTokens = null;\n globalStyles = null;\n\n const globalState = globalThis as Record<string, unknown>;\n delete globalState[GTKEY_TOKENS];\n delete globalState[GTKEY_FONT_FACE];\n delete globalState[GTKEY_COUNTER_STYLE];\n delete globalState[GTKEY_FUNCTION];\n delete globalState[GTKEY_PROPERTIES];\n delete globalState[GTKEY_GLOBAL_STYLES];\n}\n","/**\n * Global reference to the SSR collector getter function.\n *\n * This indirection avoids importing 'node:async_hooks' in the browser bundle.\n * The SSR entry point sets this ref when loaded on the server. The useStyles\n * hook calls it if set; on the client it stays null and is never called.\n *\n * Uses a module-level variable as the primary mechanism. In Next.js App\n * Router the RSC and SSR module graphs load separate copies of this module,\n * so the getter registered by TastyRegistry (SSR layer) is invisible to\n * server components (RSC layer) — which correctly fall through to inline\n * RSC styles.\n *\n * A globalThis fallback (`registerSSRCollectorGetterGlobal`) is provided\n * for frameworks like Astro where middleware and page components live in\n * different module graphs and must share the getter across them.\n */\n\nimport type { ServerStyleCollector } from './collector';\n\ntype SSRCollectorGetter = () => ServerStyleCollector | null;\n\nconst GETTER_KEY = '__tasty_ssr_collector_getter__';\n\nlet _getSSRCollector: SSRCollectorGetter | null = null;\n\n/**\n * Register the collector getter in the current module graph only.\n * Used by Next.js TastyRegistry.\n */\nexport function registerSSRCollectorGetter(fn: SSRCollectorGetter): void {\n _getSSRCollector = fn;\n}\n\n/**\n * Register the collector getter on globalThis so it is visible across\n * separate module graphs (e.g. Astro middleware ↔ page components).\n */\nexport function registerSSRCollectorGetterGlobal(fn: SSRCollectorGetter): void {\n (globalThis as Record<string, unknown>)[GETTER_KEY] = fn;\n}\n\n/**\n * Retrieve the SSR collector: module-level first, globalThis fallback.\n */\nexport function getRegisteredSSRCollector(): ServerStyleCollector | null {\n if (_getSSRCollector) return _getSSRCollector();\n const getter = (globalThis as Record<string, unknown>)[GETTER_KEY] as\n SSRCollectorGetter | undefined;\n return getter ? getter() : null;\n}\n"],"mappings":"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"}
|
|
@@ -3660,7 +3660,6 @@ function buildExclusiveConditions(entries) {
|
|
|
3660
3660
|
}
|
|
3661
3661
|
let exclusive = entry.condition;
|
|
3662
3662
|
for (const prior of priorConditions) {
|
|
3663
|
-
if (prior.kind === "true") continue;
|
|
3664
3663
|
if (entry.condition.kind !== "true" && simplifyCondition(and(entry.condition, prior)).kind === "false") continue;
|
|
3665
3664
|
exclusive = and(exclusive, not(prior));
|
|
3666
3665
|
}
|
|
@@ -3670,7 +3669,7 @@ function buildExclusiveConditions(entries) {
|
|
|
3670
3669
|
...entry,
|
|
3671
3670
|
exclusiveCondition: simplified
|
|
3672
3671
|
});
|
|
3673
|
-
|
|
3672
|
+
priorConditions.push(entry.condition);
|
|
3674
3673
|
}
|
|
3675
3674
|
for (const floor of floors) result.push({
|
|
3676
3675
|
...floor,
|
|
@@ -3755,7 +3754,6 @@ function mergeEntriesByValue(entries) {
|
|
|
3755
3754
|
let safe = true;
|
|
3756
3755
|
for (let k = j + 1; k < merged.length; k++) {
|
|
3757
3756
|
const inter = merged[k];
|
|
3758
|
-
if (inter.condition.kind === "true") continue;
|
|
3759
3757
|
if (serializeValue(inter.value) === valueKey) continue;
|
|
3760
3758
|
if (simplifyCondition(and(inter.condition, entry.condition, not(prev.condition))).kind !== "false") {
|
|
3761
3759
|
safe = false;
|
|
@@ -3786,28 +3784,67 @@ function serializeValue(value) {
|
|
|
3786
3784
|
if (typeof value === "string" || typeof value === "number") return String(value);
|
|
3787
3785
|
return JSON.stringify(value);
|
|
3788
3786
|
}
|
|
3787
|
+
const MAX_EXTRACTION_ATOMS = 32;
|
|
3789
3788
|
function extractCompoundStates(valueMap) {
|
|
3790
3789
|
const keys = Object.keys(valueMap);
|
|
3791
3790
|
if (keys.length < 3 || !keys.some((k) => k.includes("&"))) return valueMap;
|
|
3792
|
-
const
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3791
|
+
const atomBits = /* @__PURE__ */ new Map();
|
|
3792
|
+
const masks = /* @__PURE__ */ new Map();
|
|
3793
|
+
const cascade = [];
|
|
3794
|
+
let hasFloor = false;
|
|
3795
|
+
for (const key of keys) {
|
|
3796
|
+
if (key === "_" || isMisusedFallbackKey(key)) {
|
|
3797
|
+
hasFloor ||= key === "_";
|
|
3798
|
+
continue;
|
|
3799
|
+
}
|
|
3800
|
+
let mask = 0;
|
|
3801
|
+
for (const atom of splitTopLevelAnd(key) ?? [key]) {
|
|
3802
|
+
let bit = atomBits.get(atom);
|
|
3803
|
+
if (bit === void 0) {
|
|
3804
|
+
if (atomBits.size === MAX_EXTRACTION_ATOMS) return valueMap;
|
|
3805
|
+
bit = 1 << atomBits.size;
|
|
3806
|
+
atomBits.set(atom, bit);
|
|
3807
|
+
}
|
|
3808
|
+
mask |= bit;
|
|
3809
|
+
}
|
|
3810
|
+
masks.set(key, mask);
|
|
3811
|
+
const entry = {
|
|
3812
|
+
mask,
|
|
3813
|
+
value: serializeValue(valueMap[key])
|
|
3797
3814
|
};
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
for (const
|
|
3803
|
-
if (
|
|
3815
|
+
if (key === "") cascade.unshift(entry);
|
|
3816
|
+
else cascade.push(entry);
|
|
3817
|
+
}
|
|
3818
|
+
let dropMask = 0;
|
|
3819
|
+
for (const bit of atomBits.values()) if (isDontCare(cascade, bit)) dropMask |= bit;
|
|
3820
|
+
if (dropMask === 0) return valueMap;
|
|
3804
3821
|
const newMap = {};
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3822
|
+
let keptStates = false;
|
|
3823
|
+
for (const key of keys) {
|
|
3824
|
+
const mask = masks.get(key);
|
|
3825
|
+
if (mask !== void 0 && mask & dropMask) continue;
|
|
3826
|
+
newMap[key] = valueMap[key];
|
|
3827
|
+
keptStates ||= mask !== void 0 && key !== "";
|
|
3808
3828
|
}
|
|
3829
|
+
if (hasFloor && !keptStates && "" in newMap) return valueMap;
|
|
3809
3830
|
return newMap;
|
|
3810
3831
|
}
|
|
3832
|
+
function resolveCascade(cascade, state) {
|
|
3833
|
+
for (let i = cascade.length - 1; i >= 0; i--) if ((cascade[i].mask & ~state) === 0) return cascade[i].value;
|
|
3834
|
+
}
|
|
3835
|
+
function isDontCare(cascade, bit) {
|
|
3836
|
+
for (const withAtom of cascade) {
|
|
3837
|
+
if ((withAtom.mask & bit) === 0) continue;
|
|
3838
|
+
const base = withAtom.mask & ~bit;
|
|
3839
|
+
if (resolveCascade(cascade, base) !== resolveCascade(cascade, base | bit)) return false;
|
|
3840
|
+
for (const withoutAtom of cascade) {
|
|
3841
|
+
if (withoutAtom.mask & bit) continue;
|
|
3842
|
+
const state = base | withoutAtom.mask;
|
|
3843
|
+
if (resolveCascade(cascade, state) !== resolveCascade(cascade, state | bit)) return false;
|
|
3844
|
+
}
|
|
3845
|
+
}
|
|
3846
|
+
return true;
|
|
3847
|
+
}
|
|
3811
3848
|
function splitTopLevelAnd(key) {
|
|
3812
3849
|
if (key === "") return [];
|
|
3813
3850
|
const parts = [];
|
|
@@ -3831,17 +3868,6 @@ function splitTopLevelAnd(key) {
|
|
|
3831
3868
|
if (trimmed) parts.push(trimmed);
|
|
3832
3869
|
return parts;
|
|
3833
3870
|
}
|
|
3834
|
-
function isAtomRedundant(entries, atom) {
|
|
3835
|
-
const withAtom = entries.filter((e) => e.atoms.includes(atom));
|
|
3836
|
-
if (withAtom.length === 0) return false;
|
|
3837
|
-
for (const wa of withAtom) {
|
|
3838
|
-
const remaining = wa.atoms.filter((a) => a !== atom);
|
|
3839
|
-
const pair = entries.find((e) => !e.atoms.includes(atom) && e.atoms.length === remaining.length && remaining.every((r) => e.atoms.includes(r)));
|
|
3840
|
-
if (!pair) return false;
|
|
3841
|
-
if (serializeValue(wa.value) !== serializeValue(pair.value)) return false;
|
|
3842
|
-
}
|
|
3843
|
-
return true;
|
|
3844
|
-
}
|
|
3845
3871
|
function isValueMapping(value) {
|
|
3846
3872
|
return value !== null && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date);
|
|
3847
3873
|
}
|
|
@@ -3953,12 +3979,21 @@ function transformSelectorContent(content) {
|
|
|
3953
3979
|
const MAX_XOR_CHAIN_LENGTH = 4;
|
|
3954
3980
|
const parseCache = new Lru(5e3);
|
|
3955
3981
|
const INTERNAL_PSEUDO_PATTERN = /:-internal-[a-z0-9-]+/g;
|
|
3956
|
-
const SIMPLE_MODIFIER_PATTERN = /^[a-z][a-z0-9-]
|
|
3982
|
+
const SIMPLE_MODIFIER_PATTERN = /^[a-z][a-z0-9-]*$/i;
|
|
3957
3983
|
const FUNCTION_START_PATTERN = /@(?:media|supports|root|parent|own)?\(|:(?:is|has|not|where)\(/iy;
|
|
3958
|
-
const SIMPLE_TOKEN_PATTERN = /@media:[a-z]+|@[a-z][a-z0-9-]*|[a-z][a-z0-9-]*(?:\^=|\$=|\*=|=)(?:"[^"]*"|'[^']*'|[^\s&|!^()]+)|[a-z][a-z0-9-]
|
|
3959
|
-
|
|
3984
|
+
const SIMPLE_TOKEN_PATTERN = /@media:[a-z]+|@[a-z][a-z0-9-]*|[a-z][a-z0-9-]*(?:\^=|\$=|\*=|=)(?:"[^"]*"|'[^']*'|[^\s&|!^()]+)|[a-z][a-z0-9-]*|:[-a-z][a-z0-9-]*(?:\([^)]+\))?|\.[a-z][a-z0-9-]*/iy;
|
|
3985
|
+
const OPERATOR_TOKENS = new Set([
|
|
3986
|
+
"&",
|
|
3987
|
+
"|",
|
|
3988
|
+
"!",
|
|
3989
|
+
"^",
|
|
3990
|
+
"(",
|
|
3991
|
+
")"
|
|
3992
|
+
]);
|
|
3993
|
+
function tokenize(stateKey, problems) {
|
|
3960
3994
|
const tokens = [];
|
|
3961
3995
|
const source = stateKey.includes(",") ? replaceCommasOutsideParens(stateKey) : stateKey;
|
|
3996
|
+
let unread = "";
|
|
3962
3997
|
let i = 0;
|
|
3963
3998
|
while (i < source.length) {
|
|
3964
3999
|
const ch = source[i];
|
|
@@ -3995,10 +4030,15 @@ function tokenize(stateKey) {
|
|
|
3995
4030
|
i = SIMPLE_TOKEN_PATTERN.lastIndex;
|
|
3996
4031
|
continue;
|
|
3997
4032
|
}
|
|
4033
|
+
if (!/\s/.test(ch)) unread += ch;
|
|
3998
4034
|
i++;
|
|
3999
4035
|
}
|
|
4036
|
+
if (unread) problems.push(`cannot read "${excerpt(unread)}"`);
|
|
4000
4037
|
return tokens;
|
|
4001
4038
|
}
|
|
4039
|
+
function excerpt(text, max = 60) {
|
|
4040
|
+
return text.length > max ? `${text.slice(0, max)}…` : text;
|
|
4041
|
+
}
|
|
4002
4042
|
function findBalancedEnd(source, open) {
|
|
4003
4043
|
let depth = 0;
|
|
4004
4044
|
for (let i = open; i < source.length; i++) if (source[i] === "(") {
|
|
@@ -4020,13 +4060,17 @@ var Parser = class {
|
|
|
4020
4060
|
tokens;
|
|
4021
4061
|
pos = 0;
|
|
4022
4062
|
options;
|
|
4023
|
-
|
|
4063
|
+
problems;
|
|
4064
|
+
constructor(tokens, options, problems) {
|
|
4024
4065
|
this.tokens = tokens;
|
|
4025
4066
|
this.options = options;
|
|
4067
|
+
this.problems = problems;
|
|
4026
4068
|
}
|
|
4027
4069
|
parse() {
|
|
4028
4070
|
if (this.tokens.length === 0) return trueCondition();
|
|
4029
|
-
|
|
4071
|
+
const expr = this.parseExpression();
|
|
4072
|
+
if (this.pos < this.tokens.length) this.problems.push(`unexpected "${excerpt(this.tokens.slice(this.pos).join(" "))}"`);
|
|
4073
|
+
return expr;
|
|
4030
4074
|
}
|
|
4031
4075
|
match(token) {
|
|
4032
4076
|
if (this.tokens[this.pos] === token) {
|
|
@@ -4079,10 +4123,11 @@ var Parser = class {
|
|
|
4079
4123
|
return expr;
|
|
4080
4124
|
}
|
|
4081
4125
|
const token = this.tokens[this.pos];
|
|
4082
|
-
if (token && token
|
|
4126
|
+
if (token !== void 0 && !OPERATOR_TOKENS.has(token)) {
|
|
4083
4127
|
this.pos++;
|
|
4084
4128
|
return this.parseStateToken(token);
|
|
4085
4129
|
}
|
|
4130
|
+
this.problems.push(token === void 0 ? "missing a state at the end" : `missing a state before "${token}"`);
|
|
4086
4131
|
return trueCondition();
|
|
4087
4132
|
}
|
|
4088
4133
|
parseStateToken(value) {
|
|
@@ -4310,7 +4355,9 @@ function parseStateKey(stateKey, options = {}) {
|
|
|
4310
4355
|
emitWarning("INTERNAL_PSEUDO_USED", `State key "${trimmed}" references internal pseudo-class${unique.length > 1 ? "es" : ""} ${unique.map((p) => `\`${p}\``).join(", ")}. These are unmatchable from user CSS and can invalidate the surrounding rule in Safari (even inside \`:is(...)\`). Use \`:-webkit-autofill | :autofill\` instead for autofill states.`);
|
|
4311
4356
|
}
|
|
4312
4357
|
}
|
|
4313
|
-
const
|
|
4358
|
+
const problems = [];
|
|
4359
|
+
const result = SIMPLE_MODIFIER_PATTERN.test(trimmed) ? createBooleanModifier(trimmed) : new Parser(tokenize(trimmed, problems), options, problems).parse();
|
|
4360
|
+
if (problems.length > 0) emitWarning("INVALID_STATE_KEY", `State key "${excerpt(trimmed)}" is not valid state notation: ${problems.join(", ")}. Tasty skips the parts it cannot read, so the key may apply in states you did not intend.`);
|
|
4314
4361
|
parseCache.set(cacheKey, result);
|
|
4315
4362
|
return result;
|
|
4316
4363
|
}
|
|
@@ -5019,7 +5066,8 @@ function categorizeStyleKeys(styles) {
|
|
|
5019
5066
|
}
|
|
5020
5067
|
//#endregion
|
|
5021
5068
|
//#region src/chunks/cacheKey.ts
|
|
5022
|
-
const
|
|
5069
|
+
const _valueStringifyCache = /* @__PURE__ */ new WeakMap();
|
|
5070
|
+
const _stylesStringifyCache = /* @__PURE__ */ new WeakMap();
|
|
5023
5071
|
const _chunkKeyCache = /* @__PURE__ */ new WeakMap();
|
|
5024
5072
|
function isEntryFresh(styles, entry, styleKeys) {
|
|
5025
5073
|
const snapshot = entry.snapshot;
|
|
@@ -5031,25 +5079,43 @@ function isEntryFresh(styles, entry, styleKeys) {
|
|
|
5031
5079
|
}
|
|
5032
5080
|
return true;
|
|
5033
5081
|
}
|
|
5034
|
-
function
|
|
5082
|
+
function stringifyStyle(key, value) {
|
|
5083
|
+
return isSelector(key) && isPlainObject(value) ? stringifyStylesObject(value) : stringifyValue(value);
|
|
5084
|
+
}
|
|
5085
|
+
function stringifyValue(value) {
|
|
5035
5086
|
if (value === null || value === void 0) return String(value);
|
|
5036
5087
|
if (typeof value !== "object") return JSON.stringify(value);
|
|
5037
|
-
const cached =
|
|
5088
|
+
const cached = _valueStringifyCache.get(value);
|
|
5038
5089
|
if (cached !== void 0) return cached;
|
|
5039
5090
|
let result;
|
|
5040
|
-
if (Array.isArray(value)) result = "[" + value.map(
|
|
5091
|
+
if (Array.isArray(value)) result = "[" + value.map(stringifyValue).join(",") + "]";
|
|
5041
5092
|
else {
|
|
5042
5093
|
const obj = value;
|
|
5043
5094
|
result = "{";
|
|
5044
|
-
for (const key of Object.keys(obj)
|
|
5095
|
+
for (const key of Object.keys(obj)) if (obj[key] !== void 0) {
|
|
5045
5096
|
if (result.length > 1) result += ",";
|
|
5046
|
-
result += `${JSON.stringify(key)}:${
|
|
5097
|
+
result += `${JSON.stringify(key)}:${stringifyValue(obj[key])}`;
|
|
5047
5098
|
}
|
|
5048
5099
|
result += "}";
|
|
5049
5100
|
}
|
|
5050
|
-
|
|
5101
|
+
_valueStringifyCache.set(value, result);
|
|
5102
|
+
return result;
|
|
5103
|
+
}
|
|
5104
|
+
function stringifyStylesObject(obj) {
|
|
5105
|
+
const cached = _stylesStringifyCache.get(obj);
|
|
5106
|
+
if (cached !== void 0) return cached;
|
|
5107
|
+
let result = "{";
|
|
5108
|
+
for (const key of Object.keys(obj).sort()) if (obj[key] !== void 0) {
|
|
5109
|
+
if (result.length > 1) result += ",";
|
|
5110
|
+
result += `${JSON.stringify(key)}:${stringifyStyle(key, obj[key])}`;
|
|
5111
|
+
}
|
|
5112
|
+
result += "}";
|
|
5113
|
+
_stylesStringifyCache.set(obj, result);
|
|
5051
5114
|
return result;
|
|
5052
5115
|
}
|
|
5116
|
+
function isPlainObject(value) {
|
|
5117
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
5118
|
+
}
|
|
5053
5119
|
function generateChunkCacheKey(styles, chunkName, styleKeys, reusable = false) {
|
|
5054
5120
|
let perStyles = _chunkKeyCache.get(styles);
|
|
5055
5121
|
if (perStyles !== void 0) {
|
|
@@ -5068,7 +5134,7 @@ function generateChunkCacheKey(styles, chunkName, styleKeys, reusable = false) {
|
|
|
5068
5134
|
for (let at = 0; at < snapshot.length; at += 2) {
|
|
5069
5135
|
const value = snapshot[at + 1];
|
|
5070
5136
|
if (value !== void 0) {
|
|
5071
|
-
const serialized =
|
|
5137
|
+
const serialized = stringifyStyle(snapshot[at], value);
|
|
5072
5138
|
key += `\0${snapshot[at]}:${serialized}`;
|
|
5073
5139
|
chunkStylesStr += serialized;
|
|
5074
5140
|
}
|
|
@@ -5128,4 +5194,4 @@ function renderStylesForChunk(styles, chunkName, styleKeys, pipelineCacheKey) {
|
|
|
5128
5194
|
//#endregion
|
|
5129
5195
|
export { APPEARANCE_CHUNK_STYLES as A, getGlobalPredefinedStates as B, STYLE_HANDLER_MAP as C, resetHandlers as D, registerHandler as E, LAYOUT_CHUNK_STYLES as F, resetGlobalPolyfillsState as G, hasStylesGenerated as H, POSITION_CHUNK_STYLES as I, resetStylesGeneratedState as K, STYLE_TO_CHUNK as L, DIMENSION_CHUNK_STYLES as M, DISPLAY_CHUNK_STYLES as N, styleHandlers as O, FONT_CHUNK_STYLES as P, resetStyleChunks as R, camelToKebab as S, normalizeHandlerDefinition as T, isFunctionsPolyfillEnabled as U, setGlobalPredefinedStates as V, markStylesGeneratedState as W, POSITION_STYLES as _, registerBaseStyleProps as a, renderStyles as b, BLOCK_INNER_STYLES as c, COLOR_STYLES as d, CONTAINER_STYLES as f, OUTER_STYLES as g, INNER_STYLES as h, baseStylePropsRegistry as i, CHUNK_NAMES as j, createStyle as k, BLOCK_OUTER_STYLES as l, FLOW_STYLES as m, generateChunkCacheKey as n, resetBaseStyleProps as o, DIMENSION_STYLES as p, setGlobalPolyfillsState as q, categorizeStyleKeys as r, BASE_STYLES as s, renderStylesForChunk as t, BLOCK_STYLES as u, TEXT_STYLES as v, defineHandler as w, parseStateKey as x, clearPipelineCache as y, createStateParserContext as z };
|
|
5130
5196
|
|
|
5131
|
-
//# sourceMappingURL=style-engine-
|
|
5197
|
+
//# sourceMappingURL=style-engine-DeE1gFDC.js.map
|