@archie/devtools 0.0.38 → 0.0.39
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.
|
@@ -82,6 +82,26 @@ function babelPluginEditorMeta({ types: t }, opts = {}) {
|
|
|
82
82
|
const propertyName = name.property.name;
|
|
83
83
|
return propertyName[0] === propertyName[0].toLowerCase();
|
|
84
84
|
}
|
|
85
|
+
function isStaticNamespaceDestructure(binding) {
|
|
86
|
+
const bp = binding.path;
|
|
87
|
+
if (!bp.isVariableDeclarator()) return false;
|
|
88
|
+
if (!t.isObjectPattern(bp.node.id)) return false;
|
|
89
|
+
if (!binding.constant) return false;
|
|
90
|
+
const decl = bp.parentPath;
|
|
91
|
+
if (decl?.isVariableDeclaration() && decl.node.kind !== "const") return false;
|
|
92
|
+
let init = bp.node.init;
|
|
93
|
+
while (init && (t.isTSAsExpression(init) || t.isTSNonNullExpression(init) || t.isTypeCastExpression(init))) {
|
|
94
|
+
init = init.expression;
|
|
95
|
+
}
|
|
96
|
+
while (init && t.isMemberExpression(init) && !init.computed) {
|
|
97
|
+
init = init.object;
|
|
98
|
+
}
|
|
99
|
+
if (!init || !t.isIdentifier(init)) return false;
|
|
100
|
+
const rootBinding = bp.scope.getBinding(init.name);
|
|
101
|
+
if (!rootBinding) return true;
|
|
102
|
+
if (!rootBinding.constant) return false;
|
|
103
|
+
return rootBinding.scope === rootBinding.scope.getProgramParent();
|
|
104
|
+
}
|
|
85
105
|
function computeNodeId(file, line, col, componentName) {
|
|
86
106
|
return `${file}:${line}:${col}:${componentName}`;
|
|
87
107
|
}
|
|
@@ -509,7 +529,8 @@ function babelPluginEditorMeta({ types: t }, opts = {}) {
|
|
|
509
529
|
}
|
|
510
530
|
}
|
|
511
531
|
const programScope = path2.scope.getProgramParent();
|
|
512
|
-
if (binding.scope !== programScope)
|
|
532
|
+
if (binding.scope !== programScope && !isStaticNamespaceDestructure(binding))
|
|
533
|
+
return;
|
|
513
534
|
}
|
|
514
535
|
}
|
|
515
536
|
const nodeId = computeNodeId(file, line, col, componentName);
|
package/dist/index.js
CHANGED
|
@@ -281,6 +281,26 @@ function babelPluginEditorMeta({ types: t }, opts = {}) {
|
|
|
281
281
|
const propertyName = name.property.name;
|
|
282
282
|
return propertyName[0] === propertyName[0].toLowerCase();
|
|
283
283
|
}
|
|
284
|
+
function isStaticNamespaceDestructure(binding) {
|
|
285
|
+
const bp = binding.path;
|
|
286
|
+
if (!bp.isVariableDeclarator()) return false;
|
|
287
|
+
if (!t.isObjectPattern(bp.node.id)) return false;
|
|
288
|
+
if (!binding.constant) return false;
|
|
289
|
+
const decl = bp.parentPath;
|
|
290
|
+
if (decl?.isVariableDeclaration() && decl.node.kind !== "const") return false;
|
|
291
|
+
let init = bp.node.init;
|
|
292
|
+
while (init && (t.isTSAsExpression(init) || t.isTSNonNullExpression(init) || t.isTypeCastExpression(init))) {
|
|
293
|
+
init = init.expression;
|
|
294
|
+
}
|
|
295
|
+
while (init && t.isMemberExpression(init) && !init.computed) {
|
|
296
|
+
init = init.object;
|
|
297
|
+
}
|
|
298
|
+
if (!init || !t.isIdentifier(init)) return false;
|
|
299
|
+
const rootBinding = bp.scope.getBinding(init.name);
|
|
300
|
+
if (!rootBinding) return true;
|
|
301
|
+
if (!rootBinding.constant) return false;
|
|
302
|
+
return rootBinding.scope === rootBinding.scope.getProgramParent();
|
|
303
|
+
}
|
|
284
304
|
function computeNodeId(file, line, col, componentName) {
|
|
285
305
|
return `${file}:${line}:${col}:${componentName}`;
|
|
286
306
|
}
|
|
@@ -708,7 +728,8 @@ function babelPluginEditorMeta({ types: t }, opts = {}) {
|
|
|
708
728
|
}
|
|
709
729
|
}
|
|
710
730
|
const programScope = path.scope.getProgramParent();
|
|
711
|
-
if (binding.scope !== programScope)
|
|
731
|
+
if (binding.scope !== programScope && !isStaticNamespaceDestructure(binding))
|
|
732
|
+
return;
|
|
712
733
|
}
|
|
713
734
|
}
|
|
714
735
|
const nodeId = computeNodeId(file, line, col, componentName);
|
package/dist/index.mjs
CHANGED