@jskit-ai/architecture-inspector 0.1.0 → 0.1.1

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.
@@ -0,0 +1,30 @@
1
+ // Vue Preview locator: a classic script a Preview bridge can inline. It defines
2
+ // globalThis.__vibe64LocateElement(element), which returns the nearest project
3
+ // component that rendered the element in a Vue development build, as
4
+ // { file, name? } with the file as the build reports it, or null. It reads only
5
+ // Vue's own component bookkeeping (`__vueParentComponent`, the component's
6
+ // parent and its `__file`/`name`), never an element's text or value.
7
+ (function defineVueLocator() {
8
+ "use strict";
9
+ var MAX_STEPS = 512;
10
+
11
+ function projectComponent(instance) {
12
+ for (var current = instance, steps = 0; current && steps < MAX_STEPS; current = current.parent, steps += 1) {
13
+ var type = current.type;
14
+ if (type && typeof type.__file === "string" && type.__file) {
15
+ var name = type.name || type.__name;
16
+ return typeof name === "string" && name ? { file: type.__file, name: name } : { file: type.__file };
17
+ }
18
+ }
19
+ return null;
20
+ }
21
+
22
+ globalThis.__vibe64LocateElement = function locateElement(element) {
23
+ for (var node = element, steps = 0; node && steps < MAX_STEPS; node = node.parentNode, steps += 1) {
24
+ if (node.__vueParentComponent) {
25
+ return projectComponent(node.__vueParentComponent);
26
+ }
27
+ }
28
+ return null;
29
+ };
30
+ })();