synthesisui 0.16.343 → 0.16.344
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/doctor/transcribe.js +65 -0
- package/package.json +1 -1
|
@@ -2029,8 +2029,27 @@ export function definitionSpan(source, name) {
|
|
|
2029
2029
|
const decl = new RegExp(`(?:function|const|let|var)\\s+${name}\\b|${name}\\s*[:=]\\s*(?:function|\\()`).exec(source);
|
|
2030
2030
|
if (!decl)
|
|
2031
2031
|
return null;
|
|
2032
|
+
/**
|
|
2033
|
+
* O CORPO PODE NÃO TER CHAVE NENHUMA - `forwardRef((props, ref) => (<div/>))`.
|
|
2034
|
+
*
|
|
2035
|
+
* O QUE O CLIENTE PERDIA: esta é a forma canônica de uma biblioteca de componentes (o shadcn/ui
|
|
2036
|
+
* escreve assim), e para ela `bodyBrace` não acha `{` de corpo - o arrow retorna direto. O span
|
|
2037
|
+
* voltava `null`, e sem span `variantCallsIn` devolve lista vazia: a tabela `cva` do componente
|
|
2038
|
+
* NÃO era ligada a ele, e o censo gravava classe vazia num componente que declara seis linhas de
|
|
2039
|
+
* base. Ele abre o Studio e vê a caixa pelada.
|
|
2040
|
+
*
|
|
2041
|
+
* REPRODUZIDO EM 31/08, com a mesma tabela e o mesmo call site, variando só o corpo:
|
|
2042
|
+
*
|
|
2043
|
+
* forwardRef(({ s }, ref) => { return <div className={cn(v({s}))}/> }) a tabela e' ligada
|
|
2044
|
+
* forwardRef(({ s }, ref) => (<div className={cn(v({s}))}/>)) lista VAZIA
|
|
2045
|
+
*
|
|
2046
|
+
* O corpo aqui é delimitado pelo parêntese do PRÓPRIO wrapper, e é ele que fecha o span.
|
|
2047
|
+
*/
|
|
2032
2048
|
const brace = bodyBrace(source, decl.index);
|
|
2033
2049
|
if (brace === -1) {
|
|
2050
|
+
const implicito = implicitBodySpan(source, decl.index);
|
|
2051
|
+
if (implicito)
|
|
2052
|
+
return { from: decl.index, to: implicito };
|
|
2034
2053
|
// The export is an alias; the body belongs to what it wraps.
|
|
2035
2054
|
const target = aliasTarget(source, name);
|
|
2036
2055
|
if (target)
|
|
@@ -2040,6 +2059,52 @@ export function definitionSpan(source, name) {
|
|
|
2040
2059
|
const end = matchingBrace(source, brace);
|
|
2041
2060
|
return { from: decl.index, to: end === -1 ? source.length : end + 1 };
|
|
2042
2061
|
}
|
|
2062
|
+
/**
|
|
2063
|
+
* ONDE FECHA UM CORPO SEM CHAVE - `= forwardRef((props, ref) => (<div/>))`, e nada mais.
|
|
2064
|
+
*
|
|
2065
|
+
* Ela só responde para a forma que `bodyBrace` não sabe ler: um wrapper reconhecido, seguido de um
|
|
2066
|
+
* arrow cujo corpo abre em PARÊNTESE. Um arrow com chaves, uma função nomeada ou qualquer outra
|
|
2067
|
+
* coisa devolve `null` e o caminho antigo segue intacto - esta é uma porta a mais, nunca um desvio
|
|
2068
|
+
* do que já funcionava.
|
|
2069
|
+
*
|
|
2070
|
+
* O fecho é o parêntese do próprio wrapper, contado com atenção a aspas: um `)` dentro de
|
|
2071
|
+
* `color = "rgba(0,0,0,.2)"` não fecha nada, e foi essa mesma armadilha que já custou a raiz de
|
|
2072
|
+
* sete componentes de um cliente.
|
|
2073
|
+
*/
|
|
2074
|
+
function implicitBodySpan(source, declAt) {
|
|
2075
|
+
const head = source.slice(declAt, declAt + 400);
|
|
2076
|
+
const wrapper = /=\s*(?:React\.)?(?:forwardRef|memo|styled\([^)]*\))\s*(?:<[^(]*>)?\s*\(/.exec(head);
|
|
2077
|
+
if (!wrapper)
|
|
2078
|
+
return null;
|
|
2079
|
+
const open = declAt + wrapper.index + wrapper[0].length - 1;
|
|
2080
|
+
const rest = source.slice(open);
|
|
2081
|
+
const arrow = /=>\s*[({]/.exec(rest);
|
|
2082
|
+
/** Corpo em chave é do `bodyBrace`; aqui só entra o retorno implícito. */
|
|
2083
|
+
if (!arrow || arrow[0].trimEnd().endsWith("{"))
|
|
2084
|
+
return null;
|
|
2085
|
+
let depth = 0;
|
|
2086
|
+
let quote = null;
|
|
2087
|
+
for (let i = open; i < source.length; i++) {
|
|
2088
|
+
const ch = source[i];
|
|
2089
|
+
if (quote) {
|
|
2090
|
+
if (ch === "\\")
|
|
2091
|
+
i += 1;
|
|
2092
|
+
else if (ch === quote)
|
|
2093
|
+
quote = null;
|
|
2094
|
+
continue;
|
|
2095
|
+
}
|
|
2096
|
+
if (ch === '"' || ch === "'" || ch === "`")
|
|
2097
|
+
quote = ch;
|
|
2098
|
+
else if (ch === "(")
|
|
2099
|
+
depth += 1;
|
|
2100
|
+
else if (ch === ")") {
|
|
2101
|
+
depth -= 1;
|
|
2102
|
+
if (depth === 0)
|
|
2103
|
+
return i + 1;
|
|
2104
|
+
}
|
|
2105
|
+
}
|
|
2106
|
+
return null;
|
|
2107
|
+
}
|
|
2043
2108
|
/** The `{` that opens a function body declared at `declAt`, or -1. */
|
|
2044
2109
|
function bodyBrace(source, declAt) {
|
|
2045
2110
|
/**
|
package/package.json
CHANGED