@tenphi/tasty 0.0.0-snapshot.d656d18 → 0.0.0-snapshot.d7129ca
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/README.md +6 -6
- package/dist/{babel-_RVkw0iE.d.ts → babel-DD7kdEFT.d.ts} +2 -2
- package/dist/chunks/async-storage-CG5HnUT5.js +20 -0
- package/dist/chunks/{async-storage-DKK-wTD4.js.map → async-storage-CG5HnUT5.js.map} +1 -1
- package/dist/chunks/build-config-CUQVwdWF.js +42 -0
- package/dist/chunks/build-config-CUQVwdWF.js.map +1 -0
- package/dist/chunks/{collector-DBGcmUEq.js → collector-B0LTHw6Z.js} +6 -124
- package/dist/chunks/collector-B0LTHw6Z.js.map +1 -0
- package/dist/chunks/config-engine-C3pF9EK9.js +267 -0
- package/dist/chunks/config-engine-C3pF9EK9.js.map +1 -0
- package/dist/chunks/css-definitions-D_it4XZH.js +875 -0
- package/dist/chunks/css-definitions-D_it4XZH.js.map +1 -0
- package/dist/chunks/{css-resources-Cyl_axbI.js → css-resources-BN8apgxt.js} +1 -8
- package/dist/chunks/{css-resources-Cyl_axbI.js.map → css-resources-BN8apgxt.js.map} +1 -1
- package/dist/chunks/{debug-BUwqo6vC.js → debug-CiiHDgmR.js} +69 -150
- package/dist/chunks/debug-CiiHDgmR.js.map +1 -0
- package/dist/chunks/{dsl-CXvoaLnj.js → dsl-C5yuAn41.js} +62 -786
- package/dist/chunks/dsl-C5yuAn41.js.map +1 -0
- package/dist/chunks/hydration-TRcz5vnk.js +41 -0
- package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
- package/dist/chunks/react-runtime-sH6r6Ajr.js +557 -0
- package/dist/chunks/react-runtime-sH6r6Ajr.js.map +1 -0
- package/dist/chunks/runtime-engine-BrRcOZwD.js +2438 -0
- package/dist/chunks/runtime-engine-BrRcOZwD.js.map +1 -0
- package/dist/chunks/runtime-state-BTDqSYBk.js +127 -0
- package/dist/chunks/runtime-state-BTDqSYBk.js.map +1 -0
- package/dist/chunks/{shared-utils-OIg0N_dp.js → shared-utils-DWA4LjIa.js} +24 -62
- package/dist/chunks/shared-utils-DWA4LjIa.js.map +1 -0
- package/dist/chunks/{style-engine-CqSmIlud.js → style-engine-C1ECBZxR.js} +671 -2736
- package/dist/chunks/style-engine-C1ECBZxR.js.map +1 -0
- package/dist/chunks/{css-writer-PFzrSPeu.js → zero-engine-B6EnYcXY.js} +3 -120
- package/dist/chunks/zero-engine-B6EnYcXY.js.map +1 -0
- package/dist/{collector-CVdVIy7s.d.ts → collector-YpsMjV7T.d.ts} +6 -4
- package/dist/{config-BI0y21JV.d.ts → config-BnZqyYG4.d.ts} +16 -25
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.js +9 -7
- package/dist/{index-CrT0bsiI.d.ts → index-BLJLo9cl.d.ts} +17 -50
- package/dist/index.d.ts +5 -5
- package/dist/index.js +10 -7
- package/dist/{merge-styles-BFktNP8J.d.ts → merge-styles-CTDLIrO5.d.ts} +2 -2
- package/dist/ssr/astro-client.js +1 -14
- package/dist/ssr/astro-client.js.map +1 -1
- package/dist/ssr/astro-middleware-static.js +0 -11
- package/dist/ssr/astro-middleware-static.js.map +1 -1
- package/dist/ssr/astro-middleware.js +0 -12
- package/dist/ssr/astro-middleware.js.map +1 -1
- package/dist/ssr/astro.js +5 -85
- package/dist/ssr/astro.js.map +1 -1
- package/dist/ssr/index.d.ts +6 -6
- package/dist/ssr/index.js +4 -4
- package/dist/ssr/next-config.d.ts +1 -1
- package/dist/ssr/next-config.js +29 -20
- package/dist/ssr/next-config.js.map +1 -1
- package/dist/ssr/next.d.ts +1 -1
- package/dist/ssr/next.js +5 -36
- package/dist/ssr/next.js.map +1 -1
- package/dist/static/index.d.ts +2 -2
- package/dist/static/index.js +1 -19
- package/dist/static/index.js.map +1 -1
- package/dist/{index-BzAC3p06.d.ts → types-vfRQhzRd.d.ts} +811 -811
- package/dist/zero/babel.d.ts +1 -1
- package/dist/zero/babel.js +25 -95
- 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/dist/zero/next.js +0 -31
- package/dist/zero/next.js.map +1 -1
- package/docs/ai-agents.md +5 -1
- package/docs/dsl.md +2 -2
- package/docs/getting-started.md +12 -11
- package/docs/methodology.md +2 -2
- package/docs/pipeline.md +3 -0
- package/docs/plugins.md +1 -1
- package/docs/runtime-benchmarks.md +105 -68
- package/docs/ssr.md +1 -1
- package/docs/styles.md +5 -5
- package/docs/tasty-static.md +1 -1
- package/package.json +29 -10
- package/dist/chunks/async-storage-DKK-wTD4.js +0 -44
- package/dist/chunks/collector-DBGcmUEq.js.map +0 -1
- package/dist/chunks/css-writer-PFzrSPeu.js.map +0 -1
- package/dist/chunks/debug-BUwqo6vC.js.map +0 -1
- package/dist/chunks/dsl-CXvoaLnj.js.map +0 -1
- package/dist/chunks/hydrate-6YoHZP6A.js +0 -37
- package/dist/chunks/hydrate-6YoHZP6A.js.map +0 -1
- package/dist/chunks/react-runtime-B3CmvDEQ.js +0 -1525
- package/dist/chunks/react-runtime-B3CmvDEQ.js.map +0 -1
- package/dist/chunks/runtime-engine-Y00VWjrS.js +0 -4719
- package/dist/chunks/runtime-engine-Y00VWjrS.js.map +0 -1
- package/dist/chunks/shared-utils-OIg0N_dp.js.map +0 -1
- package/dist/chunks/style-engine-CqSmIlud.js.map +0 -1
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
-
//#region src/ssr/async-storage.ts
|
|
3
|
-
/**
|
|
4
|
-
* AsyncLocalStorage integration for SSR collector discovery.
|
|
5
|
-
*
|
|
6
|
-
* Used by Astro middleware and generic framework integrations where
|
|
7
|
-
* the library cannot wrap the React tree with a context provider.
|
|
8
|
-
* The middleware calls runWithCollector() around the render, and
|
|
9
|
-
* useStyles() calls getSSRCollector() to find it.
|
|
10
|
-
*
|
|
11
|
-
* Uses globalThis to ensure the AsyncLocalStorage instance is shared
|
|
12
|
-
* across module instances — frameworks like Astro may load middleware
|
|
13
|
-
* and page components from separate module graphs.
|
|
14
|
-
*
|
|
15
|
-
* This module imports from 'node:async_hooks' — it must be excluded
|
|
16
|
-
* from client bundles via the build configuration.
|
|
17
|
-
*/
|
|
18
|
-
const ALS_KEY = "__tasty_ssr_als__";
|
|
19
|
-
function getSharedStorage() {
|
|
20
|
-
const g = globalThis;
|
|
21
|
-
if (!g[ALS_KEY]) g[ALS_KEY] = new AsyncLocalStorage();
|
|
22
|
-
return g[ALS_KEY];
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Run a function with a ServerStyleCollector bound to the current
|
|
26
|
-
* async context. All useStyles() calls within `fn` (and any async
|
|
27
|
-
* continuations) will find this collector via getSSRCollector().
|
|
28
|
-
*/
|
|
29
|
-
function runWithCollector(collector, fn) {
|
|
30
|
-
return getSharedStorage().run(collector, fn);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Retrieve the ServerStyleCollector bound to the current async context.
|
|
34
|
-
* Returns null when called outside of runWithCollector() or on the client.
|
|
35
|
-
*/
|
|
36
|
-
function getSSRCollector() {
|
|
37
|
-
const storage = getSharedStorage();
|
|
38
|
-
if (typeof storage?.getStore !== "function") return null;
|
|
39
|
-
return storage.getStore() ?? null;
|
|
40
|
-
}
|
|
41
|
-
//#endregion
|
|
42
|
-
export { runWithCollector as n, getSSRCollector as t };
|
|
43
|
-
|
|
44
|
-
//# sourceMappingURL=async-storage-DKK-wTD4.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collector-DBGcmUEq.js","names":[],"sources":["../../src/ssr/collector.ts"],"sourcesContent":["/**\n * ServerStyleCollector — server-safe style collector for SSR.\n *\n * Accumulates CSS rules and cache metadata during server rendering.\n * This is the server-side counterpart to StyleInjector: it allocates\n * hash-based class names using the configured `namePrefix` (defaults\n * to `'t'`), formats CSS rules into text, and tracks rendered class\n * names for lightweight client transfer.\n *\n * One instance is created per HTTP request. Concurrent requests\n * each get their own collector (via AsyncLocalStorage or React context).\n */\n\nimport {\n getEffectiveProperties,\n getGlobalStyles,\n getGlobalCounterStyles,\n getGlobalFontFaces,\n getGlobalFunctions,\n getGlobalConfigTokens,\n getNamePrefix,\n} from '../config';\nimport { formatCounterStyleRule } from '../counter-style';\nimport { fontFaceContentHash, formatFontFaceRule } from '../font-face';\nimport { formatFunctionRule, parseFunctionName } from '../functions';\nimport { renderStyles } from '../pipeline';\nimport type { StyleResult } from '../pipeline';\nimport { hashString } from '../utils/hash';\nimport {\n makeClassName,\n makeCounterStyleName,\n makeKeyframeName,\n validateNamePrefix,\n} from '../utils/name-prefix';\nimport { formatPropertyCSS } from './format-property';\nimport { formatGlobalRules } from './format-global-rules';\nimport { formatRules } from './format-rules';\n\nexport type ServerStyleArtifactKind =\n | 'property'\n | 'font-face'\n | 'counter-style'\n | 'function'\n | 'raw'\n | 'global'\n | 'chunk'\n | 'keyframes';\n\nexport interface ServerStyleArtifact {\n /** Stable identifier derived from the artifact kind, logical key, and CSS. */\n id: string;\n kind: ServerStyleArtifactKind;\n css: string;\n /** Zero-based position in the collector's final cascade order. */\n order: number;\n}\n\nfunction artifactId(kind: ServerStyleArtifactKind, key: string, css: string) {\n const content = `${kind}\\0${key}\\0${css}`;\n return `${kind}:${hashString(content)}:${content.length.toString(36)}`;\n}\n\nexport class ServerStyleCollector {\n private chunks = new Map<string, string>();\n private cacheKeyToClassName = new Map<string, string>();\n private flushedKeys = new Set<string>();\n private propertyRules = new Map<string, string>();\n private flushedPropertyKeys = new Set<string>();\n private keyframeRules = new Map<string, string>();\n private flushedKeyframeKeys = new Set<string>();\n private globalStyles = new Map<string, string>();\n private flushedGlobalKeys = new Set<string>();\n private rawCSS = new Map<string, string>();\n private flushedRawKeys = new Set<string>();\n private fontFaceRules = new Map<string, string>();\n private flushedFontFaceKeys = new Set<string>();\n private counterStyleRules = new Map<string, string>();\n private flushedCounterStyleKeys = new Set<string>();\n private functionRules = new Map<string, string>();\n private flushedFunctionKeys = new Set<string>();\n private keyframesCounter = 0;\n private counterStyleCounter = 0;\n private internalsCollected = false;\n private namePrefix: string;\n\n /**\n * @param namePrefix - Optional override for the configured prefix.\n * Defaults to the value from `configure({ namePrefix })` (or `'t'`).\n * Pass an explicit prefix when constructing a collector outside the\n * normal configure() lifecycle (e.g. in tests). Validated eagerly\n * so misconfiguration fails before any CSS is collected.\n */\n constructor(namePrefix?: string) {\n if (namePrefix !== undefined) {\n validateNamePrefix(namePrefix);\n }\n this.namePrefix = namePrefix ?? getNamePrefix();\n }\n\n private generateClassName(cacheKey: string): string {\n return makeClassName(this.namePrefix, hashString(cacheKey));\n }\n\n /**\n * Collect internal @property rules and :root token defaults.\n * Mirrors markStylesGenerated() from the client-side injector.\n * Called automatically on first chunk collection; idempotent.\n *\n * Internals are always emitted here — the RSC path deliberately\n * defers to SSR so that tokens appear exactly once per page in\n * <style data-tasty-ssr> (avoiding duplication of large token sets).\n */\n collectInternals(): void {\n if (this.internalsCollected) return;\n this.internalsCollected = true;\n\n for (const [token, definition] of Object.entries(\n getEffectiveProperties(),\n )) {\n const css = formatPropertyCSS(token, definition);\n if (css) {\n this.collectProperty(`__prop:${token}`, css);\n }\n }\n\n const tokenStyles = getGlobalConfigTokens();\n if (tokenStyles && Object.keys(tokenStyles).length > 0) {\n const tokenRules = renderStyles(tokenStyles, ':root') as StyleResult[];\n if (tokenRules.length > 0) {\n const css = formatGlobalRules(tokenRules);\n if (css) {\n this.collectGlobalStyles('__global:tokens', css);\n }\n }\n }\n\n const globalFF = getGlobalFontFaces();\n if (globalFF) {\n for (const [family, input] of Object.entries(globalFF)) {\n const descriptors = Array.isArray(input) ? input : [input];\n for (const desc of descriptors) {\n const hash = fontFaceContentHash(family, desc);\n const css = formatFontFaceRule(family, desc);\n this.collectFontFace(hash, css);\n }\n }\n }\n\n const globalCS = getGlobalCounterStyles();\n if (globalCS) {\n for (const [name, descriptors] of Object.entries(globalCS)) {\n const css = formatCounterStyleRule(name, descriptors);\n this.collectCounterStyle(name, css, { weak: true });\n }\n }\n\n const globalFn = getGlobalFunctions();\n if (globalFn) {\n for (const [name, definition] of Object.entries(globalFn)) {\n const css = formatFunctionRule(name, definition);\n this.collectFunction(parseFunctionName(name), css, { weak: true });\n }\n }\n\n const globalStyles = getGlobalStyles();\n if (globalStyles) {\n for (const [selector, styles] of Object.entries(globalStyles)) {\n if (Object.keys(styles).length > 0) {\n const rules = renderStyles(styles, selector) as StyleResult[];\n if (rules.length > 0) {\n const css = formatGlobalRules(rules);\n if (css) {\n this.collectGlobalStyles(`__global:styles:${selector}`, css);\n }\n }\n }\n }\n }\n }\n\n /**\n * Allocate a className for a cache key, server-side.\n * Mirrors StyleInjector.allocateClassName but without DOM access.\n */\n allocateClassName(cacheKey: string): {\n className: string;\n isNewAllocation: boolean;\n } {\n const existing = this.cacheKeyToClassName.get(cacheKey);\n if (existing) {\n return { className: existing, isNewAllocation: false };\n }\n\n const className = this.generateClassName(cacheKey);\n this.cacheKeyToClassName.set(cacheKey, className);\n\n return { className, isNewAllocation: true };\n }\n\n /**\n * Record CSS rules for a chunk.\n * Called by useStyles during server render.\n */\n collectChunk(\n cacheKey: string,\n className: string,\n rules: StyleResult[],\n ): void {\n if (this.chunks.has(cacheKey)) return;\n const css = formatRules(rules, className);\n if (css) {\n this.chunks.set(cacheKey, css);\n }\n }\n\n /**\n * Record a @property rule. Deduplicated by name.\n */\n collectProperty(name: string, css: string): void {\n if (!this.propertyRules.has(name)) {\n this.propertyRules.set(name, css);\n }\n }\n\n /**\n * Record a @keyframes rule. Deduplicated by name.\n */\n collectKeyframes(name: string, css: string): void {\n if (!this.keyframeRules.has(name)) {\n this.keyframeRules.set(name, css);\n }\n }\n\n /**\n * Allocate a keyframe name for SSR. Uses provided name or generates one.\n */\n allocateKeyframeName(providedName?: string): string {\n return (\n providedName ??\n makeKeyframeName(this.namePrefix, String(this.keyframesCounter++))\n );\n }\n\n /**\n * Record a @font-face rule. Deduplicated by key (content hash).\n */\n collectFontFace(key: string, css: string): void {\n if (!this.fontFaceRules.has(key)) {\n this.fontFaceRules.set(key, css);\n }\n }\n\n /**\n * Record a @counter-style rule. Deduplicated by name and overrides an\n * existing rule by default. Pass `weak: true` for global `configure()`\n * definitions, which never clobber an existing rule.\n */\n collectCounterStyle(\n name: string,\n css: string,\n options?: { weak?: boolean },\n ): void {\n const existing = this.counterStyleRules.get(name);\n if (existing === undefined) {\n this.counterStyleRules.set(name, css);\n return;\n }\n if (options?.weak || existing === css) return;\n this.counterStyleRules.set(name, css);\n // If a rule with this name was already flushed (streaming), allow the\n // overriding rule to be flushed again so it wins by source order.\n this.flushedCounterStyleKeys.delete(name);\n }\n\n /**\n * Record a @function rule. Deduplicated by CSS function name and overrides an\n * existing rule by default. Pass `weak: true` for global `configure()`\n * definitions, which never clobber an existing rule.\n */\n collectFunction(\n name: string,\n css: string,\n options?: { weak?: boolean },\n ): void {\n const existing = this.functionRules.get(name);\n if (existing === undefined) {\n this.functionRules.set(name, css);\n return;\n }\n if (options?.weak || existing === css) return;\n this.functionRules.set(name, css);\n // If a rule with this name was already flushed (streaming), allow the\n // overriding rule to be flushed again so it wins by source order.\n this.flushedFunctionKeys.delete(name);\n }\n\n /**\n * Allocate a counter-style name for SSR. Uses provided name or generates one.\n */\n allocateCounterStyleName(providedName?: string): string {\n return (\n providedName ??\n makeCounterStyleName(this.namePrefix, String(this.counterStyleCounter++))\n );\n }\n\n /**\n * Record global styles (from useGlobalStyles). Deduplicated by key.\n *\n * Pass `replace` for slot-keyed entries (an explicit `id`), where the last\n * write must win to match the client's update-tracking behavior.\n */\n collectGlobalStyles(key: string, css: string, replace?: boolean): void {\n if (replace || !this.globalStyles.has(key)) {\n this.globalStyles.set(key, css);\n }\n }\n\n /**\n * Record raw CSS text (from useRawCSS). Deduplicated by key.\n *\n * Pass `replace` for slot-keyed entries (an explicit `id`), where the last\n * write must win to match the client's update-tracking behavior.\n */\n collectRawCSS(key: string, css: string, replace?: boolean): void {\n if (replace || !this.rawCSS.has(key)) {\n this.rawCSS.set(key, css);\n }\n }\n\n /**\n * Return the collected CSS as structured, ordered artifacts.\n *\n * Artifact boundaries are part of the collector output so build tools never\n * need to split or parse CSS text. IDs include the logical collection key\n * and content, making them stable across equivalent page renders while a CSS\n * change always produces a different ID.\n */\n getArtifacts(): ServerStyleArtifact[] {\n const artifacts: ServerStyleArtifact[] = [];\n\n const append = (\n kind: ServerStyleArtifactKind,\n entries: Iterable<[string, string]>,\n ) => {\n for (const [key, css] of entries) {\n artifacts.push({\n id: artifactId(kind, key, css),\n kind,\n css,\n order: artifacts.length,\n });\n }\n };\n\n append('property', this.propertyRules);\n append('font-face', this.fontFaceRules);\n append('counter-style', this.counterStyleRules);\n append('function', this.functionRules);\n append('raw', this.rawCSS);\n append('global', this.globalStyles);\n append('chunk', this.chunks);\n append('keyframes', this.keyframeRules);\n\n return artifacts;\n }\n\n /**\n * Extract all CSS collected so far as a single string.\n * Includes @property and @keyframes rules.\n * Used for non-streaming SSR (renderToString).\n */\n getCSS(): string {\n return this.getArtifacts()\n .map(({ css }) => css)\n .join('\\n');\n }\n\n /**\n * Flush only newly collected CSS since the last flush.\n * Used for streaming SSR (renderToPipeableStream + useServerInsertedHTML).\n */\n flushCSS(): string {\n const parts: string[] = [];\n\n for (const [name, css] of this.propertyRules) {\n if (!this.flushedPropertyKeys.has(name)) {\n parts.push(css);\n this.flushedPropertyKeys.add(name);\n }\n }\n\n for (const [key, css] of this.fontFaceRules) {\n if (!this.flushedFontFaceKeys.has(key)) {\n parts.push(css);\n this.flushedFontFaceKeys.add(key);\n }\n }\n\n for (const [key, css] of this.counterStyleRules) {\n if (!this.flushedCounterStyleKeys.has(key)) {\n parts.push(css);\n this.flushedCounterStyleKeys.add(key);\n }\n }\n\n for (const [key, css] of this.functionRules) {\n if (!this.flushedFunctionKeys.has(key)) {\n parts.push(css);\n this.flushedFunctionKeys.add(key);\n }\n }\n\n for (const [key, css] of this.rawCSS) {\n if (!this.flushedRawKeys.has(key)) {\n parts.push(css);\n this.flushedRawKeys.add(key);\n }\n }\n\n for (const [key, css] of this.globalStyles) {\n if (!this.flushedGlobalKeys.has(key)) {\n parts.push(css);\n this.flushedGlobalKeys.add(key);\n }\n }\n\n for (const [key, css] of this.chunks) {\n if (!this.flushedKeys.has(key)) {\n parts.push(css);\n this.flushedKeys.add(key);\n }\n }\n\n for (const [name, css] of this.keyframeRules) {\n if (!this.flushedKeyframeKeys.has(name)) {\n parts.push(css);\n this.flushedKeyframeKeys.add(name);\n }\n }\n\n return parts.join('\\n');\n }\n\n private flushedClassNames = new Set<string>();\n\n /**\n * Return class names rendered since the last call (for streaming).\n * Used to emit lightweight class-list scripts for client hydration.\n */\n getRenderedClassNames(): string[] {\n const names: string[] = [];\n for (const className of this.cacheKeyToClassName.values()) {\n if (!this.flushedClassNames.has(className)) {\n this.flushedClassNames.add(className);\n names.push(className);\n }\n }\n return names;\n }\n}\n\n/**\n * Factory for creating a {@link ServerStyleCollector} instance.\n *\n * Canonical functional entry point; the `ServerStyleCollector` class remains\n * exported for advanced/internal use.\n *\n * @param namePrefix - Optional override for the configured class-name prefix.\n * Defaults to the value from `configure({ namePrefix })` (or `'t'`).\n *\n * @example\n * ```ts\n * import { createServerStyleCollector } from '@tenphi/tasty/ssr';\n *\n * const collector = createServerStyleCollector();\n * ```\n */\nexport function createServerStyleCollector(\n namePrefix?: string,\n): ServerStyleCollector {\n return new ServerStyleCollector(namePrefix);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAyDA,SAAS,WAAW,MAA+B,KAAa,KAAa;CAC3E,MAAM,UAAU,GAAG,KAAK,IAAI,IAAI,IAAI;CACpC,OAAO,GAAG,KAAK,GAAG,WAAW,OAAO,EAAE,GAAG,QAAQ,OAAO,SAAS,EAAE;AACrE;AAEA,IAAa,uBAAb,MAAkC;CAChC,yBAAiB,IAAI,IAAoB;CACzC,sCAA8B,IAAI,IAAoB;C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d,YACsB;CACtB,OAAO,IAAI,qBAAqB,UAAU;AAC5C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"css-writer-PFzrSPeu.js","names":[],"sources":["../../src/zero/extractor.ts","../../src/zero/css-writer.ts"],"sourcesContent":["import { createHash } from 'crypto';\n\nimport {\n categorizeStyleKeys,\n generateChunkCacheKey,\n renderStylesForChunk,\n} from '../chunks';\nimport type {\n CounterStyleDescriptors,\n FontFaceDescriptors,\n FontFaceInput,\n FunctionDefinition,\n KeyframesSteps,\n} from '../injector/types';\nimport {\n extractLocalCounterStyle,\n formatCounterStyleRule,\n hasLocalCounterStyle,\n} from '../counter-style';\nimport {\n extractLocalFontFace,\n formatFontFaceRule,\n hasLocalFontFace,\n} from '../font-face';\nimport { isFunctionsPolyfillEnabled } from '../config';\nimport {\n extractLocalFunctions,\n formatFunctionRule,\n hasLocalFunctions,\n parseFunctionName,\n registerFunctionPolyfill,\n registerLocalFunctionPolyfills,\n} from '../functions';\nimport {\n extractAnimationNamesFromStyles,\n extractLocalKeyframes,\n filterUsedKeyframes,\n hasLocalKeyframes,\n mergeKeyframes,\n} from '../keyframes';\nimport type { StyleResult } from '../pipeline';\nimport { renderStyles } from '../pipeline';\nimport { extractLocalProperties, hasLocalProperties } from '../properties';\nimport { PropertyTypeResolver } from '../properties/property-type-resolver';\nimport type { Styles } from '../styles/types';\nimport {\n DEFAULT_ZERO_NAME_PREFIX,\n makeClassName,\n makeKeyframeName,\n validateNamePrefix,\n} from '../utils/name-prefix';\n\nexport interface ExtractedChunk {\n className: string;\n css: string;\n}\n\nexport interface ExtractedSelector {\n selector: string;\n css: string;\n}\n\nexport interface ExtractedKeyframes {\n name: string;\n css: string;\n}\n\ninterface KeyframesExtractionResult {\n /** Keyframes to inject (deduplicated by content) */\n keyframes: ExtractedKeyframes[];\n /** Map from original animation name to canonical name (for replacement) */\n nameMap: Map<string, string>;\n}\n\n/**\n * Module-level prefix used by the zero-runtime extractor.\n * Defaults to `'ts'` so static classes never collide with the runtime\n * `'t'` classes when both are loaded on the same page. Override via\n * `setExtractorNamePrefix()` from the Babel plugin so user config flows\n * into the extractor.\n */\nlet currentNamePrefix: string = DEFAULT_ZERO_NAME_PREFIX;\n\n/**\n * Set the prefix used by the zero-runtime extractor.\n * Called by the Babel plugin after resolving user config so that\n * generated class and keyframe names match the user's configuration.\n */\nexport function setExtractorNamePrefix(prefix: string): void {\n validateNamePrefix(prefix);\n currentNamePrefix = prefix;\n}\n\n/**\n * Get the prefix currently used by the zero-runtime extractor.\n * Exposed primarily for tests.\n */\nexport function getExtractorNamePrefix(): string {\n return currentNamePrefix;\n}\n\n/**\n * Generate a deterministic className from a cache key using content hash.\n * This ensures the same styles always produce the same className,\n * regardless of build order or incremental compilation.\n */\nfunction generateClassName(cacheKey: string): string {\n const hash = createHash('md5').update(cacheKey).digest('hex').slice(0, 6);\n return makeClassName(currentNamePrefix, hash);\n}\n\n/**\n * Extract styles using chunking (for className mode).\n * Returns multiple classes, one per chunk.\n */\nexport function extractStylesWithChunks(styles: Styles): ExtractedChunk[] {\n const chunks: ExtractedChunk[] = [];\n\n // Categorize style keys into chunks\n const chunkMap = categorizeStyleKeys(styles as Record<string, unknown>);\n\n for (const [chunkName, chunkStyleKeys] of chunkMap) {\n if (chunkStyleKeys.length === 0) continue;\n\n // Generate cache key for this chunk (used for className hash)\n const cacheKey = generateChunkCacheKey(styles, chunkName, chunkStyleKeys);\n\n // Render styles for this chunk\n const renderResult = renderStylesForChunk(\n styles,\n chunkName,\n chunkStyleKeys,\n );\n\n if (renderResult.rules.length === 0) continue;\n\n // Generate deterministic className from content hash\n const className = generateClassName(cacheKey);\n const selector = `.${className}.${className}`;\n\n // Format CSS\n const css = formatRulesToCSS(renderResult.rules, selector);\n\n chunks.push({ className, css });\n }\n\n return chunks;\n}\n\n/**\n * Extract styles for a specific selector (for global/selector mode).\n * Returns a single CSS block.\n */\nexport function extractStylesForSelector(\n selector: string,\n styles: Styles,\n): ExtractedSelector {\n // renderStyles with selector returns StyleResult[] with selectors already applied\n const rules = renderStyles(styles, selector);\n // Format without re-prefixing - rules already have the full selector\n const css = formatRulesDirectly(rules);\n\n return { selector, css };\n}\n\n/**\n * Format StyleResult[] to CSS string.\n * Prefixes each rule's selector with the base selector.\n * Used for chunked styles where rules have relative selectors.\n */\nfunction formatRulesToCSS(rules: StyleResult[], baseSelector: string): string {\n return rules\n .map((rule) => {\n // Handle selector as array (OR conditions) or string\n // Note: renderStyles without className joins array selectors with '|||' placeholder\n const selectorParts = Array.isArray(rule.selector)\n ? rule.selector\n : rule.selector\n ? rule.selector.split('|||')\n : [''];\n\n // Prefix each selector part with the base selector\n const fullSelector = selectorParts\n .map((part) => {\n // Build selector: [rootPrefix] baseSelector[part]\n let selector: string;\n\n // If part is empty, just use base selector\n if (!part) {\n selector = baseSelector;\n } else if (part.startsWith(':') || part.startsWith('[')) {\n // If part starts with a pseudo-class or pseudo-element, append to base\n selector = `${baseSelector}${part}`;\n } else if (\n part.startsWith('>') ||\n part.startsWith('+') ||\n part.startsWith('~')\n ) {\n // If part starts with >, +, ~ combinator, append with space\n selector = `${baseSelector}${part}`;\n } else {\n // Otherwise, combine base with part\n selector = `${baseSelector}${part}`;\n }\n\n // Prepend rootPrefix if present (for @root() states)\n if (rule.rootPrefix) {\n selector = `${rule.rootPrefix} ${selector}`;\n }\n\n return selector;\n })\n .join(', ');\n\n let css = `${fullSelector} { ${rule.declarations} }`;\n\n // Wrap in at-rules (in reverse order for proper nesting)\n if (rule.atRules && rule.atRules.length > 0) {\n for (const atRule of [...rule.atRules].reverse()) {\n css = `${atRule} {\\n ${css}\\n}`;\n }\n }\n\n return css;\n })\n .join('\\n\\n');\n}\n\n/**\n * Format StyleResult[] to CSS string directly without prefixing.\n * Used for global styles where rules already have the full selector.\n */\nfunction formatRulesDirectly(rules: StyleResult[]): string {\n return rules\n .map((rule) => {\n // Prepend rootPrefix if present (for @root() states)\n const selector = rule.rootPrefix\n ? `${rule.rootPrefix} ${rule.selector}`\n : rule.selector;\n\n let css = `${selector} { ${rule.declarations} }`;\n\n // Wrap in at-rules (in reverse order for proper nesting)\n if (rule.atRules && rule.atRules.length > 0) {\n for (const atRule of [...rule.atRules].reverse()) {\n css = `${atRule} {\\n ${css}\\n}`;\n }\n }\n\n return css;\n })\n .join('\\n\\n');\n}\n\n// Note: With hash-based className generation, counter management functions\n// are no longer needed. ClassNames are deterministic based on content.\n\n/**\n * Generate a deterministic keyframes name from content hash.\n * This ensures the same keyframes content always produces the same name,\n * enabling automatic deduplication across elements and files.\n *\n * Uses the configured prefix with a `k` discriminator so keyframe names\n * stay visually distinct from class names sharing the same prefix.\n */\nfunction generateKeyframesName(steps: KeyframesSteps): string {\n const content = JSON.stringify(steps);\n const hash = createHash('md5').update(content).digest('hex').slice(0, 6);\n return makeKeyframeName(currentNamePrefix, hash);\n}\n\n/**\n * Extract keyframes that are used in styles.\n * Merges local @keyframes with global keyframes, filters to only used ones.\n * Generates hash-based names from content for automatic deduplication.\n *\n * @param styles - The styles object (may contain @keyframes and animation properties)\n * @param globalKeyframes - Optional global keyframes from config\n * @returns Keyframes to inject and name mapping for replacement\n */\nexport function extractKeyframesFromStyles(\n styles: Styles,\n globalKeyframes?: Record<string, KeyframesSteps> | null,\n): KeyframesExtractionResult {\n const emptyResult: KeyframesExtractionResult = {\n keyframes: [],\n nameMap: new Map(),\n };\n\n // Extract animation names from styles\n const usedNames = extractAnimationNamesFromStyles(styles);\n if (usedNames.size === 0) return emptyResult;\n\n // Merge local and global keyframes\n const local = hasLocalKeyframes(styles)\n ? extractLocalKeyframes(styles)\n : null;\n const allKeyframes = mergeKeyframes(local, globalKeyframes ?? null);\n\n // Filter to only used keyframes\n const usedKeyframes = filterUsedKeyframes(allKeyframes, usedNames);\n if (!usedKeyframes) return emptyResult;\n\n // Generate hash-based names and collect unique keyframes\n const seenHashes = new Set<string>();\n const nameMap = new Map<string, string>();\n const keyframesToEmit: ExtractedKeyframes[] = [];\n\n for (const [originalName, steps] of Object.entries(usedKeyframes)) {\n const hashedName = generateKeyframesName(steps);\n\n // Always map original name to hashed name (for CSS replacement)\n nameMap.set(originalName, hashedName);\n\n // Only emit each unique keyframe once\n if (!seenHashes.has(hashedName)) {\n seenHashes.add(hashedName);\n const css = keyframesToCSS(hashedName, steps);\n keyframesToEmit.push({ name: hashedName, css });\n }\n }\n\n return { keyframes: keyframesToEmit, nameMap };\n}\n\n/**\n * Convert keyframes steps to CSS string.\n */\nfunction keyframesToCSS(name: string, steps: KeyframesSteps): string {\n const stepRules: string[] = [];\n\n for (const [key, value] of Object.entries(steps)) {\n if (typeof value === 'string') {\n // Raw CSS string\n stepRules.push(`${key} { ${value.trim()} }`);\n } else if (value && typeof value === 'object') {\n // Style map - convert to CSS declarations\n const declarations = Object.entries(value)\n .map(([prop, val]) => {\n const cssProperty = camelToKebab(prop);\n return `${cssProperty}: ${val}`;\n })\n .join('; ');\n stepRules.push(`${key} { ${declarations} }`);\n }\n }\n\n return `@keyframes ${name} { ${stepRules.join(' ')} }`;\n}\n\n/**\n * Convert camelCase to kebab-case.\n */\nfunction camelToKebab(str: string): string {\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\n// ============================================================================\n// Property Extraction (auto-infer @property types for zero-runtime)\n// ============================================================================\n\nexport interface ExtractedProperty {\n name: string;\n css: string;\n}\n\n/**\n * Extract auto-inferred @property declarations from styles.\n * Scans rendered style declarations and keyframe declarations for custom properties\n * whose types can be inferred from their values.\n *\n * @param styles - The styles object\n * @param options - Options including autoPropertyTypes flag\n * @returns Array of @property CSS rules to inject\n */\nexport function extractPropertiesFromStyles(\n styles: Styles,\n options?: { autoPropertyTypes?: boolean },\n): ExtractedProperty[] {\n if (options?.autoPropertyTypes === false) return [];\n\n const registered = new Set<string>();\n const results: ExtractedProperty[] = [];\n\n // Collect explicitly declared properties (they take precedence)\n if (hasLocalProperties(styles)) {\n const localProps = extractLocalProperties(styles);\n if (localProps) {\n for (const token of Object.keys(localProps)) {\n // Normalize token to CSS name\n let cssName: string;\n if (token.startsWith('#')) {\n cssName = `--${token.slice(1)}-color`;\n } else if (token.startsWith('$')) {\n cssName = `--${token.slice(1)}`;\n } else if (token.startsWith('--')) {\n cssName = token;\n } else {\n cssName = `--${token}`;\n }\n registered.add(cssName);\n }\n }\n }\n\n const resolver = new PropertyTypeResolver();\n\n const registerProperty = (\n name: string,\n syntax: string,\n initialValue: string,\n ) => {\n if (registered.has(name)) return;\n registered.add(name);\n\n const parts: string[] = [];\n parts.push(`syntax: \"${syntax}\";`);\n parts.push(`inherits: true;`);\n parts.push(`initial-value: ${initialValue};`);\n\n const css = `@property ${name} { ${parts.join(' ')} }`;\n results.push({ name, css });\n };\n\n const isPropertyDefined = (name: string) => registered.has(name);\n\n // Scan rendered style declarations\n const chunkMap = categorizeStyleKeys(styles as Record<string, unknown>);\n for (const [chunkName, chunkStyleKeys] of chunkMap) {\n if (chunkStyleKeys.length === 0) continue;\n const renderResult = renderStylesForChunk(\n styles,\n chunkName,\n chunkStyleKeys,\n );\n for (const rule of renderResult.rules) {\n if (!rule.declarations) continue;\n resolver.scanDeclarations(\n rule.declarations,\n isPropertyDefined,\n registerProperty,\n );\n }\n }\n\n // Scan keyframe declarations\n if (hasLocalKeyframes(styles)) {\n const localKf = extractLocalKeyframes(styles);\n if (localKf) {\n for (const steps of Object.values(localKf)) {\n scanKeyframeSteps(steps, resolver, isPropertyDefined, registerProperty);\n }\n }\n }\n\n return results;\n}\n\nfunction scanKeyframeSteps(\n steps: KeyframesSteps,\n resolver: PropertyTypeResolver,\n isPropertyDefined: (name: string) => boolean,\n registerProperty: (\n name: string,\n syntax: string,\n initialValue: string,\n ) => void,\n): void {\n for (const value of Object.values(steps)) {\n if (typeof value === 'string') {\n resolver.scanDeclarations(value, isPropertyDefined, registerProperty);\n } else if (value && typeof value === 'object') {\n const declarations = Object.entries(value)\n .map(([prop, val]) => {\n const cssProperty = camelToKebab(prop);\n return `${cssProperty}: ${val}`;\n })\n .join('; ');\n resolver.scanDeclarations(\n declarations,\n isPropertyDefined,\n registerProperty,\n );\n }\n }\n}\n\n// ============================================================================\n// Font Face Extraction (zero-runtime)\n// ============================================================================\n\nexport interface ExtractedFontFace {\n css: string;\n}\n\n/**\n * Extract @font-face rules from styles, merging with global config.\n * Deduplicates by content hash.\n */\nexport function extractFontFaceFromStyles(\n styles: Styles,\n globalFontFace?: Record<string, FontFaceInput> | null,\n): ExtractedFontFace[] {\n const results: ExtractedFontFace[] = [];\n const seenHashes = new Set<string>();\n\n function addFontFace(family: string, input: FontFaceInput) {\n const descriptors: FontFaceDescriptors[] = Array.isArray(input)\n ? input\n : [input];\n for (const desc of descriptors) {\n const hash = createHash('md5')\n .update(JSON.stringify({ family, ...desc }))\n .digest('hex')\n .slice(0, 8);\n if (!seenHashes.has(hash)) {\n seenHashes.add(hash);\n results.push({ css: formatFontFaceRule(family, desc) });\n }\n }\n }\n\n // Global font faces first\n if (globalFontFace) {\n for (const [family, input] of Object.entries(globalFontFace)) {\n addFontFace(family, input);\n }\n }\n\n // Local font faces. @font-face is keyed by content hash, not family name, so\n // distinct definitions all emit and byte-identical ones collapse — there is\n // no \"winner\" to pick between a global and a local definition.\n if (hasLocalFontFace(styles)) {\n const local = extractLocalFontFace(styles);\n if (local) {\n for (const [family, input] of Object.entries(local)) {\n addFontFace(family, input);\n }\n }\n }\n\n return results;\n}\n\n// ============================================================================\n// Counter Style Extraction (zero-runtime)\n// ============================================================================\n\nexport interface ExtractedCounterStyle {\n name: string;\n css: string;\n}\n\n/**\n * Extract @counter-style rules from styles, merging with global config.\n * Deduplicates by name; component-local definitions override global ones with\n * the same name (local wins).\n */\nexport function extractCounterStyleFromStyles(\n styles: Styles,\n globalCounterStyle?: Record<string, CounterStyleDescriptors> | null,\n): ExtractedCounterStyle[] {\n const byName = new Map<string, ExtractedCounterStyle>();\n\n function addCounterStyle(name: string, descriptors: CounterStyleDescriptors) {\n byName.set(name, { name, css: formatCounterStyleRule(name, descriptors) });\n }\n\n // Global counter styles first, then local — local replaces global on conflict.\n if (globalCounterStyle) {\n for (const [name, descriptors] of Object.entries(globalCounterStyle)) {\n addCounterStyle(name, descriptors);\n }\n }\n\n if (hasLocalCounterStyle(styles)) {\n const local = extractLocalCounterStyle(styles);\n if (local) {\n for (const [name, descriptors] of Object.entries(local)) {\n addCounterStyle(name, descriptors);\n }\n }\n }\n\n return [...byName.values()];\n}\n\n// ============================================================================\n// Function Extraction (zero-runtime)\n// ============================================================================\n\nexport interface ExtractedFunction {\n name: string;\n css: string;\n}\n\n/**\n * Extract @function rules from styles, merging with global config.\n * Deduplicates by CSS function name; component-local definitions override\n * global ones with the same name (local wins).\n */\nexport function extractFunctionsFromStyles(\n styles: Styles,\n globalFunction?: Record<string, FunctionDefinition> | null,\n): ExtractedFunction[] {\n // @function polyfill: register definitions as inline closures so call sites\n // are expanded to plain CSS during chunk rendering. No native @function rules\n // are emitted. Global definitions are also registered here as a safety net in\n // case configure() ran in a separate module scope.\n if (isFunctionsPolyfillEnabled()) {\n if (globalFunction) {\n for (const [name, definition] of Object.entries(globalFunction)) {\n registerFunctionPolyfill(name, definition);\n }\n }\n registerLocalFunctionPolyfills(styles);\n return [];\n }\n\n const byName = new Map<string, ExtractedFunction>();\n\n function addFunction(name: string, definition: FunctionDefinition) {\n const cssName = parseFunctionName(name);\n byName.set(cssName, {\n name: cssName,\n css: formatFunctionRule(name, definition),\n });\n }\n\n // Global functions first, then local — local replaces global on conflict.\n if (globalFunction) {\n for (const [name, definition] of Object.entries(globalFunction)) {\n addFunction(name, definition);\n }\n }\n\n if (hasLocalFunctions(styles)) {\n const local = extractLocalFunctions(styles);\n if (local) {\n for (const [name, definition] of Object.entries(local)) {\n addFunction(name, definition);\n }\n }\n }\n\n return [...byName.values()];\n}\n","import * as fs from 'fs';\nimport * as path from 'path';\n\nexport interface CSSWriterOptions {\n /** Enable source comments in output (e.g., \"from: Button.tsx\") */\n devMode?: boolean;\n}\n\ninterface CSSBlock {\n css: string;\n source?: string;\n}\n\nexport class CSSWriter {\n private cssBlocks = new Map<string, CSSBlock>();\n private outputPath: string;\n private devMode: boolean;\n\n constructor(outputPath: string, options: CSSWriterOptions = {}) {\n this.outputPath = outputPath;\n this.devMode = options.devMode ?? false;\n }\n\n /**\n * Add CSS block with deduplication key\n * @param key - Unique key for deduplication\n * @param css - CSS content\n * @param source - Optional source file path (used in devMode)\n */\n add(key: string, css: string, source?: string): void {\n this.cssBlocks.set(key, { css, source });\n }\n\n /**\n * Check if a key already exists\n */\n has(key: string): boolean {\n return this.cssBlocks.has(key);\n }\n\n /**\n * Get the number of CSS blocks\n */\n get size(): number {\n return this.cssBlocks.size;\n }\n\n /**\n * Write all collected CSS to the output file\n */\n write(): void {\n const outputDir = path.dirname(this.outputPath);\n\n // Ensure directory exists\n if (!fs.existsSync(outputDir)) {\n fs.mkdirSync(outputDir, { recursive: true });\n }\n\n // Combine all CSS blocks with optional source comments\n const cssBlocks: string[] = [];\n for (const block of this.cssBlocks.values()) {\n if (this.devMode && block.source) {\n cssBlocks.push(`/* from: ${block.source} */\\n${block.css}`);\n } else {\n cssBlocks.push(block.css);\n }\n }\n const css = cssBlocks.join('\\n\\n');\n\n // Add header comment\n const header = `/* Generated by @tenphi/tasty/zero - DO NOT EDIT */\\n\\n`;\n\n fs.writeFileSync(this.outputPath, header + css);\n }\n\n /**\n * Get all CSS as string (for testing or in-memory use)\n */\n getCSS(): string {\n const cssBlocks: string[] = [];\n for (const block of this.cssBlocks.values()) {\n if (this.devMode && block.source) {\n cssBlocks.push(`/* from: ${block.source} */\\n${block.css}`);\n } else {\n cssBlocks.push(block.css);\n }\n }\n return cssBlocks.join('\\n\\n');\n }\n\n /**\n * Clear all collected CSS\n */\n clear(): void {\n this.cssBlocks.clear();\n }\n\n /**\n * Get the output path\n */\n getOutputPath(): string {\n return this.outputPath;\n }\n}\n\n/**\n * Factory for creating a {@link CSSWriter} instance.\n *\n * Canonical functional entry point; the `CSSWriter` class remains exported\n * for advanced/internal use.\n *\n * @example\n * ```ts\n * import { createCSSWriter } from '@tenphi/tasty/zero';\n *\n * const writer = createCSSWriter('output.css', { devMode: true });\n * ```\n */\nexport function createCSSWriter(\n outputPath: string,\n options?: CSSWriterOptions,\n): CSSWriter {\n return new CSSWriter(outputPath, options);\n}\n"],"mappings":";;;;;;;;;;;;;AAiFA,IAAI,oBAAA;;;;;;AAOJ,SAAgB,uBAAuB,QAAsB;CAC3D,mBAAmB,MAAM;CACzB,oBAAoB;AACtB;;;;;;AAeA,SAAS,kBAAkB,UAA0B;CACnD,MAAM,OAAO,WAAW,KAAK,CAAC,CAAC,OAAO,QAAQ,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC;CACxE,OAAO,cAAc,mBAAmB,IAAI;AAC9C;;;;;AAMA,SAAgB,wBAAwB,QAAkC;CACxE,MAAM,SAA2B,CAAC;CAGlC,MAAM,WAAW,oBAAoB,MAAiC;CAEtE,KAAK,MAAM,CAAC,WAAW,mBAAmB,UAAU;EAClD,IAAI,eAAe,WAAW,GAAG;EAGjC,MAAM,WAAW,sBAAsB,QAAQ,WAAW,cAAc;EAGxE,MAAM,eAAe,qBACnB,QACA,WACA,cACF;EAEA,IAAI,aAAa,MAAM,WAAW,GAAG;EAGrC,MAAM,YAAY,kBAAkB,QAAQ;EAC5C,MAAM,WAAW,IAAI,UAAU,GAAG;EAGlC,MAAM,MAAM,iBAAiB,aAAa,OAAO,QAAQ;EAEzD,OAAO,KAAK;GAAE;GAAW;EAAI,CAAC;CAChC;CAEA,OAAO;AACT;;;;;AAMA,SAAgB,yBACd,UACA,QACmB;CAMnB,OAAO;EAAE;EAAU,KAFP,oBAFE,aAAa,QAAQ,QAEC,CAEf;CAAE;AACzB;;;;;;AAOA,SAAS,iBAAiB,OAAsB,cAA8B;CAC5E,OAAO,MACJ,KAAK,SAAS;EA0Cb,IAAI,MAAM,IAvCY,MAAM,QAAQ,KAAK,QAAQ,IAC7C,KAAK,WACL,KAAK,WAC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AAK,MAAM;CAC9B;;;;CAKA,QAAc;EACZ,KAAK,UAAU,MAAM;CACvB;;;;CAKA,gBAAwB;EACtB,OAAO,KAAK;CACd;AACF;;;;;;;;;;;;;;AAeA,SAAgB,gBACd,YACA,SACW;CACX,OAAO,IAAI,UAAU,YAAY,OAAO;AAC1C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"debug-BUwqo6vC.js","names":[],"sources":["../../src/debug.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport { CHUNK_NAMES } from './chunks/definitions';\nimport { getNamePrefix } from './config';\nimport { flushStyles, getCSSTextForNode, injector } from './injector';\nimport type { CacheMetrics, RootRegistry } from './injector/types';\nimport { tastyClassRegex } from './utils/name-prefix';\n\ndeclare global {\n interface Window {\n tastyDebug?: typeof tastyDebug;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\ntype CSSTarget =\n 'all' | 'global' | 'active' | 'unused' | 'page' | string | string[] | Element;\n\nexport interface DebugOptions {\n root?: Document | ShadowRoot;\n /** Suppress console logging and return data only (default: false) */\n raw?: boolean;\n}\n\nexport interface CSSOptions extends DebugOptions {\n prettify?: boolean;\n /** Read from stored source CSS (dev-mode only) instead of live CSSOM */\n source?: boolean;\n}\n\nexport interface DebugChunkInfo {\n className: string;\n chunkName: string | null;\n}\n\nexport interface InspectResult {\n element?: Element | null;\n classes: string[];\n chunks: DebugChunkInfo[];\n css: string;\n size: number;\n rules: number;\n}\n\nexport interface CacheStatus {\n classes: {\n active: string[];\n unused: string[];\n all: string[];\n };\n metrics: CacheMetrics | null;\n}\n\nexport interface ChunkBreakdown {\n byChunk: Record<\n string,\n { classes: string[]; cssSize: number; ruleCount: number }\n >;\n totalChunkTypes: number;\n totalClasses: number;\n}\n\nexport interface Summary {\n activeClasses: string[];\n /** Classes `gc({ force: true })` would delete right now. */\n unusedClasses: string[];\n /**\n * Held but in neither list: nothing renders them, yet collection will not\n * take them — inside the grace window, or pinned by an `inject()` handle.\n */\n hotClasses: string[];\n totalStyledClasses: string[];\n\n activeCSSSize: number;\n unusedCSSSize: number;\n globalCSSSize: number;\n rawCSSSize: number;\n keyframesCSSSize: number;\n propertyCSSSize: number;\n totalCSSSize: number;\n\n activeRuleCount: number;\n unusedRuleCount: number;\n globalRuleCount: number;\n rawRuleCount: number;\n keyframesRuleCount: number;\n propertyRuleCount: number;\n totalRuleCount: number;\n\n metrics: CacheMetrics | null;\n definedProperties: string[];\n definedKeyframes: { name: string; refCount: number }[];\n chunkBreakdown: ChunkBreakdown;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction fmtSize(bytes: number): string {\n return bytes > 1024 ? `${(bytes / 1024).toFixed(1)}KB` : `${bytes}B`;\n}\n\nfunction countRules(css: string): number {\n return (css.match(/\\{[^}]*\\}/g) || []).length;\n}\n\nfunction sortTastyClasses(classes: Iterable<string>): string[] {\n // Class names use a base36 hash format (e.g. `t3a5f`), so sort lexicographically.\n return Array.from(classes).sort((a, b) => a.localeCompare(b));\n}\n\n/** A DOM root to read, or `null` when the environment has no DOM at all. */\ntype DebugRoot = Document | ShadowRoot | null;\n\n/**\n * The root these helpers read, or `null` where there is no DOM.\n *\n * `document` used to be a default parameter value, and a default is evaluated\n * at the call site — so every read below threw a bare `ReferenceError` under\n * Node, taking out five of the eight public methods. A debug utility must not\n * be able to fail an SSR render because a call was left in, so the DOM-less\n * case reports an empty result and says why.\n */\nfunction defaultRoot(): DebugRoot {\n return typeof document === 'undefined' ? null : document;\n}\n\nlet warnedNoDom = false;\n\n/** Say once why the numbers are empty. Silent under `{ raw: true }`. */\nfunction warnNoDom(raw: boolean): void {\n if (raw || warnedNoDom) return;\n warnedNoDom = true;\n console.warn(\n '[Tasty] tastyDebug reads the DOM and this environment has none, so the ' +\n 'result is empty. During SSR, read the ServerStyleCollector instead.',\n );\n}\n\n/**\n * The registry for `root`, with every queued write landed first.\n *\n * Every injector read API is a flush point, and the reads below reach past\n * those APIs straight into the registry and the sheet manager. Without this\n * they would report a batch window's contents as absent — a rule that is\n * enqueued but not yet in a sheet is missing from `globalRules`, from the\n * sheets, and from anything counting either.\n */\nfunction getRegistry(\n root: DebugRoot = defaultRoot(),\n): RootRegistry | undefined {\n if (!root) return undefined;\n flushStyles();\n\n return injector.instance._sheetManager?.getRegistry(root);\n}\n\nfunction findDomTastyClasses(root: DebugRoot = defaultRoot()): string[] {\n if (!root) return [];\n const classes = new Set<string>();\n const elements = (root as Document).querySelectorAll?.('[class]') || [];\n const classRegex = tastyClassRegex(getNamePrefix());\n elements.forEach((el) => {\n const attr = el.getAttribute('class');\n if (attr) {\n for (const cls of attr.split(/\\s+/)) {\n if (classRegex.test(cls)) classes.add(cls);\n }\n }\n });\n return sortTastyClasses(classes);\n}\n\n/**\n * Everything this injector holds in `root`, in the order the engine applies it,\n * with the sources kept byte-for-byte — trimming would report a total smaller\n * than one of its own parts whenever raw CSS has edge whitespace.\n */\nfunction getAllCSS(root: DebugRoot = defaultRoot()): string {\n const registry = getRegistry(root);\n const sheetManager = injector.instance._sheetManager;\n // `getRegistry` already returns nothing for a null root; the `!root` is what\n // narrows the type for the call below.\n if (!root || !registry || !sheetManager) return '';\n\n return sheetManager.getOwnedCSSInOrder(registry, root).join('\\n');\n}\n\n/**\n * The injector's own readers fall back to `document` when `root` is omitted, so\n * they have to be reached with a real root or not at all.\n */\nfunction cssTextForClasses(classNames: string[], root: DebugRoot): string {\n if (!root) return '';\n\n return injector.instance.getCSSTextForClasses(classNames, { root });\n}\n\nfunction getInjectorMetrics(root: DebugRoot): CacheMetrics | null {\n if (!root) return null;\n\n return injector.instance.getMetrics({ root });\n}\n\n/**\n * Injected classes that no element carries and nobody pinned — the exact set\n * `gc({ force: true })` would delete.\n *\n * Deliberately borrowed from the injector rather than recomputed here: the two\n * drifted apart once before, when this file still read \"unused\" off the pin\n * counts the render path had stopped maintaining.\n */\nfunction getUnusedClasses(root: DebugRoot = defaultRoot()): string[] {\n if (!root) return [];\n\n return sortTastyClasses(injector.instance.getUnusedClasses({ root }));\n}\n\n/** Every class this injector holds CSS for in `root`. */\nfunction getOwnedClasses(root: DebugRoot = defaultRoot()): string[] {\n const registry = getRegistry(root);\n if (!registry) return [];\n\n const owned: string[] = [];\n for (const [className, info] of registry.rules) {\n // A negative sheet index marks a class whose CSS this injector does not\n // hold: server-rendered, pre-allocated, or queued.\n if (info.sheetIndex >= 0) owned.push(className);\n }\n\n return sortTastyClasses(owned);\n}\n\n// ---------------------------------------------------------------------------\n// prettifyCSS — readable output for nested at-rules & comma selectors\n// ---------------------------------------------------------------------------\n\nfunction prettifyCSS(css: string): string {\n if (!css || !css.trim()) return '';\n\n const out: string[] = [];\n let depth = 0;\n const indent = () => ' '.repeat(depth);\n\n let normalized = css.replace(/\\s+/g, ' ').trim();\n // Ensure braces are surrounded by spaces for splitting\n normalized = normalized.replace(/\\s*\\{\\s*/g, ' { ');\n normalized = normalized.replace(/\\s*\\}\\s*/g, ' } ');\n normalized = normalized.replace(/;\\s*/g, '; ');\n\n const tokens = normalized.split(/\\s+/);\n let buf = '';\n\n for (const t of tokens) {\n if (t === '{') {\n // buf contains the selector / at-rule header\n const header = buf.trim();\n if (header) {\n // Split comma-separated selectors onto their own lines\n // but only if the comma is outside parentheses\n const parts = splitOutsideParens(header, ',');\n if (parts.length > 1) {\n out.push(\n parts\n .map((p, idx) =>\n idx === 0\n ? `${indent()}${p.trim()},`\n : `${indent()}${p.trim()}${idx < parts.length - 1 ? ',' : ''}`,\n )\n .join('\\n') + ' {',\n );\n } else {\n out.push(`${indent()}${header} {`);\n }\n } else {\n out.push(`${indent()}{`);\n }\n depth++;\n buf = '';\n } else if (t === '}') {\n // Flush any trailing declarations\n if (buf.trim()) {\n for (const decl of buf.split(';').filter((s) => s.trim())) {\n out.push(`${indent()}${decl.trim()};`);\n }\n buf = '';\n }\n depth = Math.max(0, depth - 1);\n out.push(`${indent()}}`);\n } else if (t.endsWith(';')) {\n buf += ` ${t}`;\n const full = buf.trim();\n if (full) out.push(`${indent()}${full}`);\n buf = '';\n } else {\n buf += ` ${t}`;\n }\n }\n if (buf.trim()) out.push(buf.trim());\n\n return out\n .filter((l) => l.trim())\n .join('\\n')\n .replace(/\\n{3,}/g, '\\n\\n')\n .trim();\n}\n\n/** Split `str` by `sep` only when not inside parentheses */\nfunction splitOutsideParens(str: string, sep: string): string[] {\n const parts: string[] = [];\n let depth = 0;\n let start = 0;\n for (let i = 0; i < str.length; i++) {\n const ch = str[i];\n if (ch === '(') depth++;\n else if (ch === ')') depth--;\n else if (depth === 0 && str.startsWith(sep, i)) {\n parts.push(str.slice(start, i));\n start = i + sep.length;\n }\n }\n parts.push(str.slice(start));\n return parts;\n}\n\n// ---------------------------------------------------------------------------\n// Chunk helpers\n// ---------------------------------------------------------------------------\n\nfunction extractChunkName(cacheKey: string): string | null {\n for (const part of cacheKey.split('\\0')) {\n if (part.startsWith('[states:')) continue;\n if (!part.includes(':') && part.length > 0) return part;\n }\n return null;\n}\n\nfunction getChunkForClass(\n className: string,\n root: DebugRoot = defaultRoot(),\n): string | null {\n const registry = getRegistry(root);\n if (!registry) return null;\n for (const [key, cn] of registry.cacheKeyToClassName) {\n if (cn === className) return extractChunkName(key);\n }\n return null;\n}\n\nfunction buildChunkBreakdown(root: DebugRoot = defaultRoot()): ChunkBreakdown {\n const registry = getRegistry(root);\n if (!root || !registry)\n return { byChunk: {}, totalChunkTypes: 0, totalClasses: 0 };\n\n const byChunk: ChunkBreakdown['byChunk'] = {};\n for (const [cacheKey, className] of registry.cacheKeyToClassName) {\n const chunk = extractChunkName(cacheKey) || 'unknown';\n if (!byChunk[chunk])\n byChunk[chunk] = { classes: [], cssSize: 0, ruleCount: 0 };\n byChunk[chunk].classes.push(className);\n const css = injector.instance.getCSSTextForClasses([className], { root });\n byChunk[chunk].cssSize += css.length;\n byChunk[chunk].ruleCount += countRules(css);\n }\n\n for (const entry of Object.values(byChunk)) {\n entry.classes = sortTastyClasses(entry.classes);\n }\n\n const totalClasses = Object.values(byChunk).reduce(\n (s, e) => s + e.classes.length,\n 0,\n );\n return {\n byChunk,\n totalChunkTypes: Object.keys(byChunk).length,\n totalClasses,\n };\n}\n\n// ---------------------------------------------------------------------------\n// Global-type CSS helper (internal only)\n// ---------------------------------------------------------------------------\n\n/**\n * Every prefix `registry.globalRules` is keyed by. Anything missing here is a\n * rule the summary would hold but never count, which is how the totals stopped\n * adding up the first time.\n */\nconst GLOBAL_RULE_PREFIXES = {\n global: 'global:',\n property: 'property:',\n fontFace: 'fontface:',\n counterStyle: 'counterstyle:',\n function: 'function:',\n} as const;\n\nfunction getGlobalTypeCSS(\n type: keyof typeof GLOBAL_RULE_PREFIXES | 'raw' | 'keyframes',\n root: DebugRoot = defaultRoot(),\n): { css: string; ruleCount: number; size: number } {\n const registry = getRegistry(root);\n if (!root || !registry) return { css: '', ruleCount: 0, size: 0 };\n\n const chunks: string[] = [];\n let rc = 0;\n\n if (type === 'raw') {\n // Raw blocks are kept by the sheet manager, not in `globalRules`, so the\n // prefix scan below never sees them — and their rules are counted from the\n // parsed sheet, since one raw block is one string but any number of rules.\n const css = injector.instance.getRawCSSText({ root });\n const sheetManager = injector.instance._sheetManager;\n\n return {\n css: prettifyCSS(css),\n ruleCount: sheetManager?.getRawRuleCount(root) ?? 0,\n size: css.length,\n };\n }\n\n if (type === 'keyframes') {\n for (const [, entry] of registry.keyframesCache) {\n const info = entry.info;\n const sheetInfo = registry.sheets[info.sheetIndex];\n const sm = injector.instance._sheetManager;\n const ss = sheetInfo && sm ? sm.getCSSSheet(sheetInfo) : null;\n if (ss && info.ruleIndex < ss.cssRules.length) {\n const rule = ss.cssRules[info.ruleIndex];\n if (rule) {\n chunks.push(rule.cssText);\n rc++;\n }\n } else if (info.cssText) {\n chunks.push(info.cssText);\n rc++;\n }\n }\n } else {\n const prefix = GLOBAL_RULE_PREFIXES[type];\n for (const [key, ri] of registry.globalRules) {\n if (!key.startsWith(prefix)) continue;\n const sheetInfo = registry.sheets[ri.sheetIndex];\n const sm = injector.instance._sheetManager;\n const ss = sheetInfo && sm ? sm.getCSSSheet(sheetInfo) : null;\n if (ss) {\n const start = Math.max(0, ri.ruleIndex);\n const end = Math.min(\n ss.cssRules.length - 1,\n (ri.endRuleIndex as number) ?? ri.ruleIndex,\n );\n if (start >= 0 && end >= start && start < ss.cssRules.length) {\n for (let i = start; i <= end; i++) {\n const rule = ss.cssRules[i];\n if (rule) {\n chunks.push(rule.cssText);\n rc++;\n }\n }\n }\n } else if (ri.cssText?.length) {\n chunks.push(...ri.cssText);\n rc += ri.cssText.length;\n }\n }\n }\n\n const raw = chunks.join('\\n');\n return { css: prettifyCSS(raw), ruleCount: rc, size: raw.length };\n}\n\n// ---------------------------------------------------------------------------\n// Source CSS (dev-mode RuleInfo.cssText)\n// ---------------------------------------------------------------------------\n\nfunction getSourceCssForClasses(\n classNames: string[],\n root: DebugRoot = defaultRoot(),\n): string | null {\n const registry = getRegistry(root);\n if (!registry) return null;\n\n const chunks: string[] = [];\n let found = false;\n for (const cls of classNames) {\n const info = registry.rules.get(cls);\n if (info?.cssText?.length) {\n chunks.push(...info.cssText);\n found = true;\n }\n }\n return found ? chunks.join('\\n') : null;\n}\n\n// ---------------------------------------------------------------------------\n// Definitions helper (internal)\n// ---------------------------------------------------------------------------\n\nfunction getDefs(root: DebugRoot = defaultRoot()) {\n const registry = getRegistry(root);\n let properties: string[] = [];\n if (registry?.injectedProperties) {\n properties = Array.from(\n (registry.injectedProperties as Map<string, string>).keys(),\n ).sort();\n }\n\n const keyframes: { name: string; refCount: number }[] = [];\n if (registry) {\n for (const entry of registry.keyframesCache.values()) {\n keyframes.push({ name: entry.name, refCount: entry.refCount });\n }\n keyframes.sort((a, b) => a.name.localeCompare(b.name));\n }\n\n return { properties, keyframes };\n}\n\n// ---------------------------------------------------------------------------\n// Chunk display order\n// ---------------------------------------------------------------------------\n\nconst CHUNK_ORDER = [\n CHUNK_NAMES.COMBINED,\n CHUNK_NAMES.APPEARANCE,\n CHUNK_NAMES.FONT,\n CHUNK_NAMES.DIMENSION,\n CHUNK_NAMES.DISPLAY,\n CHUNK_NAMES.LAYOUT,\n CHUNK_NAMES.POSITION,\n CHUNK_NAMES.MISC,\n CHUNK_NAMES.SUBCOMPONENTS,\n];\n\n// ---------------------------------------------------------------------------\n// tastyDebug API\n// ---------------------------------------------------------------------------\n\nexport const tastyDebug = {\n css(target: CSSTarget, opts?: CSSOptions): string {\n const {\n root = defaultRoot(),\n prettify = true,\n raw = false,\n source = false,\n } = opts || {};\n if (!root) {\n warnNoDom(raw);\n\n return '';\n }\n let css = '';\n\n const classRegex = tastyClassRegex(getNamePrefix());\n if (source && typeof target === 'string' && classRegex.test(target)) {\n const src = getSourceCssForClasses([target], root);\n if (src) {\n css = src;\n } else {\n if (!raw) {\n console.warn(\n '[Tasty] source CSS not available (requires dev mode or TASTY_DEBUG=true). Falling back to live CSSOM.',\n );\n }\n css = injector.instance.getCSSTextForClasses([target], { root });\n }\n } else if (source && Array.isArray(target)) {\n const src = getSourceCssForClasses(target, root);\n if (src) {\n css = src;\n } else {\n if (!raw) {\n console.warn(\n '[Tasty] source CSS not available. Falling back to live CSSOM.',\n );\n }\n css = injector.instance.getCSSTextForClasses(target, { root });\n }\n } else if (typeof target === 'string') {\n if (target === 'all') {\n // Documented as component + global + raw, and raw has its own sheet.\n css = getAllCSS(root);\n } else if (target === 'global') {\n css = getGlobalTypeCSS('global', root).css;\n return css; // already prettified\n } else if (target === 'active') {\n const active = findDomTastyClasses(root);\n css = injector.instance.getCSSTextForClasses(active, { root });\n } else if (target === 'unused') {\n const unused = getUnusedClasses(root);\n css = injector.instance.getCSSTextForClasses(unused, { root });\n } else if (target === 'page') {\n css = getPageCSS(root);\n } else if (classRegex.test(target)) {\n css = injector.instance.getCSSTextForClasses([target], { root });\n } else {\n const el = (root as Document).querySelector?.(target);\n if (el) css = getCSSTextForNode(el, { root });\n }\n } else if (Array.isArray(target)) {\n css = injector.instance.getCSSTextForClasses(target, { root });\n } else if (target instanceof Element) {\n css = getCSSTextForNode(target, { root });\n }\n\n const result = prettify ? prettifyCSS(css) : css;\n\n if (!raw) {\n const label = Array.isArray(target) ? `[${target.join(', ')}]` : target;\n const rc = countRules(css);\n console.group(`CSS for ${label} (${rc} rules, ${fmtSize(css.length)})`);\n console.log(result || '(empty)');\n console.groupEnd();\n }\n\n return result;\n },\n\n inspect(target: string | Element, opts?: DebugOptions): InspectResult {\n const { root = defaultRoot(), raw = false } = opts || {};\n const element = !root\n ? null\n : typeof target === 'string'\n ? (root as Document).querySelector?.(target)\n : target;\n if (!root) warnNoDom(raw);\n\n if (!element) {\n const empty: InspectResult = {\n element: null,\n classes: [],\n chunks: [],\n css: '',\n size: 0,\n rules: 0,\n };\n // With no DOM at all, `warnNoDom` above already said why; \"element not\n // found\" would only misdirect.\n if (!raw && root)\n console.warn('[Tasty] debug.inspect: element not found');\n return empty;\n }\n\n const classList = element.getAttribute('class') || '';\n const classRegex = tastyClassRegex(getNamePrefix());\n const tastyClasses = classList\n .split(/\\s+/)\n .filter((cls) => classRegex.test(cls));\n\n const chunks: DebugChunkInfo[] = tastyClasses.map((className) => ({\n className,\n chunkName: getChunkForClass(className, root),\n }));\n\n const css = getCSSTextForNode(element, { root: root ?? undefined });\n const rules = countRules(css);\n\n const result: InspectResult = {\n element,\n classes: tastyClasses,\n chunks,\n css: prettifyCSS(css),\n size: css.length,\n rules,\n };\n\n if (!raw) {\n const tag = element.tagName.toLowerCase();\n const id = element.id ? `#${element.id}` : '';\n console.group(\n `inspect ${tag}${id} — ${tastyClasses.length} classes, ${rules} rules, ${fmtSize(css.length)}`,\n );\n if (chunks.length) {\n console.log(\n 'Chunks:',\n chunks.map((c) => `${c.className}→${c.chunkName || '?'}`).join(', '),\n );\n }\n console.groupCollapsed('CSS');\n console.log(result.css || '(empty)');\n console.groupEnd();\n console.groupEnd();\n }\n\n return result;\n },\n\n summary(opts?: DebugOptions): Summary {\n const { root = defaultRoot(), raw = false } = opts || {};\n if (!root) warnNoDom(raw);\n\n const activeClasses = findDomTastyClasses(root);\n const unusedClasses = getUnusedClasses(root);\n // Everything, not just the two bands above: a class that went cold a\n // moment ago is in neither, and dropping it here is the accounting failure\n // this whole change started from.\n const ownedClasses = getOwnedClasses(root);\n const totalStyledClasses = sortTastyClasses(\n new Set([...activeClasses, ...ownedClasses]),\n );\n const unusedSet = new Set(unusedClasses);\n const activeSet = new Set(activeClasses);\n const hotClasses = ownedClasses.filter(\n (className) => !activeSet.has(className) && !unusedSet.has(className),\n );\n const hotCSS = cssTextForClasses(hotClasses, root);\n\n const activeCSS = cssTextForClasses(activeClasses, root);\n const unusedCSS = cssTextForClasses(unusedClasses, root);\n const allCSS = getAllCSS(root);\n\n const activeRuleCount = countRules(activeCSS);\n const unusedRuleCount = countRules(unusedCSS);\n\n const globalData = getGlobalTypeCSS('global', root);\n const rawData = getGlobalTypeCSS('raw', root);\n const kfData = getGlobalTypeCSS('keyframes', root);\n const propData = getGlobalTypeCSS('property', root);\n // Folded into the global line rather than given their own: they are all\n // at-rules injected once and kept forever, and leaving them out of the\n // total is what made it not a total.\n const atRuleData = (\n ['fontFace', 'counterStyle', 'function'] as const\n ).reduce(\n (all, type) => {\n const data = getGlobalTypeCSS(type, root);\n return {\n css: data.css ? `${all.css}\\n${data.css}`.trim() : all.css,\n ruleCount: all.ruleCount + data.ruleCount,\n size: all.size + data.size,\n };\n },\n { css: '', ruleCount: 0, size: 0 },\n );\n\n const totalRuleCount =\n activeRuleCount +\n unusedRuleCount +\n countRules(hotCSS) +\n globalData.ruleCount +\n atRuleData.ruleCount +\n rawData.ruleCount +\n kfData.ruleCount +\n propData.ruleCount;\n\n const metrics = getInjectorMetrics(root);\n const defs = getDefs(root);\n const chunkBreakdown = buildChunkBreakdown(root);\n\n const summary: Summary = {\n activeClasses,\n unusedClasses,\n hotClasses,\n totalStyledClasses,\n activeCSSSize: activeCSS.length,\n unusedCSSSize: unusedCSS.length,\n globalCSSSize: globalData.size + atRuleData.size,\n rawCSSSize: rawData.size,\n keyframesCSSSize: kfData.size,\n propertyCSSSize: propData.size,\n totalCSSSize: allCSS.length,\n activeRuleCount,\n unusedRuleCount,\n globalRuleCount: globalData.ruleCount + atRuleData.ruleCount,\n rawRuleCount: rawData.ruleCount,\n keyframesRuleCount: kfData.ruleCount,\n propertyRuleCount: propData.ruleCount,\n totalRuleCount,\n metrics,\n definedProperties: defs.properties,\n definedKeyframes: defs.keyframes,\n chunkBreakdown,\n };\n\n if (!raw) {\n console.group('Tasty Summary');\n console.log(\n `Active: ${activeClasses.length} classes, ${activeRuleCount} rules, ${fmtSize(activeCSS.length)}`,\n );\n console.log(\n `Unused: ${unusedClasses.length} classes, ${unusedRuleCount} rules, ${fmtSize(unusedCSS.length)}`,\n );\n if (hotClasses.length)\n console.log(\n `Held: ${hotClasses.length} classes, ${countRules(hotCSS)} rules, ${fmtSize(hotCSS.length)} (not rendered, not yet collectable)`,\n );\n console.log(\n `Global: ${globalData.ruleCount + atRuleData.ruleCount} rules, ${fmtSize(globalData.size + atRuleData.size)}`,\n );\n if (rawData.ruleCount)\n console.log(\n `Raw: ${rawData.ruleCount} rules, ${fmtSize(rawData.size)}`,\n );\n if (kfData.ruleCount)\n console.log(\n `Keyframes: ${kfData.ruleCount} rules, ${fmtSize(kfData.size)}`,\n );\n if (propData.ruleCount)\n console.log(\n `@property: ${propData.ruleCount} rules, ${fmtSize(propData.size)}`,\n );\n console.log(\n `Total: ${totalStyledClasses.length} classes, ${totalRuleCount} rules, ${fmtSize(allCSS.length)}`,\n );\n\n if (metrics) {\n const total = metrics.hits + metrics.misses;\n const rate = total > 0 ? ((metrics.hits / total) * 100).toFixed(1) : 0;\n console.log(`Cache: ${rate}% hit rate (${total} lookups)`);\n }\n\n if (chunkBreakdown.totalChunkTypes > 0) {\n console.groupCollapsed(\n `Chunks (${chunkBreakdown.totalChunkTypes} types, ${chunkBreakdown.totalClasses} classes)`,\n );\n for (const name of CHUNK_ORDER) {\n const d = chunkBreakdown.byChunk[name];\n if (d)\n console.log(\n ` ${name}: ${d.classes.length} cls, ${d.ruleCount} rules, ${fmtSize(d.cssSize)}`,\n );\n }\n for (const [name, d] of Object.entries(chunkBreakdown.byChunk)) {\n if (!CHUNK_ORDER.includes(name as (typeof CHUNK_ORDER)[number]))\n console.log(\n ` ${name}: ${d.classes.length} cls, ${d.ruleCount} rules, ${fmtSize(d.cssSize)}`,\n );\n }\n console.groupEnd();\n }\n\n if (defs.properties.length || defs.keyframes.length) {\n console.log(\n `Defs: ${defs.properties.length} @property, ${defs.keyframes.length} @keyframes`,\n );\n }\n\n console.groupEnd();\n }\n\n return summary;\n },\n\n chunks(opts?: DebugOptions): ChunkBreakdown {\n const { root = defaultRoot(), raw = false } = opts || {};\n if (!root) warnNoDom(raw);\n const breakdown = buildChunkBreakdown(root);\n\n if (!raw) {\n console.group(\n `Chunks (${breakdown.totalChunkTypes} types, ${breakdown.totalClasses} classes)`,\n );\n for (const name of CHUNK_ORDER) {\n const d = breakdown.byChunk[name];\n if (d)\n console.log(\n ` ${name}: ${d.classes.length} cls, ${d.ruleCount} rules, ${fmtSize(d.cssSize)}`,\n );\n }\n for (const [name, d] of Object.entries(breakdown.byChunk)) {\n if (!CHUNK_ORDER.includes(name as (typeof CHUNK_ORDER)[number]))\n console.log(\n ` ${name}: ${d.classes.length} cls, ${d.ruleCount} rules, ${fmtSize(d.cssSize)}`,\n );\n }\n console.groupEnd();\n }\n\n return breakdown;\n },\n\n cache(opts?: DebugOptions): CacheStatus {\n const { root = defaultRoot(), raw = false } = opts || {};\n if (!root) warnNoDom(raw);\n const active = findDomTastyClasses(root);\n const unused = getUnusedClasses(root);\n const metrics = getInjectorMetrics(root);\n\n // `all` is everything held, not the two bands above: a class that went cold\n // a moment ago is in neither, and it is still taking up a sheet.\n const all = sortTastyClasses(\n new Set([...active, ...getOwnedClasses(root)]),\n );\n\n const status: CacheStatus = {\n classes: { active, unused, all },\n metrics,\n };\n\n if (!raw) {\n console.group('Cache');\n console.log(`Active: ${active.length}, Unused: ${unused.length}`);\n if (metrics) {\n const total = metrics.hits + metrics.misses;\n const rate = total > 0 ? ((metrics.hits / total) * 100).toFixed(1) : 0;\n console.log(\n `Hits: ${metrics.hits}, Misses: ${metrics.misses}, Rate: ${rate}%`,\n );\n }\n console.groupEnd();\n }\n\n return status;\n },\n\n cleanup(opts?: { root?: Document | ShadowRoot }): void {\n const root = opts?.root ?? defaultRoot();\n if (!root) return;\n injector.instance.cleanup(root);\n },\n\n help(): void {\n console.log(`tastyDebug API:\n .summary() — overview (classes, rules, sizes)\n .css(\"active\") — CSS for classes in DOM\n .css(\"t42\") — CSS for a specific class\n .css(\"t42\",{source:1})— original CSS before browser parsing (dev only)\n .css(\".selector\") — CSS for a DOM element\n .inspect(\".selector\") — element details (classes, chunks, rules)\n .chunks() — style chunk breakdown\n .cache() — cache status and metrics\n .cleanup() — force unused style cleanup\nOptions: { raw: true } suppresses logging, { root: shadowRoot } targets Shadow DOM`);\n },\n\n install(): void {\n if (typeof window !== 'undefined' && window.tastyDebug !== tastyDebug) {\n window.tastyDebug = tastyDebug;\n console.log('tastyDebug installed. Run tastyDebug.help() for commands.');\n }\n },\n};\n\n// ---------------------------------------------------------------------------\n// Page CSS (minimal, kept internal)\n// ---------------------------------------------------------------------------\n\nfunction getPageCSS(root: DebugRoot = defaultRoot()): string {\n if (!root) return '';\n const chunks: string[] = [];\n try {\n if ('styleSheets' in root) {\n for (const sheet of Array.from((root as Document).styleSheets)) {\n try {\n if (sheet.cssRules)\n chunks.push(\n Array.from(sheet.cssRules)\n .map((r) => r.cssText)\n .join('\\n'),\n );\n } catch {\n /* cross-origin */\n }\n }\n }\n } catch {\n /* ignore */\n }\n return chunks.join('\\n');\n}\n"],"mappings":";;;AAqGA,SAAS,QAAQ,OAAuB;CACtC,OAAO,QAAQ,OAAO,IAAI,QAAQ,KAAA,CAAM,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM;AACpE;AAEA,SAAS,WAAW,KAA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