mirror of
https://github.com/morluto/rea.git
synced 2026-11-12 01:41:21 +00:00
fix(javascript): preserve route flag values and lexical RPC names
This commit is contained in:
1 parent
ee0ad17a1a
commit
38ecc0248e
7 files changed
+144
-12
No files matched your search
@@ -169,8 +169,9 @@ const trpcLinkUrl = (
|
||||
* Create the per-source scan. Hook and option-factory methods are distinctive.
|
||||
* `query`/`mutate` need a root bound to a tRPC client factory, or a tRPC source
|
||||
* marker with a router path of at least two segments; `subscribe` needs the
|
||||
* marker and a tRPC observer argument. `this` roots, browser globals and RTK
|
||||
* Query `endpoints` chains are never procedures.
|
||||
* marker and a tRPC observer argument. Unshadowed browser globals and `this`
|
||||
* roots are excluded; RTK Query `endpoints` exclusions apply only without a
|
||||
* recognized client binding. Router segment spelling does not supply identity.
|
||||
*/
|
||||
export const createJavaScriptRpcScan = (
|
||||
source: string,
|
||||
@@ -187,15 +188,18 @@ export const createJavaScriptRpcScan = (
|
||||
): JavaScriptRpcEndpoint | undefined => {
|
||||
const path = memberPath(node.callee);
|
||||
if (path === undefined || t.isThisExpression(path.root)) return undefined;
|
||||
if (t.isIdentifier(path.root) && BROWSER_GLOBAL_NAMES.has(path.root.name))
|
||||
const bound = clientRoots.has(path.root);
|
||||
if (
|
||||
t.isIdentifier(path.root) &&
|
||||
BROWSER_GLOBAL_NAMES.has(path.root.name) &&
|
||||
index.bindingForReferenceAt(path.root) === undefined
|
||||
)
|
||||
return undefined;
|
||||
const method = path.properties[path.properties.length - 1];
|
||||
const segments = path.properties.slice(0, -1);
|
||||
const first = segments[0];
|
||||
if (method === undefined || first === undefined) return undefined;
|
||||
if (BROWSER_GLOBAL_NAMES.has(first) || segments.includes("endpoints"))
|
||||
return undefined;
|
||||
const bound = clientRoots.has(path.root);
|
||||
if (!bound && segments.includes("endpoints")) return undefined;
|
||||
const recognized = TRPC_HOOK_METHODS.has(method)
|
||||
? true
|
||||
: TRPC_REQUEST_METHODS.has(method)
|
||||
|
||||
Reference in new issue
Block a user