@tenphi/tasty 0.0.0-snapshot.05e04ff → 0.0.0-snapshot.06c8a41
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/astro-CeYENy2x.js +301 -0
- package/dist/astro-CeYENy2x.js.map +1 -0
- package/dist/{babel-B_P8t-f0.d.ts → babel-DWCsafYw.d.ts} +2 -2
- package/dist/{collector-DCI2yzwx.js → collector-B3OsM252.js} +36 -13
- package/dist/collector-B3OsM252.js.map +1 -0
- package/dist/{collector-CQDeU7WS.d.ts → collector-BTVXj2hS.d.ts} +21 -3
- package/dist/{config-B97n_EIv.js → config-B3gPdCqd.js} +202 -393
- package/dist/config-B3gPdCqd.js.map +1 -0
- package/dist/{config-CwRr6-fG.d.ts → config-LfIDmVHx.d.ts} +93 -65
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.js +6 -6
- package/dist/{core-DWrUWxog.js → core-DGm0CFHP.js} +271 -184
- package/dist/core-DGm0CFHP.js.map +1 -0
- package/dist/css-resources-Cyl_axbI.js +149 -0
- package/dist/css-resources-Cyl_axbI.js.map +1 -0
- package/dist/{css-writer-Cq0fg5v8.js → css-writer-Bgowobbx.js} +3 -3
- package/dist/{css-writer-Cq0fg5v8.js.map → css-writer-Bgowobbx.js.map} +1 -1
- package/dist/{format-rules-Wb7dJOoL.js → format-rules-XRw9u7d4.js} +3 -29
- package/dist/format-rules-XRw9u7d4.js.map +1 -0
- package/dist/{hydrate-gFTLBDK9.js → hydrate-CNOmZprz.js} +2 -2
- package/dist/{hydrate-gFTLBDK9.js.map → hydrate-CNOmZprz.js.map} +1 -1
- package/dist/{index-C0W21Qcb.d.ts → index-Bm9ltvdH.d.ts} +28 -53
- package/dist/{index-DpykQKO8.d.ts → index-BmogEzTo.d.ts} +60 -38
- package/dist/index.d.ts +5 -5
- package/dist/index.js +41 -117
- package/dist/index.js.map +1 -1
- package/dist/{renderChunk-COXABoQz.js → keyframes-DE-OE76F.js} +248 -3
- package/dist/keyframes-DE-OE76F.js.map +1 -0
- package/dist/{merge-styles-Bpwfy1CS.d.ts → merge-styles-BcLl1u_d.d.ts} +2 -2
- package/dist/{merge-styles-CzVxdtav.js → merge-styles-DuoZEsm9.js} +2 -2
- package/dist/{merge-styles-CzVxdtav.js.map → merge-styles-DuoZEsm9.js.map} +1 -1
- package/dist/{resolve-recipes-BnrUEjWV.js → resolve-recipes-H9NqOQuP.js} +3 -3
- package/dist/{resolve-recipes-BnrUEjWV.js.map → resolve-recipes-H9NqOQuP.js.map} +1 -1
- package/dist/ssr/astro-client.js +1 -1
- package/dist/ssr/astro-middleware-extract-static.d.ts +11 -0
- package/dist/ssr/astro-middleware-extract-static.js +9 -0
- package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
- package/dist/ssr/astro-middleware-extract.d.ts +11 -0
- package/dist/ssr/astro-middleware-extract.js +9 -0
- package/dist/ssr/astro-middleware-extract.js.map +1 -0
- package/dist/ssr/astro-middleware-static.d.ts +3 -1
- package/dist/ssr/astro-middleware-static.js +1 -1
- package/dist/ssr/astro-middleware.d.ts +3 -1
- package/dist/ssr/astro-middleware.js +1 -1
- package/dist/ssr/astro.d.ts +45 -3
- package/dist/ssr/astro.js +1 -156
- package/dist/ssr/index.d.ts +2 -2
- package/dist/ssr/index.js +3 -3
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/next-config.d.ts +66 -0
- package/dist/ssr/next-config.js +115 -0
- package/dist/ssr/next-config.js.map +1 -0
- package/dist/ssr/next.d.ts +9 -2
- package/dist/ssr/next.js +26 -9
- package/dist/ssr/next.js.map +1 -1
- package/dist/ssr-collector-ref-COs_ioWl.js +29 -0
- package/dist/ssr-collector-ref-COs_ioWl.js.map +1 -0
- package/dist/static/index.d.ts +2 -2
- package/dist/static/index.js +1 -1
- package/dist/zero/babel.d.ts +1 -1
- package/dist/zero/babel.js +4 -4
- package/dist/zero/babel.js.map +1 -1
- 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/debug.md +13 -0
- package/docs/injector.md +21 -7
- package/docs/runtime-benchmarks.md +192 -75
- package/docs/ssr.md +179 -20
- package/package.json +30 -9
- package/dist/collector-DCI2yzwx.js.map +0 -1
- package/dist/config-B97n_EIv.js.map +0 -1
- package/dist/core-DWrUWxog.js.map +0 -1
- package/dist/format-rules-Wb7dJOoL.js.map +0 -1
- package/dist/renderChunk-COXABoQz.js.map +0 -1
- package/dist/ssr/astro.js.map +0 -1
|
@@ -3186,7 +3186,14 @@ function resetStyleBatch() {
|
|
|
3186
3186
|
* Automatically infers CSS @property types from custom property values.
|
|
3187
3187
|
* Supports deferred resolution for var() reference chains of arbitrary depth.
|
|
3188
3188
|
*/
|
|
3189
|
-
|
|
3189
|
+
/**
|
|
3190
|
+
* One `--name: value` declaration, with the surrounding whitespace dropped.
|
|
3191
|
+
*
|
|
3192
|
+
* The value is anchored on `\S` at both ends so no two quantifiers can claim
|
|
3193
|
+
* the same character. A lazy `(.+?)\s*$` is quadratic on a value of nothing
|
|
3194
|
+
* but spaces — every split point gets tried (CodeQL `js/polynomial-redos`).
|
|
3195
|
+
*/
|
|
3196
|
+
const CUSTOM_PROP_DECL = /^\s*(--[a-z0-9_-]+)\s*:\s*(\S|\S.*\S)\s*$/i;
|
|
3190
3197
|
const SINGLE_VAR_REF = /^var\((--[a-z0-9_-]+)\)$/i;
|
|
3191
3198
|
var PropertyTypeResolver = class {
|
|
3192
3199
|
/** propName → the prop it depends on */
|
|
@@ -5054,9 +5061,9 @@ var SheetManager = class {
|
|
|
5054
5061
|
injectedFunctions: /* @__PURE__ */ new Map(),
|
|
5055
5062
|
globalRules: /* @__PURE__ */ new Map(),
|
|
5056
5063
|
propertyTypeResolver: new PropertyTypeResolver(),
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5064
|
+
unusedSince: /* @__PURE__ */ new Map(),
|
|
5065
|
+
localKeyframes: /* @__PURE__ */ new Map(),
|
|
5066
|
+
touchCount: 0,
|
|
5060
5067
|
serverClassSyncIndex: 0,
|
|
5061
5068
|
rscStylesScanned: false,
|
|
5062
5069
|
injectionMode: this.detectInjectionMode(root)
|
|
@@ -5489,14 +5496,16 @@ var SheetManager = class {
|
|
|
5489
5496
|
const endIdx = ruleInfo.endRuleIndex ?? ruleInfo.ruleIndex;
|
|
5490
5497
|
if (startIdx < 0 || endIdx > maxRuleIndex || startIdx > endIdx) continue;
|
|
5491
5498
|
this.deleteRule(registry, ruleInfo);
|
|
5492
|
-
const keyframeHandles = registry.keyframeHandles.get(className);
|
|
5493
|
-
if (keyframeHandles) {
|
|
5494
|
-
for (const dispose of keyframeHandles) dispose();
|
|
5495
|
-
registry.keyframeHandles.delete(className);
|
|
5496
|
-
}
|
|
5497
5499
|
registry.rules.delete(className);
|
|
5498
5500
|
registry.pinCounts.delete(className);
|
|
5499
|
-
registry.
|
|
5501
|
+
registry.unusedSince.delete(className);
|
|
5502
|
+
for (const [key, entry] of registry.localKeyframes) {
|
|
5503
|
+
if (!entry.owners.delete(className)) continue;
|
|
5504
|
+
if (entry.owners.size === 0) {
|
|
5505
|
+
entry.dispose();
|
|
5506
|
+
registry.localKeyframes.delete(key);
|
|
5507
|
+
}
|
|
5508
|
+
}
|
|
5500
5509
|
deleted.add(className);
|
|
5501
5510
|
cleanedUpCount++;
|
|
5502
5511
|
}
|
|
@@ -5523,25 +5532,31 @@ var SheetManager = class {
|
|
|
5523
5532
|
return registry.sheets.reduce((total, sheet) => total + sheet.ruleCount - sheet.holes.length, 0);
|
|
5524
5533
|
}
|
|
5525
5534
|
/**
|
|
5526
|
-
*
|
|
5535
|
+
* The CSS of one managed sheet, or `null` when it holds none this can read —
|
|
5536
|
+
* an empty style element, or a sheet the engine refuses to hand over.
|
|
5527
5537
|
*/
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
if (sheetInfo.
|
|
5532
|
-
const rules = Array.from(sheetInfo.constructableSheet.cssRules);
|
|
5533
|
-
cssChunks.push(rules.map((rule) => rule.cssText).join("\n"));
|
|
5534
|
-
} else if (sheetInfo.sheet) {
|
|
5538
|
+
readSheetCSS(sheetInfo) {
|
|
5539
|
+
try {
|
|
5540
|
+
if (sheetInfo.constructableSheet) return Array.from(sheetInfo.constructableSheet.cssRules).map((rule) => rule.cssText).join("\n");
|
|
5541
|
+
if (sheetInfo.sheet) {
|
|
5535
5542
|
const styleElement = sheetInfo.sheet;
|
|
5536
|
-
if (styleElement.textContent)
|
|
5537
|
-
|
|
5538
|
-
const rules = Array.from(styleElement.sheet.cssRules);
|
|
5539
|
-
cssChunks.push(rules.map((rule) => rule.cssText).join("\n"));
|
|
5540
|
-
}
|
|
5543
|
+
if (styleElement.textContent) return styleElement.textContent;
|
|
5544
|
+
if (styleElement.sheet) return Array.from(styleElement.sheet.cssRules).map((rule) => rule.cssText).join("\n");
|
|
5541
5545
|
}
|
|
5542
5546
|
} catch (error) {
|
|
5543
5547
|
console.warn("[Tasty] Failed to read CSS from sheet:", error);
|
|
5544
5548
|
}
|
|
5549
|
+
return null;
|
|
5550
|
+
}
|
|
5551
|
+
/**
|
|
5552
|
+
* Get CSS text from all sheets (for SSR)
|
|
5553
|
+
*/
|
|
5554
|
+
getCSSText(registry) {
|
|
5555
|
+
const cssChunks = [];
|
|
5556
|
+
for (const sheetInfo of registry.sheets) {
|
|
5557
|
+
const css = this.readSheetCSS(sheetInfo);
|
|
5558
|
+
if (css !== null) cssChunks.push(css);
|
|
5559
|
+
}
|
|
5545
5560
|
return cssChunks.join("\n");
|
|
5546
5561
|
}
|
|
5547
5562
|
/**
|
|
@@ -5853,6 +5868,49 @@ var SheetManager = class {
|
|
|
5853
5868
|
/**
|
|
5854
5869
|
* Get the raw CSS content
|
|
5855
5870
|
*/
|
|
5871
|
+
/**
|
|
5872
|
+
* The CSS this injector owns in `root`, one entry per sheet, in the order the
|
|
5873
|
+
* engine applies them.
|
|
5874
|
+
*
|
|
5875
|
+
* `getCSSText()` walks the managed sheets only, and raw CSS has its own —
|
|
5876
|
+
* which sits before, after, or *between* them depending on how it got there:
|
|
5877
|
+
* prepended to `adoptedStyleSheets`, or wherever in `<head>` the first raw
|
|
5878
|
+
* injection happened to land, with every managed sheet opened afterwards
|
|
5879
|
+
* following it. Reporting a fixed order would describe the opposite winner
|
|
5880
|
+
* from the live page whenever two rules of equal specificity meet, so the raw
|
|
5881
|
+
* sheet is spliced in at the position the DOM actually gives it.
|
|
5882
|
+
*/
|
|
5883
|
+
getOwnedCSSInOrder(registry, root) {
|
|
5884
|
+
const raw = this.getRawCSSText(root);
|
|
5885
|
+
const rawElement = this.isAdoptedMode(root) ? null : this.rawStyleElements.get(root);
|
|
5886
|
+
let rawIndex = raw && !rawElement ? 0 : -1;
|
|
5887
|
+
const chunks = [];
|
|
5888
|
+
for (const sheetInfo of registry.sheets) {
|
|
5889
|
+
const css = this.readSheetCSS(sheetInfo);
|
|
5890
|
+
if (css === null) continue;
|
|
5891
|
+
if (rawIndex < 0 && rawElement && sheetInfo.sheet && rawElement.compareDocumentPosition(sheetInfo.sheet) & Node.DOCUMENT_POSITION_FOLLOWING) rawIndex = chunks.length;
|
|
5892
|
+
chunks.push(css);
|
|
5893
|
+
}
|
|
5894
|
+
if (!raw) return chunks;
|
|
5895
|
+
chunks.splice(rawIndex < 0 ? chunks.length : rawIndex, 0, raw);
|
|
5896
|
+
return chunks;
|
|
5897
|
+
}
|
|
5898
|
+
/**
|
|
5899
|
+
* Top-level rules in the raw sheet.
|
|
5900
|
+
*
|
|
5901
|
+
* Read from the sheet the engine parsed, not from the text: a raw block is
|
|
5902
|
+
* one string but any number of rules, and one rule — `@keyframes`, `@media` —
|
|
5903
|
+
* can contain any number of blocks, so counting braces answers neither
|
|
5904
|
+
* question.
|
|
5905
|
+
*/
|
|
5906
|
+
getRawRuleCount(root) {
|
|
5907
|
+
const sheet = this.isAdoptedMode(root) ? this.rawConstructableSheets.get(root) : this.rawStyleElements.get(root)?.sheet;
|
|
5908
|
+
try {
|
|
5909
|
+
return sheet?.cssRules.length ?? 0;
|
|
5910
|
+
} catch {
|
|
5911
|
+
return 0;
|
|
5912
|
+
}
|
|
5913
|
+
}
|
|
5856
5914
|
getRawCSSText(root) {
|
|
5857
5915
|
if (this.isAdoptedMode(root)) {
|
|
5858
5916
|
const blocksMap = this.rawCSSBlocks.get(root);
|
|
@@ -5925,209 +5983,6 @@ function fontFaceContentHash(family, descriptors) {
|
|
|
5925
5983
|
});
|
|
5926
5984
|
}
|
|
5927
5985
|
//#endregion
|
|
5928
|
-
//#region src/keyframes/index.ts
|
|
5929
|
-
const KEYFRAMES_KEY = "@keyframes";
|
|
5930
|
-
/**
|
|
5931
|
-
* Pattern to extract animation names from CSS animation property values.
|
|
5932
|
-
* Animation name is typically the first identifier in the shorthand.
|
|
5933
|
-
* Handles: "fadeIn 300ms ease-in", "pulse 1s infinite", etc.
|
|
5934
|
-
*
|
|
5935
|
-
* CSS animation shorthand order (all optional except name):
|
|
5936
|
-
* animation: name | duration | timing | delay | iteration | direction | fill-mode | play-state
|
|
5937
|
-
*
|
|
5938
|
-
* Animation names must:
|
|
5939
|
-
* - Start with a letter, underscore, or hyphen (but not a digit or CSS keyword)
|
|
5940
|
-
* - Not be CSS keywords: none, initial, inherit, unset, revert
|
|
5941
|
-
*/
|
|
5942
|
-
const CSS_KEYWORDS = new Set([
|
|
5943
|
-
"none",
|
|
5944
|
-
"initial",
|
|
5945
|
-
"inherit",
|
|
5946
|
-
"unset",
|
|
5947
|
-
"revert",
|
|
5948
|
-
"auto",
|
|
5949
|
-
"normal",
|
|
5950
|
-
"running",
|
|
5951
|
-
"paused"
|
|
5952
|
-
]);
|
|
5953
|
-
/**
|
|
5954
|
-
* Pattern to match animation name at the start of an animation value.
|
|
5955
|
-
* Must start with letter, underscore, or hyphen (not digit).
|
|
5956
|
-
*/
|
|
5957
|
-
const ANIMATION_NAME_PATTERN = /^([a-zA-Z_-][a-zA-Z0-9_-]*)/;
|
|
5958
|
-
/**
|
|
5959
|
-
* Check if styles object has local @keyframes definition.
|
|
5960
|
-
* Fast path: single property lookup.
|
|
5961
|
-
*/
|
|
5962
|
-
function hasLocalKeyframes(styles) {
|
|
5963
|
-
return KEYFRAMES_KEY in styles;
|
|
5964
|
-
}
|
|
5965
|
-
/**
|
|
5966
|
-
* Extract local @keyframes from styles object.
|
|
5967
|
-
* Returns null if no local keyframes (fast path).
|
|
5968
|
-
*/
|
|
5969
|
-
function extractLocalKeyframes(styles) {
|
|
5970
|
-
const keyframes = styles[KEYFRAMES_KEY];
|
|
5971
|
-
if (!keyframes || typeof keyframes !== "object") return null;
|
|
5972
|
-
return keyframes;
|
|
5973
|
-
}
|
|
5974
|
-
/**
|
|
5975
|
-
* Merge local and global keyframes.
|
|
5976
|
-
* Local keyframes take priority over global.
|
|
5977
|
-
* Returns null if no keyframes exist (fast path).
|
|
5978
|
-
*/
|
|
5979
|
-
function mergeKeyframes(local, global) {
|
|
5980
|
-
if (!local && !global) return null;
|
|
5981
|
-
if (!local) return global;
|
|
5982
|
-
if (!global) return local;
|
|
5983
|
-
return {
|
|
5984
|
-
...global,
|
|
5985
|
-
...local
|
|
5986
|
-
};
|
|
5987
|
-
}
|
|
5988
|
-
/**
|
|
5989
|
-
* Extract animation name from a single animation value.
|
|
5990
|
-
* Returns null if no valid name found.
|
|
5991
|
-
*
|
|
5992
|
-
* Examples:
|
|
5993
|
-
* - "fadeIn 300ms ease-in" → "fadeIn"
|
|
5994
|
-
* - "1s pulse infinite" → "pulse" (name can be anywhere)
|
|
5995
|
-
* - "none" → null (CSS keyword)
|
|
5996
|
-
* - "300ms ease-in" → null (no name, just duration/timing)
|
|
5997
|
-
*/
|
|
5998
|
-
function extractAnimationNameFromValue(value) {
|
|
5999
|
-
const trimmed = value.trim();
|
|
6000
|
-
if (!trimmed) return null;
|
|
6001
|
-
const parts = trimmed.split(/\s+/);
|
|
6002
|
-
for (const part of parts) {
|
|
6003
|
-
if (CSS_KEYWORDS.has(part.toLowerCase())) continue;
|
|
6004
|
-
if (/^-?[\d.]+m?s$/i.test(part)) continue;
|
|
6005
|
-
if (part === "infinite" || /^\d+$/.test(part)) continue;
|
|
6006
|
-
if ([
|
|
6007
|
-
"normal",
|
|
6008
|
-
"reverse",
|
|
6009
|
-
"alternate",
|
|
6010
|
-
"alternate-reverse"
|
|
6011
|
-
].includes(part.toLowerCase())) continue;
|
|
6012
|
-
if ([
|
|
6013
|
-
"forwards",
|
|
6014
|
-
"backwards",
|
|
6015
|
-
"both"
|
|
6016
|
-
].includes(part.toLowerCase())) continue;
|
|
6017
|
-
if (["running", "paused"].includes(part.toLowerCase())) continue;
|
|
6018
|
-
if (/^(ease|linear|ease-in|ease-out|ease-in-out|step-start|step-end)$/i.test(part)) continue;
|
|
6019
|
-
if (/^(cubic-bezier|steps)\(/i.test(part)) continue;
|
|
6020
|
-
const match = ANIMATION_NAME_PATTERN.exec(part);
|
|
6021
|
-
if (match) return match[1];
|
|
6022
|
-
}
|
|
6023
|
-
return null;
|
|
6024
|
-
}
|
|
6025
|
-
/**
|
|
6026
|
-
* Extract all animation names from an animation property value.
|
|
6027
|
-
* Handles multiple animations separated by commas.
|
|
6028
|
-
*
|
|
6029
|
-
* Example: "fadeIn 300ms, slideIn 500ms ease-out" → ["fadeIn", "slideIn"]
|
|
6030
|
-
*/
|
|
6031
|
-
function extractAnimationNamesFromAnimationValue(value) {
|
|
6032
|
-
const names = [];
|
|
6033
|
-
const animations = value.split(",");
|
|
6034
|
-
for (const animation of animations) {
|
|
6035
|
-
const name = extractAnimationNameFromValue(animation);
|
|
6036
|
-
if (name && !names.includes(name)) names.push(name);
|
|
6037
|
-
}
|
|
6038
|
-
return names;
|
|
6039
|
-
}
|
|
6040
|
-
/**
|
|
6041
|
-
* Extract animation names from a style value (handles mappings and arrays).
|
|
6042
|
-
*/
|
|
6043
|
-
function extractAnimationNamesFromStyleValue(value, names) {
|
|
6044
|
-
if (typeof value === "string") for (const name of extractAnimationNamesFromAnimationValue(value)) names.add(name);
|
|
6045
|
-
else if (Array.isArray(value)) for (const v of value) extractAnimationNamesFromStyleValue(v, names);
|
|
6046
|
-
else if (value && typeof value === "object") for (const v of Object.values(value)) extractAnimationNamesFromStyleValue(v, names);
|
|
6047
|
-
}
|
|
6048
|
-
/**
|
|
6049
|
-
* Extract all animation names referenced in styles.
|
|
6050
|
-
* Scans 'animation' and 'animationName' properties including in state mappings.
|
|
6051
|
-
* Returns empty set if no animation properties found (fast path).
|
|
6052
|
-
*/
|
|
6053
|
-
function extractAnimationNamesFromStyles(styles) {
|
|
6054
|
-
const names = /* @__PURE__ */ new Set();
|
|
6055
|
-
if ("animation" in styles) extractAnimationNamesFromStyleValue(styles.animation, names);
|
|
6056
|
-
if ("animationName" in styles) extractAnimationNamesFromStyleValue(styles.animationName, names);
|
|
6057
|
-
for (const [key, value] of Object.entries(styles)) {
|
|
6058
|
-
if (key === "$" || key === KEYFRAMES_KEY) continue;
|
|
6059
|
-
if ((key.startsWith("&") || key.startsWith(".") || /^[A-Z]/.test(key)) && value && typeof value === "object") {
|
|
6060
|
-
const nestedNames = extractAnimationNamesFromStyles(value);
|
|
6061
|
-
for (const name of nestedNames) names.add(name);
|
|
6062
|
-
}
|
|
6063
|
-
}
|
|
6064
|
-
return names;
|
|
6065
|
-
}
|
|
6066
|
-
/**
|
|
6067
|
-
* Replace animation names in CSS declarations with injected names.
|
|
6068
|
-
* Optimized to avoid regex creation - uses simple string replacement.
|
|
6069
|
-
*
|
|
6070
|
-
* @param declarations CSS declarations string
|
|
6071
|
-
* @param nameMap Map from original name to injected name (only contains names that differ)
|
|
6072
|
-
* @returns Updated declarations string
|
|
6073
|
-
*/
|
|
6074
|
-
function replaceAnimationNames(declarations, nameMap) {
|
|
6075
|
-
if (!declarations.includes("animation")) return declarations;
|
|
6076
|
-
const parts = declarations.split(";");
|
|
6077
|
-
let modified = false;
|
|
6078
|
-
for (let i = 0; i < parts.length; i++) {
|
|
6079
|
-
const part = parts[i];
|
|
6080
|
-
const colonIdx = part.indexOf(":");
|
|
6081
|
-
if (colonIdx === -1) continue;
|
|
6082
|
-
const prop = part.slice(0, colonIdx).trim().toLowerCase();
|
|
6083
|
-
if (prop === "animation" || prop === "animation-name") {
|
|
6084
|
-
const prefix = part.slice(0, colonIdx + 1);
|
|
6085
|
-
let value = part.slice(colonIdx + 1);
|
|
6086
|
-
for (const [original, injected] of nameMap) {
|
|
6087
|
-
const newValue = replaceWord(value, original, injected);
|
|
6088
|
-
if (newValue !== value) {
|
|
6089
|
-
value = newValue;
|
|
6090
|
-
modified = true;
|
|
6091
|
-
}
|
|
6092
|
-
}
|
|
6093
|
-
parts[i] = prefix + value;
|
|
6094
|
-
}
|
|
6095
|
-
}
|
|
6096
|
-
return modified ? parts.join(";") : declarations;
|
|
6097
|
-
}
|
|
6098
|
-
/**
|
|
6099
|
-
* Replace a word in a string (word boundary aware, no regex).
|
|
6100
|
-
*/
|
|
6101
|
-
function replaceWord(str, word, replacement) {
|
|
6102
|
-
let result = str;
|
|
6103
|
-
let idx = 0;
|
|
6104
|
-
while ((idx = result.indexOf(word, idx)) !== -1) {
|
|
6105
|
-
const before = idx === 0 ? " " : result[idx - 1];
|
|
6106
|
-
const after = idx + word.length >= result.length ? " " : result[idx + word.length];
|
|
6107
|
-
const isWordBoundaryBefore = !/[a-zA-Z0-9_-]/.test(before);
|
|
6108
|
-
const isWordBoundaryAfter = !/[a-zA-Z0-9_-]/.test(after);
|
|
6109
|
-
if (isWordBoundaryBefore && isWordBoundaryAfter) {
|
|
6110
|
-
result = result.slice(0, idx) + replacement + result.slice(idx + word.length);
|
|
6111
|
-
idx += replacement.length;
|
|
6112
|
-
} else idx += word.length;
|
|
6113
|
-
}
|
|
6114
|
-
return result;
|
|
6115
|
-
}
|
|
6116
|
-
/**
|
|
6117
|
-
* Filter keyframes to only those that are actually used.
|
|
6118
|
-
* Returns null if no keyframes are used (fast path).
|
|
6119
|
-
*/
|
|
6120
|
-
function filterUsedKeyframes(keyframes, usedNames) {
|
|
6121
|
-
if (!keyframes || usedNames.size === 0) return null;
|
|
6122
|
-
const used = {};
|
|
6123
|
-
let hasAny = false;
|
|
6124
|
-
for (const name of usedNames) if (keyframes[name]) {
|
|
6125
|
-
used[name] = keyframes[name];
|
|
6126
|
-
hasAny = true;
|
|
6127
|
-
}
|
|
6128
|
-
return hasAny ? used : null;
|
|
6129
|
-
}
|
|
6130
|
-
//#endregion
|
|
6131
5986
|
//#region src/counter-style/index.ts
|
|
6132
5987
|
const COUNTER_STYLE_KEY = "@counter-style";
|
|
6133
5988
|
/**
|
|
@@ -6177,6 +6032,11 @@ function formatCounterStyleRule(name, descriptors) {
|
|
|
6177
6032
|
}
|
|
6178
6033
|
//#endregion
|
|
6179
6034
|
//#region src/injector/injector.ts
|
|
6035
|
+
/**
|
|
6036
|
+
* How long a class is left alone after it was last known to be wanted.
|
|
6037
|
+
* Long enough that a render cannot plausibly still be waiting to commit one.
|
|
6038
|
+
*/
|
|
6039
|
+
const DEFAULT_GC_GRACE = 1e4;
|
|
6180
6040
|
/** Dispose handle handed back for injections that took no pin. */
|
|
6181
6041
|
const noop = () => {};
|
|
6182
6042
|
/**
|
|
@@ -6242,19 +6102,8 @@ var StyleInjector = class {
|
|
|
6242
6102
|
sheetManager;
|
|
6243
6103
|
config;
|
|
6244
6104
|
globalRuleCounter = 0;
|
|
6245
|
-
/** Cancels the scheduled
|
|
6105
|
+
/** Cancels the scheduled sweep, whichever timer scheduled it. */
|
|
6246
6106
|
cancelPendingGC = null;
|
|
6247
|
-
/** className -> the CSS it stands for, so a collected class can come back. */
|
|
6248
|
-
recipes = /* @__PURE__ */ new Map();
|
|
6249
|
-
/**
|
|
6250
|
-
* cacheKey -> the class name it resolves to, and whether its CSS has been
|
|
6251
|
-
* described yet. A managed render is then one lookup rather than a hash plus
|
|
6252
|
-
* a second lookup, which matters because it runs for every chunk of every
|
|
6253
|
-
* component on every render.
|
|
6254
|
-
*/
|
|
6255
|
-
classNames = /* @__PURE__ */ new Map();
|
|
6256
|
-
/** Releases since the last scheduled pass. */
|
|
6257
|
-
releaseCount = 0;
|
|
6258
6107
|
namePrefix;
|
|
6259
6108
|
classRegex;
|
|
6260
6109
|
rscClassRegex;
|
|
@@ -6394,6 +6243,7 @@ var StyleInjector = class {
|
|
|
6394
6243
|
className = registry.cacheKeyToClassName.get(cacheKey);
|
|
6395
6244
|
const existingRuleInfo = registry.rules.get(className);
|
|
6396
6245
|
if (existingRuleInfo.ruleIndex === -3) {
|
|
6246
|
+
registry.unusedSince.delete(className);
|
|
6397
6247
|
if (pin) registry.pinCounts.set(className, (registry.pinCounts.get(className) || 0) + 1);
|
|
6398
6248
|
if (registry.metrics) registry.metrics.hits++;
|
|
6399
6249
|
return {
|
|
@@ -6402,6 +6252,7 @@ var StyleInjector = class {
|
|
|
6402
6252
|
};
|
|
6403
6253
|
}
|
|
6404
6254
|
if (!(existingRuleInfo.ruleIndex === -1 && existingRuleInfo.sheetIndex === -1)) {
|
|
6255
|
+
registry.unusedSince.delete(className);
|
|
6405
6256
|
if (pin) {
|
|
6406
6257
|
const pins = registry.pinCounts.get(className) || 0;
|
|
6407
6258
|
registry.pinCounts.set(className, pins + 1);
|
|
@@ -6481,6 +6332,7 @@ var StyleInjector = class {
|
|
|
6481
6332
|
});
|
|
6482
6333
|
if (cacheKey) registry.cacheKeyToClassName.set(cacheKey, className);
|
|
6483
6334
|
if (pin) registry.pinCounts.set(className, 1);
|
|
6335
|
+
registry.unusedSince.set(className, Date.now());
|
|
6484
6336
|
const queued = enqueueStyleWrite(() => {
|
|
6485
6337
|
if (applySheetWrite()) return;
|
|
6486
6338
|
registry.rules.set(className, {
|
|
@@ -6508,6 +6360,7 @@ var StyleInjector = class {
|
|
|
6508
6360
|
dispose: () => {}
|
|
6509
6361
|
};
|
|
6510
6362
|
if (pin) registry.pinCounts.set(className, 1);
|
|
6363
|
+
registry.unusedSince.set(className, Date.now());
|
|
6511
6364
|
return {
|
|
6512
6365
|
className,
|
|
6513
6366
|
dispose: pin ? () => this.unpin(className, registry) : noop
|
|
@@ -6590,6 +6443,49 @@ var StyleInjector = class {
|
|
|
6590
6443
|
return this.sheetManager.getRawCSSText(root);
|
|
6591
6444
|
}
|
|
6592
6445
|
/**
|
|
6446
|
+
* Take a reference on local `@keyframes`, under the deterministic names the
|
|
6447
|
+
* caller resolved.
|
|
6448
|
+
*
|
|
6449
|
+
* One reference per distinct set of steps, shared by every class that ends up
|
|
6450
|
+
* animating it, so a repeat render takes nothing further. Ownership is
|
|
6451
|
+
* assigned by `ownKeyframes()` once the rules exist to be inspected.
|
|
6452
|
+
*/
|
|
6453
|
+
holdKeyframes(steps, names, options) {
|
|
6454
|
+
const root = options?.root || document;
|
|
6455
|
+
const registry = this.sheetManager.getRegistry(root);
|
|
6456
|
+
const keys = /* @__PURE__ */ new Map();
|
|
6457
|
+
for (const [authored, definition] of Object.entries(steps)) {
|
|
6458
|
+
const resolved = names.get(authored) ?? authored;
|
|
6459
|
+
let entry = registry.localKeyframes.get(resolved);
|
|
6460
|
+
if (!entry) {
|
|
6461
|
+
const injected = this.keyframes(definition, {
|
|
6462
|
+
name: resolved,
|
|
6463
|
+
root,
|
|
6464
|
+
distinctByName: true
|
|
6465
|
+
});
|
|
6466
|
+
entry = {
|
|
6467
|
+
name: injected.toString(),
|
|
6468
|
+
dispose: injected.dispose,
|
|
6469
|
+
owners: /* @__PURE__ */ new Set()
|
|
6470
|
+
};
|
|
6471
|
+
registry.localKeyframes.set(resolved, entry);
|
|
6472
|
+
}
|
|
6473
|
+
keys.set(authored, resolved);
|
|
6474
|
+
}
|
|
6475
|
+
return keys;
|
|
6476
|
+
}
|
|
6477
|
+
/**
|
|
6478
|
+
* Record that `className` animates these keyframes, so the reference is
|
|
6479
|
+
* released when the last such class is collected.
|
|
6480
|
+
*
|
|
6481
|
+
* Only classes whose rules actually reference the animation should be here:
|
|
6482
|
+
* a class that merely rendered alongside one would otherwise keep the
|
|
6483
|
+
* keyframes alive for as long as it lives.
|
|
6484
|
+
*/
|
|
6485
|
+
ownKeyframes(key, className, options) {
|
|
6486
|
+
this.sheetManager.getRegistry(options?.root || document).localKeyframes.get(key)?.owners.add(className);
|
|
6487
|
+
}
|
|
6488
|
+
/**
|
|
6593
6489
|
* Pin an already-injected cacheKey and return the handle that releases it.
|
|
6594
6490
|
* For callers that skipped the pipeline on a cache hit but still need the
|
|
6595
6491
|
* class held. Returns null if the cacheKey is not found.
|
|
@@ -6670,7 +6566,7 @@ var StyleInjector = class {
|
|
|
6670
6566
|
const root = options?.root || document;
|
|
6671
6567
|
const registry = this.sheetManager.getRegistry(root);
|
|
6672
6568
|
const metrics = this.sheetManager.getMetrics(registry);
|
|
6673
|
-
if (metrics && typeof document !== "undefined") metrics.unusedHits = this.collectUnused(registry).length;
|
|
6569
|
+
if (metrics && typeof document !== "undefined") metrics.unusedHits = this.collectUnused(registry, root).length;
|
|
6674
6570
|
return metrics;
|
|
6675
6571
|
}
|
|
6676
6572
|
/**
|
|
@@ -6845,13 +6741,14 @@ var StyleInjector = class {
|
|
|
6845
6741
|
keyframes(steps, nameOrOptions) {
|
|
6846
6742
|
const isStringName = typeof nameOrOptions === "string";
|
|
6847
6743
|
const providedName = isStringName ? nameOrOptions : nameOrOptions?.name;
|
|
6744
|
+
const distinctByName = isStringName ? false : nameOrOptions?.distinctByName ?? false;
|
|
6848
6745
|
const root = isStringName ? document : nameOrOptions?.root || document;
|
|
6849
6746
|
const registry = this.sheetManager.getRegistry(root);
|
|
6850
6747
|
if (Object.keys(steps).length === 0) return {
|
|
6851
6748
|
toString: () => "",
|
|
6852
6749
|
dispose: () => {}
|
|
6853
6750
|
};
|
|
6854
|
-
const contentHash = JSON.stringify(steps);
|
|
6751
|
+
const contentHash = distinctByName && providedName ? `${providedName}\u0000${JSON.stringify(steps)}` : JSON.stringify(steps);
|
|
6855
6752
|
const existing = registry.keyframesCache.get(contentHash);
|
|
6856
6753
|
if (existing) {
|
|
6857
6754
|
existing.refCount++;
|
|
@@ -6943,131 +6840,31 @@ var StyleInjector = class {
|
|
|
6943
6840
|
}
|
|
6944
6841
|
}
|
|
6945
6842
|
/**
|
|
6946
|
-
*
|
|
6947
|
-
*
|
|
6948
|
-
*
|
|
6949
|
-
*/
|
|
6950
|
-
/**
|
|
6951
|
-
* The class name a cache key resolves to, and whether its CSS is already
|
|
6952
|
-
* described. Pure: no allocation beyond the memo, nothing written — safe
|
|
6953
|
-
* during render, and stable because the name is a hash of the key.
|
|
6954
|
-
*/
|
|
6955
|
-
resolveChunk(cacheKey) {
|
|
6956
|
-
let entry = this.classNames.get(cacheKey);
|
|
6957
|
-
if (entry === void 0) {
|
|
6958
|
-
entry = {
|
|
6959
|
-
name: this.generateClassName(cacheKey),
|
|
6960
|
-
described: false
|
|
6961
|
-
};
|
|
6962
|
-
this.classNames.set(cacheKey, entry);
|
|
6963
|
-
}
|
|
6964
|
-
return entry;
|
|
6965
|
-
}
|
|
6966
|
-
/** Whether this class has already been described, so its CSS need not be re-rendered. */
|
|
6967
|
-
hasRecipe(className) {
|
|
6968
|
-
return this.recipes.has(className);
|
|
6969
|
-
}
|
|
6970
|
-
/**
|
|
6971
|
-
* Record the CSS a class name stands for without writing it to a sheet.
|
|
6972
|
-
*
|
|
6973
|
-
* Called during render. Nothing is inserted yet: the component that will
|
|
6974
|
-
* carry the class inserts it from here when it commits, so a render that is
|
|
6975
|
-
* discarded leaves no rule behind, and a rule collected between render and
|
|
6976
|
-
* commit comes back.
|
|
6977
|
-
*/
|
|
6978
|
-
defineRecipe(className, recipe) {
|
|
6979
|
-
if (this.recipes.has(className)) return;
|
|
6980
|
-
this.recipes.set(className, recipe);
|
|
6981
|
-
if (recipe.cacheKey) {
|
|
6982
|
-
const entry = this.classNames.get(recipe.cacheKey);
|
|
6983
|
-
if (entry) entry.described = true;
|
|
6984
|
-
}
|
|
6985
|
-
}
|
|
6986
|
-
/**
|
|
6987
|
-
* Take up a class on commit: insert its rules if they are not in the sheet,
|
|
6988
|
-
* and count one more mounted holder.
|
|
6843
|
+
* Count a render, and schedule a collection pass every `touchInterval` of
|
|
6844
|
+
* them. Nothing else: what a class is worth keeping is decided by the sweep's
|
|
6845
|
+
* own DOM scan, so rendering does not track usage at all.
|
|
6989
6846
|
*
|
|
6990
|
-
*
|
|
6991
|
-
*
|
|
6992
|
-
|
|
6993
|
-
|
|
6994
|
-
if (!className) return;
|
|
6995
|
-
const root = options?.root || document;
|
|
6996
|
-
const registry = this.sheetManager.getRegistry(root);
|
|
6997
|
-
const parts = className.indexOf(" ") === -1 ? [className] : className.split(" ");
|
|
6998
|
-
for (const cls of parts) {
|
|
6999
|
-
const held = registry.committed.get(cls) ?? 0;
|
|
7000
|
-
registry.committed.set(cls, held + 1);
|
|
7001
|
-
registry.candidates.delete(cls);
|
|
7002
|
-
if (held > 0) continue;
|
|
7003
|
-
const existing = registry.rules.get(cls);
|
|
7004
|
-
if (existing && existing.sheetIndex !== -1) continue;
|
|
7005
|
-
const recipe = this.recipes.get(cls);
|
|
7006
|
-
if (!recipe) continue;
|
|
7007
|
-
let rules = recipe.rules;
|
|
7008
|
-
if (recipe.keyframes) {
|
|
7009
|
-
const handles = [];
|
|
7010
|
-
let nameMap = null;
|
|
7011
|
-
for (const [name, steps] of Object.entries(recipe.keyframes)) {
|
|
7012
|
-
const injected = this.keyframes(steps, {
|
|
7013
|
-
name,
|
|
7014
|
-
root
|
|
7015
|
-
});
|
|
7016
|
-
handles.push(injected.dispose);
|
|
7017
|
-
const injectedName = injected.toString();
|
|
7018
|
-
if (injectedName !== name) {
|
|
7019
|
-
if (!nameMap) nameMap = /* @__PURE__ */ new Map();
|
|
7020
|
-
nameMap.set(name, injectedName);
|
|
7021
|
-
}
|
|
7022
|
-
}
|
|
7023
|
-
registry.keyframeHandles.set(cls, handles);
|
|
7024
|
-
if (nameMap) rules = rules.map((rule) => ({
|
|
7025
|
-
...rule,
|
|
7026
|
-
declarations: replaceAnimationNames(rule.declarations, nameMap)
|
|
7027
|
-
}));
|
|
7028
|
-
}
|
|
7029
|
-
this.inject(rules, {
|
|
7030
|
-
root,
|
|
7031
|
-
cacheKey: recipe.cacheKey,
|
|
7032
|
-
pin: false
|
|
7033
|
-
});
|
|
7034
|
-
}
|
|
7035
|
-
}
|
|
7036
|
-
/**
|
|
7037
|
-
* Give up a class on unmount. At zero holders it becomes a candidate, but is
|
|
7038
|
-
* not deleted here: insertion-effect cleanups and setups interleave component
|
|
7039
|
-
* by component, so a sibling mounting the same class must get to say so
|
|
7040
|
-
* first. The scheduled pass re-checks before deleting anything.
|
|
6847
|
+
* @deprecated The class name is ignored — pass anything, or stop calling it.
|
|
6848
|
+
* Collection no longer records per-class usage, and scheduling does not need
|
|
6849
|
+
* to know which class was rendered. A class handed back by `inject()` is
|
|
6850
|
+
* marked wanted there, which is what reuse actually goes through.
|
|
7041
6851
|
*/
|
|
7042
|
-
|
|
7043
|
-
if (
|
|
7044
|
-
const root = options?.root || document;
|
|
7045
|
-
const registry = this.sheetManager.getRegistry(root);
|
|
7046
|
-
const parts = className.indexOf(" ") === -1 ? [className] : className.split(" ");
|
|
7047
|
-
const now = Date.now();
|
|
7048
|
-
for (const cls of parts) {
|
|
7049
|
-
const held = registry.committed.get(cls) ?? 0;
|
|
7050
|
-
if (held <= 1) {
|
|
7051
|
-
registry.committed.delete(cls);
|
|
7052
|
-
registry.candidates.set(cls, now);
|
|
7053
|
-
this.releaseCount++;
|
|
7054
|
-
} else registry.committed.set(cls, held - 1);
|
|
7055
|
-
}
|
|
6852
|
+
touch(_className, options) {
|
|
6853
|
+
if (typeof document === "undefined") return;
|
|
7056
6854
|
if (!this.config.gc) return;
|
|
7057
|
-
const
|
|
7058
|
-
if (
|
|
7059
|
-
|
|
6855
|
+
const registry = this.sheetManager.getRegistry(options?.root || document);
|
|
6856
|
+
if (++registry.touchCount >= (this.config.gc.touchInterval ?? 1e3)) {
|
|
6857
|
+
registry.touchCount = 0;
|
|
7060
6858
|
this.scheduleGC();
|
|
7061
6859
|
}
|
|
7062
6860
|
}
|
|
7063
6861
|
/**
|
|
7064
|
-
* Schedule a
|
|
6862
|
+
* Schedule a GC in idle time. Runs GC on all active roots, and avoids
|
|
7065
6863
|
* double-scheduling.
|
|
7066
6864
|
*
|
|
7067
|
-
*
|
|
7068
|
-
*
|
|
7069
|
-
*
|
|
7070
|
-
* Deleting on the way past would race that; the pass re-checks instead.
|
|
6865
|
+
* Idle only. Without `requestIdleCallback` nothing is collected
|
|
6866
|
+
* automatically: running the sweep inline here would put it inside the render
|
|
6867
|
+
* that touched the class, and collection is never urgent enough for that.
|
|
7071
6868
|
*/
|
|
7072
6869
|
scheduleGC() {
|
|
7073
6870
|
if (this.cancelPendingGC) return;
|
|
@@ -7079,30 +6876,54 @@ var StyleInjector = class {
|
|
|
7079
6876
|
if (typeof requestIdleCallback !== "undefined") {
|
|
7080
6877
|
const handle = requestIdleCallback(() => runGC());
|
|
7081
6878
|
this.cancelPendingGC = () => cancelIdleCallback(handle);
|
|
7082
|
-
} else {
|
|
7083
|
-
const handle = setTimeout(runGC, 0);
|
|
7084
|
-
this.cancelPendingGC = () => clearTimeout(handle);
|
|
7085
6879
|
}
|
|
7086
6880
|
}
|
|
7087
6881
|
/**
|
|
7088
|
-
* The one definition of "unused":
|
|
7089
|
-
*
|
|
7090
|
-
*
|
|
7091
|
-
*
|
|
6882
|
+
* The one definition of "unused": this injector owns the class's rules, no
|
|
6883
|
+
* element in `root` carries it, and nobody pinned it.
|
|
6884
|
+
*
|
|
6885
|
+
* `gc()` evicts from this set, `getMetrics()` counts it, and `tastyDebug`
|
|
6886
|
+
* reports it — all through here, so the three can never disagree about what
|
|
6887
|
+
* "unused" means. Entries carry their last `touch()` so callers can drop the
|
|
6888
|
+
* oldest first; a class that was never touched sorts as oldest.
|
|
6889
|
+
*/
|
|
6890
|
+
/**
|
|
6891
|
+
* Everything the injector holds falls into one of five bands, and only the
|
|
6892
|
+
* last of them is ever deleted:
|
|
6893
|
+
*
|
|
6894
|
+
* 1. rendered — some element carries the class right now
|
|
6895
|
+
* 2. not ours — queued for a batched write, pre-allocated, or server-rendered
|
|
6896
|
+
* 3. hot — nothing carries it, but that was noticed less than `grace` ago
|
|
6897
|
+
* 4. cached — cold, but within `capacity` when ordered by when it went cold
|
|
6898
|
+
* 5. the rest
|
|
7092
6899
|
*
|
|
7093
|
-
*
|
|
7094
|
-
*
|
|
7095
|
-
*
|
|
6900
|
+
* This returns bands 4 and 5 together, most recently cold first; `gc()` draws
|
|
6901
|
+
* the capacity line through them. Band 3 is what makes collection safe
|
|
6902
|
+
* without a commit signal: a render can resolve a class and commit it a
|
|
6903
|
+
* little later, and during that gap nothing on the page carries it.
|
|
7096
6904
|
*/
|
|
7097
|
-
collectUnused(registry) {
|
|
6905
|
+
collectUnused(registry, root) {
|
|
6906
|
+
const now = Date.now();
|
|
6907
|
+
const grace = this.config.gc?.grace ?? DEFAULT_GC_GRACE;
|
|
6908
|
+
const liveClasses = /* @__PURE__ */ new Set();
|
|
6909
|
+
for (const el of root.querySelectorAll("[class]")) for (const token of el.classList) if (this.classRegex.test(token)) liveClasses.add(token);
|
|
7098
6910
|
const unused = [];
|
|
7099
|
-
for (const className of registry.
|
|
7100
|
-
if (
|
|
6911
|
+
for (const [className, ruleInfo] of registry.rules) {
|
|
6912
|
+
if (ruleInfo.sheetIndex < 0) continue;
|
|
6913
|
+
if (liveClasses.has(className)) {
|
|
6914
|
+
registry.unusedSince.delete(className);
|
|
6915
|
+
continue;
|
|
6916
|
+
}
|
|
7101
6917
|
if ((registry.pinCounts.get(className) ?? 0) > 0) continue;
|
|
7102
|
-
|
|
7103
|
-
if (
|
|
6918
|
+
let since = registry.unusedSince.get(className);
|
|
6919
|
+
if (since === void 0) {
|
|
6920
|
+
since = now;
|
|
6921
|
+
registry.unusedSince.set(className, now);
|
|
6922
|
+
}
|
|
6923
|
+
if (now - since < grace) continue;
|
|
7104
6924
|
unused.push(className);
|
|
7105
6925
|
}
|
|
6926
|
+
unused.sort((a, b) => (registry.unusedSince.get(b) ?? 0) - (registry.unusedSince.get(a) ?? 0));
|
|
7106
6927
|
return unused;
|
|
7107
6928
|
}
|
|
7108
6929
|
/**
|
|
@@ -7112,8 +6933,9 @@ var StyleInjector = class {
|
|
|
7112
6933
|
getUnusedClasses(options) {
|
|
7113
6934
|
flushStyles();
|
|
7114
6935
|
if (typeof document === "undefined") return [];
|
|
7115
|
-
const
|
|
7116
|
-
|
|
6936
|
+
const root = options?.root || document;
|
|
6937
|
+
const registry = this.sheetManager.getRegistry(root);
|
|
6938
|
+
return this.collectUnused(registry, root);
|
|
7117
6939
|
}
|
|
7118
6940
|
/**
|
|
7119
6941
|
* Synchronous garbage collection.
|
|
@@ -7136,15 +6958,12 @@ var StyleInjector = class {
|
|
|
7136
6958
|
const force = options?.force;
|
|
7137
6959
|
const registry = this.sheetManager.getRegistry(root);
|
|
7138
6960
|
const capacity = this.config.gc?.capacity ?? 1e3;
|
|
7139
|
-
if (!force && registry.
|
|
7140
|
-
const unused = this.collectUnused(registry);
|
|
6961
|
+
if (!force && registry.rules.size <= capacity) return 0;
|
|
6962
|
+
const unused = this.collectUnused(registry, root);
|
|
7141
6963
|
let doomed;
|
|
7142
6964
|
if (force) doomed = unused;
|
|
7143
|
-
else if (unused.length > capacity)
|
|
7144
|
-
|
|
7145
|
-
unused.sort((a, b) => releasedAt(a) - releasedAt(b));
|
|
7146
|
-
doomed = unused.slice(0, unused.length - capacity);
|
|
7147
|
-
} else return 0;
|
|
6965
|
+
else if (unused.length > capacity) doomed = unused.slice(capacity);
|
|
6966
|
+
else return 0;
|
|
7148
6967
|
if (doomed.length === 0) return 0;
|
|
7149
6968
|
return this.sheetManager.deleteClasses(registry, doomed);
|
|
7150
6969
|
}
|
|
@@ -12027,19 +11846,10 @@ function createDefaultConfig(isTest) {
|
|
|
12027
11846
|
* This locks the configuration - no further changes allowed.
|
|
12028
11847
|
* Also injects internal and global properties.
|
|
12029
11848
|
*/
|
|
12030
|
-
/**
|
|
12031
|
-
* Bumped whenever the global injector is replaced. Caches that hold class names
|
|
12032
|
-
* across renders compare it to notice that the injector which knew what those
|
|
12033
|
-
* names stand for is gone.
|
|
12034
|
-
*/
|
|
12035
|
-
let styleEpoch = 0;
|
|
12036
|
-
function getStyleEpoch() {
|
|
12037
|
-
return styleEpoch;
|
|
12038
|
-
}
|
|
12039
11849
|
function markStylesGenerated() {
|
|
12040
11850
|
if (stylesGenerated) return;
|
|
12041
11851
|
stylesGenerated = true;
|
|
12042
|
-
if (typeof document !== "undefined" && document.querySelector("
|
|
11852
|
+
if (typeof document !== "undefined" && document.querySelector("[data-tasty-ssr]")) {
|
|
12043
11853
|
warnOnce("ssr-globals-skip", "[Tasty] SSR styles detected — skipping client-side global CSS injection to avoid duplicates.");
|
|
12044
11854
|
return;
|
|
12045
11855
|
}
|
|
@@ -12604,9 +12414,8 @@ function resetConfig() {
|
|
|
12604
12414
|
resetStyleWarnings();
|
|
12605
12415
|
const storage = typeof window !== "undefined" ? window : globalThis;
|
|
12606
12416
|
delete storage[GLOBAL_INJECTOR_KEY];
|
|
12607
|
-
styleEpoch++;
|
|
12608
12417
|
}
|
|
12609
12418
|
//#endregion
|
|
12610
|
-
export {
|
|
12419
|
+
export { SheetManager as $, StyleParser as $t, FLOW_STYLES as A, STYLE_TO_CHUNK as At, createStateParserContext as B, getGlobalParseFunctions as Bt, BASE_STYLES as C, APPEARANCE_CHUNK_STYLES as Ct, COLOR_STYLES as D, FONT_CHUNK_STYLES as Dt, BLOCK_STYLES as E, DISPLAY_CHUNK_STYLES as Et, hasPipelineCacheEntry as F, registerFunctionPolyfill as Ft, StyleInjector as G, parseStyle as Gt, extractPredefinedStateRefs as H, getGlobalPredefinedTokens as Ht, isSelector as I, registerLocalFunctionPolyfills as It, hasLocalCounterStyle as J, okhstPlugin as Jt, extractLocalCounterStyle as K, stringifyStyles as Kt, renderStyles as L, CUSTOM_UNITS as Lt, OUTER_STYLES as M, formatFunctionRule as Mt, POSITION_STYLES as N, hasLocalFunctions as Nt, CONTAINER_STYLES as O, LAYOUT_CHUNK_STYLES as Ot, TEXT_STYLES as P, parseFunctionName as Pt, hasLocalFontFace as Q, isDevEnv as Qt, parseStateKey as R, DIRECTIONS as Rt, baseStylePropsRegistry as S, propHandlerRegistry as St, BLOCK_OUTER_STYLES as T, DIMENSION_CHUNK_STYLES as Tt, getGlobalPredefinedStates as U, normalizeColorTokenValue as Ut, extractLocalPredefinedStates as V, getGlobalParser as Vt, setGlobalPredefinedStates as W, parseColor as Wt, fontFaceContentHash as X, okhslPlugin as Xt, extractLocalFontFace as Y, okhslFunction as Yt, formatFontFaceRule as Z, createColorFunc as Zt, isFunctionsPolyfillEnabled as _, hashString as _t, getGlobalCounterStyles as a, hslToRgbValues as an, closeBatchWindow as at, resetConfig as b, hasLocalProperties as bt, getGlobalInjector as c, openBatchWindow as ct, getGlobalStyles as d, DEFAULT_ZERO_NAME_PREFIX as dt, Lru as en, STYLE_HANDLER_MAP as et, getNamePrefix as f, makeClassName as ft, isConfigLocked as g, validateNamePrefix as gt, hasStylesGenerated as h, tastyClassRegex as ht, getGlobalConfigTokens as i, hexToRgb as in, PropertyTypeResolver as it, INNER_STYLES as j, extractLocalFunctions as jt, DIMENSION_STYLES as k, POSITION_CHUNK_STYLES as kt, getGlobalKeyframes as l, resetStyleBatch as lt, hasGlobalRecipes as m, makeKeyframeName as mt, getConfig as n, getNamedColorHex as nn, styleHandlers as nt, getGlobalFontFaces as o, strToRgb as on, flushStyles as ot, hasGlobalKeyframes as p, makeCounterStyleName as pt, formatCounterStyleRule as q, okhstFunction as qt, getEffectiveProperties as r, getRgbValuesFromRgbaString as rn, createStyle as rt, getGlobalFunctions as s, normalizeDslName as sn, hasPendingStyleWrites as st, configure as t, overrideColorAlpha as tn, defineHandler as tt, getGlobalRecipes as u, DEFAULT_NAME_PREFIX as ut, isTestEnvironment as v, extractLocalProperties as vt, BLOCK_INNER_STYLES as w, CHUNK_NAMES as wt, generateTypographyTokens as x, parsePropertyToken as xt, markStylesGenerated as y, getEffectiveDefinition as yt, camelToKebab as z, filterMods as zt };
|
|
12611
12420
|
|
|
12612
|
-
//# sourceMappingURL=config-
|
|
12421
|
+
//# sourceMappingURL=config-B3gPdCqd.js.map
|