@tenphi/tasty 3.5.0 → 3.7.0
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-ib7E7V4Y.js → astro-CeYENy2x.js} +61 -67
- package/dist/astro-CeYENy2x.js.map +1 -0
- package/dist/{collector-C6TtL8HJ.js → collector-B3OsM252.js} +2 -2
- package/dist/{collector-C6TtL8HJ.js.map → collector-B3OsM252.js.map} +1 -1
- package/dist/core/index.js +1 -1
- package/dist/{core-Bq7w2kti.js → core-DGm0CFHP.js} +76 -30
- package/dist/{core-Bq7w2kti.js.map → core-DGm0CFHP.js.map} +1 -1
- package/dist/css-resources-Cyl_axbI.js +149 -0
- package/dist/css-resources-Cyl_axbI.js.map +1 -0
- package/dist/{format-rules-rCZ37rqY.js → format-rules-XRw9u7d4.js} +2 -28
- package/dist/format-rules-XRw9u7d4.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/ssr/astro-middleware-extract-static.js +1 -1
- package/dist/ssr/astro-middleware-extract.js +1 -1
- package/dist/ssr/astro-middleware-static.js +1 -1
- package/dist/ssr/astro-middleware.js +1 -1
- package/dist/ssr/astro.d.ts +9 -1
- package/dist/ssr/astro.js +1 -1
- package/dist/ssr/index.js +2 -2
- 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 +8 -1
- package/dist/ssr/next.js +24 -7
- 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/docs/debug.md +13 -0
- package/docs/runtime-benchmarks.md +185 -12
- package/docs/ssr.md +151 -31
- package/package.json +9 -1
- package/dist/astro-ib7E7V4Y.js.map +0 -1
- package/dist/format-rules-rCZ37rqY.js.map +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Bt as getGlobalParseFunctions, G as StyleInjector, Gt as parseStyle, It as registerLocalFunctionPolyfills, J as hasLocalCounterStyle, K as extractLocalCounterStyle, Mt as formatFunctionRule, Nt as hasLocalFunctions, Pt as parseFunctionName, Q as hasLocalFontFace, Qt as isDevEnv, Ut as normalizeColorTokenValue, Vt as getGlobalParser, X as fontFaceContentHash, Y as extractLocalFontFace, Z as formatFontFaceRule, _ as isFunctionsPolyfillEnabled, _t as hashString, bt as hasLocalProperties, c as getGlobalInjector, en as Lru, et as STYLE_HANDLER_MAP, f as getNamePrefix, ft as makeClassName, ht as tastyClassRegex, it as PropertyTypeResolver, jt as extractLocalFunctions, l as getGlobalKeyframes, n as getConfig, ot as flushStyles, p as hasGlobalKeyframes, q as formatCounterStyleRule, rt as createStyle, sn as normalizeDslName, tn as overrideColorAlpha, v as isTestEnvironment, vt as extractLocalProperties, wt as CHUNK_NAMES, xt as parsePropertyToken, y as markStylesGenerated, z as camelToKebab } from "./config-B3gPdCqd.js";
|
|
2
2
|
import { a as mergeKeyframes, c as resolveKeyframesNames, d as categorizeStyleKeys, i as hasLocalKeyframes, l as renderStylesForChunk, n as extractLocalKeyframes, o as referencesAnimation, r as filterUsedKeyframes, s as replaceAnimationNames, t as extractAnimationNamesFromStyles, u as generateChunkCacheKey } from "./keyframes-DE-OE76F.js";
|
|
3
|
-
import {
|
|
3
|
+
import { t as getRegisteredSSRCollector } from "./ssr-collector-ref-COs_ioWl.js";
|
|
4
|
+
import { n as formatPropertyCSS, t as formatRules } from "./format-rules-XRw9u7d4.js";
|
|
4
5
|
import { t as resolveRecipes } from "./resolve-recipes-H9NqOQuP.js";
|
|
5
6
|
import { cache } from "react";
|
|
6
7
|
//#region src/utils/function-color.ts
|
|
@@ -1159,6 +1160,25 @@ function sortTastyClasses(classes) {
|
|
|
1159
1160
|
return Array.from(classes).sort((a, b) => a.localeCompare(b));
|
|
1160
1161
|
}
|
|
1161
1162
|
/**
|
|
1163
|
+
* The root these helpers read, or `null` where there is no DOM.
|
|
1164
|
+
*
|
|
1165
|
+
* `document` used to be a default parameter value, and a default is evaluated
|
|
1166
|
+
* at the call site — so every read below threw a bare `ReferenceError` under
|
|
1167
|
+
* Node, taking out five of the eight public methods. A debug utility must not
|
|
1168
|
+
* be able to fail an SSR render because a call was left in, so the DOM-less
|
|
1169
|
+
* case reports an empty result and says why.
|
|
1170
|
+
*/
|
|
1171
|
+
function defaultRoot() {
|
|
1172
|
+
return typeof document === "undefined" ? null : document;
|
|
1173
|
+
}
|
|
1174
|
+
let warnedNoDom = false;
|
|
1175
|
+
/** Say once why the numbers are empty. Silent under `{ raw: true }`. */
|
|
1176
|
+
function warnNoDom(raw) {
|
|
1177
|
+
if (raw || warnedNoDom) return;
|
|
1178
|
+
warnedNoDom = true;
|
|
1179
|
+
console.warn("[Tasty] tastyDebug reads the DOM and this environment has none, so the result is empty. During SSR, read the ServerStyleCollector instead.");
|
|
1180
|
+
}
|
|
1181
|
+
/**
|
|
1162
1182
|
* The registry for `root`, with every queued write landed first.
|
|
1163
1183
|
*
|
|
1164
1184
|
* Every injector read API is a flush point, and the reads below reach past
|
|
@@ -1167,11 +1187,13 @@ function sortTastyClasses(classes) {
|
|
|
1167
1187
|
* enqueued but not yet in a sheet is missing from `globalRules`, from the
|
|
1168
1188
|
* sheets, and from anything counting either.
|
|
1169
1189
|
*/
|
|
1170
|
-
function getRegistry(root =
|
|
1190
|
+
function getRegistry(root = defaultRoot()) {
|
|
1191
|
+
if (!root) return void 0;
|
|
1171
1192
|
flushStyles();
|
|
1172
1193
|
return injector.instance._sheetManager?.getRegistry(root);
|
|
1173
1194
|
}
|
|
1174
|
-
function findDomTastyClasses(root =
|
|
1195
|
+
function findDomTastyClasses(root = defaultRoot()) {
|
|
1196
|
+
if (!root) return [];
|
|
1175
1197
|
const classes = /* @__PURE__ */ new Set();
|
|
1176
1198
|
const elements = root.querySelectorAll?.("[class]") || [];
|
|
1177
1199
|
const classRegex = tastyClassRegex(getNamePrefix());
|
|
@@ -1188,13 +1210,25 @@ function findDomTastyClasses(root = document) {
|
|
|
1188
1210
|
* with the sources kept byte-for-byte — trimming would report a total smaller
|
|
1189
1211
|
* than one of its own parts whenever raw CSS has edge whitespace.
|
|
1190
1212
|
*/
|
|
1191
|
-
function getAllCSS(root =
|
|
1213
|
+
function getAllCSS(root = defaultRoot()) {
|
|
1192
1214
|
const registry = getRegistry(root);
|
|
1193
1215
|
const sheetManager = injector.instance._sheetManager;
|
|
1194
|
-
if (!registry || !sheetManager) return "";
|
|
1216
|
+
if (!root || !registry || !sheetManager) return "";
|
|
1195
1217
|
return sheetManager.getOwnedCSSInOrder(registry, root).join("\n");
|
|
1196
1218
|
}
|
|
1197
1219
|
/**
|
|
1220
|
+
* The injector's own readers fall back to `document` when `root` is omitted, so
|
|
1221
|
+
* they have to be reached with a real root or not at all.
|
|
1222
|
+
*/
|
|
1223
|
+
function cssTextForClasses(classNames, root) {
|
|
1224
|
+
if (!root) return "";
|
|
1225
|
+
return injector.instance.getCSSTextForClasses(classNames, { root });
|
|
1226
|
+
}
|
|
1227
|
+
function getInjectorMetrics(root) {
|
|
1228
|
+
if (!root) return null;
|
|
1229
|
+
return injector.instance.getMetrics({ root });
|
|
1230
|
+
}
|
|
1231
|
+
/**
|
|
1198
1232
|
* Injected classes that no element carries and nobody pinned — the exact set
|
|
1199
1233
|
* `gc({ force: true })` would delete.
|
|
1200
1234
|
*
|
|
@@ -1202,11 +1236,12 @@ function getAllCSS(root = document) {
|
|
|
1202
1236
|
* drifted apart once before, when this file still read "unused" off the pin
|
|
1203
1237
|
* counts the render path had stopped maintaining.
|
|
1204
1238
|
*/
|
|
1205
|
-
function getUnusedClasses(root =
|
|
1239
|
+
function getUnusedClasses(root = defaultRoot()) {
|
|
1240
|
+
if (!root) return [];
|
|
1206
1241
|
return sortTastyClasses(injector.instance.getUnusedClasses({ root }));
|
|
1207
1242
|
}
|
|
1208
1243
|
/** Every class this injector holds CSS for in `root`. */
|
|
1209
|
-
function getOwnedClasses(root =
|
|
1244
|
+
function getOwnedClasses(root = defaultRoot()) {
|
|
1210
1245
|
const registry = getRegistry(root);
|
|
1211
1246
|
if (!registry) return [];
|
|
1212
1247
|
const owned = [];
|
|
@@ -1273,15 +1308,15 @@ function extractChunkName(cacheKey) {
|
|
|
1273
1308
|
}
|
|
1274
1309
|
return null;
|
|
1275
1310
|
}
|
|
1276
|
-
function getChunkForClass(className, root =
|
|
1311
|
+
function getChunkForClass(className, root = defaultRoot()) {
|
|
1277
1312
|
const registry = getRegistry(root);
|
|
1278
1313
|
if (!registry) return null;
|
|
1279
1314
|
for (const [key, cn] of registry.cacheKeyToClassName) if (cn === className) return extractChunkName(key);
|
|
1280
1315
|
return null;
|
|
1281
1316
|
}
|
|
1282
|
-
function buildChunkBreakdown(root =
|
|
1317
|
+
function buildChunkBreakdown(root = defaultRoot()) {
|
|
1283
1318
|
const registry = getRegistry(root);
|
|
1284
|
-
if (!registry) return {
|
|
1319
|
+
if (!root || !registry) return {
|
|
1285
1320
|
byChunk: {},
|
|
1286
1321
|
totalChunkTypes: 0,
|
|
1287
1322
|
totalClasses: 0
|
|
@@ -1319,9 +1354,9 @@ const GLOBAL_RULE_PREFIXES = {
|
|
|
1319
1354
|
counterStyle: "counterstyle:",
|
|
1320
1355
|
function: "function:"
|
|
1321
1356
|
};
|
|
1322
|
-
function getGlobalTypeCSS(type, root =
|
|
1357
|
+
function getGlobalTypeCSS(type, root = defaultRoot()) {
|
|
1323
1358
|
const registry = getRegistry(root);
|
|
1324
|
-
if (!registry) return {
|
|
1359
|
+
if (!root || !registry) return {
|
|
1325
1360
|
css: "",
|
|
1326
1361
|
ruleCount: 0,
|
|
1327
1362
|
size: 0
|
|
@@ -1383,7 +1418,7 @@ function getGlobalTypeCSS(type, root = document) {
|
|
|
1383
1418
|
size: raw.length
|
|
1384
1419
|
};
|
|
1385
1420
|
}
|
|
1386
|
-
function getSourceCssForClasses(classNames, root =
|
|
1421
|
+
function getSourceCssForClasses(classNames, root = defaultRoot()) {
|
|
1387
1422
|
const registry = getRegistry(root);
|
|
1388
1423
|
if (!registry) return null;
|
|
1389
1424
|
const chunks = [];
|
|
@@ -1397,7 +1432,7 @@ function getSourceCssForClasses(classNames, root = document) {
|
|
|
1397
1432
|
}
|
|
1398
1433
|
return found ? chunks.join("\n") : null;
|
|
1399
1434
|
}
|
|
1400
|
-
function getDefs(root =
|
|
1435
|
+
function getDefs(root = defaultRoot()) {
|
|
1401
1436
|
const registry = getRegistry(root);
|
|
1402
1437
|
let properties = [];
|
|
1403
1438
|
if (registry?.injectedProperties) properties = Array.from(registry.injectedProperties.keys()).sort();
|
|
@@ -1427,7 +1462,11 @@ const CHUNK_ORDER = [
|
|
|
1427
1462
|
];
|
|
1428
1463
|
const tastyDebug = {
|
|
1429
1464
|
css(target, opts) {
|
|
1430
|
-
const { root =
|
|
1465
|
+
const { root = defaultRoot(), prettify = true, raw = false, source = false } = opts || {};
|
|
1466
|
+
if (!root) {
|
|
1467
|
+
warnNoDom(raw);
|
|
1468
|
+
return "";
|
|
1469
|
+
}
|
|
1431
1470
|
let css = "";
|
|
1432
1471
|
const classRegex = tastyClassRegex(getNamePrefix());
|
|
1433
1472
|
if (source && typeof target === "string" && classRegex.test(target)) {
|
|
@@ -1473,8 +1512,9 @@ const tastyDebug = {
|
|
|
1473
1512
|
return result;
|
|
1474
1513
|
},
|
|
1475
1514
|
inspect(target, opts) {
|
|
1476
|
-
const { root =
|
|
1477
|
-
const element = typeof target === "string" ? root.querySelector?.(target) : target;
|
|
1515
|
+
const { root = defaultRoot(), raw = false } = opts || {};
|
|
1516
|
+
const element = !root ? null : typeof target === "string" ? root.querySelector?.(target) : target;
|
|
1517
|
+
if (!root) warnNoDom(raw);
|
|
1478
1518
|
if (!element) {
|
|
1479
1519
|
const empty = {
|
|
1480
1520
|
element: null,
|
|
@@ -1484,7 +1524,7 @@ const tastyDebug = {
|
|
|
1484
1524
|
size: 0,
|
|
1485
1525
|
rules: 0
|
|
1486
1526
|
};
|
|
1487
|
-
if (!raw) console.warn("[Tasty] debug.inspect: element not found");
|
|
1527
|
+
if (!raw && root) console.warn("[Tasty] debug.inspect: element not found");
|
|
1488
1528
|
return empty;
|
|
1489
1529
|
}
|
|
1490
1530
|
const classList = element.getAttribute("class") || "";
|
|
@@ -1494,7 +1534,7 @@ const tastyDebug = {
|
|
|
1494
1534
|
className,
|
|
1495
1535
|
chunkName: getChunkForClass(className, root)
|
|
1496
1536
|
}));
|
|
1497
|
-
const css = getCSSTextForNode(element, { root });
|
|
1537
|
+
const css = getCSSTextForNode(element, { root: root ?? void 0 });
|
|
1498
1538
|
const rules = countRules(css);
|
|
1499
1539
|
const result = {
|
|
1500
1540
|
element,
|
|
@@ -1517,7 +1557,8 @@ const tastyDebug = {
|
|
|
1517
1557
|
return result;
|
|
1518
1558
|
},
|
|
1519
1559
|
summary(opts) {
|
|
1520
|
-
const { root =
|
|
1560
|
+
const { root = defaultRoot(), raw = false } = opts || {};
|
|
1561
|
+
if (!root) warnNoDom(raw);
|
|
1521
1562
|
const activeClasses = findDomTastyClasses(root);
|
|
1522
1563
|
const unusedClasses = getUnusedClasses(root);
|
|
1523
1564
|
const ownedClasses = getOwnedClasses(root);
|
|
@@ -1525,9 +1566,9 @@ const tastyDebug = {
|
|
|
1525
1566
|
const unusedSet = new Set(unusedClasses);
|
|
1526
1567
|
const activeSet = new Set(activeClasses);
|
|
1527
1568
|
const hotClasses = ownedClasses.filter((className) => !activeSet.has(className) && !unusedSet.has(className));
|
|
1528
|
-
const hotCSS =
|
|
1529
|
-
const activeCSS =
|
|
1530
|
-
const unusedCSS =
|
|
1569
|
+
const hotCSS = cssTextForClasses(hotClasses, root);
|
|
1570
|
+
const activeCSS = cssTextForClasses(activeClasses, root);
|
|
1571
|
+
const unusedCSS = cssTextForClasses(unusedClasses, root);
|
|
1531
1572
|
const allCSS = getAllCSS(root);
|
|
1532
1573
|
const activeRuleCount = countRules(activeCSS);
|
|
1533
1574
|
const unusedRuleCount = countRules(unusedCSS);
|
|
@@ -1552,7 +1593,7 @@ const tastyDebug = {
|
|
|
1552
1593
|
size: 0
|
|
1553
1594
|
});
|
|
1554
1595
|
const totalRuleCount = activeRuleCount + unusedRuleCount + countRules(hotCSS) + globalData.ruleCount + atRuleData.ruleCount + rawData.ruleCount + kfData.ruleCount + propData.ruleCount;
|
|
1555
|
-
const metrics =
|
|
1596
|
+
const metrics = getInjectorMetrics(root);
|
|
1556
1597
|
const defs = getDefs(root);
|
|
1557
1598
|
const chunkBreakdown = buildChunkBreakdown(root);
|
|
1558
1599
|
const summary = {
|
|
@@ -1609,7 +1650,8 @@ const tastyDebug = {
|
|
|
1609
1650
|
return summary;
|
|
1610
1651
|
},
|
|
1611
1652
|
chunks(opts) {
|
|
1612
|
-
const { root =
|
|
1653
|
+
const { root = defaultRoot(), raw = false } = opts || {};
|
|
1654
|
+
if (!root) warnNoDom(raw);
|
|
1613
1655
|
const breakdown = buildChunkBreakdown(root);
|
|
1614
1656
|
if (!raw) {
|
|
1615
1657
|
console.group(`Chunks (${breakdown.totalChunkTypes} types, ${breakdown.totalClasses} classes)`);
|
|
@@ -1623,10 +1665,11 @@ const tastyDebug = {
|
|
|
1623
1665
|
return breakdown;
|
|
1624
1666
|
},
|
|
1625
1667
|
cache(opts) {
|
|
1626
|
-
const { root =
|
|
1668
|
+
const { root = defaultRoot(), raw = false } = opts || {};
|
|
1669
|
+
if (!root) warnNoDom(raw);
|
|
1627
1670
|
const active = findDomTastyClasses(root);
|
|
1628
1671
|
const unused = getUnusedClasses(root);
|
|
1629
|
-
const metrics =
|
|
1672
|
+
const metrics = getInjectorMetrics(root);
|
|
1630
1673
|
const status = {
|
|
1631
1674
|
classes: {
|
|
1632
1675
|
active,
|
|
@@ -1648,7 +1691,9 @@ const tastyDebug = {
|
|
|
1648
1691
|
return status;
|
|
1649
1692
|
},
|
|
1650
1693
|
cleanup(opts) {
|
|
1651
|
-
|
|
1694
|
+
const root = opts?.root ?? defaultRoot();
|
|
1695
|
+
if (!root) return;
|
|
1696
|
+
injector.instance.cleanup(root);
|
|
1652
1697
|
},
|
|
1653
1698
|
help() {
|
|
1654
1699
|
console.log(`tastyDebug API:
|
|
@@ -1670,7 +1715,8 @@ Options: { raw: true } suppresses logging, { root: shadowRoot } targets Shadow D
|
|
|
1670
1715
|
}
|
|
1671
1716
|
}
|
|
1672
1717
|
};
|
|
1673
|
-
function getPageCSS(root =
|
|
1718
|
+
function getPageCSS(root = defaultRoot()) {
|
|
1719
|
+
if (!root) return "";
|
|
1674
1720
|
const chunks = [];
|
|
1675
1721
|
try {
|
|
1676
1722
|
if ("styleSheets" in root) for (const sheet of Array.from(root.styleSheets)) try {
|
|
@@ -1683,4 +1729,4 @@ if (typeof window !== "undefined" && isDevEnv()) tastyDebug.install();
|
|
|
1683
1729
|
//#endregion
|
|
1684
1730
|
export { keyframes as A, getRawCSSText as C, injectRawCSS as D, injectGlobal as E, chunkSheetRegistry as F, resolveFunctionColor as I, property as M, touch as N, injector as O, ChunkSheetRegistry as P, getCSSTextForNode as S, inject as T, destroy as _, color as a, gc as b, hasKeys as c, collectAutoInferredPropertiesRSC as d, getStyleTarget as f, createInjector as g, counterStyle as h, _modAttrs as i, ownKeyframes as j, isPropertyDefined as k, formatKeyframesCSS as l, cleanup as m, processTokens as n, filterBaseProps as o, pushRSCCSS as p, dotize as r, computeStyles as s, tastyDebug as t, collectAutoInferredProperties as u, fontFace as v, holdKeyframes as w, getCSSText as x, func as y };
|
|
1685
1731
|
|
|
1686
|
-
//# sourceMappingURL=core-
|
|
1732
|
+
//# sourceMappingURL=core-DGm0CFHP.js.map
|