@tenphi/tasty 0.0.0-snapshot.fdb16ea → 0.0.0-snapshot.fde6cf3
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-Dj8YpRd7.js +301 -0
- package/dist/astro-Dj8YpRd7.js.map +1 -0
- package/dist/{babel-CMYf4JZ2.d.ts → babel-Cbp2C2bj.d.ts} +2 -2
- package/dist/{collector-Ctn5s74s.d.ts → collector-DBY6liC2.d.ts} +94 -11
- package/dist/collector-NjmUiB8f.js +529 -0
- package/dist/collector-NjmUiB8f.js.map +1 -0
- package/dist/{config-B23gZrfP.js → config-Bd2vOF0Z.js} +454 -105
- package/dist/config-Bd2vOF0Z.js.map +1 -0
- package/dist/{config-CZx8_DCu.d.ts → config-CA7iAlEI.d.ts} +112 -22
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.js +6 -6
- package/dist/{core-B1tyn69d.js → core-ClInK6YG.js} +386 -107
- package/dist/core-ClInK6YG.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-CvAxkR6S.js → css-writer-BDQXG9Jo.js} +3 -3
- package/dist/{css-writer-CvAxkR6S.js.map → css-writer-BDQXG9Jo.js.map} +1 -1
- package/dist/{format-rules-BCTWVvcS.js → format-rules-CGhgoVLR.js} +22 -32
- package/dist/format-rules-CGhgoVLR.js.map +1 -0
- package/dist/{hydrate-BCPvkJj3.js → hydrate-CqbxwVh_.js} +2 -2
- package/dist/{hydrate-BCPvkJj3.js.map → hydrate-CqbxwVh_.js.map} +1 -1
- package/dist/{index-B3o0aCYV.d.ts → index-C8RFYeFW.d.ts} +61 -12
- package/dist/{index-CsvB0EXZ.d.ts → index-FpYK0H5g.d.ts} +49 -8
- package/dist/index.d.ts +5 -5
- package/dist/index.js +43 -27
- package/dist/index.js.map +1 -1
- package/dist/{keyframes-Dxdx3KOo.js → keyframes-BjfNVhaB.js} +45 -3
- package/dist/keyframes-BjfNVhaB.js.map +1 -0
- package/dist/{merge-styles-DJTSfz_M.d.ts → merge-styles-BQv7d3fx.d.ts} +2 -2
- package/dist/{merge-styles-C-uwpoNW.js → merge-styles-BbJhjesV.js} +2 -2
- package/dist/{merge-styles-C-uwpoNW.js.map → merge-styles-BbJhjesV.js.map} +1 -1
- package/dist/precompile/index.d.ts +11 -0
- package/dist/precompile/index.js +72 -0
- package/dist/precompile/index.js.map +1 -0
- package/dist/precompile/register.d.ts +13 -0
- package/dist/precompile/register.js +2 -0
- package/dist/register-BkC-8Zuy.js +333 -0
- package/dist/register-BkC-8Zuy.js.map +1 -0
- package/dist/{resolve-recipes-BuOvSEa2.js → resolve-recipes-B2Sf36AH.js} +3 -3
- package/dist/{resolve-recipes-BuOvSEa2.js.map → resolve-recipes-B2Sf36AH.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/types-Bo5ePLZh.d.ts +111 -0
- 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/README.md +3 -1
- package/docs/debug.md +17 -6
- package/docs/injector.md +23 -3
- package/docs/precompile.md +202 -0
- package/docs/runtime-benchmarks.md +143 -72
- package/docs/ssr.md +179 -20
- package/package.json +44 -10
- package/dist/collector-DMSR6ANK.js +0 -304
- package/dist/collector-DMSR6ANK.js.map +0 -1
- package/dist/config-B23gZrfP.js.map +0 -1
- package/dist/core-B1tyn69d.js.map +0 -1
- package/dist/format-rules-BCTWVvcS.js.map +0 -1
- package/dist/keyframes-Dxdx3KOo.js.map +0 -1
- package/dist/ssr/astro.js.map +0 -1
|
@@ -2561,8 +2561,8 @@ function resetStyleChunks() {
|
|
|
2561
2561
|
* unused is one property load and one branch.
|
|
2562
2562
|
*/
|
|
2563
2563
|
const GTKEY$1 = "__tasty_prop_handlers__";
|
|
2564
|
-
const globalStore$
|
|
2565
|
-
const propHandlerRegistry = globalStore$
|
|
2564
|
+
const globalStore$2 = globalThis;
|
|
2565
|
+
const propHandlerRegistry = globalStore$2[GTKEY$1] ?? (globalStore$2[GTKEY$1] = {
|
|
2566
2566
|
apply: null,
|
|
2567
2567
|
list: []
|
|
2568
2568
|
});
|
|
@@ -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 */
|
|
@@ -5030,6 +5037,8 @@ var SheetManager = class {
|
|
|
5030
5037
|
if (!registry) {
|
|
5031
5038
|
const metrics = this.config.devMode ? {
|
|
5032
5039
|
hits: 0,
|
|
5040
|
+
precompiledHits: 0,
|
|
5041
|
+
precompiledUniqueHits: 0,
|
|
5033
5042
|
misses: 0,
|
|
5034
5043
|
bulkCleanups: 0,
|
|
5035
5044
|
totalInsertions: 0,
|
|
@@ -5054,10 +5063,9 @@ var SheetManager = class {
|
|
|
5054
5063
|
injectedFunctions: /* @__PURE__ */ new Map(),
|
|
5055
5064
|
globalRules: /* @__PURE__ */ new Map(),
|
|
5056
5065
|
propertyTypeResolver: new PropertyTypeResolver(),
|
|
5057
|
-
|
|
5066
|
+
unusedSince: /* @__PURE__ */ new Map(),
|
|
5067
|
+
localKeyframes: /* @__PURE__ */ new Map(),
|
|
5058
5068
|
touchCount: 0,
|
|
5059
|
-
touchTick: -1,
|
|
5060
|
-
touchedTick: /* @__PURE__ */ new Set(),
|
|
5061
5069
|
serverClassSyncIndex: 0,
|
|
5062
5070
|
rscStylesScanned: false,
|
|
5063
5071
|
injectionMode: this.detectInjectionMode(root)
|
|
@@ -5492,7 +5500,14 @@ var SheetManager = class {
|
|
|
5492
5500
|
this.deleteRule(registry, ruleInfo);
|
|
5493
5501
|
registry.rules.delete(className);
|
|
5494
5502
|
registry.pinCounts.delete(className);
|
|
5495
|
-
registry.
|
|
5503
|
+
registry.unusedSince.delete(className);
|
|
5504
|
+
for (const [key, entry] of registry.localKeyframes) {
|
|
5505
|
+
if (!entry.owners.delete(className)) continue;
|
|
5506
|
+
if (entry.owners.size === 0) {
|
|
5507
|
+
entry.dispose();
|
|
5508
|
+
registry.localKeyframes.delete(key);
|
|
5509
|
+
}
|
|
5510
|
+
}
|
|
5496
5511
|
deleted.add(className);
|
|
5497
5512
|
cleanedUpCount++;
|
|
5498
5513
|
}
|
|
@@ -5519,25 +5534,31 @@ var SheetManager = class {
|
|
|
5519
5534
|
return registry.sheets.reduce((total, sheet) => total + sheet.ruleCount - sheet.holes.length, 0);
|
|
5520
5535
|
}
|
|
5521
5536
|
/**
|
|
5522
|
-
*
|
|
5537
|
+
* The CSS of one managed sheet, or `null` when it holds none this can read —
|
|
5538
|
+
* an empty style element, or a sheet the engine refuses to hand over.
|
|
5523
5539
|
*/
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
if (sheetInfo.
|
|
5528
|
-
const rules = Array.from(sheetInfo.constructableSheet.cssRules);
|
|
5529
|
-
cssChunks.push(rules.map((rule) => rule.cssText).join("\n"));
|
|
5530
|
-
} else if (sheetInfo.sheet) {
|
|
5540
|
+
readSheetCSS(sheetInfo) {
|
|
5541
|
+
try {
|
|
5542
|
+
if (sheetInfo.constructableSheet) return Array.from(sheetInfo.constructableSheet.cssRules).map((rule) => rule.cssText).join("\n");
|
|
5543
|
+
if (sheetInfo.sheet) {
|
|
5531
5544
|
const styleElement = sheetInfo.sheet;
|
|
5532
|
-
if (styleElement.textContent)
|
|
5533
|
-
|
|
5534
|
-
const rules = Array.from(styleElement.sheet.cssRules);
|
|
5535
|
-
cssChunks.push(rules.map((rule) => rule.cssText).join("\n"));
|
|
5536
|
-
}
|
|
5545
|
+
if (styleElement.textContent) return styleElement.textContent;
|
|
5546
|
+
if (styleElement.sheet) return Array.from(styleElement.sheet.cssRules).map((rule) => rule.cssText).join("\n");
|
|
5537
5547
|
}
|
|
5538
5548
|
} catch (error) {
|
|
5539
5549
|
console.warn("[Tasty] Failed to read CSS from sheet:", error);
|
|
5540
5550
|
}
|
|
5551
|
+
return null;
|
|
5552
|
+
}
|
|
5553
|
+
/**
|
|
5554
|
+
* Get CSS text from all sheets (for SSR)
|
|
5555
|
+
*/
|
|
5556
|
+
getCSSText(registry) {
|
|
5557
|
+
const cssChunks = [];
|
|
5558
|
+
for (const sheetInfo of registry.sheets) {
|
|
5559
|
+
const css = this.readSheetCSS(sheetInfo);
|
|
5560
|
+
if (css !== null) cssChunks.push(css);
|
|
5561
|
+
}
|
|
5541
5562
|
return cssChunks.join("\n");
|
|
5542
5563
|
}
|
|
5543
5564
|
/**
|
|
@@ -5554,16 +5575,21 @@ var SheetManager = class {
|
|
|
5554
5575
|
* Reset cache performance metrics
|
|
5555
5576
|
*/
|
|
5556
5577
|
resetMetrics(registry) {
|
|
5557
|
-
if (registry.metrics)
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
5578
|
+
if (registry.metrics) {
|
|
5579
|
+
registry.metrics = {
|
|
5580
|
+
hits: 0,
|
|
5581
|
+
precompiledHits: 0,
|
|
5582
|
+
precompiledUniqueHits: 0,
|
|
5583
|
+
misses: 0,
|
|
5584
|
+
bulkCleanups: 0,
|
|
5585
|
+
totalInsertions: 0,
|
|
5586
|
+
totalUnused: 0,
|
|
5587
|
+
stylesCleanedUp: 0,
|
|
5588
|
+
cleanupHistory: [],
|
|
5589
|
+
startTime: Date.now()
|
|
5590
|
+
};
|
|
5591
|
+
registry.precompiledUsedClasses = void 0;
|
|
5592
|
+
}
|
|
5567
5593
|
}
|
|
5568
5594
|
/**
|
|
5569
5595
|
* Convert keyframes steps to CSS string.
|
|
@@ -5849,6 +5875,49 @@ var SheetManager = class {
|
|
|
5849
5875
|
/**
|
|
5850
5876
|
* Get the raw CSS content
|
|
5851
5877
|
*/
|
|
5878
|
+
/**
|
|
5879
|
+
* The CSS this injector owns in `root`, one entry per sheet, in the order the
|
|
5880
|
+
* engine applies them.
|
|
5881
|
+
*
|
|
5882
|
+
* `getCSSText()` walks the managed sheets only, and raw CSS has its own —
|
|
5883
|
+
* which sits before, after, or *between* them depending on how it got there:
|
|
5884
|
+
* prepended to `adoptedStyleSheets`, or wherever in `<head>` the first raw
|
|
5885
|
+
* injection happened to land, with every managed sheet opened afterwards
|
|
5886
|
+
* following it. Reporting a fixed order would describe the opposite winner
|
|
5887
|
+
* from the live page whenever two rules of equal specificity meet, so the raw
|
|
5888
|
+
* sheet is spliced in at the position the DOM actually gives it.
|
|
5889
|
+
*/
|
|
5890
|
+
getOwnedCSSInOrder(registry, root) {
|
|
5891
|
+
const raw = this.getRawCSSText(root);
|
|
5892
|
+
const rawElement = this.isAdoptedMode(root) ? null : this.rawStyleElements.get(root);
|
|
5893
|
+
let rawIndex = raw && !rawElement ? 0 : -1;
|
|
5894
|
+
const chunks = [];
|
|
5895
|
+
for (const sheetInfo of registry.sheets) {
|
|
5896
|
+
const css = this.readSheetCSS(sheetInfo);
|
|
5897
|
+
if (css === null) continue;
|
|
5898
|
+
if (rawIndex < 0 && rawElement && sheetInfo.sheet && rawElement.compareDocumentPosition(sheetInfo.sheet) & Node.DOCUMENT_POSITION_FOLLOWING) rawIndex = chunks.length;
|
|
5899
|
+
chunks.push(css);
|
|
5900
|
+
}
|
|
5901
|
+
if (!raw) return chunks;
|
|
5902
|
+
chunks.splice(rawIndex < 0 ? chunks.length : rawIndex, 0, raw);
|
|
5903
|
+
return chunks;
|
|
5904
|
+
}
|
|
5905
|
+
/**
|
|
5906
|
+
* Top-level rules in the raw sheet.
|
|
5907
|
+
*
|
|
5908
|
+
* Read from the sheet the engine parsed, not from the text: a raw block is
|
|
5909
|
+
* one string but any number of rules, and one rule — `@keyframes`, `@media` —
|
|
5910
|
+
* can contain any number of blocks, so counting braces answers neither
|
|
5911
|
+
* question.
|
|
5912
|
+
*/
|
|
5913
|
+
getRawRuleCount(root) {
|
|
5914
|
+
const sheet = this.isAdoptedMode(root) ? this.rawConstructableSheets.get(root) : this.rawStyleElements.get(root)?.sheet;
|
|
5915
|
+
try {
|
|
5916
|
+
return sheet?.cssRules.length ?? 0;
|
|
5917
|
+
} catch {
|
|
5918
|
+
return 0;
|
|
5919
|
+
}
|
|
5920
|
+
}
|
|
5852
5921
|
getRawCSSText(root) {
|
|
5853
5922
|
if (this.isAdoptedMode(root)) {
|
|
5854
5923
|
const blocksMap = this.rawCSSBlocks.get(root);
|
|
@@ -5970,6 +6039,11 @@ function formatCounterStyleRule(name, descriptors) {
|
|
|
5970
6039
|
}
|
|
5971
6040
|
//#endregion
|
|
5972
6041
|
//#region src/injector/injector.ts
|
|
6042
|
+
/**
|
|
6043
|
+
* How long a class is left alone after it was last known to be wanted.
|
|
6044
|
+
* Long enough that a render cannot plausibly still be waiting to commit one.
|
|
6045
|
+
*/
|
|
6046
|
+
const DEFAULT_GC_GRACE = 1e4;
|
|
5973
6047
|
/** Dispose handle handed back for injections that took no pin. */
|
|
5974
6048
|
const noop = () => {};
|
|
5975
6049
|
/**
|
|
@@ -6035,16 +6109,48 @@ var StyleInjector = class {
|
|
|
6035
6109
|
sheetManager;
|
|
6036
6110
|
config;
|
|
6037
6111
|
globalRuleCounter = 0;
|
|
6038
|
-
/** Cancels the scheduled
|
|
6112
|
+
/** Cancels the scheduled sweep, whichever timer scheduled it. */
|
|
6039
6113
|
cancelPendingGC = null;
|
|
6040
6114
|
namePrefix;
|
|
6041
6115
|
classRegex;
|
|
6042
6116
|
rscClassRegex;
|
|
6117
|
+
precompiledRevision = -1;
|
|
6043
6118
|
/** @internal — exposed for debug utilities only */
|
|
6044
6119
|
get _sheetManager() {
|
|
6045
6120
|
return this.sheetManager;
|
|
6046
6121
|
}
|
|
6047
6122
|
/**
|
|
6123
|
+
* Seed deduplication metadata for rules supplied by an immutable external
|
|
6124
|
+
* stylesheet. This records no owned sheet entries and performs no CSS work.
|
|
6125
|
+
* @internal
|
|
6126
|
+
*/
|
|
6127
|
+
registerPrecompiledDependencies(dependencies, revision) {
|
|
6128
|
+
if (typeof document === "undefined" || this.precompiledRevision === revision) return;
|
|
6129
|
+
const registry = this.sheetManager.getRegistry(document);
|
|
6130
|
+
for (const item of dependencies.properties) if (!registry.injectedProperties.has(item.name)) registry.injectedProperties.set(item.name, item.definition);
|
|
6131
|
+
for (const hash of dependencies.fontFaces) registry.injectedFontFaces.add(hash);
|
|
6132
|
+
for (const item of dependencies.counterStyles) if (!registry.injectedCounterStyles.has(item.name)) registry.injectedCounterStyles.set(item.name, true);
|
|
6133
|
+
for (const name of dependencies.functions) if (!registry.injectedFunctions.has(name)) registry.injectedFunctions.set(name, true);
|
|
6134
|
+
for (const item of dependencies.keyframes) {
|
|
6135
|
+
if (!registry.keyframesCache.has(item.contentKey)) registry.keyframesCache.set(item.contentKey, {
|
|
6136
|
+
name: item.name,
|
|
6137
|
+
refCount: Number.POSITIVE_INFINITY,
|
|
6138
|
+
info: {
|
|
6139
|
+
name: item.name,
|
|
6140
|
+
ruleIndex: -2,
|
|
6141
|
+
sheetIndex: -2
|
|
6142
|
+
}
|
|
6143
|
+
});
|
|
6144
|
+
if (!registry.keyframesNameToContent.has(item.name)) registry.keyframesNameToContent.set(item.name, item.contentKey);
|
|
6145
|
+
if (!registry.localKeyframes.has(item.name)) registry.localKeyframes.set(item.name, {
|
|
6146
|
+
name: item.name,
|
|
6147
|
+
dispose: () => {},
|
|
6148
|
+
owners: /* @__PURE__ */ new Set()
|
|
6149
|
+
});
|
|
6150
|
+
}
|
|
6151
|
+
this.precompiledRevision = revision;
|
|
6152
|
+
}
|
|
6153
|
+
/**
|
|
6048
6154
|
* Whether sheet writes should be queued instead of applied immediately.
|
|
6049
6155
|
*
|
|
6050
6156
|
* Only ever true on the client: SSR collects CSS as text and the RSC path
|
|
@@ -6124,6 +6230,28 @@ var StyleInjector = class {
|
|
|
6124
6230
|
return false;
|
|
6125
6231
|
}
|
|
6126
6232
|
/**
|
|
6233
|
+
* Resolve an already-owned or server-hydrated class before its declarations
|
|
6234
|
+
* are rendered. A miss does not reserve a class or mutate the rule cache.
|
|
6235
|
+
* @internal
|
|
6236
|
+
*/
|
|
6237
|
+
prepareClassName(cacheKey, options) {
|
|
6238
|
+
const root = options?.root || document;
|
|
6239
|
+
const registry = this.sheetManager.getRegistry(root);
|
|
6240
|
+
const mapped = registry.cacheKeyToClassName.get(cacheKey);
|
|
6241
|
+
if (mapped) {
|
|
6242
|
+
const info = registry.rules.get(mapped);
|
|
6243
|
+
if (info && !(info.ruleIndex === -1 && info.sheetIndex === -1)) return {
|
|
6244
|
+
className: mapped,
|
|
6245
|
+
isExisting: true
|
|
6246
|
+
};
|
|
6247
|
+
}
|
|
6248
|
+
const className = this.generateClassName(cacheKey);
|
|
6249
|
+
return {
|
|
6250
|
+
className,
|
|
6251
|
+
isExisting: this.tryHydratedHit(registry, cacheKey, className)
|
|
6252
|
+
};
|
|
6253
|
+
}
|
|
6254
|
+
/**
|
|
6127
6255
|
* Allocate a className for a cacheKey without injecting styles yet.
|
|
6128
6256
|
* This allows separating className allocation (render phase) from style injection (insertion phase).
|
|
6129
6257
|
*/
|
|
@@ -6171,11 +6299,14 @@ var StyleInjector = class {
|
|
|
6171
6299
|
dispose: () => {}
|
|
6172
6300
|
};
|
|
6173
6301
|
const cacheKey = options?.cacheKey;
|
|
6302
|
+
const preparedClassName = options?.preparedClassName;
|
|
6174
6303
|
let className;
|
|
6175
|
-
if (
|
|
6304
|
+
if (preparedClassName) className = preparedClassName;
|
|
6305
|
+
else if (cacheKey && registry.cacheKeyToClassName.has(cacheKey)) {
|
|
6176
6306
|
className = registry.cacheKeyToClassName.get(cacheKey);
|
|
6177
6307
|
const existingRuleInfo = registry.rules.get(className);
|
|
6178
6308
|
if (existingRuleInfo.ruleIndex === -3) {
|
|
6309
|
+
registry.unusedSince.delete(className);
|
|
6179
6310
|
if (pin) registry.pinCounts.set(className, (registry.pinCounts.get(className) || 0) + 1);
|
|
6180
6311
|
if (registry.metrics) registry.metrics.hits++;
|
|
6181
6312
|
return {
|
|
@@ -6184,6 +6315,7 @@ var StyleInjector = class {
|
|
|
6184
6315
|
};
|
|
6185
6316
|
}
|
|
6186
6317
|
if (!(existingRuleInfo.ruleIndex === -1 && existingRuleInfo.sheetIndex === -1)) {
|
|
6318
|
+
registry.unusedSince.delete(className);
|
|
6187
6319
|
if (pin) {
|
|
6188
6320
|
const pins = registry.pinCounts.get(className) || 0;
|
|
6189
6321
|
registry.pinCounts.set(className, pins + 1);
|
|
@@ -6263,7 +6395,7 @@ var StyleInjector = class {
|
|
|
6263
6395
|
});
|
|
6264
6396
|
if (cacheKey) registry.cacheKeyToClassName.set(cacheKey, className);
|
|
6265
6397
|
if (pin) registry.pinCounts.set(className, 1);
|
|
6266
|
-
|
|
6398
|
+
registry.unusedSince.set(className, Date.now());
|
|
6267
6399
|
const queued = enqueueStyleWrite(() => {
|
|
6268
6400
|
if (applySheetWrite()) return;
|
|
6269
6401
|
registry.rules.set(className, {
|
|
@@ -6280,7 +6412,6 @@ var StyleInjector = class {
|
|
|
6280
6412
|
registry.rules.delete(className);
|
|
6281
6413
|
if (cacheKey) registry.cacheKeyToClassName.delete(cacheKey);
|
|
6282
6414
|
registry.pinCounts.set(className, 0);
|
|
6283
|
-
registry.usageMap.delete(className);
|
|
6284
6415
|
return;
|
|
6285
6416
|
}
|
|
6286
6417
|
this.unpin(className, registry);
|
|
@@ -6292,7 +6423,7 @@ var StyleInjector = class {
|
|
|
6292
6423
|
dispose: () => {}
|
|
6293
6424
|
};
|
|
6294
6425
|
if (pin) registry.pinCounts.set(className, 1);
|
|
6295
|
-
|
|
6426
|
+
registry.unusedSince.set(className, Date.now());
|
|
6296
6427
|
return {
|
|
6297
6428
|
className,
|
|
6298
6429
|
dispose: pin ? () => this.unpin(className, registry) : noop
|
|
@@ -6375,6 +6506,63 @@ var StyleInjector = class {
|
|
|
6375
6506
|
return this.sheetManager.getRawCSSText(root);
|
|
6376
6507
|
}
|
|
6377
6508
|
/**
|
|
6509
|
+
* Take a reference on local `@keyframes`, under the deterministic names the
|
|
6510
|
+
* caller resolved.
|
|
6511
|
+
*
|
|
6512
|
+
* One reference per distinct set of steps, shared by every class that ends up
|
|
6513
|
+
* animating it, so a repeat render takes nothing further. Ownership is
|
|
6514
|
+
* assigned by `ownKeyframes()` once the rules exist to be inspected.
|
|
6515
|
+
*/
|
|
6516
|
+
holdKeyframes(steps, names, options) {
|
|
6517
|
+
const root = options?.root || document;
|
|
6518
|
+
const registry = this.sheetManager.getRegistry(root);
|
|
6519
|
+
const keys = /* @__PURE__ */ new Map();
|
|
6520
|
+
for (const [authored, definition] of Object.entries(steps)) {
|
|
6521
|
+
const resolved = names.get(authored) ?? authored;
|
|
6522
|
+
let entry = registry.localKeyframes.get(resolved);
|
|
6523
|
+
if (!entry) {
|
|
6524
|
+
const injected = this.keyframes(definition, {
|
|
6525
|
+
name: resolved,
|
|
6526
|
+
root,
|
|
6527
|
+
distinctByName: true
|
|
6528
|
+
});
|
|
6529
|
+
entry = {
|
|
6530
|
+
name: injected.toString(),
|
|
6531
|
+
dispose: injected.dispose,
|
|
6532
|
+
owners: /* @__PURE__ */ new Set()
|
|
6533
|
+
};
|
|
6534
|
+
registry.localKeyframes.set(resolved, entry);
|
|
6535
|
+
}
|
|
6536
|
+
keys.set(authored, resolved);
|
|
6537
|
+
}
|
|
6538
|
+
return keys;
|
|
6539
|
+
}
|
|
6540
|
+
/**
|
|
6541
|
+
* Record that `className` animates these keyframes, so the reference is
|
|
6542
|
+
* released when the last such class is collected.
|
|
6543
|
+
*
|
|
6544
|
+
* Only classes whose rules actually reference the animation should be here:
|
|
6545
|
+
* a class that merely rendered alongside one would otherwise keep the
|
|
6546
|
+
* keyframes alive for as long as it lives.
|
|
6547
|
+
*/
|
|
6548
|
+
ownKeyframes(key, className, options) {
|
|
6549
|
+
this.sheetManager.getRegistry(options?.root || document).localKeyframes.get(key)?.owners.add(className);
|
|
6550
|
+
}
|
|
6551
|
+
/** Record a chunk lookup served by an immutable external stylesheet. */
|
|
6552
|
+
recordPrecompiledHit(className, options) {
|
|
6553
|
+
if (!this.config.devMode) return;
|
|
6554
|
+
const registry = this.sheetManager.getRegistry(options?.root || document);
|
|
6555
|
+
if (registry.metrics) {
|
|
6556
|
+
registry.metrics.hits++;
|
|
6557
|
+
registry.metrics.precompiledHits++;
|
|
6558
|
+
const used = registry.precompiledUsedClasses ??= /* @__PURE__ */ new Set();
|
|
6559
|
+
if (!used.has(className)) {
|
|
6560
|
+
used.add(className);
|
|
6561
|
+
registry.metrics.precompiledUniqueHits++;
|
|
6562
|
+
}
|
|
6563
|
+
}
|
|
6564
|
+
}
|
|
6565
|
+
/**
|
|
6378
6566
|
* Pin an already-injected cacheKey and return the handle that releases it.
|
|
6379
6567
|
* For callers that skipped the pipeline on a cache hit but still need the
|
|
6380
6568
|
* class held. Returns null if the cacheKey is not found.
|
|
@@ -6393,19 +6581,6 @@ var StyleInjector = class {
|
|
|
6393
6581
|
};
|
|
6394
6582
|
}
|
|
6395
6583
|
/**
|
|
6396
|
-
* Seed the LRU stamp for a newly injected class.
|
|
6397
|
-
*
|
|
6398
|
-
* Without it a class injected during a render but not yet touched would carry
|
|
6399
|
-
* no timestamp at all and sort as the oldest candidate, so `gc()` could evict
|
|
6400
|
-
* the very rule the current render just wrote.
|
|
6401
|
-
*/
|
|
6402
|
-
markUsage(registry, className) {
|
|
6403
|
-
const now = Date.now();
|
|
6404
|
-
const entry = registry.usageMap.get(className);
|
|
6405
|
-
if (entry) entry.lastTouchedAt = now;
|
|
6406
|
-
else registry.usageMap.set(className, { lastTouchedAt: now });
|
|
6407
|
-
}
|
|
6408
|
-
/**
|
|
6409
6584
|
* Release one pin on a className. At zero pins the class is not deleted — it
|
|
6410
6585
|
* stays cached and collectible, and `gc()` decides when it actually goes.
|
|
6411
6586
|
*/
|
|
@@ -6643,13 +6818,14 @@ var StyleInjector = class {
|
|
|
6643
6818
|
keyframes(steps, nameOrOptions) {
|
|
6644
6819
|
const isStringName = typeof nameOrOptions === "string";
|
|
6645
6820
|
const providedName = isStringName ? nameOrOptions : nameOrOptions?.name;
|
|
6821
|
+
const distinctByName = isStringName ? false : nameOrOptions?.distinctByName ?? false;
|
|
6646
6822
|
const root = isStringName ? document : nameOrOptions?.root || document;
|
|
6647
6823
|
const registry = this.sheetManager.getRegistry(root);
|
|
6648
6824
|
if (Object.keys(steps).length === 0) return {
|
|
6649
6825
|
toString: () => "",
|
|
6650
6826
|
dispose: () => {}
|
|
6651
6827
|
};
|
|
6652
|
-
const contentHash = JSON.stringify(steps);
|
|
6828
|
+
const contentHash = distinctByName && providedName ? `${providedName}\u0000${JSON.stringify(steps)}` : JSON.stringify(steps);
|
|
6653
6829
|
const existing = registry.keyframesCache.get(contentHash);
|
|
6654
6830
|
if (existing) {
|
|
6655
6831
|
existing.refCount++;
|
|
@@ -6666,7 +6842,7 @@ var StyleInjector = class {
|
|
|
6666
6842
|
actualName = providedName;
|
|
6667
6843
|
registry.keyframesNameToContent.set(providedName, contentHash);
|
|
6668
6844
|
}
|
|
6669
|
-
} else actualName = makeKeyframeName(this.namePrefix,
|
|
6845
|
+
} else actualName = makeKeyframeName(this.namePrefix, hashString(contentHash));
|
|
6670
6846
|
const applyWrite = () => {
|
|
6671
6847
|
const result = this.sheetManager.insertKeyframes(registry, steps, actualName, root);
|
|
6672
6848
|
if (!result) return false;
|
|
@@ -6741,45 +6917,31 @@ var StyleInjector = class {
|
|
|
6741
6917
|
}
|
|
6742
6918
|
}
|
|
6743
6919
|
/**
|
|
6744
|
-
*
|
|
6745
|
-
*
|
|
6746
|
-
*
|
|
6747
|
-
*
|
|
6748
|
-
*
|
|
6920
|
+
* Count a render, and schedule a collection pass every `touchInterval` of
|
|
6921
|
+
* them. Nothing else: what a class is worth keeping is decided by the sweep's
|
|
6922
|
+
* own DOM scan, so rendering does not track usage at all.
|
|
6923
|
+
*
|
|
6924
|
+
* @deprecated The class name is ignored — pass anything, or stop calling it.
|
|
6925
|
+
* Collection no longer records per-class usage, and scheduling does not need
|
|
6926
|
+
* to know which class was rendered. A class handed back by `inject()` is
|
|
6927
|
+
* marked wanted there, which is what reuse actually goes through.
|
|
6749
6928
|
*/
|
|
6750
|
-
touch(
|
|
6929
|
+
touch(_className, options) {
|
|
6751
6930
|
if (typeof document === "undefined") return;
|
|
6752
6931
|
if (!this.config.gc) return;
|
|
6753
|
-
const
|
|
6754
|
-
|
|
6755
|
-
const now = Date.now();
|
|
6756
|
-
if (registry.touchTick !== now) {
|
|
6757
|
-
registry.touchTick = now;
|
|
6758
|
-
registry.touchedTick.clear();
|
|
6759
|
-
} else if (registry.touchedTick.has(className)) return;
|
|
6760
|
-
registry.touchedTick.add(className);
|
|
6761
|
-
const parts = className.indexOf(" ") === -1 ? [className] : className.split(" ");
|
|
6762
|
-
for (const cls of parts) {
|
|
6763
|
-
if (!this.classRegex.test(cls)) continue;
|
|
6764
|
-
if (!registry.rules.has(cls)) continue;
|
|
6765
|
-
const entry = registry.usageMap.get(cls);
|
|
6766
|
-
if (entry) entry.lastTouchedAt = now;
|
|
6767
|
-
else registry.usageMap.set(cls, { lastTouchedAt: now });
|
|
6768
|
-
registry.touchCount++;
|
|
6769
|
-
}
|
|
6770
|
-
const touchInterval = this.config.gc.touchInterval ?? 1e3;
|
|
6771
|
-
if (registry.touchCount >= touchInterval) {
|
|
6932
|
+
const registry = this.sheetManager.getRegistry(options?.root || document);
|
|
6933
|
+
if (++registry.touchCount >= (this.config.gc.touchInterval ?? 1e3)) {
|
|
6772
6934
|
registry.touchCount = 0;
|
|
6773
6935
|
this.scheduleGC();
|
|
6774
6936
|
}
|
|
6775
6937
|
}
|
|
6776
6938
|
/**
|
|
6777
|
-
* Schedule a GC
|
|
6778
|
-
*
|
|
6939
|
+
* Schedule a GC in idle time. Runs GC on all active roots, and avoids
|
|
6940
|
+
* double-scheduling.
|
|
6779
6941
|
*
|
|
6780
|
-
*
|
|
6781
|
-
*
|
|
6782
|
-
*
|
|
6942
|
+
* Idle only. Without `requestIdleCallback` nothing is collected
|
|
6943
|
+
* automatically: running the sweep inline here would put it inside the render
|
|
6944
|
+
* that touched the class, and collection is never urgent enough for that.
|
|
6783
6945
|
*/
|
|
6784
6946
|
scheduleGC() {
|
|
6785
6947
|
if (this.cancelPendingGC) return;
|
|
@@ -6791,9 +6953,6 @@ var StyleInjector = class {
|
|
|
6791
6953
|
if (typeof requestIdleCallback !== "undefined") {
|
|
6792
6954
|
const handle = requestIdleCallback(() => runGC());
|
|
6793
6955
|
this.cancelPendingGC = () => cancelIdleCallback(handle);
|
|
6794
|
-
} else {
|
|
6795
|
-
const handle = setTimeout(runGC, 0);
|
|
6796
|
-
this.cancelPendingGC = () => clearTimeout(handle);
|
|
6797
6956
|
}
|
|
6798
6957
|
}
|
|
6799
6958
|
/**
|
|
@@ -6805,19 +6964,43 @@ var StyleInjector = class {
|
|
|
6805
6964
|
* "unused" means. Entries carry their last `touch()` so callers can drop the
|
|
6806
6965
|
* oldest first; a class that was never touched sorts as oldest.
|
|
6807
6966
|
*/
|
|
6967
|
+
/**
|
|
6968
|
+
* Everything the injector holds falls into one of five bands, and only the
|
|
6969
|
+
* last of them is ever deleted:
|
|
6970
|
+
*
|
|
6971
|
+
* 1. rendered — some element carries the class right now
|
|
6972
|
+
* 2. not ours — queued for a batched write, pre-allocated, or server-rendered
|
|
6973
|
+
* 3. hot — nothing carries it, but that was noticed less than `grace` ago
|
|
6974
|
+
* 4. cached — cold, but within `capacity` when ordered by when it went cold
|
|
6975
|
+
* 5. the rest
|
|
6976
|
+
*
|
|
6977
|
+
* This returns bands 4 and 5 together, most recently cold first; `gc()` draws
|
|
6978
|
+
* the capacity line through them. Band 3 is what makes collection safe
|
|
6979
|
+
* without a commit signal: a render can resolve a class and commit it a
|
|
6980
|
+
* little later, and during that gap nothing on the page carries it.
|
|
6981
|
+
*/
|
|
6808
6982
|
collectUnused(registry, root) {
|
|
6983
|
+
const now = Date.now();
|
|
6984
|
+
const grace = this.config.gc?.grace ?? DEFAULT_GC_GRACE;
|
|
6809
6985
|
const liveClasses = /* @__PURE__ */ new Set();
|
|
6810
6986
|
for (const el of root.querySelectorAll("[class]")) for (const token of el.classList) if (this.classRegex.test(token)) liveClasses.add(token);
|
|
6811
6987
|
const unused = [];
|
|
6812
6988
|
for (const [className, ruleInfo] of registry.rules) {
|
|
6813
6989
|
if (ruleInfo.sheetIndex < 0) continue;
|
|
6814
|
-
if (liveClasses.has(className))
|
|
6990
|
+
if (liveClasses.has(className)) {
|
|
6991
|
+
registry.unusedSince.delete(className);
|
|
6992
|
+
continue;
|
|
6993
|
+
}
|
|
6815
6994
|
if ((registry.pinCounts.get(className) ?? 0) > 0) continue;
|
|
6816
|
-
|
|
6817
|
-
|
|
6818
|
-
|
|
6819
|
-
|
|
6995
|
+
let since = registry.unusedSince.get(className);
|
|
6996
|
+
if (since === void 0) {
|
|
6997
|
+
since = now;
|
|
6998
|
+
registry.unusedSince.set(className, now);
|
|
6999
|
+
}
|
|
7000
|
+
if (now - since < grace) continue;
|
|
7001
|
+
unused.push(className);
|
|
6820
7002
|
}
|
|
7003
|
+
unused.sort((a, b) => (registry.unusedSince.get(b) ?? 0) - (registry.unusedSince.get(a) ?? 0));
|
|
6821
7004
|
return unused;
|
|
6822
7005
|
}
|
|
6823
7006
|
/**
|
|
@@ -6829,7 +7012,7 @@ var StyleInjector = class {
|
|
|
6829
7012
|
if (typeof document === "undefined") return [];
|
|
6830
7013
|
const root = options?.root || document;
|
|
6831
7014
|
const registry = this.sheetManager.getRegistry(root);
|
|
6832
|
-
return this.collectUnused(registry, root)
|
|
7015
|
+
return this.collectUnused(registry, root);
|
|
6833
7016
|
}
|
|
6834
7017
|
/**
|
|
6835
7018
|
* Synchronous garbage collection.
|
|
@@ -6849,17 +7032,15 @@ var StyleInjector = class {
|
|
|
6849
7032
|
this.cancelPendingGC?.();
|
|
6850
7033
|
this.cancelPendingGC = null;
|
|
6851
7034
|
const root = options?.root || document;
|
|
6852
|
-
const force = options?.force
|
|
7035
|
+
const force = options?.force;
|
|
6853
7036
|
const registry = this.sheetManager.getRegistry(root);
|
|
6854
7037
|
const capacity = this.config.gc?.capacity ?? 1e3;
|
|
6855
7038
|
if (!force && registry.rules.size <= capacity) return 0;
|
|
6856
7039
|
const unused = this.collectUnused(registry, root);
|
|
6857
7040
|
let doomed;
|
|
6858
|
-
if (force) doomed = unused
|
|
6859
|
-
else if (unused.length > capacity)
|
|
6860
|
-
|
|
6861
|
-
doomed = unused.slice(0, unused.length - capacity).map((entry) => entry.className);
|
|
6862
|
-
} else return 0;
|
|
7041
|
+
if (force) doomed = unused;
|
|
7042
|
+
else if (unused.length > capacity) doomed = unused.slice(capacity);
|
|
7043
|
+
else return 0;
|
|
6863
7044
|
if (doomed.length === 0) return 0;
|
|
6864
7045
|
return this.sheetManager.deleteClasses(registry, doomed);
|
|
6865
7046
|
}
|
|
@@ -6877,6 +7058,131 @@ var StyleInjector = class {
|
|
|
6877
7058
|
}
|
|
6878
7059
|
};
|
|
6879
7060
|
//#endregion
|
|
7061
|
+
//#region src/precompile/runtime.ts
|
|
7062
|
+
const STORE_KEY = Symbol.for("@tenphi/tasty/precompiled/v1");
|
|
7063
|
+
const globalStore$1 = globalThis;
|
|
7064
|
+
const store = globalStore$1[STORE_KEY] ??= {
|
|
7065
|
+
manifests: null,
|
|
7066
|
+
chunks: null,
|
|
7067
|
+
dependencies: null,
|
|
7068
|
+
buildCount: 0,
|
|
7069
|
+
active: false,
|
|
7070
|
+
validatedRevision: -1,
|
|
7071
|
+
validate: null,
|
|
7072
|
+
revision: 0,
|
|
7073
|
+
warnings: null
|
|
7074
|
+
};
|
|
7075
|
+
const EMPTY_DEPENDENCIES = Object.freeze({
|
|
7076
|
+
properties: Object.freeze([]),
|
|
7077
|
+
keyframes: Object.freeze([]),
|
|
7078
|
+
fontFaces: Object.freeze([]),
|
|
7079
|
+
counterStyles: Object.freeze([]),
|
|
7080
|
+
functions: Object.freeze([]),
|
|
7081
|
+
rscKeys: Object.freeze([])
|
|
7082
|
+
});
|
|
7083
|
+
function getPrecompileStore() {
|
|
7084
|
+
return store;
|
|
7085
|
+
}
|
|
7086
|
+
function warnPrecompileOnce(key, message) {
|
|
7087
|
+
if (!isDevEnv()) return;
|
|
7088
|
+
const warnings = store.warnings ??= /* @__PURE__ */ new Set();
|
|
7089
|
+
if (warnings.has(key)) return;
|
|
7090
|
+
warnings.add(key);
|
|
7091
|
+
console.warn(message);
|
|
7092
|
+
}
|
|
7093
|
+
/** Shared single-read gate for the unregistered render hot path. */
|
|
7094
|
+
const precompileRuntimeState = store;
|
|
7095
|
+
/** @internal Keep catalog recording on the isolated compiler path. */
|
|
7096
|
+
function beginPrecompileBuild() {
|
|
7097
|
+
store.buildCount = (store.buildCount ?? 0) + 1;
|
|
7098
|
+
store.active = true;
|
|
7099
|
+
}
|
|
7100
|
+
/** @internal Balance beginPrecompileBuild(), including failed catalog cases. */
|
|
7101
|
+
function endPrecompileBuild() {
|
|
7102
|
+
store.buildCount--;
|
|
7103
|
+
if (store.buildCount === 0 && store.chunks === null) store.active = false;
|
|
7104
|
+
}
|
|
7105
|
+
function findPrecompiledChunk(lookupKey, namePrefix) {
|
|
7106
|
+
store.validate?.();
|
|
7107
|
+
const chunk = store.chunks?.get(lookupKey);
|
|
7108
|
+
if (!chunk) return null;
|
|
7109
|
+
if (chunk.namePrefix !== namePrefix) {
|
|
7110
|
+
warnPrecompileOnce(`prefix:${chunk.manifestId}:${namePrefix}`, `[Tasty] Ignoring precompiled styles "${chunk.manifestId}": generated with namePrefix "${chunk.namePrefix}", but the runtime uses "${namePrefix}".`);
|
|
7111
|
+
return null;
|
|
7112
|
+
}
|
|
7113
|
+
return chunk;
|
|
7114
|
+
}
|
|
7115
|
+
function getPrecompiledRevision() {
|
|
7116
|
+
return store.revision;
|
|
7117
|
+
}
|
|
7118
|
+
function getRegisteredPrecompiledDependencies(namePrefix) {
|
|
7119
|
+
store.validate?.();
|
|
7120
|
+
return store.dependencies?.get(namePrefix) ?? EMPTY_DEPENDENCIES;
|
|
7121
|
+
}
|
|
7122
|
+
/** @internal Metadata used by tastyDebug without reading or parsing CSSOM. */
|
|
7123
|
+
function getRegisteredPrecompiledStats(namePrefix) {
|
|
7124
|
+
const classNames = /* @__PURE__ */ new Set();
|
|
7125
|
+
let manifestCount = 0;
|
|
7126
|
+
let cssSize = 0;
|
|
7127
|
+
let ruleCount = 0;
|
|
7128
|
+
for (const manifest of store.manifests?.values() ?? []) {
|
|
7129
|
+
if (manifest.namePrefix !== namePrefix) continue;
|
|
7130
|
+
manifestCount++;
|
|
7131
|
+
cssSize += manifest.stats.cssSize;
|
|
7132
|
+
ruleCount += manifest.stats.ruleCount;
|
|
7133
|
+
for (const chunk of manifest.chunks) classNames.add(chunk.className);
|
|
7134
|
+
}
|
|
7135
|
+
return {
|
|
7136
|
+
manifestCount,
|
|
7137
|
+
classNames: [...classNames],
|
|
7138
|
+
cssSize,
|
|
7139
|
+
ruleCount
|
|
7140
|
+
};
|
|
7141
|
+
}
|
|
7142
|
+
function applyRegisteredDependenciesToInjector(injector, namePrefix) {
|
|
7143
|
+
if (!store.manifests) return;
|
|
7144
|
+
injector.registerPrecompiledDependencies(getRegisteredPrecompiledDependencies(namePrefix), store.revision);
|
|
7145
|
+
}
|
|
7146
|
+
function applyRegisteredDependenciesToRSC(cache, namePrefix) {
|
|
7147
|
+
if (cache.precompiledRevision === store.revision) return;
|
|
7148
|
+
for (const key of cache.precompiledEmittedKeys) cache.emittedKeys.delete(key);
|
|
7149
|
+
for (const [key, name] of cache.precompiledGeneratedNames) if (cache.generatedNames.get(key) === name) cache.generatedNames.delete(key);
|
|
7150
|
+
cache.precompiledEmittedKeys.clear();
|
|
7151
|
+
cache.precompiledGeneratedNames.clear();
|
|
7152
|
+
if (!store.manifests) {
|
|
7153
|
+
cache.precompiledRevision = store.revision;
|
|
7154
|
+
return;
|
|
7155
|
+
}
|
|
7156
|
+
const dependencies = getRegisteredPrecompiledDependencies(namePrefix);
|
|
7157
|
+
for (const key of dependencies.rscKeys) {
|
|
7158
|
+
cache.emittedKeys.add(key);
|
|
7159
|
+
cache.precompiledEmittedKeys.add(key);
|
|
7160
|
+
}
|
|
7161
|
+
for (const item of dependencies.keyframes) for (const key of item.rscKeys) {
|
|
7162
|
+
cache.emittedKeys.add(key);
|
|
7163
|
+
cache.generatedNames.set(key, item.name);
|
|
7164
|
+
cache.precompiledEmittedKeys.add(key);
|
|
7165
|
+
cache.precompiledGeneratedNames.set(key, item.name);
|
|
7166
|
+
}
|
|
7167
|
+
for (const item of dependencies.counterStyles) for (const key of item.rscKeys) {
|
|
7168
|
+
cache.emittedKeys.add(key);
|
|
7169
|
+
cache.generatedNames.set(key, item.name);
|
|
7170
|
+
cache.precompiledEmittedKeys.add(key);
|
|
7171
|
+
cache.precompiledGeneratedNames.set(key, item.name);
|
|
7172
|
+
}
|
|
7173
|
+
cache.precompiledRevision = store.revision;
|
|
7174
|
+
}
|
|
7175
|
+
/** @internal Test-only reset; resetConfig() calls this to isolate suites. */
|
|
7176
|
+
function resetPrecompiledStyles() {
|
|
7177
|
+
store.manifests = null;
|
|
7178
|
+
store.chunks = null;
|
|
7179
|
+
store.dependencies = null;
|
|
7180
|
+
store.buildCount = 0;
|
|
7181
|
+
store.active = false;
|
|
7182
|
+
store.revision++;
|
|
7183
|
+
store.warnings?.clear();
|
|
7184
|
+
}
|
|
7185
|
+
//#endregion
|
|
6880
7186
|
//#region src/states/index.ts
|
|
6881
7187
|
/**
|
|
6882
7188
|
* Advanced State Mapping - Predefined States Management
|
|
@@ -11595,6 +11901,36 @@ function warnOnce(key, message) {
|
|
|
11595
11901
|
}
|
|
11596
11902
|
}
|
|
11597
11903
|
let stylesGenerated = false;
|
|
11904
|
+
/**
|
|
11905
|
+
* What the host passed to `configure()`, for the settings whose live registry
|
|
11906
|
+
* is not a faithful record of it. Accumulated across every `configure()` call.
|
|
11907
|
+
*
|
|
11908
|
+
* - Handlers and props middleware: `configure()` applies them into the handler
|
|
11909
|
+
* registry and then strips them from the stored config, and that registry is
|
|
11910
|
+
* populated lazily as styles are encountered — so neither is a stable record
|
|
11911
|
+
* of what the host asked for.
|
|
11912
|
+
* - Declarative `@function` definitions: with `polyfills.functions` enabled,
|
|
11913
|
+
* `configure()` compiles each into a parse-function closure and deliberately
|
|
11914
|
+
* leaves `getGlobalFunctions()` empty, so the definition body survives
|
|
11915
|
+
* nowhere a fingerprint can read it.
|
|
11916
|
+
*
|
|
11917
|
+
* A precompiled catalog needs exactly that record: replacing a built-in handler
|
|
11918
|
+
* or rewriting a function body changes what an already-compiled chunk should
|
|
11919
|
+
* contain without changing its lookup key.
|
|
11920
|
+
*/
|
|
11921
|
+
const configuredOverrides = {
|
|
11922
|
+
handlers: [],
|
|
11923
|
+
propHandlers: [],
|
|
11924
|
+
functions: []
|
|
11925
|
+
};
|
|
11926
|
+
/** @internal */
|
|
11927
|
+
function getConfiguredOverrides() {
|
|
11928
|
+
return {
|
|
11929
|
+
handlers: configuredOverrides.handlers,
|
|
11930
|
+
propHandlers: configuredOverrides.propHandlers,
|
|
11931
|
+
functions: configuredOverrides.functions
|
|
11932
|
+
};
|
|
11933
|
+
}
|
|
11598
11934
|
let currentConfig = null;
|
|
11599
11935
|
let globalKeyframes = null;
|
|
11600
11936
|
let globalFontFace = null;
|
|
@@ -11745,7 +12081,7 @@ function createDefaultConfig(isTest) {
|
|
|
11745
12081
|
function markStylesGenerated() {
|
|
11746
12082
|
if (stylesGenerated) return;
|
|
11747
12083
|
stylesGenerated = true;
|
|
11748
|
-
if (typeof document !== "undefined" && document.querySelector("
|
|
12084
|
+
if (typeof document !== "undefined" && document.querySelector("[data-tasty-ssr]")) {
|
|
11749
12085
|
warnOnce("ssr-globals-skip", "[Tasty] SSR styles detected — skipping client-side global CSS injection to avoid duplicates.");
|
|
11750
12086
|
return;
|
|
11751
12087
|
}
|
|
@@ -12217,17 +12553,26 @@ function configure(config = {}) {
|
|
|
12217
12553
|
parser.setFunctions(finalFuncs);
|
|
12218
12554
|
Object.assign(currentFuncs, parseFuncs);
|
|
12219
12555
|
}
|
|
12220
|
-
if (Object.keys(functionDefs).length > 0)
|
|
12221
|
-
|
|
12556
|
+
if (Object.keys(functionDefs).length > 0) {
|
|
12557
|
+
for (const entry of Object.entries(functionDefs)) configuredOverrides.functions.push(entry);
|
|
12558
|
+
if (isFunctionsPolyfillEnabled()) for (const [name, definition] of Object.entries(functionDefs)) registerFunctionPolyfill(name, definition);
|
|
12559
|
+
else setGlobalFunction(functionDefs);
|
|
12560
|
+
}
|
|
12222
12561
|
if (Object.keys(mergedKeyframes).length > 0) setGlobalKeyframes(mergedKeyframes);
|
|
12223
12562
|
if (Object.keys(mergedProperties).length > 0) setGlobalProperties(mergedProperties);
|
|
12224
12563
|
if (Object.keys(mergedFontFaces).length > 0) setGlobalFontFace(mergedFontFaces);
|
|
12225
12564
|
if (Object.keys(mergedCounterStyles).length > 0) setGlobalCounterStyle(mergedCounterStyles);
|
|
12226
|
-
if (Object.keys(mergedHandlers).length > 0) for (const [name, definition] of Object.entries(mergedHandlers))
|
|
12227
|
-
|
|
12228
|
-
|
|
12229
|
-
|
|
12230
|
-
|
|
12565
|
+
if (Object.keys(mergedHandlers).length > 0) for (const [name, definition] of Object.entries(mergedHandlers)) {
|
|
12566
|
+
configuredOverrides.handlers.push([name, definition]);
|
|
12567
|
+
registerHandler(normalizeHandlerDefinition(name, definition), {
|
|
12568
|
+
key: name,
|
|
12569
|
+
source: handlerSources.get(name)
|
|
12570
|
+
});
|
|
12571
|
+
}
|
|
12572
|
+
if (Object.keys(mergedPropHandlers).length > 0) for (const [name, definition] of Object.entries(mergedPropHandlers)) {
|
|
12573
|
+
configuredOverrides.propHandlers.push([name, definition]);
|
|
12574
|
+
registerPropHandler(name, definition, { source: propHandlerSources.get(name) });
|
|
12575
|
+
}
|
|
12231
12576
|
if (mergedBaseStyleProps.length > 0) registerBaseStyleProps(mergedBaseStyleProps);
|
|
12232
12577
|
if (Object.keys(mergedReplaceTokens).length > 0) {
|
|
12233
12578
|
const processedTokens = {};
|
|
@@ -12304,14 +12649,18 @@ function resetConfig() {
|
|
|
12304
12649
|
resetHandlers();
|
|
12305
12650
|
resetStyleChunks();
|
|
12306
12651
|
resetPropHandlers();
|
|
12652
|
+
configuredOverrides.handlers.length = 0;
|
|
12653
|
+
configuredOverrides.propHandlers.length = 0;
|
|
12654
|
+
configuredOverrides.functions.length = 0;
|
|
12307
12655
|
resetBaseStyleProps();
|
|
12308
12656
|
clearPipelineCache();
|
|
12657
|
+
resetPrecompiledStyles();
|
|
12309
12658
|
emittedWarnings.clear();
|
|
12310
12659
|
resetStyleWarnings();
|
|
12311
12660
|
const storage = typeof window !== "undefined" ? window : globalThis;
|
|
12312
12661
|
delete storage[GLOBAL_INJECTOR_KEY];
|
|
12313
12662
|
}
|
|
12314
12663
|
//#endregion
|
|
12315
|
-
export {
|
|
12664
|
+
export { getRegisteredPrecompiledDependencies as $, getGlobalParseFunctions as $t, DIMENSION_STYLES as A, extractLocalProperties as At, camelToKebab as B, FONT_CHUNK_STYLES as Bt, baseStylePropsRegistry as C, DEFAULT_ZERO_NAME_PREFIX as Ct, BLOCK_STYLES as D, tastyClassRegex as Dt, BLOCK_OUTER_STYLES as E, makeKeyframeName as Et, TEXT_STYLES as F, propHandlerRegistry as Ft, setGlobalPredefinedStates as G, formatFunctionRule as Gt, extractLocalPredefinedStates as H, POSITION_CHUNK_STYLES as Ht, hasPipelineCacheEntry as I, APPEARANCE_CHUNK_STYLES as It, beginPrecompileBuild as J, registerFunctionPolyfill as Jt, applyRegisteredDependenciesToInjector as K, hasLocalFunctions as Kt, isSelector as L, CHUNK_NAMES as Lt, INNER_STYLES as M, hasLocalProperties as Mt, OUTER_STYLES as N, normalizePropertyDefinition as Nt, COLOR_STYLES as O, validateNamePrefix as Ot, POSITION_STYLES as P, parsePropertyToken as Pt, getPrecompiledRevision as Q, filterMods as Qt, renderStyles as R, DIMENSION_CHUNK_STYLES as Rt, generateTypographyTokens as S, DEFAULT_NAME_PREFIX as St, BLOCK_INNER_STYLES as T, makeCounterStyleName as Tt, extractPredefinedStateRefs as U, STYLE_TO_CHUNK as Ut, createStateParserContext as V, LAYOUT_CHUNK_STYLES as Vt, getGlobalPredefinedStates as W, extractLocalFunctions as Wt, findPrecompiledChunk as X, CUSTOM_UNITS as Xt, endPrecompileBuild as Y, registerLocalFunctionPolyfills as Yt, getPrecompileStore as Z, DIRECTIONS as Zt, isConfigLocked as _, hexToRgb as _n, closeBatchWindow as _t, getGlobalConfigTokens as a, stringifyStyles as an, formatCounterStyleRule as at, markStylesGenerated as b, normalizeDslName as bn, openBatchWindow as bt, getGlobalFunctions as c, okhslFunction as cn, fontFaceContentHash as ct, getGlobalRecipes as d, isDevEnv as dn, SheetManager as dt, getGlobalParser as en, getRegisteredPrecompiledStats as et, getGlobalStyles as f, StyleParser as fn, STYLE_HANDLER_MAP as ft, hasStylesGenerated as g, getRgbValuesFromRgbaString as gn, PropertyTypeResolver as gt, hasGlobalRecipes as h, getNamedColorHex as hn, createStyle as ht, getEffectiveProperties as i, parseStyle as in, extractLocalCounterStyle as it, FLOW_STYLES as j, getEffectiveDefinition as jt, CONTAINER_STYLES as k, hashString as kt, getGlobalInjector as l, okhslPlugin as ln, formatFontFaceRule as lt, hasGlobalKeyframes as m, overrideColorAlpha as mn, styleHandlers as mt, getConfig as n, normalizeColorTokenValue as nn, warnPrecompileOnce as nt, getGlobalCounterStyles as o, okhstFunction as on, hasLocalCounterStyle as ot, getNamePrefix as p, Lru as pn, defineHandler as pt, applyRegisteredDependenciesToRSC as q, parseFunctionName as qt, getConfiguredOverrides as r, parseColor as rn, StyleInjector as rt, getGlobalFontFaces as s, okhstPlugin as sn, extractLocalFontFace as st, configure as t, getGlobalPredefinedTokens as tn, precompileRuntimeState as tt, getGlobalKeyframes as u, createColorFunc as un, hasLocalFontFace as ut, isFunctionsPolyfillEnabled as v, hslToRgbValues as vn, flushStyles as vt, BASE_STYLES as w, makeClassName as wt, resetConfig as x, resetStyleBatch as xt, isTestEnvironment as y, strToRgb as yn, hasPendingStyleWrites as yt, parseStateKey as z, DISPLAY_CHUNK_STYLES as zt };
|
|
12316
12665
|
|
|
12317
|
-
//# sourceMappingURL=config-
|
|
12666
|
+
//# sourceMappingURL=config-Bd2vOF0Z.js.map
|