@tenphi/tasty 3.6.0 → 3.8.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.
Files changed (65) hide show
  1. package/dist/{astro-CzY4LCpr.js → astro-w8r-u4qo.js} +6 -142
  2. package/dist/astro-w8r-u4qo.js.map +1 -0
  3. package/dist/{babel-DWCsafYw.d.ts → babel-Cp_dRhuS.d.ts} +2 -2
  4. package/dist/{collector-C6TtL8HJ.js → collector-C7YBiY7D.js} +3 -3
  5. package/dist/{collector-C6TtL8HJ.js.map → collector-C7YBiY7D.js.map} +1 -1
  6. package/dist/{collector-BTVXj2hS.d.ts → collector-CUtAFyIb.d.ts} +2 -2
  7. package/dist/{config-LfIDmVHx.d.ts → config-BY1e5y7V.d.ts} +2 -2
  8. package/dist/{config-B3gPdCqd.js → config-yXpe2jAV.js} +404 -157
  9. package/dist/config-yXpe2jAV.js.map +1 -0
  10. package/dist/core/index.d.ts +4 -4
  11. package/dist/core/index.js +5 -5
  12. package/dist/{core-Bq7w2kti.js → core-DoEZAHJq.js} +79 -33
  13. package/dist/{core-Bq7w2kti.js.map → core-DoEZAHJq.js.map} +1 -1
  14. package/dist/css-resources-Cyl_axbI.js +149 -0
  15. package/dist/css-resources-Cyl_axbI.js.map +1 -0
  16. package/dist/{css-writer-Bgowobbx.js → css-writer-BiumPvq-.js} +3 -3
  17. package/dist/{css-writer-Bgowobbx.js.map → css-writer-BiumPvq-.js.map} +1 -1
  18. package/dist/{format-rules-rCZ37rqY.js → format-rules-DHuG25KU.js} +3 -29
  19. package/dist/format-rules-DHuG25KU.js.map +1 -0
  20. package/dist/{hydrate-CNOmZprz.js → hydrate-BvRP6QEC.js} +2 -2
  21. package/dist/{hydrate-CNOmZprz.js.map → hydrate-BvRP6QEC.js.map} +1 -1
  22. package/dist/{index-BmogEzTo.d.ts → index-DBjd4MAb.d.ts} +46 -5
  23. package/dist/{index-Bm9ltvdH.d.ts → index-uX74k5jG.d.ts} +93 -46
  24. package/dist/index.d.ts +4 -4
  25. package/dist/index.js +6 -6
  26. package/dist/{keyframes-DE-OE76F.js → keyframes-B8uPLZwx.js} +2 -2
  27. package/dist/{keyframes-DE-OE76F.js.map → keyframes-B8uPLZwx.js.map} +1 -1
  28. package/dist/{merge-styles-DuoZEsm9.js → merge-styles-ChW1k-ZM.js} +2 -2
  29. package/dist/{merge-styles-DuoZEsm9.js.map → merge-styles-ChW1k-ZM.js.map} +1 -1
  30. package/dist/{merge-styles-BcLl1u_d.d.ts → merge-styles-pf6iPs82.d.ts} +2 -2
  31. package/dist/{resolve-recipes-H9NqOQuP.js → resolve-recipes-BNmjANzT.js} +3 -3
  32. package/dist/{resolve-recipes-H9NqOQuP.js.map → resolve-recipes-BNmjANzT.js.map} +1 -1
  33. package/dist/ssr/astro-client.js +1 -1
  34. package/dist/ssr/astro-middleware-extract-static.js +1 -1
  35. package/dist/ssr/astro-middleware-extract.js +1 -1
  36. package/dist/ssr/astro-middleware-static.js +1 -1
  37. package/dist/ssr/astro-middleware.js +1 -1
  38. package/dist/ssr/astro.js +1 -1
  39. package/dist/ssr/index.d.ts +1 -1
  40. package/dist/ssr/index.js +3 -3
  41. package/dist/ssr/next-config.d.ts +66 -0
  42. package/dist/ssr/next-config.js +115 -0
  43. package/dist/ssr/next-config.js.map +1 -0
  44. package/dist/ssr/next.d.ts +9 -2
  45. package/dist/ssr/next.js +26 -9
  46. package/dist/ssr/next.js.map +1 -1
  47. package/dist/ssr-collector-ref-COs_ioWl.js +29 -0
  48. package/dist/ssr-collector-ref-COs_ioWl.js.map +1 -0
  49. package/dist/static/index.d.ts +2 -2
  50. package/dist/static/index.js +1 -1
  51. package/dist/zero/babel.d.ts +1 -1
  52. package/dist/zero/babel.js +4 -4
  53. package/dist/zero/index.d.ts +1 -1
  54. package/dist/zero/index.js +1 -1
  55. package/dist/zero/next.d.ts +1 -1
  56. package/docs/ai-agents.md +8 -3
  57. package/docs/debug.md +13 -0
  58. package/docs/methodology.md +3 -3
  59. package/docs/runtime-benchmarks.md +185 -12
  60. package/docs/ssr.md +113 -18
  61. package/docs/styles.md +43 -11
  62. package/package.json +14 -6
  63. package/dist/astro-CzY4LCpr.js.map +0 -1
  64. package/dist/config-B3gPdCqd.js.map +0 -1
  65. package/dist/format-rules-rCZ37rqY.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"format-rules-rCZ37rqY.js","names":[],"sources":["../src/ssr/ssr-collector-ref.ts","../src/ssr/format-property.ts","../src/ssr/format-rules.ts"],"sourcesContent":["/**\n * Global reference to the SSR collector getter function.\n *\n * This indirection avoids importing 'node:async_hooks' in the browser bundle.\n * The SSR entry point sets this ref when loaded on the server. The useStyles\n * hook calls it if set; on the client it stays null and is never called.\n *\n * Uses a module-level variable as the primary mechanism. In Next.js App\n * Router the RSC and SSR module graphs load separate copies of this module,\n * so the getter registered by TastyRegistry (SSR layer) is invisible to\n * server components (RSC layer) — which correctly fall through to inline\n * RSC styles.\n *\n * A globalThis fallback (`registerSSRCollectorGetterGlobal`) is provided\n * for frameworks like Astro where middleware and page components live in\n * different module graphs and must share the getter across them.\n */\n\nimport type { ServerStyleCollector } from './collector';\n\ntype SSRCollectorGetter = () => ServerStyleCollector | null;\n\nconst GETTER_KEY = '__tasty_ssr_collector_getter__';\n\nlet _getSSRCollector: SSRCollectorGetter | null = null;\n\n/**\n * Register the collector getter in the current module graph only.\n * Used by Next.js TastyRegistry.\n */\nexport function registerSSRCollectorGetter(fn: SSRCollectorGetter): void {\n _getSSRCollector = fn;\n}\n\n/**\n * Register the collector getter on globalThis so it is visible across\n * separate module graphs (e.g. Astro middleware ↔ page components).\n */\nexport function registerSSRCollectorGetterGlobal(fn: SSRCollectorGetter): void {\n (globalThis as Record<string, unknown>)[GETTER_KEY] = fn;\n}\n\n/**\n * Retrieve the SSR collector: module-level first, globalThis fallback.\n */\nexport function getRegisteredSSRCollector(): ServerStyleCollector | null {\n if (_getSSRCollector) return _getSSRCollector();\n const getter = (globalThis as Record<string, unknown>)[GETTER_KEY] as\n SSRCollectorGetter | undefined;\n return getter ? getter() : null;\n}\n","/**\n * Format @property CSS rules for SSR output.\n *\n * Replicates the CSS construction from StyleInjector.property()\n * but returns a CSS string instead of inserting into the DOM.\n */\n\nimport type { PropertyDefinition } from '../injector/types';\nimport { getEffectiveDefinition } from '../properties';\nimport type { StyleValue } from '../utils/styles';\nimport { parseStyle } from '../utils/styles';\n\n/**\n * Format a single @property rule as a CSS string.\n *\n * Returns the full `@property --name { ... }` text, or empty string\n * if the token is invalid.\n */\nexport function formatPropertyCSS(\n token: string,\n definition: PropertyDefinition,\n): string {\n const result = getEffectiveDefinition(token, definition);\n if (!result.isValid) return '';\n\n return buildPropertyRule(result.cssName, result.definition);\n}\n\nfunction buildPropertyRule(\n cssName: string,\n definition: PropertyDefinition,\n): string {\n const parts: string[] = [];\n\n if (definition.syntax != null) {\n let syntax = String(definition.syntax).trim();\n if (!/^['\"]/u.test(syntax)) syntax = `\"${syntax}\"`;\n parts.push(`syntax: ${syntax};`);\n }\n\n const inherits = definition.inherits ?? true;\n parts.push(`inherits: ${inherits ? 'true' : 'false'};`);\n\n if (definition.initialValue != null) {\n let initialValueStr: string;\n if (typeof definition.initialValue === 'number') {\n initialValueStr = String(definition.initialValue);\n } else {\n initialValueStr = parseStyle(\n definition.initialValue as StyleValue,\n ).output;\n }\n parts.push(`initial-value: ${initialValueStr};`);\n }\n\n const declarations = parts.join(' ').trim();\n return `@property ${cssName} { ${declarations} }`;\n}\n","/**\n * Shared CSS rule formatting utility.\n *\n * Extracted from SheetManager to allow both the DOM-based injector (client)\n * and the ServerStyleCollector (server) to produce identical CSS text\n * from StyleResult arrays.\n */\n\nimport type { StyleResult } from '../pipeline';\n\n/**\n * Resolve selectors for a rule, applying className-based specificity doubling\n * and rootPrefix handling. Mirrors the logic in StyleInjector.inject().\n */\nfunction resolveSelector(rule: StyleResult, className: string): string {\n let selector = rule.selector;\n\n if (rule.needsClassName) {\n const selectorParts = selector ? selector.split('|||') : [''];\n const classPrefix = `.${className}.${className}`;\n\n selector = selectorParts\n .map((part) => {\n const classSelector = part ? `${classPrefix}${part}` : classPrefix;\n\n if (rule.rootPrefix) {\n return `${rule.rootPrefix} ${classSelector}`;\n }\n return classSelector;\n })\n .join(', ');\n }\n\n return selector;\n}\n\ninterface GroupedRule {\n selector: string;\n declarations: string;\n atRules?: string[];\n startingStyle?: boolean;\n}\n\n/**\n * Group rules by selector + at-rules + startingStyle and merge their declarations.\n * Mirrors the grouping logic in SheetManager.insertRule().\n */\nfunction groupRules(rules: GroupedRule[]): GroupedRule[] {\n const groupMap = new Map<string, GroupedRule>();\n const order: string[] = [];\n\n const atKey = (at?: string[]) => (at && at.length ? at.join('|') : '');\n\n for (const r of rules) {\n const key = `${atKey(r.atRules)}||${r.selector}||${r.startingStyle ? '1' : '0'}`;\n const existing = groupMap.get(key);\n if (existing) {\n existing.declarations = existing.declarations\n ? `${existing.declarations} ${r.declarations}`\n : r.declarations;\n } else {\n groupMap.set(key, {\n selector: r.selector,\n atRules: r.atRules,\n startingStyle: r.startingStyle,\n declarations: r.declarations,\n });\n order.push(key);\n }\n }\n\n return order.map((key) => groupMap.get(key)!);\n}\n\n/**\n * Format an array of StyleResult rules into a CSS text string.\n *\n * Applies className-based specificity doubling (.cls.cls),\n * groups rules by selector + at-rules, and wraps with at-rule blocks.\n *\n * Produces the same CSS text as SheetManager.insertRule() would insert\n * into the DOM, but as a plain string suitable for SSR output.\n */\nexport function formatRules(rules: StyleResult[], className: string): string {\n if (rules.length === 0) return '';\n\n const resolvedRules = rules.map((rule) => ({\n selector: resolveSelector(rule, className),\n declarations: rule.declarations,\n atRules: rule.atRules,\n startingStyle: rule.startingStyle,\n }));\n\n const grouped = groupRules(resolvedRules);\n const cssRules: string[] = [];\n\n for (const rule of grouped) {\n const innerContent = rule.startingStyle\n ? `@starting-style { ${rule.declarations} }`\n : rule.declarations;\n const baseRule = `${rule.selector} { ${innerContent} }`;\n\n let fullRule = baseRule;\n if (rule.atRules && rule.atRules.length > 0) {\n fullRule = rule.atRules.reduce(\n (css, atRule) => `${atRule} { ${css} }`,\n baseRule,\n );\n }\n\n cssRules.push(fullRule);\n }\n\n return cssRules.join('\\n');\n}\n"],"mappings":";;AAsBA,MAAM,aAAa;AAEnB,IAAI,mBAA8C;;;;;AAMlD,SAAgB,2BAA2B,IAA8B;CACvE,mBAAmB;AACrB;;;;;AAMA,SAAgB,iCAAiC,IAA8B;CAC7E,WAAwC,cAAc;AACxD;;;;AAKA,SAAgB,4BAAyD;CACvE,IAAI,kBAAkB,OAAO,iBAAiB;CAC9C,MAAM,SAAU,WAAuC;CAEvD,OAAO,SAAS,OAAO,IAAI;AAC7B;;;;;;;;;AChCA,SAAgB,kBACd,OACA,YACQ;CACR,MAAM,SAAS,uBAAuB,OAAO,UAAU;CACvD,IAAI,CAAC,OAAO,SAAS,OAAO;CAE5B,OAAO,kBAAkB,OAAO,SAAS,OAAO,UAAU;AAC5D;AAEA,SAAS,kBACP,SACA,YACQ;CACR,MAAM,QAAkB,CAAC;CAEzB,IAAI,WAAW,UAAU,MAAM;EAC7B,IAAI,SAAS,OAAO,WAAW,MAAM,CAAC,CAAC,KAAK;EAC5C,IAAI,CAAC,SAAS,KAAK,MAAM,GAAG,SAAS,IAAI,OAAO;EAChD,MAAM,KAAK,WAAW,OAAO,EAAE;CACjC;CAEA,MAAM,WAAW,WAAW,YAAY;CACxC,MAAM,KAAK,aAAa,WAAW,SAAS,QAAQ,EAAE;CAEtD,IAAI,WAAW,gBAAgB,MAAM;EACnC,IAAI;EACJ,IAAI,OAAO,WAAW,iBAAiB,UACrC,kBAAkB,OAAO,WAAW,YAAY;OAEhD,kBAAkB,WAChB,WAAW,YACb,CAAC,CAAC;EAEJ,MAAM,KAAK,kBAAkB,gBAAgB,EAAE;CACjD;CAGA,OAAO,aAAa,QAAQ,KADP,MAAM,KAAK,GAAG,CAAC,CAAC,KACO,EAAE;AAChD;;;;;;;AC3CA,SAAS,gBAAgB,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