@stillwind/host 0.6.0 → 0.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.
- package/dist/browser.js +8 -5
- package/dist/browser.js.map +1 -1
- package/dist/{configuration-CnrzO-F3.js → configuration-MQZe6ufN.js} +26 -8
- package/dist/configuration-MQZe6ufN.js.map +1 -0
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/dist/{options-yvOsPpQU.js → options-PMjJ1c8W.js} +3 -3
- package/dist/{options-yvOsPpQU.js.map → options-PMjJ1c8W.js.map} +1 -1
- package/dist/{plugin-DvCyhK1k.js → plugin-CxD6forV.js} +2 -2
- package/dist/{plugin-DvCyhK1k.js.map → plugin-CxD6forV.js.map} +1 -1
- package/package.json +6 -5
- package/dist/configuration-CnrzO-F3.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration-MQZe6ufN.js","names":[],"sources":["../src/css/plugins/tailwind/css.ts","../src/css/plugins/tailwind/configuration.ts"],"sourcesContent":["import type { NativePluginOption } from \"@stillwind/native\";\n\n/**\n * Serializes a plugin CSS object, as plugins pass it to Tailwind's API, while preserving\n * repeated declarations and nested rules.\n *\n * @param input - CSS-in-JS object or array of them. An array value of a property repeats the\n * declaration, camel-case property names become kebab-case, and null, undefined, and false\n * values are skipped. `@slot` keys and values become `@slot` statements.\n * @returns CSS declarations and rules without surrounding braces, or an empty string for input\n * that is not an object.\n */\nexport function serializeCss(input: unknown): string {\n if (Array.isArray(input)) {\n return input.map(serializeCss).join(\"\\n\");\n }\n if (!input || typeof input !== \"object\") {\n return \"\";\n }\n let output = \"\";\n for (const [key, value] of Object.entries(input)) {\n if (value === null || value === undefined || value === false) {\n continue;\n }\n if (key === \"@slot\") {\n output += \"@slot;\";\n continue;\n }\n if (!key.startsWith(\"--\") && value === \"@slot\") {\n output += `${key}{@slot;}`;\n continue;\n }\n if (statement(key, value)) {\n output += `${key};`;\n continue;\n }\n const values = Array.isArray(value) ? value : [value];\n for (const entry of values) {\n if (entry && typeof entry === \"object\") {\n output += `${key}{${serializeCss(entry)}}`;\n } else if (entry !== null && entry !== undefined && entry !== false) {\n const property = key.startsWith(\"--\")\n ? key\n : key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`).replace(/^ms-/, \"-ms-\");\n output += `${property}:${String(entry)};`;\n }\n }\n }\n return output;\n}\n\n/**\n * Whether an entry is an at-rule without a block, such as `{ \"@apply p-4\": {} }`, which\n * Tailwind serializes as the statement `@apply p-4;`.\n *\n * @param key - Entry key.\n * @param value - Entry value.\n * @returns Whether the key is an at-rule and the value an empty object.\n */\nfunction statement(key: string, value: unknown): boolean {\n return (\n key.startsWith(\"@\") &&\n typeof value === \"object\" &&\n value !== null &&\n !Array.isArray(value) &&\n Object.keys(value).length === 0\n );\n}\n\n/**\n * Escapes a complete candidate as one CSS identifier, including arbitrary-value punctuation.\n *\n * @param value - Candidate or variant name, such as `-probe-[3px]/mirror`.\n * @returns An identifier whose CSS escapes decode to `value`. A leading digit becomes a\n * six-digit hexadecimal escape.\n */\nexport function identifier(value: string): string {\n return Array.from(value)\n .map((character, index) => {\n if (/[_a-zA-Z\\u0080-\\uffff-]/u.test(character) || (index > 0 && /\\d/.test(character))) {\n return character;\n }\n if (/\\d/.test(character)) {\n return `\\\\${character.codePointAt(0)!.toString(16).padStart(6, \"0\")}`;\n }\n return `\\\\${character}`;\n })\n .join(\"\");\n}\n\n/**\n * Applies an alpha value to a color as Tailwind's `withAlpha()` does.\n *\n * Every plain number is multiplied by 100, so `0.5` means 50% and `50` means 5000%, which\n * `color-mix()` rejects. Tailwind applies this to the `/50` of `theme(\"colors.red.500 / 50\")`,\n * while a `/50` color modifier of a utility arrives here already as `50%`.\n *\n * @param value - CSS color.\n * @param alpha - Number, percentage, or other CSS value such as `var(--opacity)`.\n * @returns The color itself for `100%`, and a `color-mix()` toward transparent otherwise.\n */\nexport function withAlpha(value: string, alpha: string): string {\n const number = Number(alpha);\n const percentage = Number.isNaN(number) ? alpha : `${number * 100}%`;\n return percentage === \"100%\" ? value : `color-mix(in oklab, ${value} ${percentage}, transparent)`;\n}\n\n/** Class names that Tailwind's `addUtilities()` registers. */\nconst IS_VALID_UTILITY_NAME = /^[a-z@][a-zA-Z0-9/%._-]*$/;\n\n/**\n * Finds the classes that a plugin selector registers, as Tailwind's `addUtilities()` does: every\n * class outside attribute selectors and outside the arguments of `:not()`, `:nth-child()`, and\n * `:nth-last-child()`, whose classes are conditions rather than utilities. `.outer .inner`\n * registers both `outer` and `inner`.\n *\n * @param selector - One complex selector without top-level commas.\n * @returns The decoded class names with the range of each `.name`, in source order.\n */\nfunction utilityClasses(selector: string): { name: string; start: number; end: number }[] {\n const classes: {\n name: string;\n start: number;\n end: number;\n }[] = [];\n const parentheses: boolean[] = [];\n let excluded = 0;\n let attribute = 0;\n let quote = \"\";\n for (let index = 0; index < selector.length; index++) {\n const char = selector[index];\n if (char === \"\\\\\") {\n index++;\n } else if (quote) {\n quote = char === quote ? \"\" : quote;\n } else if (char === '\"' || char === \"'\") {\n quote = char;\n } else if (char === \"[\") {\n attribute++;\n } else if (char === \"]\") {\n attribute--;\n } else if (char === \"(\") {\n const condition = /:(?:not|nth-child|nth-last-child)$/i.test(selector.slice(0, index));\n parentheses.push(condition);\n excluded += condition ? 1 : 0;\n } else if (char === \")\") {\n excluded -= parentheses.pop() ? 1 : 0;\n } else if (char === \".\" && !excluded && !attribute) {\n const { name, end } = readIdentifier(selector, index + 1);\n if (IS_VALID_UTILITY_NAME.test(name)) {\n classes.push({\n name,\n start: index,\n end,\n });\n }\n index = end - 1;\n }\n }\n return classes;\n}\n\n/**\n * Reads a CSS identifier and decodes its escapes.\n *\n * @param text - Text that contains the identifier.\n * @param start - Index of the first character of the identifier.\n * @returns The decoded name, empty when no identifier starts at `start`, and the index after it.\n */\nfunction readIdentifier(text: string, start: number): { name: string; end: number } {\n let end = start;\n let name = \"\";\n while (end < text.length) {\n const next = text[end];\n if (next === \"\\\\\") {\n const hex = /^[0-9a-f]{1,6}\\s?/i.exec(text.slice(end + 1));\n name += hex ? String.fromCodePoint(Number.parseInt(hex[0], 16)) : text[end + 1];\n end += 1 + (hex ? hex[0].length : 1);\n } else if (/[\\w\\u0080--]/u.test(next)) {\n name += next;\n end++;\n } else {\n break;\n }\n }\n return {\n name,\n end,\n };\n}\n\n/**\n * Serializes text as a CSS string.\n *\n * @param value - Text, such as generated CSS.\n * @returns A double-quoted CSS string whose escapes decode to `value`.\n */\nexport function cssString(value: string): string {\n return `\"${value\n .replace(/[\"\\\\]/g, \"\\\\$&\")\n .replace(/[\\n\\r\\f]/g, (character) => `\\\\${character.codePointAt(0)!.toString(16)} `)}\"`;\n}\n\n/**\n * Replaces every `&` outside strings and attribute selectors.\n *\n * @param selector - Selector that may contain `&`.\n * @param parent - Replacement for `&`.\n * @returns The selector with the parent substituted, or undefined when it has no `&`.\n */\nfunction substituteNesting(selector: string, parent: string): string | undefined {\n let output = \"\";\n let nested = false;\n let attribute = 0;\n let quote = \"\";\n for (let index = 0; index < selector.length; index++) {\n const char = selector[index];\n if (char === \"\\\\\") {\n output += selector.slice(index, index + 2);\n index++;\n continue;\n }\n if (quote) {\n quote = char === quote ? \"\" : quote;\n } else if (char === '\"' || char === \"'\") {\n quote = char;\n } else if (char === \"[\") {\n attribute++;\n } else if (char === \"]\") {\n attribute--;\n } else if (char === \"&\" && !attribute) {\n output += parent;\n nested = true;\n continue;\n }\n output += char;\n }\n return nested ? output : undefined;\n}\n\n/**\n * Converts the rules that `addUtilities()` receives into utility bodies. At-rules retain their\n * enclosing conditions.\n *\n * @param input - CSS-in-JS object keyed by selectors and at-rules, or an array of them.\n * @param register - Receives the anchor class of a selector and one body for it, once for each\n * selector of the body.\n * @param global - Receives top-level `@keyframes` and `@property` rules, which apply whether or\n * not a utility is used. The compiler emits such rules nested in a utility body only with that\n * utility.\n * @param wrappers - Enclosing at-rule preludes, outermost first.\n * @throws If a selector has no class outside `:not()` and attribute selectors, or if an\n * `@scope` rule encloses a selector.\n */\nexport function utilityRules(\n input: unknown,\n register: (name: string, body: string) => void,\n global: (css: string) => void,\n wrappers: string[] = [],\n): void {\n if (Array.isArray(input)) {\n for (const entry of input) {\n utilityRules(entry, register, global, wrappers);\n }\n return;\n }\n if (!input || typeof input !== \"object\") {\n return;\n }\n /**\n * Wraps CSS in the enclosing at-rules.\n * @param body - CSS inside the innermost at-rule.\n * @returns The wrapped CSS.\n */\n const wrap = (body: string) => wrappers.reduceRight((css, rule) => `${rule}{${css}}`, body);\n for (const [selector, body] of Object.entries(input)) {\n if (selector.startsWith(\"@keyframes \") || selector.startsWith(\"@property \")) {\n global(wrap(`${selector}{${serializeCss(body)}}`));\n } else if (scopeRule(selector)) {\n // A utility body is nested in its class rule, and nesting changes `@scope` there:\n // `.item{@scope (.theme){color:red}}` colors `.theme` elements inside `.item`, while\n // `@scope (.theme){.item{color:red}}` colors `.item` elements inside `.theme`.\n throw new Error(\n `Tailwind plugin utility selectors cannot be nested in @scope outside a selector: ${selector}`,\n );\n } else if (selector.startsWith(\"@\")) {\n utilityRules(body, register, global, [...wrappers, selector]);\n } else {\n for (const branch of splitTopLevel(selector, \",\").map((part) => part.trim())) {\n const classes = utilityClasses(branch);\n if (!classes.length) {\n throw new Error(`Tailwind plugin utility requires a class selector: ${selector}`);\n }\n // Each class becomes `&` in its own registration and stays literal in the others.\n for (const anchor of classes) {\n const relative = `${branch.slice(0, anchor.start)}&${branch.slice(anchor.end)}`;\n for (const css of utilityBodies(body, relative, wrappers)) {\n register(anchor.name, css);\n }\n }\n }\n }\n }\n}\n\n/**\n * Whether a CSS-in-JS key is an `@scope` rule.\n *\n * @param key - Entry key.\n * @returns Whether the key is `@scope` with or without a prelude.\n */\nfunction scopeRule(key: string): boolean {\n return /^@scope(?![\\w-])/.test(key);\n}\n\n/**\n * Lists the selectors of the nested rules in CSS-in-JS input, each as an empty rule, so that\n * the compiler can collect the classes that they name without the declarations.\n *\n * @param input - CSS-in-JS body, or an array of them.\n * @returns Each selector key as written followed by `{}`, in source order. Selectors inside\n * conditional at-rules are included, and `@keyframes` and `@property` rules are skipped.\n */\nexport function selectorRules(input: unknown): string[] {\n if (Array.isArray(input)) {\n return input.flatMap(selectorRules);\n }\n if (!input || typeof input !== \"object\") {\n return [];\n }\n const rules: string[] = [];\n for (const [key, value] of Object.entries(input)) {\n // An array of strings is a declaration with fallback values, as in `utilityBodies`.\n if (\n !value ||\n typeof value !== \"object\" ||\n statement(key, value) ||\n (Array.isArray(value) && !value.some((entry) => entry && typeof entry === \"object\")) ||\n key.startsWith(\"@keyframes \") ||\n key.startsWith(\"@property \")\n ) {\n continue;\n }\n if (!key.startsWith(\"@\")) {\n rules.push(`${key}{}`);\n }\n rules.push(...selectorRules(value));\n }\n return rules;\n}\n\n/**\n * Flattens nested selector rules into utility bodies with one selector block each, which the\n * compiler composes as independent targets.\n *\n * @param input - CSS-in-JS body, or an array of them.\n * @param selector - Selector of the body relative to the utility class, `&` for the class itself.\n * @param conditions - Enclosing at-rule preludes, outermost first.\n * @returns Bodies in source order. Each one is either declarations, possibly inside\n * conditions, for `&`, one rule for another selector, one `@scope` rule with its nested rules\n * for `&` or another selector, or one `@keyframes` or `@property` rule inside its conditions.\n */\nexport function utilityBodies(input: unknown, selector = \"&\", conditions: string[] = []): string[] {\n if (Array.isArray(input)) {\n return input.flatMap((entry) => utilityBodies(entry, selector, conditions));\n }\n if (!input || typeof input !== \"object\") {\n return [];\n }\n const result: string[] = [];\n let declarations: Record<string, unknown> = {};\n /**\n * Adds CSS as one body for the current selector inside the current conditions.\n *\n * @param css - Declarations or rules for the current selector.\n */\n const place = (css: string) => {\n const body = conditions.reduceRight((body, condition) => `${condition}{${body}}`, css);\n result.push(selector === \"&\" ? body : `${selector}{${body}}`);\n };\n /** Adds the declarations collected so far as one body and starts a new collection. */\n const flush = () => {\n const css = serializeCss(declarations);\n if (css) {\n place(css);\n }\n declarations = {};\n };\n for (const [key, value] of Object.entries(input)) {\n if (\n value &&\n typeof value === \"object\" &&\n !statement(key, value) &&\n (!Array.isArray(value) || value.some((entry) => entry && typeof entry === \"object\"))\n ) {\n flush();\n if (key.startsWith(\"@keyframes \") || key.startsWith(\"@property \")) {\n result.push(\n conditions.reduceRight(\n (body, condition) => `${condition}{${body}}`,\n `${key}{${serializeCss(value)}}`,\n ),\n );\n } else if (scopeRule(key)) {\n // Nested rules stay inside `@scope`, because `:scope` in a selector means the scoping\n // root only there. Moved out, `:where(:scope > :first-child)` from `@scope (&)` becomes\n // the prelude `& :where(:scope > :first-child)`, where `:scope` matches `:root`.\n place(`${key}{${serializeCss(value)}}`);\n } else if (key.startsWith(\"@\")) {\n result.push(...utilityBodies(value, selector, [...conditions, key]));\n } else {\n // Each target keeps one selector, because a utility body holds one selector block.\n for (const parent of splitTopLevel(selector, \",\").map((part) => part.trim())) {\n for (const child of splitTopLevel(key, \",\").map((part) => part.trim())) {\n result.push(\n ...utilityBodies(\n value,\n substituteNesting(child, parent) ?? `${parent} ${child}`,\n conditions,\n ),\n );\n }\n }\n }\n } else {\n declarations[key] = value;\n }\n }\n flush();\n return result;\n}\n\n/**\n * Splits text at a delimiter outside CSS strings, brackets, and function calls.\n *\n * @param value - Text to split. Escaped characters never delimit.\n * @param delimiter - One character, such as `,` or `/`.\n * @returns The parts without trimming, including empty ones. Text without the delimiter is one\n * part.\n */\nexport function splitTopLevel(value: string, delimiter: string): string[] {\n const parts: string[] = [];\n let start = 0;\n let depth = 0;\n let quote = \"\";\n for (let index = 0; index < value.length; index++) {\n const char = value[index];\n if (char === \"\\\\\") {\n index++;\n continue;\n }\n if (quote) {\n if (char === quote) {\n quote = \"\";\n }\n continue;\n }\n if (char === '\"' || char === \"'\") {\n quote = char;\n continue;\n }\n if (char === \"[\" || char === \"(\") {\n depth++;\n } else if (char === \"]\" || char === \")\") {\n depth--;\n } else if (depth === 0 && char === delimiter) {\n parts.push(value.slice(start, index));\n start = index + 1;\n }\n }\n parts.push(value.slice(start));\n return parts;\n}\n\n/**\n * Converts the declarations of a Tailwind `@plugin` options block into the values that\n * `plugin.withOptions()` factories receive.\n *\n * @param options - Declarations in authored order, such as `prefix` with the value `\"x\"`.\n * @returns Options by name, converted as Tailwind converts them. A later declaration of a\n * name replaces an earlier one. `true`, `false`, `null`, and numeric text become those values.\n * A quoted string loses its quotes and keeps its backslashes. Other text stays a string, and a\n * comma-separated list becomes an array.\n */\nexport function pluginOptions(options: readonly NativePluginOption[]): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const { name, value: text } of options) {\n const entries = splitTopLevel(text, \",\").map((part) => {\n const value = part.trim();\n if (value === \"true\") {\n return true;\n }\n if (value === \"false\") {\n return false;\n }\n if (value === \"null\") {\n return null;\n }\n if (!Number.isNaN(Number(value))) {\n return Number(value);\n }\n return (value.startsWith('\"') && value.endsWith('\"')) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\"))\n ? value.slice(1, -1)\n : value;\n });\n result[name] = entries.length === 1 ? entries[0] : entries;\n }\n return result;\n}\n","import type { NativePluginOption } from \"@stillwind/native\";\nimport type { PluginCreator, PluginWithConfig } from \"tailwindcss/plugin\";\n\nimport type { TailwindPlugin } from \"../host.ts\";\nimport { pluginOptions } from \"./css.ts\";\n\n/**\n * Normalizes a Tailwind plugin export to `{ handler, config }` and applies the options of its\n * `@plugin` statement.\n *\n * @param plugin - Handler, `{ handler, config }`, or factory from `plugin.withOptions()`.\n * @param options - Declarations of the statement's options block, empty without a block.\n * @returns The factory's result for converted `options`, or the plugin in object form.\n * @throws If a handler that is not a factory receives options, or an option value is invalid.\n */\nexport function configurePlugin(\n plugin: TailwindPlugin,\n options: readonly NativePluginOption[],\n): PluginWithConfig {\n if (\n typeof plugin === \"function\" &&\n \"__isOptionsFunction\" in plugin &&\n plugin.__isOptionsFunction\n ) {\n return (plugin as unknown as (options: Record<string, unknown>) => PluginWithConfig)(\n pluginOptions(options),\n );\n }\n if (options.length) {\n throw new Error(\"This Tailwind plugin does not accept options\");\n }\n return typeof plugin === \"function\"\n ? {\n handler: plugin as PluginCreator,\n }\n : (plugin as PluginWithConfig);\n}\n\n/**\n * Builds the part of Tailwind's resolved config that `config()` reads besides `theme`.\n *\n * Like Tailwind, the result keeps only `darkMode`, `prefix`, `blocklist`, and `important` from\n * the configs, so `config(\"custom\")` returns the fallback. The last config that defines one of\n * these keys sets it, and a `null` value restores the default.\n *\n * @param configs - Plugin configs in registration order, presets first.\n * @returns The resolved keys with Tailwind's defaults for the others.\n */\nexport function resolveConfig(\n configs: readonly Record<string, unknown>[],\n): Record<string, unknown> {\n const defaults: Record<string, unknown> = {\n darkMode: null,\n prefix: \"\",\n blocklist: [],\n important: false,\n };\n const result: Record<string, unknown> = {\n ...defaults,\n future: {},\n experimental: {},\n plugins: [],\n content: {\n files: [],\n },\n };\n for (const config of configs) {\n for (const [key, fallback] of Object.entries(defaults)) {\n if (config[key] !== undefined) {\n result[key] = config[key] ?? fallback;\n }\n }\n }\n return result;\n}\n\n/**\n * Returns the `dark` variant that Tailwind's `darkMode` configuration key defines.\n *\n * @param setting - `\"media\"`, `\"selector\"`, `\"class\"`, or a tuple of one of these modes and a\n * selector, which defaults to `.dark`. `[\"variant\", selectors]` uses a selector or a list of\n * selectors, and each must contain `&`.\n * @returns The value for `addVariant()`, or undefined when the setting defines no variant,\n * including `null`, `false`, and the `variant` mode with a selector that Tailwind rejects.\n */\nexport function darkModeVariant(setting: unknown): string | string[] | undefined {\n const [mode, selector = \".dark\"] = Array.isArray(setting) ? setting : [setting];\n switch (mode) {\n case \"media\":\n return \"@media (prefers-color-scheme: dark)\";\n\n case \"selector\":\n return `&:where(${selector}, ${selector} *)`;\n\n case \"class\":\n return `&:is(${selector} *)`;\n\n case \"variant\": {\n const selectors: unknown[] = Array.isArray(selector) ? selector : [selector];\n // Tailwind warns and defines no variant for the default selector or a selector without `&`.\n return selectors.every(\n (entry): entry is string =>\n typeof entry === \"string\" && entry !== \".dark\" && entry.includes(\"&\"),\n )\n ? (selectors as string[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OAAO,SAAS,KAAA,GAClB,OAAO,OAAO,OAAO,QAAQ;CAInC,OAAO;AACT;;;;;;;;;;AAWA,SAAgB,gBAAgB,SAAiD;CAC/E,MAAM,CAAC,MAAM,WAAW,WAAW,MAAM,QAAQ,OAAO,IAAI,UAAU,CAAC,OAAO;CAC9E,QAAQ,MAAR;EACE,KAAK,SACH,OAAO;EAET,KAAK,YACH,OAAO,WAAW,SAAS,IAAI,SAAS;EAE1C,KAAK,SACH,OAAO,QAAQ,SAAS;EAE1B,KAAK,WAAW;GACd,MAAM,YAAuB,MAAM,QAAQ,QAAQ,IAAI,WAAW,CAAC,QAAQ;GAE3E,OAAO,UAAU,OACd,UACC,OAAO,UAAU,YAAY,UAAU,WAAW,MAAM,SAAS,GAAG,CACxE,IACK,YACD,KAAA;EACN;EAEA,SACE;CACJ;AACF"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as compileWithPlugins, C as compileModule, D as fileSourceKind, E as cleanModuleId, M as prepareSourcePlugins, O as TypeFactsError, S as analyzeModule, T as CompilationFailure, _ as loadEditorCssGraph, a as pluginDirectory, b as cssBannerPrefix, c as CheckerSource, d as CompilationProject, f as sourceKey, g as loadCssGraph, h as lintsStylesheet, i as completePluginPaths, j as pluginLoader, k as attachPlugins, l as checkerId, m as isStylesheet, n as cssEntrypoint, o as queryPluginPaths, p as queryDesignSystem, r as StylesheetEditor, s as EditorSnapshot, t as compilerOptions, u as withRequestedProbes, v as PluginRuntime, w as warnRejectedNames, x as finalizeCss, y as defaultPluginExport } from "./options-
|
|
1
|
+
import { A as compileWithPlugins, C as compileModule, D as fileSourceKind, E as cleanModuleId, M as prepareSourcePlugins, O as TypeFactsError, S as analyzeModule, T as CompilationFailure, _ as loadEditorCssGraph, a as pluginDirectory, b as cssBannerPrefix, c as CheckerSource, d as CompilationProject, f as sourceKey, g as loadCssGraph, h as lintsStylesheet, i as completePluginPaths, j as pluginLoader, k as attachPlugins, l as checkerId, m as isStylesheet, n as cssEntrypoint, o as queryPluginPaths, p as queryDesignSystem, r as StylesheetEditor, s as EditorSnapshot, t as compilerOptions, u as withRequestedProbes, v as PluginRuntime, w as warnRejectedNames, x as finalizeCss, y as defaultPluginExport } from "./options-PMjJ1c8W.js";
|
|
2
2
|
import { createRequire, syncBuiltinESMExports } from "node:module";
|
|
3
3
|
import { NativeProjectSession, fingerprint } from "@stillwind/native";
|
|
4
4
|
import path, { isAbsolute, relative, resolve } from "node:path";
|
|
@@ -869,7 +869,7 @@ var AssetTypeDecoder = class {
|
|
|
869
869
|
return properties;
|
|
870
870
|
}
|
|
871
871
|
/**
|
|
872
|
-
* Discovers ref, keyframe,
|
|
872
|
+
* Discovers ref, keyframe, view-transition, and stored-variant brands in a producer type's declaring module.
|
|
873
873
|
*
|
|
874
874
|
* @param type - Producer call type from this decoder's checker snapshot. The type is retained for
|
|
875
875
|
* later decoding. Missing alias modules and already inspected modules are skipped. The discovered
|
|
@@ -895,6 +895,11 @@ var AssetTypeDecoder = class {
|
|
|
895
895
|
"StyleViewTransition",
|
|
896
896
|
"viewTransition",
|
|
897
897
|
"viewTransitionIdentity"
|
|
898
|
+
],
|
|
899
|
+
[
|
|
900
|
+
"StyleStoredVariant",
|
|
901
|
+
"storedVariant",
|
|
902
|
+
"storedVariantIdentity"
|
|
898
903
|
]
|
|
899
904
|
]) {
|
|
900
905
|
const symbol = this.#checker.getMemberInModuleExports(module, name);
|
|
@@ -947,7 +952,7 @@ var AssetTypeDecoder = class {
|
|
|
947
952
|
if (!candidateKind) continue;
|
|
948
953
|
const callable = candidateKind === "viewTransition" ? this.#property(constituent, "for") : void 0;
|
|
949
954
|
const method = callable && this.#checker.getTypeOfSymbol(callable);
|
|
950
|
-
if (!(candidateKind === "viewTransition" ? method && this.#checker.getSignaturesOfType(method, SignatureKind.Call).length > 0 : this.#checker.getSignaturesOfType(constituent, SignatureKind.Call).length > 0)) continue;
|
|
955
|
+
if (!(candidateKind === "storedVariant" || (candidateKind === "viewTransition" ? method && this.#checker.getSignaturesOfType(method, SignatureKind.Call).length > 0 : this.#checker.getSignaturesOfType(constituent, SignatureKind.Call).length > 0))) continue;
|
|
951
956
|
kind = candidateKind;
|
|
952
957
|
identityType = this.#checker.getTypeOfSymbol(brand);
|
|
953
958
|
if (kind === "ref" && identityType) {
|
|
@@ -957,7 +962,7 @@ var AssetTypeDecoder = class {
|
|
|
957
962
|
break;
|
|
958
963
|
}
|
|
959
964
|
const name = (constituent.getAliasSymbol() ?? constituent.getSymbol())?.name;
|
|
960
|
-
recognized ||= !!kind || !!name && /^Style(?:Result|Ref|Keyframes|ViewTransition)$/.test(name);
|
|
965
|
+
recognized ||= !!kind || !!name && /^Style(?:Result|Ref|Keyframes|ViewTransition|StoredVariant)$/.test(name);
|
|
961
966
|
if (!kind) {
|
|
962
967
|
valid = false;
|
|
963
968
|
continue;
|
|
@@ -993,7 +998,8 @@ var AssetTypeDecoder = class {
|
|
|
993
998
|
style: "styles",
|
|
994
999
|
ref: "refs",
|
|
995
1000
|
keyframes: "keyframes",
|
|
996
|
-
viewTransition: "viewTransitions"
|
|
1001
|
+
viewTransition: "viewTransitions",
|
|
1002
|
+
storedVariant: "storedVariants"
|
|
997
1003
|
}[family],
|
|
998
1004
|
value: symbolic(family, values)
|
|
999
1005
|
}
|
|
@@ -1238,7 +1244,7 @@ var TypeScriptFactsService = class {
|
|
|
1238
1244
|
diagnostics = [...project.program.getSyntacticDiagnostics(mapping.id), ...project.program.getSemanticDiagnostics(mapping.id)];
|
|
1239
1245
|
this.#checker.diagnostics.set(mapping.id, diagnostics);
|
|
1240
1246
|
}
|
|
1241
|
-
const diagnostic = diagnostics.find((d) => !producerArgumentDiagnostic(d, sourceFile, mapping) && /stillwind\/v1:|StyleResult|StyleRef|StyleKeyframes|StyleViewTransition|__stillwindDeclarationIdentity|data-__stillwindStyleIdentity/.test(diagnosticText(d)));
|
|
1247
|
+
const diagnostic = diagnostics.find((d) => !producerArgumentDiagnostic(d, sourceFile, mapping) && /stillwind\/v1:|StyleResult|StyleRef|StyleKeyframes|StyleViewTransition|StyleStoredVariant|__stillwindDeclarationIdentity|data-__stillwindStyleIdentity/.test(diagnosticText(d)));
|
|
1242
1248
|
if (diagnostic) {
|
|
1243
1249
|
const start = mapping.originalOffset(diagnostic.pos) ?? void 0;
|
|
1244
1250
|
const end = mapping.originalOffset(diagnostic.end, true) ?? void 0;
|