rune-grab 0.1.11 → 0.1.13
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/react.cjs +61 -32
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +61 -32
- package/dist/react.js.map +1 -1
- package/dist/rune-grab.cjs +61 -32
- package/dist/rune-grab.cjs.map +1 -1
- package/dist/rune-grab.iife.global.js +21 -21
- package/dist/rune-grab.iife.global.js.map +1 -1
- package/dist/rune-grab.js +61 -32
- package/dist/rune-grab.js.map +1 -1
- package/package.json +1 -1
package/dist/react.cjs
CHANGED
|
@@ -260,6 +260,9 @@ function isSourceFile(filePath) {
|
|
|
260
260
|
if (!filePath) return false;
|
|
261
261
|
if (isLibraryFile(filePath)) return false;
|
|
262
262
|
if (filePath.startsWith("webpack-internal:///node_modules/")) return false;
|
|
263
|
+
if (filePath.includes("_next/static/")) return false;
|
|
264
|
+
if (filePath.includes(".vite/deps/")) return false;
|
|
265
|
+
if (/^webpack[\w-]*\.js$/.test(filePath) || /[\\/]webpack[\w-]*\.js$/.test(filePath)) return false;
|
|
263
266
|
return true;
|
|
264
267
|
}
|
|
265
268
|
var SKIP_PREFIXES, STYLE_PROPS, STYLE_DEFAULTS, KEEP_ATTRS, Z_OVERLAY, Z_TOOLBAR, OWN_IDS, DRAG_THRESHOLD_PX, HELPER_PORT2, HEALTH_CHECK_TIMEOUT_MS, FLASH_VISIBLE_MS, FLASH_REMOVE_MS, LS_KEY;
|
|
@@ -1022,6 +1025,19 @@ function isUsefulName(name, filePath, customSkip) {
|
|
|
1022
1025
|
if (filePath && !isSourceFile(filePath)) return false;
|
|
1023
1026
|
return true;
|
|
1024
1027
|
}
|
|
1028
|
+
function isCleanComponentName(name, customSkip) {
|
|
1029
|
+
if (!name || name.length <= 1) return false;
|
|
1030
|
+
if (customSkip?.has(name)) return false;
|
|
1031
|
+
if (name[0] !== name[0].toUpperCase()) return false;
|
|
1032
|
+
for (const pfx of SKIP_PREFIXES) {
|
|
1033
|
+
if (name.startsWith(pfx)) return false;
|
|
1034
|
+
}
|
|
1035
|
+
if (/^[A-Z][a-zA-Z]+\d+$/.test(name)) return false;
|
|
1036
|
+
return true;
|
|
1037
|
+
}
|
|
1038
|
+
function isInfraName(name) {
|
|
1039
|
+
return /(?:Provider|Context|Consumer|Boundary|Wrapper|Root|Layout|Suspense)$/i.test(name);
|
|
1040
|
+
}
|
|
1025
1041
|
function cleanFilePath(raw) {
|
|
1026
1042
|
return raw.replace(/^https?:\/\/[^/]+\//, "").replace(/^rsc:\/\/[^/]+\/[^/]+\//, "").replace(/^webpack-internal:\/\/\//, "").replace(/^\([\w-]+\)\//, "").replace(/\?.*$/, "").replace(/^\/app\//, "").replace(/^\.\//, "");
|
|
1027
1043
|
}
|
|
@@ -1106,13 +1122,24 @@ function getReactComponentInfo(el, customSkip) {
|
|
|
1106
1122
|
if (!fiber) return null;
|
|
1107
1123
|
const elementSrc = getSourceFromFiber(fiber);
|
|
1108
1124
|
let isFirst = true;
|
|
1125
|
+
let fallback = null;
|
|
1109
1126
|
let cur = fiber;
|
|
1110
1127
|
while (cur) {
|
|
1128
|
+
let name = null;
|
|
1129
|
+
let src = null;
|
|
1111
1130
|
if (cur.type && typeof cur.type === "function") {
|
|
1112
|
-
|
|
1113
|
-
|
|
1131
|
+
name = cur.type.displayName || cur.type.name;
|
|
1132
|
+
src = isFirst && elementSrc ? elementSrc : getSourceFromFiber(cur);
|
|
1133
|
+
} else if (cur.type?.$$typeof) {
|
|
1134
|
+
const inner = cur.type.render || cur.type.type;
|
|
1135
|
+
name = cur.type.displayName || (inner && typeof inner === "function" ? inner.displayName || inner.name : null) || null;
|
|
1136
|
+
if (name) {
|
|
1137
|
+
src = isFirst && elementSrc ? elementSrc : getSourceFromFiber(cur);
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
if (name) {
|
|
1114
1141
|
const filePath = src?.fileName ? cleanFilePath(src.fileName) : null;
|
|
1115
|
-
if (
|
|
1142
|
+
if (filePath && isUsefulName(name, filePath, customSkip)) {
|
|
1116
1143
|
const info = {
|
|
1117
1144
|
name,
|
|
1118
1145
|
filePath,
|
|
@@ -1122,29 +1149,21 @@ function getReactComponentInfo(el, customSkip) {
|
|
|
1122
1149
|
if (src) storePendingResolution(info, src);
|
|
1123
1150
|
return info;
|
|
1124
1151
|
}
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
const src = isFirst && elementSrc ? elementSrc : getSourceFromFiber(cur);
|
|
1132
|
-
const filePath = src?.fileName ? cleanFilePath(src.fileName) : null;
|
|
1133
|
-
if (name && filePath && isUsefulName(name, filePath, customSkip)) {
|
|
1134
|
-
const info = {
|
|
1135
|
-
name,
|
|
1136
|
-
filePath,
|
|
1137
|
-
line: src?.lineNumber ?? null,
|
|
1138
|
-
column: src?.columnNumber ?? null
|
|
1139
|
-
};
|
|
1140
|
-
if (src) storePendingResolution(info, src);
|
|
1141
|
-
return info;
|
|
1142
|
-
}
|
|
1143
|
-
isFirst = false;
|
|
1152
|
+
if (!fallback && isCleanComponentName(name, customSkip) && !isInfraName(name)) {
|
|
1153
|
+
const validPath = filePath && isSourceFile(filePath) ? filePath : null;
|
|
1154
|
+
fallback = {
|
|
1155
|
+
info: { name, filePath: validPath, line: validPath ? src?.lineNumber ?? null : null, column: validPath ? src?.columnNumber ?? null : null },
|
|
1156
|
+
src: src || null
|
|
1157
|
+
};
|
|
1144
1158
|
}
|
|
1159
|
+
isFirst = false;
|
|
1145
1160
|
}
|
|
1146
1161
|
cur = cur.return;
|
|
1147
1162
|
}
|
|
1163
|
+
if (fallback) {
|
|
1164
|
+
if (fallback.src) storePendingResolution(fallback.info, fallback.src);
|
|
1165
|
+
return fallback.info;
|
|
1166
|
+
}
|
|
1148
1167
|
return null;
|
|
1149
1168
|
}
|
|
1150
1169
|
function getReactComponentStack(el, maxDepth = 6, customSkip) {
|
|
@@ -1152,7 +1171,9 @@ function getReactComponentStack(el, maxDepth = 6, customSkip) {
|
|
|
1152
1171
|
if (!fiber) return [];
|
|
1153
1172
|
const elementSrc = getSourceFromFiber(fiber);
|
|
1154
1173
|
const stack = [];
|
|
1174
|
+
const fallbackStack = [];
|
|
1155
1175
|
const seen = /* @__PURE__ */ new Set();
|
|
1176
|
+
const fallbackSeen = /* @__PURE__ */ new Set();
|
|
1156
1177
|
let cur = fiber;
|
|
1157
1178
|
let isFirst = true;
|
|
1158
1179
|
while (cur && stack.length < maxDepth) {
|
|
@@ -1163,22 +1184,30 @@ function getReactComponentStack(el, maxDepth = 6, customSkip) {
|
|
|
1163
1184
|
src = isFirst && elementSrc ? elementSrc : getSourceFromFiber(cur);
|
|
1164
1185
|
} else if (cur.type?.$$typeof) {
|
|
1165
1186
|
const inner = cur.type.render || cur.type.type;
|
|
1166
|
-
|
|
1167
|
-
|
|
1187
|
+
name = cur.type.displayName || (inner && typeof inner === "function" ? inner.displayName || inner.name : null) || null;
|
|
1188
|
+
if (name) {
|
|
1168
1189
|
src = isFirst && elementSrc ? elementSrc : getSourceFromFiber(cur);
|
|
1169
1190
|
}
|
|
1170
1191
|
}
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
seen.
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1192
|
+
if (name) {
|
|
1193
|
+
let filePath = src?.fileName ? cleanFilePath(src.fileName) : null;
|
|
1194
|
+
if (filePath && isUsefulName(name, filePath, customSkip) && !seen.has(name)) {
|
|
1195
|
+
seen.add(name);
|
|
1196
|
+
const frame = { name, filePath, line: src?.lineNumber ?? null };
|
|
1197
|
+
if (src) storePendingResolution(frame, src);
|
|
1198
|
+
stack.push(frame);
|
|
1199
|
+
isFirst = false;
|
|
1200
|
+
} else if (fallbackStack.length < maxDepth && isCleanComponentName(name, customSkip) && !isInfraName(name) && !fallbackSeen.has(name)) {
|
|
1201
|
+
fallbackSeen.add(name);
|
|
1202
|
+
const validPath = filePath && isSourceFile(filePath) ? filePath : null;
|
|
1203
|
+
const frame = { name, filePath: validPath, line: validPath ? src?.lineNumber ?? null : null };
|
|
1204
|
+
if (src) storePendingResolution(frame, src);
|
|
1205
|
+
fallbackStack.push(frame);
|
|
1206
|
+
}
|
|
1178
1207
|
}
|
|
1179
1208
|
cur = cur.return;
|
|
1180
1209
|
}
|
|
1181
|
-
return stack;
|
|
1210
|
+
return stack.length > 0 ? stack : fallbackStack;
|
|
1182
1211
|
}
|
|
1183
1212
|
function getVueComponentInfo(el) {
|
|
1184
1213
|
let cur = el;
|