react-code-locator 0.1.4
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/README.md +243 -0
- package/dist/babel.cjs +152 -0
- package/dist/babel.cjs.map +1 -0
- package/dist/babel.d.cts +2 -0
- package/dist/babel.d.ts +2 -0
- package/dist/babel.js +115 -0
- package/dist/babel.js.map +1 -0
- package/dist/babelInjectComponentSource.cjs +150 -0
- package/dist/babelInjectComponentSource.cjs.map +1 -0
- package/dist/babelInjectComponentSource.d.cts +12 -0
- package/dist/babelInjectComponentSource.d.ts +12 -0
- package/dist/babelInjectComponentSource.js +115 -0
- package/dist/babelInjectComponentSource.js.map +1 -0
- package/dist/client.cjs +153 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +14 -0
- package/dist/client.d.ts +14 -0
- package/dist/client.js +125 -0
- package/dist/client.js.map +1 -0
- package/dist/index.cjs +153 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +125 -0
- package/dist/index.js.map +1 -0
- package/dist/vite.cjs +211 -0
- package/dist/vite.cjs.map +1 -0
- package/dist/vite.d.cts +13 -0
- package/dist/vite.d.ts +13 -0
- package/dist/vite.js +173 -0
- package/dist/vite.js.map +1 -0
- package/dist/webpack.cjs +68 -0
- package/dist/webpack.cjs.map +1 -0
- package/dist/webpack.d.cts +2 -0
- package/dist/webpack.d.ts +2 -0
- package/dist/webpack.js +82 -0
- package/dist/webpack.js.map +1 -0
- package/dist/webpackRuntimeEntry.cjs +128 -0
- package/dist/webpackRuntimeEntry.cjs.map +1 -0
- package/dist/webpackRuntimeEntry.d.cts +2 -0
- package/dist/webpackRuntimeEntry.d.ts +2 -0
- package/dist/webpackRuntimeEntry.js +126 -0
- package/dist/webpackRuntimeEntry.js.map +1 -0
- package/package.json +64 -0
package/dist/vite.js
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
// src/elementLocatorReact.ts
|
|
2
|
+
import react from "@vitejs/plugin-react";
|
|
3
|
+
|
|
4
|
+
// src/babelInjectComponentSource.ts
|
|
5
|
+
import path from "path";
|
|
6
|
+
import { types as t } from "@babel/core";
|
|
7
|
+
|
|
8
|
+
// src/constants.ts
|
|
9
|
+
var SOURCE_PROP = "__componentSourceLoc";
|
|
10
|
+
|
|
11
|
+
// src/babelInjectComponentSource.ts
|
|
12
|
+
function isComponentName(name) {
|
|
13
|
+
return /^[A-Z]/.test(name);
|
|
14
|
+
}
|
|
15
|
+
function getSourceValue(state, loc) {
|
|
16
|
+
const filename = state.file?.opts?.filename;
|
|
17
|
+
if (!filename || !loc) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const relPath = path.relative(process.cwd(), filename).replace(/\\/g, "/");
|
|
21
|
+
return `${relPath}:${loc.line}:${loc.column + 1}`;
|
|
22
|
+
}
|
|
23
|
+
function buildAssignment(name, sourceValue) {
|
|
24
|
+
return t.expressionStatement(
|
|
25
|
+
t.assignmentExpression(
|
|
26
|
+
"=",
|
|
27
|
+
t.memberExpression(t.identifier(name), t.identifier(SOURCE_PROP)),
|
|
28
|
+
t.stringLiteral(sourceValue)
|
|
29
|
+
)
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
function visitDeclaration(declarationPath, insertAfterPath, state, seen) {
|
|
33
|
+
if (declarationPath.isFunctionDeclaration() || declarationPath.isClassDeclaration()) {
|
|
34
|
+
const name = declarationPath.node.id?.name;
|
|
35
|
+
if (!name || !isComponentName(name) || seen.has(name)) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const sourceValue = getSourceValue(state, declarationPath.node.loc?.start);
|
|
39
|
+
if (!sourceValue) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
seen.add(name);
|
|
43
|
+
insertAfterPath.insertAfter(buildAssignment(name, sourceValue));
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (!declarationPath.isVariableDeclaration()) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const assignments = declarationPath.node.declarations.flatMap((declarator) => {
|
|
50
|
+
if (!t.isIdentifier(declarator.id) || !isComponentName(declarator.id.name) || seen.has(declarator.id.name)) {
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
if (!declarator.init) {
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
56
|
+
if (!t.isArrowFunctionExpression(declarator.init) && !t.isFunctionExpression(declarator.init)) {
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
const sourceValue = getSourceValue(state, declarator.loc?.start ?? declarator.init.loc?.start);
|
|
60
|
+
if (!sourceValue) {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
seen.add(declarator.id.name);
|
|
64
|
+
return [buildAssignment(declarator.id.name, sourceValue)];
|
|
65
|
+
});
|
|
66
|
+
if (assignments.length > 0) {
|
|
67
|
+
insertAfterPath.insertAfter(assignments);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function babelInjectComponentSource() {
|
|
71
|
+
return {
|
|
72
|
+
name: "babel-inject-component-source",
|
|
73
|
+
visitor: {
|
|
74
|
+
JSXOpeningElement(pathNode, state) {
|
|
75
|
+
const hasSourceProp = pathNode.node.attributes.some(
|
|
76
|
+
(attr) => t.isJSXAttribute(attr) && t.isJSXIdentifier(attr.name) && attr.name.name === "__source"
|
|
77
|
+
);
|
|
78
|
+
if (hasSourceProp) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const filename = state.file?.opts?.filename;
|
|
82
|
+
const loc = pathNode.node.loc?.start;
|
|
83
|
+
if (!filename || !loc) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
pathNode.node.attributes.push(
|
|
87
|
+
t.jsxAttribute(
|
|
88
|
+
t.jsxIdentifier("__source"),
|
|
89
|
+
t.jsxExpressionContainer(
|
|
90
|
+
t.objectExpression([
|
|
91
|
+
t.objectProperty(t.identifier("fileName"), t.stringLiteral(filename)),
|
|
92
|
+
t.objectProperty(t.identifier("lineNumber"), t.numericLiteral(loc.line)),
|
|
93
|
+
t.objectProperty(t.identifier("columnNumber"), t.numericLiteral(loc.column + 1))
|
|
94
|
+
])
|
|
95
|
+
)
|
|
96
|
+
)
|
|
97
|
+
);
|
|
98
|
+
},
|
|
99
|
+
Program(programPath, state) {
|
|
100
|
+
const seen = /* @__PURE__ */ new Set();
|
|
101
|
+
for (const childPath of programPath.get("body")) {
|
|
102
|
+
if (childPath.isExportNamedDeclaration() || childPath.isExportDefaultDeclaration()) {
|
|
103
|
+
const declarationPath = childPath.get("declaration");
|
|
104
|
+
if (!Array.isArray(declarationPath) && declarationPath.node) {
|
|
105
|
+
visitDeclaration(declarationPath, childPath, state, seen);
|
|
106
|
+
}
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
visitDeclaration(childPath, childPath, state, seen);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// src/elementLocatorReact.ts
|
|
117
|
+
function withLocatorBabel(reactOptions = {}) {
|
|
118
|
+
const baseBabel = reactOptions.babel;
|
|
119
|
+
if (typeof baseBabel === "function") {
|
|
120
|
+
return {
|
|
121
|
+
...reactOptions,
|
|
122
|
+
babel(id, options) {
|
|
123
|
+
const result = baseBabel(id, options);
|
|
124
|
+
const resolved2 = result ?? {};
|
|
125
|
+
const plugins = [...resolved2.plugins ?? [], babelInjectComponentSource];
|
|
126
|
+
return {
|
|
127
|
+
...resolved2,
|
|
128
|
+
plugins
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
const resolved = baseBabel ?? {};
|
|
134
|
+
return {
|
|
135
|
+
...reactOptions,
|
|
136
|
+
babel: {
|
|
137
|
+
...resolved,
|
|
138
|
+
plugins: [...resolved.plugins ?? [], babelInjectComponentSource]
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function createClientInjector(locatorOptions = {}) {
|
|
143
|
+
const serialized = JSON.stringify(locatorOptions);
|
|
144
|
+
return {
|
|
145
|
+
name: "element-locator-client-injector",
|
|
146
|
+
apply: "serve",
|
|
147
|
+
transformIndexHtml() {
|
|
148
|
+
return [
|
|
149
|
+
{
|
|
150
|
+
tag: "script",
|
|
151
|
+
attrs: {
|
|
152
|
+
type: "module"
|
|
153
|
+
},
|
|
154
|
+
children: `import { enableReactComponentJump } from "react-component-jump/client"; enableReactComponentJump(${serialized});`,
|
|
155
|
+
injectTo: "head"
|
|
156
|
+
}
|
|
157
|
+
];
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function elementLocatorReact(options = {}) {
|
|
162
|
+
const { command = "serve", react: reactOptions, locator = {}, injectClient = true } = options;
|
|
163
|
+
const isServe = command === "serve";
|
|
164
|
+
return [
|
|
165
|
+
react(isServe ? withLocatorBabel(reactOptions) : reactOptions),
|
|
166
|
+
isServe && injectClient ? createClientInjector(locator) : null
|
|
167
|
+
].filter(Boolean);
|
|
168
|
+
}
|
|
169
|
+
export {
|
|
170
|
+
elementLocatorReact,
|
|
171
|
+
elementLocatorReact as reactComponentJump
|
|
172
|
+
};
|
|
173
|
+
//# sourceMappingURL=vite.js.map
|
package/dist/vite.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/elementLocatorReact.ts","../src/babelInjectComponentSource.ts","../src/constants.ts"],"sourcesContent":["import type { TransformOptions, PluginItem } from \"@babel/core\";\nimport react, { type Options as ReactOptions } from \"@vitejs/plugin-react\";\nimport type { Plugin, PluginOption } from \"vite\";\nimport { babelInjectComponentSource } from \"./babelInjectComponentSource\";\nimport { type LocatorOptions } from \"./runtime\";\n\nexport type ElementLocatorReactOptions = {\n command?: \"serve\" | \"build\";\n react?: ReactOptions;\n locator?: LocatorOptions;\n injectClient?: boolean;\n};\n\nfunction withLocatorBabel(reactOptions: ReactOptions = {}): ReactOptions {\n const baseBabel = reactOptions.babel;\n\n if (typeof baseBabel === \"function\") {\n return {\n ...reactOptions,\n babel(id, options) {\n const result = baseBabel(id, options);\n const resolved = (result ?? {}) as TransformOptions;\n const plugins = [...(resolved.plugins ?? []), babelInjectComponentSource as PluginItem];\n\n return {\n ...resolved,\n plugins,\n };\n },\n };\n }\n\n const resolved = (baseBabel ?? {}) as TransformOptions;\n return {\n ...reactOptions,\n babel: {\n ...resolved,\n plugins: [...(resolved.plugins ?? []), babelInjectComponentSource as PluginItem],\n },\n };\n}\n\nfunction createClientInjector(locatorOptions: LocatorOptions = {}): Plugin {\n const serialized = JSON.stringify(locatorOptions);\n\n return {\n name: \"element-locator-client-injector\",\n apply: \"serve\",\n transformIndexHtml() {\n return [\n {\n tag: \"script\",\n attrs: {\n type: \"module\",\n },\n children: `import { enableReactComponentJump } from \"react-component-jump/client\"; enableReactComponentJump(${serialized});`,\n injectTo: \"head\",\n },\n ];\n },\n };\n}\n\nexport function elementLocatorReact(options: ElementLocatorReactOptions = {}): PluginOption[] {\n const { command = \"serve\", react: reactOptions, locator = {}, injectClient = true } = options;\n const isServe = command === \"serve\";\n\n return [\n react(isServe ? withLocatorBabel(reactOptions) : reactOptions),\n isServe && injectClient ? createClientInjector(locator) : null,\n ].filter(Boolean);\n}\n","import path from \"node:path\";\nimport { types as t, type NodePath, type PluginObj } from \"@babel/core\";\nimport { SOURCE_PROP } from \"./constants\";\n\ntype BabelState = {\n file?: {\n opts?: {\n filename?: string;\n };\n };\n};\n\nfunction isComponentName(name: string) {\n return /^[A-Z]/.test(name);\n}\n\nfunction getSourceValue(state: BabelState, loc: { line: number; column: number } | null | undefined) {\n const filename = state.file?.opts?.filename;\n if (!filename || !loc) {\n return null;\n }\n\n const relPath = path.relative(process.cwd(), filename).replace(/\\\\/g, \"/\");\n return `${relPath}:${loc.line}:${loc.column + 1}`;\n}\n\nfunction buildAssignment(name: string, sourceValue: string) {\n return t.expressionStatement(\n t.assignmentExpression(\n \"=\",\n t.memberExpression(t.identifier(name), t.identifier(SOURCE_PROP)),\n t.stringLiteral(sourceValue),\n ),\n );\n}\n\nfunction visitDeclaration(\n declarationPath: NodePath,\n insertAfterPath: NodePath,\n state: BabelState,\n seen: Set<string>,\n) {\n if (declarationPath.isFunctionDeclaration() || declarationPath.isClassDeclaration()) {\n const name = declarationPath.node.id?.name;\n if (!name || !isComponentName(name) || seen.has(name)) {\n return;\n }\n\n const sourceValue = getSourceValue(state, declarationPath.node.loc?.start);\n if (!sourceValue) {\n return;\n }\n\n seen.add(name);\n insertAfterPath.insertAfter(buildAssignment(name, sourceValue));\n return;\n }\n\n if (!declarationPath.isVariableDeclaration()) {\n return;\n }\n\n const assignments = declarationPath.node.declarations.flatMap((declarator) => {\n if (!t.isIdentifier(declarator.id) || !isComponentName(declarator.id.name) || seen.has(declarator.id.name)) {\n return [];\n }\n\n if (!declarator.init) {\n return [];\n }\n\n if (!t.isArrowFunctionExpression(declarator.init) && !t.isFunctionExpression(declarator.init)) {\n return [];\n }\n\n const sourceValue = getSourceValue(state, declarator.loc?.start ?? declarator.init.loc?.start);\n if (!sourceValue) {\n return [];\n }\n\n seen.add(declarator.id.name);\n return [buildAssignment(declarator.id.name, sourceValue)];\n });\n\n if (assignments.length > 0) {\n insertAfterPath.insertAfter(assignments);\n }\n}\n\nexport function babelInjectComponentSource(): PluginObj<BabelState> {\n return {\n name: \"babel-inject-component-source\",\n visitor: {\n JSXOpeningElement(pathNode, state) {\n const hasSourceProp = pathNode.node.attributes.some(\n (attr) => t.isJSXAttribute(attr) && t.isJSXIdentifier(attr.name) && attr.name.name === \"__source\",\n );\n if (hasSourceProp) {\n return;\n }\n\n const filename = state.file?.opts?.filename;\n const loc = pathNode.node.loc?.start;\n if (!filename || !loc) {\n return;\n }\n\n pathNode.node.attributes.push(\n t.jsxAttribute(\n t.jsxIdentifier(\"__source\"),\n t.jsxExpressionContainer(\n t.objectExpression([\n t.objectProperty(t.identifier(\"fileName\"), t.stringLiteral(filename)),\n t.objectProperty(t.identifier(\"lineNumber\"), t.numericLiteral(loc.line)),\n t.objectProperty(t.identifier(\"columnNumber\"), t.numericLiteral(loc.column + 1)),\n ]),\n ),\n ),\n );\n },\n Program(programPath, state) {\n const seen = new Set<string>();\n\n for (const childPath of programPath.get(\"body\")) {\n if (childPath.isExportNamedDeclaration() || childPath.isExportDefaultDeclaration()) {\n const declarationPath = childPath.get(\"declaration\");\n if (!Array.isArray(declarationPath) && declarationPath.node) {\n visitDeclaration(declarationPath, childPath, state, seen);\n }\n continue;\n }\n\n visitDeclaration(childPath, childPath, state, seen);\n }\n },\n },\n };\n}\n","export const SOURCE_PROP = \"__componentSourceLoc\";\n\n"],"mappings":";AACA,OAAO,WAA6C;;;ACDpD,OAAO,UAAU;AACjB,SAAS,SAAS,SAAwC;;;ACDnD,IAAM,cAAc;;;ADY3B,SAAS,gBAAgB,MAAc;AACrC,SAAO,SAAS,KAAK,IAAI;AAC3B;AAEA,SAAS,eAAe,OAAmB,KAA0D;AACnG,QAAM,WAAW,MAAM,MAAM,MAAM;AACnC,MAAI,CAAC,YAAY,CAAC,KAAK;AACrB,WAAO;AAAA,EACT;AAEA,QAAM,UAAU,KAAK,SAAS,QAAQ,IAAI,GAAG,QAAQ,EAAE,QAAQ,OAAO,GAAG;AACzE,SAAO,GAAG,OAAO,IAAI,IAAI,IAAI,IAAI,IAAI,SAAS,CAAC;AACjD;AAEA,SAAS,gBAAgB,MAAc,aAAqB;AAC1D,SAAO,EAAE;AAAA,IACP,EAAE;AAAA,MACA;AAAA,MACA,EAAE,iBAAiB,EAAE,WAAW,IAAI,GAAG,EAAE,WAAW,WAAW,CAAC;AAAA,MAChE,EAAE,cAAc,WAAW;AAAA,IAC7B;AAAA,EACF;AACF;AAEA,SAAS,iBACP,iBACA,iBACA,OACA,MACA;AACA,MAAI,gBAAgB,sBAAsB,KAAK,gBAAgB,mBAAmB,GAAG;AACnF,UAAM,OAA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AACjB,cAAM,SAAS,UAAU,IAAI,OAAO;AACpC,cAAMA,YAAY,UAAU,CAAC;AAC7B,cAAM,UAAU,CAAC,GAAIA,UAAS,WAAW,CAAC,GAAI,0BAAwC;AAEtF,eAAO;AAAA,UACL,GAAGA;AAAA,UACH;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,WAAY,aAAa,CAAC;AAChC,SAAO;AAAA,IACL,GAAG;AAAA,IACH,OAAO;AAAA,MACL,GAAG;AAAA,MACH,SAAS,CAAC,GAAI,SAAS,WAAW,CAAC,GAAI,0BAAwC;AAAA,IACjF;AAAA,EACF;AACF;AAEA,SAAS,qBAAqB,iBAAiC,CAAC,GAAW;AACzE,QAAM,aAAa,KAAK,UAAU,cAAc;AAEhD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,IACP,qBAAqB;AACnB,aAAO;AAAA,QACL;AAAA,UACE,KAAK;AAAA,UACL,OAAO;AAAA,YACL,MAAM;AAAA,UACR;AAAA,UACA,UAAU,oGAAoG,UAAU;AAAA,UACxH,UAAU;AAAA,QACZ;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEO,SAAS,oBAAoB,UAAsC,CAAC,GAAmB;AAC5F,QAAM,EAAE,UAAU,SAAS,OAAO,cAAc,UAAU,CAAC,GAAG,eAAe,KAAK,IAAI;AACtF,QAAM,UAAU,YAAY;AAE5B,SAAO;AAAA,IACL,MAAM,UAAU,iBAAiB,YAAY,IAAI,YAAY;AAAA,IAC7D,WAAW,eAAe,qBAAqB,OAAO,IAAI;AAAA,EAC5D,EAAE,OAAO,OAAO;AAClB;","names":["resolved"]}
|
package/dist/webpack.cjs
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// src/webpack.cts
|
|
4
|
+
var path = require("path");
|
|
5
|
+
function injectEntry(entry, runtimeEntry) {
|
|
6
|
+
if (!entry) {
|
|
7
|
+
return entry;
|
|
8
|
+
}
|
|
9
|
+
if (typeof entry === "string") {
|
|
10
|
+
return [runtimeEntry, entry];
|
|
11
|
+
}
|
|
12
|
+
if (Array.isArray(entry)) {
|
|
13
|
+
return [runtimeEntry, ...entry];
|
|
14
|
+
}
|
|
15
|
+
return Object.fromEntries(
|
|
16
|
+
Object.entries(entry).map(([key, value]) => {
|
|
17
|
+
if (Array.isArray(value)) {
|
|
18
|
+
return [key, [runtimeEntry, ...value]];
|
|
19
|
+
}
|
|
20
|
+
return [key, [runtimeEntry, value]];
|
|
21
|
+
})
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
function patchRules(rules, babelPluginPath) {
|
|
25
|
+
if (!rules) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
for (const rule of rules) {
|
|
29
|
+
if (rule.oneOf) {
|
|
30
|
+
patchRules(rule.oneOf, babelPluginPath);
|
|
31
|
+
}
|
|
32
|
+
if (rule.loader?.includes("babel-loader")) {
|
|
33
|
+
rule.options = {
|
|
34
|
+
...rule.options ?? {},
|
|
35
|
+
plugins: [...rule.options?.plugins ?? [], babelPluginPath]
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
if (rule.use) {
|
|
39
|
+
rule.use = rule.use.map((useEntry) => {
|
|
40
|
+
if (!useEntry.loader?.includes("babel-loader")) {
|
|
41
|
+
return useEntry;
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
...useEntry,
|
|
45
|
+
options: {
|
|
46
|
+
...useEntry.options ?? {},
|
|
47
|
+
plugins: [...useEntry.options?.plugins ?? [], babelPluginPath]
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function withReactComponentJump(config, options = {}) {
|
|
55
|
+
const { env = process.env.NODE_ENV ?? "development" } = options;
|
|
56
|
+
if (env !== "development") {
|
|
57
|
+
return config;
|
|
58
|
+
}
|
|
59
|
+
const babelPluginPath = path.join(__dirname, "babelInjectComponentSource.cjs");
|
|
60
|
+
const runtimeEntry = path.join(__dirname, "webpackRuntimeEntry.cjs");
|
|
61
|
+
patchRules(config.module?.rules, babelPluginPath);
|
|
62
|
+
config.entry = injectEntry(config.entry, runtimeEntry);
|
|
63
|
+
return config;
|
|
64
|
+
}
|
|
65
|
+
module.exports = {
|
|
66
|
+
withReactComponentJump
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=webpack.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/webpack.cts"],"sourcesContent":["const path = require(\"node:path\");\n\ntype WebpackAdapterOptions = {\n env?: \"development\" | \"production\" | string;\n};\n\ntype Rule = {\n oneOf?: Rule[];\n use?: Array<{ loader?: string; options?: { plugins?: unknown[] } }>;\n loader?: string;\n options?: { plugins?: unknown[] };\n};\n\ntype WebpackConfig = {\n entry?: string | string[] | Record<string, string | string[]>;\n module?: {\n rules?: Rule[];\n };\n};\n\nfunction injectEntry(entry: WebpackConfig[\"entry\"], runtimeEntry: string) {\n if (!entry) {\n return entry;\n }\n\n if (typeof entry === \"string\") {\n return [runtimeEntry, entry];\n }\n\n if (Array.isArray(entry)) {\n return [runtimeEntry, ...entry];\n }\n\n return Object.fromEntries(\n Object.entries(entry).map(([key, value]) => {\n if (Array.isArray(value)) {\n return [key, [runtimeEntry, ...value]];\n }\n\n return [key, [runtimeEntry, value]];\n }),\n );\n}\n\nfunction patchRules(rules: Rule[] | undefined, babelPluginPath: string) {\n if (!rules) {\n return;\n }\n\n for (const rule of rules) {\n if (rule.oneOf) {\n patchRules(rule.oneOf, babelPluginPath);\n }\n\n if (rule.loader?.includes(\"babel-loader\")) {\n rule.options = {\n ...(rule.options ?? {}),\n plugins: [...(rule.options?.plugins ?? []), babelPluginPath],\n };\n }\n\n if (rule.use) {\n rule.use = rule.use.map((useEntry) => {\n if (!useEntry.loader?.includes(\"babel-loader\")) {\n return useEntry;\n }\n\n return {\n ...useEntry,\n options: {\n ...(useEntry.options ?? {}),\n plugins: [...(useEntry.options?.plugins ?? []), babelPluginPath],\n },\n };\n });\n }\n }\n}\n\nfunction withReactComponentJump(config: WebpackConfig, options: WebpackAdapterOptions = {}) {\n const { env = process.env.NODE_ENV ?? \"development\" } = options;\n if (env !== \"development\") {\n return config;\n }\n\n const babelPluginPath = path.join(__dirname, \"babelInjectComponentSource.cjs\");\n const runtimeEntry = path.join(__dirname, \"webpackRuntimeEntry.cjs\");\n\n patchRules(config.module?.rules, babelPluginPath);\n config.entry = injectEntry(config.entry, runtimeEntry);\n return config;\n}\n\nmodule.exports = {\n withReactComponentJump,\n};\n"],"mappings":";;;AAAA,IAAM,OAAO,QAAQ,MAAW;AAoBhC,SAAS,YAAY,OAA+B,cAAsB;AACxE,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,CAAC,cAAc,KAAK;AAAA,EAC7B;AAEA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,CAAC,cAAc,GAAG,KAAK;AAAA,EAChC;AAEA,SAAO,OAAO;AAAA,IACZ,OAAO,QAAQ,KAAK,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM;AAC1C,UAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,eAAO,CAAC,KAAK,CAAC,cAAc,GAAG,KAAK,CAAC;AAAA,MACvC;AAEA,aAAO,CAAC,KAAK,CAAC,cAAc,KAAK,CAAC;AAAA,IACpC,CAAC;AAAA,EACH;AACF;AAEA,SAAS,WAAW,OAA2B,iBAAyB;AACtE,MAAI,CAAC,OAAO;AACV;AAAA,EACF;AAEA,aAAW,QAAQ,OAAO;AACxB,QAAI,KAAK,OAAO;AACd,iBAAW,KAAK,OAAO,eAAe;AAAA,IACxC;AAEA,QAAI,KAAK,QAAQ,SAAS,cAAc,GAAG;AACzC,WAAK,UAAU;AAAA,QACb,GAAI,KAAK,WAAW,CAAC;AAAA,QACrB,SAAS,CAAC,GAAI,KAAK,SAAS,WAAW,CAAC,GAAI,eAAe;AAAA,MAC7D;AAAA,IACF;AAEA,QAAI,KAAK,KAAK;AACZ,WAAK,MAAM,KAAK,IAAI,IAAI,CAAC,aAAa;AACpC,YAAI,CAAC,SAAS,QAAQ,SAAS,cAAc,GAAG;AAC9C,iBAAO;AAAA,QACT;AAEA,eAAO;AAAA,UACL,GAAG;AAAA,UACH,SAAS;AAAA,YACP,GAAI,SAAS,WAAW,CAAC;AAAA,YACzB,SAAS,CAAC,GAAI,SAAS,SAAS,WAAW,CAAC,GAAI,eAAe;AAAA,UACjE;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEA,SAAS,uBAAuB,QAAuB,UAAiC,CAAC,GAAG;AAC1F,QAAM,EAAE,MAAM,QAAQ,IAAI,YAAY,cAAc,IAAI;AACxD,MAAI,QAAQ,eAAe;AACzB,WAAO;AAAA,EACT;AAEA,QAAM,kBAAkB,KAAK,KAAK,WAAW,gCAAgC;AAC7E,QAAM,eAAe,KAAK,KAAK,WAAW,yBAAyB;AAEnE,aAAW,OAAO,QAAQ,OAAO,eAAe;AAChD,SAAO,QAAQ,YAAY,OAAO,OAAO,YAAY;AACrD,SAAO;AACT;AAEA,OAAO,UAAU;AAAA,EACf;AACF;","names":[]}
|
package/dist/webpack.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
|
+
}) : x)(function(x) {
|
|
5
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// src/webpack.cts
|
|
13
|
+
var require_webpack = __commonJS({
|
|
14
|
+
"src/webpack.cts"(exports, module) {
|
|
15
|
+
var path = __require("path");
|
|
16
|
+
function injectEntry(entry, runtimeEntry) {
|
|
17
|
+
if (!entry) {
|
|
18
|
+
return entry;
|
|
19
|
+
}
|
|
20
|
+
if (typeof entry === "string") {
|
|
21
|
+
return [runtimeEntry, entry];
|
|
22
|
+
}
|
|
23
|
+
if (Array.isArray(entry)) {
|
|
24
|
+
return [runtimeEntry, ...entry];
|
|
25
|
+
}
|
|
26
|
+
return Object.fromEntries(
|
|
27
|
+
Object.entries(entry).map(([key, value]) => {
|
|
28
|
+
if (Array.isArray(value)) {
|
|
29
|
+
return [key, [runtimeEntry, ...value]];
|
|
30
|
+
}
|
|
31
|
+
return [key, [runtimeEntry, value]];
|
|
32
|
+
})
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
function patchRules(rules, babelPluginPath) {
|
|
36
|
+
if (!rules) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
for (const rule of rules) {
|
|
40
|
+
if (rule.oneOf) {
|
|
41
|
+
patchRules(rule.oneOf, babelPluginPath);
|
|
42
|
+
}
|
|
43
|
+
if (rule.loader?.includes("babel-loader")) {
|
|
44
|
+
rule.options = {
|
|
45
|
+
...rule.options ?? {},
|
|
46
|
+
plugins: [...rule.options?.plugins ?? [], babelPluginPath]
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (rule.use) {
|
|
50
|
+
rule.use = rule.use.map((useEntry) => {
|
|
51
|
+
if (!useEntry.loader?.includes("babel-loader")) {
|
|
52
|
+
return useEntry;
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
...useEntry,
|
|
56
|
+
options: {
|
|
57
|
+
...useEntry.options ?? {},
|
|
58
|
+
plugins: [...useEntry.options?.plugins ?? [], babelPluginPath]
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function withReactComponentJump(config, options = {}) {
|
|
66
|
+
const { env = process.env.NODE_ENV ?? "development" } = options;
|
|
67
|
+
if (env !== "development") {
|
|
68
|
+
return config;
|
|
69
|
+
}
|
|
70
|
+
const babelPluginPath = path.join(__dirname, "babelInjectComponentSource.cjs");
|
|
71
|
+
const runtimeEntry = path.join(__dirname, "webpackRuntimeEntry.cjs");
|
|
72
|
+
patchRules(config.module?.rules, babelPluginPath);
|
|
73
|
+
config.entry = injectEntry(config.entry, runtimeEntry);
|
|
74
|
+
return config;
|
|
75
|
+
}
|
|
76
|
+
module.exports = {
|
|
77
|
+
withReactComponentJump
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
export default require_webpack();
|
|
82
|
+
//# sourceMappingURL=webpack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/webpack.cts"],"sourcesContent":["const path = require(\"node:path\");\n\ntype WebpackAdapterOptions = {\n env?: \"development\" | \"production\" | string;\n};\n\ntype Rule = {\n oneOf?: Rule[];\n use?: Array<{ loader?: string; options?: { plugins?: unknown[] } }>;\n loader?: string;\n options?: { plugins?: unknown[] };\n};\n\ntype WebpackConfig = {\n entry?: string | string[] | Record<string, string | string[]>;\n module?: {\n rules?: Rule[];\n };\n};\n\nfunction injectEntry(entry: WebpackConfig[\"entry\"], runtimeEntry: string) {\n if (!entry) {\n return entry;\n }\n\n if (typeof entry === \"string\") {\n return [runtimeEntry, entry];\n }\n\n if (Array.isArray(entry)) {\n return [runtimeEntry, ...entry];\n }\n\n return Object.fromEntries(\n Object.entries(entry).map(([key, value]) => {\n if (Array.isArray(value)) {\n return [key, [runtimeEntry, ...value]];\n }\n\n return [key, [runtimeEntry, value]];\n }),\n );\n}\n\nfunction patchRules(rules: Rule[] | undefined, babelPluginPath: string) {\n if (!rules) {\n return;\n }\n\n for (const rule of rules) {\n if (rule.oneOf) {\n patchRules(rule.oneOf, babelPluginPath);\n }\n\n if (rule.loader?.includes(\"babel-loader\")) {\n rule.options = {\n ...(rule.options ?? {}),\n plugins: [...(rule.options?.plugins ?? []), babelPluginPath],\n };\n }\n\n if (rule.use) {\n rule.use = rule.use.map((useEntry) => {\n if (!useEntry.loader?.includes(\"babel-loader\")) {\n return useEntry;\n }\n\n return {\n ...useEntry,\n options: {\n ...(useEntry.options ?? {}),\n plugins: [...(useEntry.options?.plugins ?? []), babelPluginPath],\n },\n };\n });\n }\n }\n}\n\nfunction withReactComponentJump(config: WebpackConfig, options: WebpackAdapterOptions = {}) {\n const { env = process.env.NODE_ENV ?? \"development\" } = options;\n if (env !== \"development\") {\n return config;\n }\n\n const babelPluginPath = path.join(__dirname, \"babelInjectComponentSource.cjs\");\n const runtimeEntry = path.join(__dirname, \"webpackRuntimeEntry.cjs\");\n\n patchRules(config.module?.rules, babelPluginPath);\n config.entry = injectEntry(config.entry, runtimeEntry);\n return config;\n}\n\nmodule.exports = {\n withReactComponentJump,\n};\n"],"mappings":";;;;;;;;;;;;AAAA;AAAA;AAAA,QAAM,OAAO,UAAQ,MAAW;AAoBhC,aAAS,YAAY,OAA+B,cAAsB;AACxE,UAAI,CAAC,OAAO;AACV,eAAO;AAAA,MACT;AAEA,UAAI,OAAO,UAAU,UAAU;AAC7B,eAAO,CAAC,cAAc,KAAK;AAAA,MAC7B;AAEA,UAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,eAAO,CAAC,cAAc,GAAG,KAAK;AAAA,MAChC;AAEA,aAAO,OAAO;AAAA,QACZ,OAAO,QAAQ,KAAK,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM;AAC1C,cAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,mBAAO,CAAC,KAAK,CAAC,cAAc,GAAG,KAAK,CAAC;AAAA,UACvC;AAEA,iBAAO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@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// src/constants.ts
|
|
4
|
+
var SOURCE_PROP = "__componentSourceLoc";
|
|
5
|
+
|
|
6
|
+
// src/runtime.ts
|
|
7
|
+
function isTriggerPressed(event, triggerKey) {
|
|
8
|
+
if (triggerKey === "none") {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
if (triggerKey === "alt") {
|
|
12
|
+
return event.altKey;
|
|
13
|
+
}
|
|
14
|
+
if (triggerKey === "meta") {
|
|
15
|
+
return event.metaKey;
|
|
16
|
+
}
|
|
17
|
+
if (triggerKey === "ctrl") {
|
|
18
|
+
return event.ctrlKey;
|
|
19
|
+
}
|
|
20
|
+
return event.shiftKey;
|
|
21
|
+
}
|
|
22
|
+
function getReactFiberKey(element) {
|
|
23
|
+
return Object.keys(element).find((key) => key.startsWith("__reactFiber$") || key.startsWith("__reactInternalInstance$"));
|
|
24
|
+
}
|
|
25
|
+
function getClosestReactFiber(target) {
|
|
26
|
+
let current = target;
|
|
27
|
+
while (current) {
|
|
28
|
+
const fiberKey = getReactFiberKey(current);
|
|
29
|
+
if (fiberKey) {
|
|
30
|
+
return current[fiberKey];
|
|
31
|
+
}
|
|
32
|
+
current = current.parentElement;
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
function getSourceFromType(type) {
|
|
37
|
+
if (!type) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
if (typeof type === "function") {
|
|
41
|
+
const source2 = type[SOURCE_PROP];
|
|
42
|
+
return typeof source2 === "string" ? source2 : null;
|
|
43
|
+
}
|
|
44
|
+
if (typeof type !== "object") {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const record = type;
|
|
48
|
+
const source = record[SOURCE_PROP] ?? record.type?.[SOURCE_PROP] ?? record.render?.[SOURCE_PROP];
|
|
49
|
+
return typeof source === "string" ? source : null;
|
|
50
|
+
}
|
|
51
|
+
function resolveSourceFromFiber(fiber) {
|
|
52
|
+
let current = fiber;
|
|
53
|
+
while (current) {
|
|
54
|
+
const source = getSourceFromType(current.type) ?? getSourceFromType(current.elementType);
|
|
55
|
+
if (source) {
|
|
56
|
+
return source;
|
|
57
|
+
}
|
|
58
|
+
current = current.return ?? null;
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
function getDebugSource(fiber) {
|
|
63
|
+
let current = fiber;
|
|
64
|
+
while (current) {
|
|
65
|
+
const debugSource = current._debugSource;
|
|
66
|
+
if (debugSource?.fileName && typeof debugSource.lineNumber === "number") {
|
|
67
|
+
return `${debugSource.fileName.replace(/\\/g, "/")}:${debugSource.lineNumber}:${debugSource.columnNumber ?? 1}`;
|
|
68
|
+
}
|
|
69
|
+
current = current.return ?? null;
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
function locateComponentSource(target) {
|
|
74
|
+
const elementTarget = target instanceof Element ? target : target instanceof Node ? target.parentElement : null;
|
|
75
|
+
const fiber = getClosestReactFiber(elementTarget);
|
|
76
|
+
if (!fiber) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
const debugSource = getDebugSource(fiber);
|
|
80
|
+
if (debugSource) {
|
|
81
|
+
return {
|
|
82
|
+
source: debugSource,
|
|
83
|
+
mode: "jsx"
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
const componentSource = resolveSourceFromFiber(fiber);
|
|
87
|
+
if (!componentSource) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
source: componentSource,
|
|
92
|
+
mode: "component"
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function enableReactComponentJump(options = {}) {
|
|
96
|
+
const {
|
|
97
|
+
triggerKey = "shift",
|
|
98
|
+
onLocate = (result) => {
|
|
99
|
+
console.log(`[react-component-jump] ${result.source}`);
|
|
100
|
+
},
|
|
101
|
+
onError = (error) => {
|
|
102
|
+
console.error("[react-component-jump]", error);
|
|
103
|
+
}
|
|
104
|
+
} = options;
|
|
105
|
+
const handler = (event) => {
|
|
106
|
+
if (!isTriggerPressed(event, triggerKey)) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const result = locateComponentSource(event.target);
|
|
110
|
+
if (!result) {
|
|
111
|
+
onError(new Error("No React component source metadata found for clicked element."));
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
event.preventDefault();
|
|
115
|
+
event.stopPropagation();
|
|
116
|
+
onLocate(result);
|
|
117
|
+
};
|
|
118
|
+
document.addEventListener("click", handler, true);
|
|
119
|
+
return () => {
|
|
120
|
+
document.removeEventListener("click", handler, true);
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// src/webpackRuntimeEntry.ts
|
|
125
|
+
if (typeof document !== "undefined") {
|
|
126
|
+
enableReactComponentJump();
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=webpackRuntimeEntry.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/constants.ts","../src/runtime.ts","../src/webpackRuntimeEntry.ts"],"sourcesContent":["export const SOURCE_PROP = \"__componentSourceLoc\";\n\n","import { SOURCE_PROP } from \"./constants\";\n\nexport type TriggerKey = \"alt\" | \"meta\" | \"ctrl\" | \"shift\" | \"none\";\n\ntype ReactFiber = {\n return?: ReactFiber | null;\n type?: unknown;\n elementType?: unknown;\n _debugSource?: {\n fileName?: string;\n lineNumber?: number;\n columnNumber?: number;\n } | null;\n};\n\nexport type LocatorResult = {\n source: string;\n mode: \"jsx\" | \"component\";\n};\n\nexport type LocatorOptions = {\n triggerKey?: TriggerKey;\n onLocate?: (result: LocatorResult) => void;\n onError?: (error: unknown) => void;\n};\n\nfunction isTriggerPressed(event: MouseEvent, triggerKey: TriggerKey) {\n if (triggerKey === \"none\") {\n return true;\n }\n\n if (triggerKey === \"alt\") {\n return event.altKey;\n }\n\n if (triggerKey === \"meta\") {\n return event.metaKey;\n }\n\n if (triggerKey === \"ctrl\") {\n return event.ctrlKey;\n }\n\n return event.shiftKey;\n}\n\nfunction getReactFiberKey(element: Element) {\n return Object.keys(element).find((key) => key.startsWith(\"__reactFiber$\") || key.startsWith(\"__reactInternalInstance$\"));\n}\n\nfunction getClosestReactFiber(target: Element | null) {\n let current = target;\n\n while (current) {\n const fiberKey = getReactFiberKey(current);\n if (fiberKey) {\n return (current as unknown as Record<string, unknown>)[fiberKey] as ReactFiber;\n }\n\n current = current.parentElement;\n }\n\n return null;\n}\n\nfunction getSourceFromType(type: unknown) {\n if (!type) {\n return null;\n }\n\n if (typeof type === \"function\") {\n const source = (type as unknown as Record<string, unknown>)[SOURCE_PROP];\n return typeof source === \"string\" ? source : null;\n }\n\n if (typeof type !== \"object\") {\n return null;\n }\n\n const record = type as {\n type?: Record<string, unknown>;\n render?: Record<string, unknown>;\n [SOURCE_PROP]?: unknown;\n };\n\n const source = record[SOURCE_PROP] ?? record.type?.[SOURCE_PROP] ?? record.render?.[SOURCE_PROP];\n return typeof source === \"string\" ? source : null;\n}\n\nfunction resolveSourceFromFiber(fiber: ReactFiber | null) {\n let current = fiber;\n\n while (current) {\n const source = getSourceFromType(current.type) ?? getSourceFromType(current.elementType);\n if (source) {\n return source;\n }\n\n current = current.return ?? null;\n }\n\n return null;\n}\n\nfunction getDebugSource(fiber: ReactFiber | null) {\n let current = fiber;\n\n while (current) {\n const debugSource = current._debugSource;\n if (debugSource?.fileName && typeof debugSource.lineNumber === \"number\") {\n return `${debugSource.fileName.replace(/\\\\/g, \"/\")}:${debugSource.lineNumber}:${debugSource.columnNumber ?? 1}`;\n }\n\n current = current.return ?? null;\n }\n\n return null;\n}\n\nexport function locateComponentSource(target: EventTarget | null): LocatorResult | null {\n const elementTarget =\n target instanceof Element ? target : target instanceof Node ? target.parentElement : null;\n const fiber = getClosestReactFiber(elementTarget);\n if (!fiber) {\n return null;\n }\n\n const debugSource = getDebugSource(fiber);\n if (debugSource) {\n return {\n source: debugSource,\n mode: \"jsx\",\n };\n }\n\n const componentSource = resolveSourceFromFiber(fiber);\n if (!componentSource) {\n return null;\n }\n\n return {\n source: componentSource,\n mode: \"component\",\n };\n}\n\nexport function enableReactComponentJump(options: LocatorOptions = {}) {\n const {\n triggerKey = \"shift\",\n onLocate = (result) => {\n console.log(`[react-component-jump] ${result.source}`);\n },\n onError = (error) => {\n console.error(\"[react-component-jump]\", error);\n },\n } = options;\n\n const handler = (event: MouseEvent) => {\n if (!isTriggerPressed(event, triggerKey)) {\n return;\n }\n\n const result = locateComponentSource(event.target);\n if (!result) {\n onError(new Error(\"No React component source metadata found for clicked element.\"));\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n onLocate(result);\n };\n\n document.addEventListener(\"click\", handler, true);\n\n return () => {\n document.removeEventListener(\"click\", handler, true);\n };\n}\n","import { enableReactComponentJump } from \"./runtime\";\n\nif (typeof document !== \"undefined\") {\n enableReactComponentJump();\n}\n\n"],"mappings":";;;AAAO,IAAM,cAAc;;;AC0B3B,SAAS,iBAAiB,OAAmB,YAAwB;AACnE,MAAI,eAAe,QAAQ;AACzB,WAAO;AAAA,EACT;AAEA,MAAI,eAAe,OAAO;AACxB,WAAO,MAAM;AAAA,EACf;AAEA,MAAI,eAAe,QAAQ;AACzB,WAAO,MAAM;AAAA,EACf;AAEA,MAAI,eAAe,QAAQ;AACzB,WAAO,MAAM;AAAA,EACf;AAEA,SAAO,MAAM;AACf;AAEA,SAAS,iBAAiB,SAAkB;AAC1C,SAAO,OAAO,KAAK,OAAO,EAAE,KAAK,CAAC,QAAQ,IAAI,WAAW,eAAe,KAAK,IAAI,WAAW,0BAA0B,CAAC;AACzH;AAEA,SAAS,qBAAqB,QAAwB;AACpD,MAAI,UAAU;AAEd,SAAO,SAAS;AACd,UAAM,WAAW,iBAAiB,OAAO;AACzC,QAAI,UAAU;AACZ,aAAQ,QAA+C,QAAQ;AAAA,IACjE;AAEA,cAAU,QAAQ;AAA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A,QAAM,kBAAkB,uBAAuB,KAAK;AACpD,MAAI,CAAC,iBAAiB;AACpB,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,QAAQ;AAAA,IACR,MAAM;AAAA,EACR;AACF;AAEO,SAAS,yBAAyB,UAA0B,CAAC,GAAG;AACrE,QAAM;AAAA,IACJ,aAAa;AAAA,IACb,WAAW,CAAC,WAAW;AACrB,cAAQ,IAAI,0BAA0B,OAAO,MAAM,EAAE;AAAA,IACvD;AAAA,IACA,UAAU,CAAC,UAAU;AACnB,cAAQ,MAAM,0BAA0B,KAAK;AAAA,IAC/C;AAAA,EACF,IAAI;AAEJ,QAAM,UAAU,CAAC,UAAsB;AACrC,QAAI,CAAC,iBAAiB,OAAO,UAAU,GAAG;AACxC;AAAA,IACF;AAEA,UAAM,SAAS,sBAAsB,MAAM,MAAM;AACjD,QAAI,CAAC,QAAQ;AACX,cAAQ,IAAI,MAAM,+DAA+D,CAAC;AAClF;AAAA,IACF;AAEA,UAAM,eAAe;AACrB,UAAM,gBAAgB;AACtB,aAAS,MAAM;AAAA,EACjB;AAEA,WAAS,iBAAiB,SAAS,SAAS,IAAI;AAEhD,SAAO,MAAM;AACX,aAAS,oBAAoB,SAAS,SAAS,IAAI;AAAA,EACrD;AACF;;;AChLA,IAAI,OAAO,aAAa,aAAa;AACnC,2BAAyB;AAC3B;","names":["source"]}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// src/constants.ts
|
|
2
|
+
var SOURCE_PROP = "__componentSourceLoc";
|
|
3
|
+
|
|
4
|
+
// src/runtime.ts
|
|
5
|
+
function isTriggerPressed(event, triggerKey) {
|
|
6
|
+
if (triggerKey === "none") {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
if (triggerKey === "alt") {
|
|
10
|
+
return event.altKey;
|
|
11
|
+
}
|
|
12
|
+
if (triggerKey === "meta") {
|
|
13
|
+
return event.metaKey;
|
|
14
|
+
}
|
|
15
|
+
if (triggerKey === "ctrl") {
|
|
16
|
+
return event.ctrlKey;
|
|
17
|
+
}
|
|
18
|
+
return event.shiftKey;
|
|
19
|
+
}
|
|
20
|
+
function getReactFiberKey(element) {
|
|
21
|
+
return Object.keys(element).find((key) => key.startsWith("__reactFiber$") || key.startsWith("__reactInternalInstance$"));
|
|
22
|
+
}
|
|
23
|
+
function getClosestReactFiber(target) {
|
|
24
|
+
let current = target;
|
|
25
|
+
while (current) {
|
|
26
|
+
const fiberKey = getReactFiberKey(current);
|
|
27
|
+
if (fiberKey) {
|
|
28
|
+
return current[fiberKey];
|
|
29
|
+
}
|
|
30
|
+
current = current.parentElement;
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
function getSourceFromType(type) {
|
|
35
|
+
if (!type) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
if (typeof type === "function") {
|
|
39
|
+
const source2 = type[SOURCE_PROP];
|
|
40
|
+
return typeof source2 === "string" ? source2 : null;
|
|
41
|
+
}
|
|
42
|
+
if (typeof type !== "object") {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const record = type;
|
|
46
|
+
const source = record[SOURCE_PROP] ?? record.type?.[SOURCE_PROP] ?? record.render?.[SOURCE_PROP];
|
|
47
|
+
return typeof source === "string" ? source : null;
|
|
48
|
+
}
|
|
49
|
+
function resolveSourceFromFiber(fiber) {
|
|
50
|
+
let current = fiber;
|
|
51
|
+
while (current) {
|
|
52
|
+
const source = getSourceFromType(current.type) ?? getSourceFromType(current.elementType);
|
|
53
|
+
if (source) {
|
|
54
|
+
return source;
|
|
55
|
+
}
|
|
56
|
+
current = current.return ?? null;
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
function getDebugSource(fiber) {
|
|
61
|
+
let current = fiber;
|
|
62
|
+
while (current) {
|
|
63
|
+
const debugSource = current._debugSource;
|
|
64
|
+
if (debugSource?.fileName && typeof debugSource.lineNumber === "number") {
|
|
65
|
+
return `${debugSource.fileName.replace(/\\/g, "/")}:${debugSource.lineNumber}:${debugSource.columnNumber ?? 1}`;
|
|
66
|
+
}
|
|
67
|
+
current = current.return ?? null;
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
function locateComponentSource(target) {
|
|
72
|
+
const elementTarget = target instanceof Element ? target : target instanceof Node ? target.parentElement : null;
|
|
73
|
+
const fiber = getClosestReactFiber(elementTarget);
|
|
74
|
+
if (!fiber) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
const debugSource = getDebugSource(fiber);
|
|
78
|
+
if (debugSource) {
|
|
79
|
+
return {
|
|
80
|
+
source: debugSource,
|
|
81
|
+
mode: "jsx"
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
const componentSource = resolveSourceFromFiber(fiber);
|
|
85
|
+
if (!componentSource) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
source: componentSource,
|
|
90
|
+
mode: "component"
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function enableReactComponentJump(options = {}) {
|
|
94
|
+
const {
|
|
95
|
+
triggerKey = "shift",
|
|
96
|
+
onLocate = (result) => {
|
|
97
|
+
console.log(`[react-component-jump] ${result.source}`);
|
|
98
|
+
},
|
|
99
|
+
onError = (error) => {
|
|
100
|
+
console.error("[react-component-jump]", error);
|
|
101
|
+
}
|
|
102
|
+
} = options;
|
|
103
|
+
const handler = (event) => {
|
|
104
|
+
if (!isTriggerPressed(event, triggerKey)) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const result = locateComponentSource(event.target);
|
|
108
|
+
if (!result) {
|
|
109
|
+
onError(new Error("No React component source metadata found for clicked element."));
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
event.preventDefault();
|
|
113
|
+
event.stopPropagation();
|
|
114
|
+
onLocate(result);
|
|
115
|
+
};
|
|
116
|
+
document.addEventListener("click", handler, true);
|
|
117
|
+
return () => {
|
|
118
|
+
document.removeEventListener("click", handler, true);
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// src/webpackRuntimeEntry.ts
|
|
123
|
+
if (typeof document !== "undefined") {
|
|
124
|
+
enableReactComponentJump();
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=webpackRuntimeEntry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/constants.ts","../src/runtime.ts","../src/webpackRuntimeEntry.ts"],"sourcesContent":["export const SOURCE_PROP = \"__componentSourceLoc\";\n\n","import { SOURCE_PROP } from \"./constants\";\n\nexport type TriggerKey = \"alt\" | \"meta\" | \"ctrl\" | \"shift\" | \"none\";\n\ntype ReactFiber = {\n return?: ReactFiber | null;\n type?: unknown;\n elementType?: unknown;\n _debugSource?: {\n fileName?: string;\n lineNumber?: number;\n columnNumber?: number;\n } | null;\n};\n\nexport type LocatorResult = {\n source: string;\n mode: \"jsx\" | \"component\";\n};\n\nexport type LocatorOptions = {\n triggerKey?: TriggerKey;\n onLocate?: (result: LocatorResult) => void;\n onError?: (error: unknown) => void;\n};\n\nfunction isTriggerPressed(event: MouseEvent, triggerKey: TriggerKey) {\n if (triggerKey === \"none\") {\n return true;\n }\n\n if (triggerKey === \"alt\") {\n return event.altKey;\n }\n\n if (triggerKey === \"meta\") {\n return event.metaKey;\n }\n\n if (triggerKey === \"ctrl\") {\n return event.ctrlKey;\n }\n\n return event.shiftKey;\n}\n\nfunction getReactFiberKey(element: Element) {\n return Object.keys(element).find((key) => key.startsWith(\"__reactFiber$\") || key.startsWith(\"__reactInternalInstance$\"));\n}\n\nfunction getClosestReactFiber(target: Element | null) {\n let current = target;\n\n while (current) {\n const fiberKey = getReactFiberKey(current);\n if (fiberKey) {\n return (current as unknown as Record<string, unknown>)[fiberKey] as ReactFiber;\n }\n\n current = current.parentElement;\n }\n\n return null;\n}\n\nfunction getSourceFromType(type: unknown) {\n if (!type) {\n return null;\n }\n\n if (typeof type === \"function\") {\n const source = (type as unknown as Record<string, unknown>)[SOURCE_PROP];\n return typeof source === \"string\" ? source : null;\n }\n\n if (typeof type !== \"object\") {\n return null;\n }\n\n const record = type as {\n type?: Record<string, unknown>;\n render?: Record<string, unknown>;\n [SOURCE_PROP]?: unknown;\n };\n\n const source = record[SOURCE_PROP] ?? record.type?.[SOURCE_PROP] ?? record.render?.[SOURCE_PROP];\n return typeof source === \"string\" ? source : null;\n}\n\nfunction resolveSourceFromFiber(fiber: ReactFiber | null) {\n let current = fiber;\n\n while (current) {\n const source = getSourceFromType(current.type) ?? getSourceFromType(current.elementType);\n if (source) {\n return source;\n }\n\n current = current.return ?? null;\n }\n\n return null;\n}\n\nfunction getDebugSource(fiber: ReactFiber | null) {\n let current = fiber;\n\n while (current) {\n const debugSource = current._debugSource;\n if (debugSource?.fileName && typeof debugSource.lineNumber === \"number\") {\n return `${debugSource.fileName.replace(/\\\\/g, \"/\")}:${debugSource.lineNumber}:${debugSource.columnNumber ?? 1}`;\n }\n\n current = current.return ?? null;\n }\n\n return null;\n}\n\nexport function locateComponentSource(target: EventTarget | null): LocatorResult | null {\n const elementTarget =\n target instanceof Element ? target : target instanceof Node ? target.parentElement : null;\n const fiber = getClosestReactFiber(elementTarget);\n if (!fiber) {\n return null;\n }\n\n const debugSource = getDebugSource(fiber);\n if (debugSource) {\n return {\n source: debugSource,\n mode: \"jsx\",\n };\n }\n\n const componentSource = resolveSourceFromFiber(fiber);\n if (!componentSource) {\n return null;\n }\n\n return {\n source: componentSource,\n mode: \"component\",\n };\n}\n\nexport function enableReactComponentJump(options: LocatorOptions = {}) {\n const {\n triggerKey = \"shift\",\n onLocate = (result) => {\n console.log(`[react-component-jump] ${result.source}`);\n },\n onError = (error) => {\n console.error(\"[react-component-jump]\", error);\n },\n } = options;\n\n const handler = (event: MouseEvent) => {\n if (!isTriggerPressed(event, triggerKey)) {\n return;\n }\n\n const result = locateComponentSource(event.target);\n if (!result) {\n onError(new Error(\"No React component source metadata found for clicked element.\"));\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n onLocate(result);\n };\n\n document.addEventListener(\"click\", handler, true);\n\n return () => {\n document.removeEventListener(\"click\", handler, true);\n };\n}\n","import { enableReactComponentJump } from \"./runtime\";\n\nif (typeof document !== \"undefined\") {\n enableReactComponentJump();\n}\n\n"],"mappings":";AAAO,IAAM,cAAc;;;AC0B3B,SAAS,iBAAiB,OAAmB,YAAwB;AACnE,MAAI,eAAe,QAAQ;AACzB,WAAO;AAAA,EACT;AAEA,MAAI,eAAe,OAAO;AACxB,WAAO,MAAM;AAAA,EACf;AAEA,MAAI,eAAe,QAAQ;AACzB,WAAO,MAAM;AAAA,EACf;AAEA,MAAI,eAAe,QAAQ;AACzB,WAAO,MAAM;AAAA,EACf;AAEA,SAAO,MAAM;AACf;AAEA,SAAS,iBAAiB,SAAkB;AAC1C,SAAO,OAAO,KAAK,OAAO,EAAE,KAAK,CAAC,QAAQ,IAAI,WAAW,eAAe,KAAK,IAAI,WAAW,0BAA0B,CAAC;AACzH;AAEA,SAAS,qBAAqB,QAAwB;AACpD,MAAI,UAAU;AAEd,SAAO,SAAS;AACd,UAAM,WAAW,iBAAiB,OAAO;AACzC,QAAI,UAAU;AACZ,aAAQ,QAA+C,QAAQ;AAAA,IACjE;AAEA,cAAU,QAAQ;AAAA,EACpB;AAEA,SAAO;AACT;AAEA,SAAS,kBAAkB,MAAe;AACxC,MAAI,CAAC,MAAM;AACT,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,SAAS,YAAY;AAC9B,UAAMA,UAAU,KAA4C,WAAW;AACvE,WAAO,OAAOA,YAAW,WAAWA,UAAS;AAAA,EAC/C;AAEA,MAAI,OAAO,SAAS,UAAU;AAC5B,WAAO;AAAA,EACT;AAEA,QAAM,SAAS;AAMf,QAAM,SAAS,OAAO,WAAW,KAAK,OAAO,OAAO,WAAW,KAAK,OAAO,SAAS,WAAW;AAC/F,SAAO,OAAO,WAAW,WAAW,S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