@unpackjs/plugin-react 1.7.5 → 1.7.7

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.
@@ -1,72 +1,83 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var click_to_component_exports = {};
29
- __export(click_to_component_exports, {
30
- applyClickToComponentConfig: () => applyClickToComponentConfig
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = function(module) {
5
+ var getter = module && module.__esModule ? function() {
6
+ return module['default'];
7
+ } : function() {
8
+ return module;
9
+ };
10
+ __webpack_require__.d(getter, {
11
+ a: getter
12
+ });
13
+ return getter;
14
+ };
15
+ })();
16
+ (()=>{
17
+ __webpack_require__.d = function(exports1, definition) {
18
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
19
+ enumerable: true,
20
+ get: definition[key]
21
+ });
22
+ };
23
+ })();
24
+ (()=>{
25
+ __webpack_require__.o = function(obj, prop) {
26
+ return Object.prototype.hasOwnProperty.call(obj, prop);
27
+ };
28
+ })();
29
+ (()=>{
30
+ __webpack_require__.r = function(exports1) {
31
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
32
+ value: 'Module'
33
+ });
34
+ Object.defineProperty(exports1, '__esModule', {
35
+ value: true
36
+ });
37
+ };
38
+ })();
39
+ var __webpack_exports__ = {};
40
+ __webpack_require__.r(__webpack_exports__);
41
+ __webpack_require__.d(__webpack_exports__, {
42
+ applyClickToComponentConfig: ()=>applyClickToComponentConfig
31
43
  });
32
- module.exports = __toCommonJS(click_to_component_exports);
33
- var import_node_fs = __toESM(require("node:fs"));
34
- var import_node_http = __toESM(require("node:http"));
35
- var import_node_path = __toESM(require("node:path"));
36
- var import_core = require("@unpackjs/core");
37
- var import_launch_editor = __toESM(require("launch-editor"));
38
- const createServer = () => {
39
- return new Promise((resolve) => {
40
- const server = import_node_http.default.createServer((req, res) => {
41
- const params = new URLSearchParams(req.url.slice(1));
42
- const file = decodeURIComponent(params.get("file"));
43
- const line = Number(params.get("line"));
44
- const column = Number(params.get("column"));
45
- res.writeHead(200, {
46
- "Access-Control-Allow-Origin": "*",
47
- "Access-Control-Allow-Methods": "*",
48
- "Access-Control-Allow-Headers": "*",
49
- "Access-Control-Allow-Private-Network": "true"
50
- });
51
- res.end("ok");
52
- (0, import_launch_editor.default)(`${file}:${line}:${column}`);
53
- });
54
- (0, import_core.getPort)(3100).then((port) => {
55
- server.listen(port, () => {
56
- resolve({
57
- port
44
+ const external_node_fs_namespaceObject = require("node:fs");
45
+ var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
46
+ const external_node_http_namespaceObject = require("node:http");
47
+ var external_node_http_default = /*#__PURE__*/ __webpack_require__.n(external_node_http_namespaceObject);
48
+ const external_node_path_namespaceObject = require("node:path");
49
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
50
+ const core_namespaceObject = require("@unpackjs/core");
51
+ const external_launch_editor_namespaceObject = require("launch-editor");
52
+ var external_launch_editor_default = /*#__PURE__*/ __webpack_require__.n(external_launch_editor_namespaceObject);
53
+ const createServer = ()=>new Promise((resolve)=>{
54
+ const server = external_node_http_default().createServer((req, res)=>{
55
+ const params = new URLSearchParams(req.url.slice(1));
56
+ const file = decodeURIComponent(params.get('file'));
57
+ const line = Number(params.get('line'));
58
+ const column = Number(params.get('column'));
59
+ res.writeHead(200, {
60
+ 'Access-Control-Allow-Origin': '*',
61
+ 'Access-Control-Allow-Methods': '*',
62
+ 'Access-Control-Allow-Headers': '*',
63
+ 'Access-Control-Allow-Private-Network': 'true'
64
+ });
65
+ res.end('ok');
66
+ external_launch_editor_default()(`${file}:${line}:${column}`);
67
+ });
68
+ (0, core_namespaceObject.getPort)(3100).then((port)=>{
69
+ server.listen(port, ()=>{
70
+ resolve({
71
+ port
72
+ });
73
+ });
58
74
  });
59
- });
75
+ core_namespaceObject.restartCleaners.push(()=>new Promise((resolve)=>server.close(()=>resolve())));
60
76
  });
61
- });
62
- };
63
- const applyClickToComponentConfig = async ({
64
- config,
65
- unpackConfig
66
- }) => {
67
- const { port } = await createServer();
68
- const injectScript = import_node_fs.default.readFileSync(import_node_path.default.resolve(__dirname, "./injectScript.js"), "utf-8");
69
- const scriptTpl = `
77
+ const applyClickToComponentConfig = async ({ config, unpackConfig })=>{
78
+ const { port } = await createServer();
79
+ const injectScript = external_node_fs_default().readFileSync(external_node_path_default().resolve(__dirname, './injectScript.js'), 'utf-8');
80
+ const scriptTpl = `
70
81
  if (!document.querySelector('#__click-to-component__')) {
71
82
  const script = document.createElement('script')
72
83
  window['CLICK_TO_COMPONENT'] = { port: ${port} }
@@ -74,30 +85,30 @@ if (!document.querySelector('#__click-to-component__')) {
74
85
  script.textContent = \`${injectScript}\`
75
86
  document.body.appendChild(script)
76
87
  }`;
77
- if (unpackConfig.mpa) {
78
- Object.values(config.entry).forEach((entryConfig) => {
79
- const filePath = entryConfig.import[0];
80
- const content = import_node_fs.default.readFileSync(filePath, "utf-8");
81
- import_node_fs.default.writeFileSync(filePath, `${scriptTpl}
82
- ${content}`, "utf-8");
88
+ if (unpackConfig.mpa) Object.values(config.entry).forEach((entryConfig)=>{
89
+ const filePath = entryConfig.import[0];
90
+ const content = external_node_fs_default().readFileSync(filePath, 'utf-8');
91
+ external_node_fs_default().writeFileSync(filePath, `${scriptTpl}\n${content}`, 'utf-8');
83
92
  });
84
- } else {
85
- const realEntryPath = import_node_path.default.resolve(config.context, import_core.TEMP_DIR, "entries", `index.${port}.jsx`);
86
- const tpl = `
93
+ else {
94
+ const realEntryPath = external_node_path_default().resolve(config.context, core_namespaceObject.TEMP_DIR, 'entries', `index.${port}.jsx`);
95
+ const tpl = `
87
96
  ${scriptTpl}
88
- import '${(0, import_core.getPathInJs)(import_node_path.default.resolve(Object.values(config.entry)[0]))}'
97
+ import '${(0, core_namespaceObject.getPathInJs)(external_node_path_default().resolve(Object.values(config.entry)[0]))}'
89
98
  `;
90
- const dir = import_node_path.default.dirname(realEntryPath);
91
- if (!import_node_fs.default.existsSync(dir))
92
- import_node_fs.default.mkdirSync(dir, { recursive: true });
93
- import_node_fs.default.writeFileSync(realEntryPath, tpl, "utf-8");
94
- config.entry = {
95
- main: realEntryPath
96
- };
97
- }
98
- return config;
99
+ const dir = external_node_path_default().dirname(realEntryPath);
100
+ if (!external_node_fs_default().existsSync(dir)) external_node_fs_default().mkdirSync(dir, {
101
+ recursive: true
102
+ });
103
+ external_node_fs_default().writeFileSync(realEntryPath, tpl, 'utf-8');
104
+ config.entry = {
105
+ main: realEntryPath
106
+ };
107
+ }
108
+ return config;
99
109
  };
100
- // Annotate the CommonJS export names for ESM import in node:
101
- 0 && (module.exports = {
102
- applyClickToComponentConfig
110
+ var __webpack_export_target__ = exports;
111
+ for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
112
+ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
113
+ value: true
103
114
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/click-to-component/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,oBAAoB,EAEzB,KAAK,YAAY,EAGlB,MAAM,gBAAgB,CAAA;AA4BvB,eAAO,MAAM,2BAA2B,8BAGrC;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;CAC3B,KAAG,OAAO,CAAC,oBAAoB,CA+B/B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/click-to-component/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,oBAAoB,EAEzB,KAAK,YAAY,EAIlB,MAAM,gBAAgB,CAAA;AA6BvB,eAAO,MAAM,2BAA2B,8BAGrC;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;CAC3B,KAAG,OAAO,CAAC,oBAAoB,CA+B/B,CAAA"}
@@ -1,53 +1,41 @@
1
- import { createRequire } from 'node:module';
2
- var require = createRequire(import.meta['url']);
3
-
4
- import path from "path";
5
- import { fileURLToPath } from "url";
6
- var getFilename = () => fileURLToPath(import.meta.url);
7
- var getDirname = () => path.dirname(getFilename());
8
- var __dirname = /* @__PURE__ */ getDirname();
9
- var __filename = /* @__PURE__ */ getFilename();
10
- import fs from "node:fs";
11
- import http from "node:http";
12
- import path2 from "node:path";
13
- import {
14
- TEMP_DIR,
15
- getPathInJs,
16
- getPort
17
- } from "@unpackjs/core";
18
- import launchEditor from "launch-editor";
19
- const createServer = () => {
20
- return new Promise((resolve) => {
21
- const server = http.createServer((req, res) => {
22
- const params = new URLSearchParams(req.url.slice(1));
23
- const file = decodeURIComponent(params.get("file"));
24
- const line = Number(params.get("line"));
25
- const column = Number(params.get("column"));
26
- res.writeHead(200, {
27
- "Access-Control-Allow-Origin": "*",
28
- "Access-Control-Allow-Methods": "*",
29
- "Access-Control-Allow-Headers": "*",
30
- "Access-Control-Allow-Private-Network": "true"
31
- });
32
- res.end("ok");
33
- launchEditor(`${file}:${line}:${column}`);
34
- });
35
- getPort(3100).then((port) => {
36
- server.listen(port, () => {
37
- resolve({
38
- port
1
+ import __rslib_shim_module__ from 'module';
2
+ /*#__PURE__*/ import.meta.url;
3
+ import { fileURLToPath as __webpack_fileURLToPath__ } from "node:url";
4
+ import { dirname as __webpack_dirname__ } from "node:path";
5
+ import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
6
+ import * as __WEBPACK_EXTERNAL_MODULE_node_http_2dc67212__ from "node:http";
7
+ import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
8
+ import * as __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__ from "@unpackjs/core";
9
+ import * as __WEBPACK_EXTERNAL_MODULE_launch_editor_c6c8c971__ from "launch-editor";
10
+ var click_to_component_rslib_entry_dirname = __webpack_dirname__(__webpack_fileURLToPath__(import.meta.url));
11
+ const createServer = ()=>new Promise((resolve)=>{
12
+ const server = __WEBPACK_EXTERNAL_MODULE_node_http_2dc67212__["default"].createServer((req, res)=>{
13
+ const params = new URLSearchParams(req.url.slice(1));
14
+ const file = decodeURIComponent(params.get('file'));
15
+ const line = Number(params.get('line'));
16
+ const column = Number(params.get('column'));
17
+ res.writeHead(200, {
18
+ 'Access-Control-Allow-Origin': '*',
19
+ 'Access-Control-Allow-Methods': '*',
20
+ 'Access-Control-Allow-Headers': '*',
21
+ 'Access-Control-Allow-Private-Network': 'true'
22
+ });
23
+ res.end('ok');
24
+ (0, __WEBPACK_EXTERNAL_MODULE_launch_editor_c6c8c971__["default"])(`${file}:${line}:${column}`);
25
+ });
26
+ (0, __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.getPort)(3100).then((port)=>{
27
+ server.listen(port, ()=>{
28
+ resolve({
29
+ port
30
+ });
31
+ });
39
32
  });
40
- });
33
+ __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.restartCleaners.push(()=>new Promise((resolve)=>server.close(()=>resolve())));
41
34
  });
42
- });
43
- };
44
- const applyClickToComponentConfig = async ({
45
- config,
46
- unpackConfig
47
- }) => {
48
- const { port } = await createServer();
49
- const injectScript = fs.readFileSync(path2.resolve(__dirname, "./injectScript.js"), "utf-8");
50
- const scriptTpl = `
35
+ const applyClickToComponentConfig = async ({ config, unpackConfig })=>{
36
+ const { port } = await createServer();
37
+ const injectScript = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(click_to_component_rslib_entry_dirname, './injectScript.js'), 'utf-8');
38
+ const scriptTpl = `
51
39
  if (!document.querySelector('#__click-to-component__')) {
52
40
  const script = document.createElement('script')
53
41
  window['CLICK_TO_COMPONENT'] = { port: ${port} }
@@ -55,29 +43,26 @@ if (!document.querySelector('#__click-to-component__')) {
55
43
  script.textContent = \`${injectScript}\`
56
44
  document.body.appendChild(script)
57
45
  }`;
58
- if (unpackConfig.mpa) {
59
- Object.values(config.entry).forEach((entryConfig) => {
60
- const filePath = entryConfig.import[0];
61
- const content = fs.readFileSync(filePath, "utf-8");
62
- fs.writeFileSync(filePath, `${scriptTpl}
63
- ${content}`, "utf-8");
46
+ if (unpackConfig.mpa) Object.values(config.entry).forEach((entryConfig)=>{
47
+ const filePath = entryConfig.import[0];
48
+ const content = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(filePath, 'utf-8');
49
+ __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].writeFileSync(filePath, `${scriptTpl}\n${content}`, 'utf-8');
64
50
  });
65
- } else {
66
- const realEntryPath = path2.resolve(config.context, TEMP_DIR, "entries", `index.${port}.jsx`);
67
- const tpl = `
51
+ else {
52
+ const realEntryPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(config.context, __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.TEMP_DIR, 'entries', `index.${port}.jsx`);
53
+ const tpl = `
68
54
  ${scriptTpl}
69
- import '${getPathInJs(path2.resolve(Object.values(config.entry)[0]))}'
55
+ import '${(0, __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.getPathInJs)(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(Object.values(config.entry)[0]))}'
70
56
  `;
71
- const dir = path2.dirname(realEntryPath);
72
- if (!fs.existsSync(dir))
73
- fs.mkdirSync(dir, { recursive: true });
74
- fs.writeFileSync(realEntryPath, tpl, "utf-8");
75
- config.entry = {
76
- main: realEntryPath
77
- };
78
- }
79
- return config;
80
- };
81
- export {
82
- applyClickToComponentConfig
57
+ const dir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(realEntryPath);
58
+ if (!__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync(dir)) __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].mkdirSync(dir, {
59
+ recursive: true
60
+ });
61
+ __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].writeFileSync(realEntryPath, tpl, 'utf-8');
62
+ config.entry = {
63
+ main: realEntryPath
64
+ };
65
+ }
66
+ return config;
83
67
  };
68
+ export { applyClickToComponentConfig };
@@ -1,137 +1,116 @@
1
- const COVER_ID = '__click-to-component__'
2
- let cover = null
3
- let currentDebugSource = null
4
- let enabled = false
1
+ const COVER_ID = '__click-to-component__';
2
+ let cover = null;
3
+ let currentDebugSource = null;
4
+ let enabled = false;
5
5
  function debounce(fn, delay = 200) {
6
- let timer = null
7
- return (...args) => {
8
- clearTimeout(timer)
9
- timer = setTimeout(() => {
10
- fn(...args)
11
- }, delay)
12
- }
6
+ let timer = null;
7
+ return (...args)=>{
8
+ clearTimeout(timer);
9
+ timer = setTimeout(()=>{
10
+ fn(...args);
11
+ }, delay);
12
+ };
13
13
  }
14
14
  function applyStyles(target, styles) {
15
- Object.entries(styles).forEach(([key, value]) => {
16
- target.style[key] = value
17
- })
15
+ Object.entries(styles).forEach(([key, value])=>{
16
+ target.style[key] = value;
17
+ });
18
18
  }
19
19
  function createCover() {
20
- cover = document.createElement('div')
21
- cover.id = COVER_ID
22
- applyStyles(cover, {
23
- position: 'fixed',
24
- zIndex: '999999',
25
- background: 'rgba(120, 170, 210, 0.6)',
26
- display: 'none',
27
- pointerEvents: 'none',
28
- })
29
- document.body.appendChild(cover)
20
+ cover = document.createElement('div');
21
+ cover.id = COVER_ID;
22
+ applyStyles(cover, {
23
+ position: 'fixed',
24
+ zIndex: '999999',
25
+ background: 'rgba(120, 170, 210, 0.6)',
26
+ display: 'none',
27
+ pointerEvents: 'none'
28
+ });
29
+ document.body.appendChild(cover);
30
30
  }
31
31
  function updateCover(target) {
32
- if (typeof target.getBoundingClientRect !== 'function') {
33
- currentDebugSource = null
34
- return
35
- }
36
- const { top, left, width, height } = target.getBoundingClientRect()
37
- applyStyles(cover, {
38
- top: top + 'px',
39
- left: left + 'px',
40
- width: width + 'px',
41
- height: height + 'px',
42
- display: 'block',
43
- })
32
+ if ('function' != typeof target.getBoundingClientRect) {
33
+ currentDebugSource = null;
34
+ return;
35
+ }
36
+ const { top, left, width, height } = target.getBoundingClientRect();
37
+ applyStyles(cover, {
38
+ top: top + 'px',
39
+ left: left + 'px',
40
+ width: width + 'px',
41
+ height: height + 'px',
42
+ display: 'block'
43
+ });
44
44
  }
45
45
  function hideCover() {
46
- cover.style.display = 'none'
46
+ cover.style.display = 'none';
47
47
  }
48
48
  function getFiberWithDebugSourceByTarget(target) {
49
- const fiberKey = Object.keys(target).find((key) => key.includes('__reactFiber'))
50
- const maxDepth = 10
51
- const doNext = (fiber, depth = 0) => {
52
- if (!fiber) return
53
- if (depth > maxDepth) {
54
- console.warn('Recursion depth exceeded. Aborting to prevent stack overflow.')
55
- return
56
- }
57
- if (fiber._debugSource) {
58
- // console.log('_debugSource-depth', depth, fiber)
59
- return fiber
60
- }
61
- if (fiber._debugOwner) {
62
- return doNext(fiber._debugOwner, depth + 1)
63
- }
64
- console.warn('[WARN] click-to-component cannot work with the minified version of React.')
65
- }
66
- return doNext(target[fiberKey])
49
+ const fiberKey = Object.keys(target).find((key)=>key.includes('__reactFiber'));
50
+ const maxDepth = 10;
51
+ const doNext = (fiber, depth = 0)=>{
52
+ if (!fiber) return;
53
+ if (depth > maxDepth) return;
54
+ if (fiber._debugSource) return fiber;
55
+ if (fiber._debugOwner) return doNext(fiber._debugOwner, depth + 1);
56
+ console.warn('[WARN] click-to-component cannot work with the minified version of React.');
57
+ };
58
+ return doNext(target[fiberKey]);
67
59
  }
68
60
  function getClosestNodeFromFiber(fiber) {
69
- if (fiber.stateNode) {
70
- return fiber.stateNode
71
- }
72
- return getClosestNodeFromFiber(fiber.return)
61
+ if (fiber.stateNode) return fiber.stateNode;
62
+ return getClosestNodeFromFiber(fiber.return);
73
63
  }
74
64
  function openEditor() {
75
- if (!currentDebugSource) return
76
- const port = window.CLICK_TO_COMPONENT.port
77
- const { fileName, lineNumber, columnNumber } = currentDebugSource
78
- const url = [
79
- 'http://localhost:',
80
- port,
81
- '/?file=',
82
- fileName,
83
- '&line=',
84
- lineNumber,
85
- '&column=',
86
- columnNumber,
87
- ].join('')
88
- const sendXHR = () => {
89
- const xhr = new XMLHttpRequest()
90
- xhr.open('GET', url, true)
91
- xhr.send()
92
- xhr.addEventListener('error', () => {
93
- // 通过img方式发送请求
94
- const img = document.createElement('img')
95
- img.src = url
96
- })
97
- }
98
- sendXHR()
65
+ if (!currentDebugSource) return;
66
+ const port = window.CLICK_TO_COMPONENT.port;
67
+ const { fileName, lineNumber, columnNumber } = currentDebugSource;
68
+ const url = [
69
+ 'http://localhost:',
70
+ port,
71
+ '/?file=',
72
+ fileName,
73
+ '&line=',
74
+ lineNumber,
75
+ '&column=',
76
+ columnNumber
77
+ ].join('');
78
+ const sendXHR = ()=>{
79
+ const xhr = new XMLHttpRequest();
80
+ xhr.open('GET', url, true);
81
+ xhr.send();
82
+ xhr.addEventListener('error', ()=>{
83
+ const img = document.createElement('img');
84
+ img.src = url;
85
+ });
86
+ };
87
+ sendXHR();
99
88
  }
100
- document.addEventListener(
101
- 'mouseover',
102
- debounce((e) => {
103
- if (!enabled) return
104
- const target = e.target
105
- const fiber = getFiberWithDebugSourceByTarget(target)
106
- if (!fiber) return
107
- const closestNode = getClosestNodeFromFiber(fiber)
108
- if (!closestNode) return
109
- currentDebugSource = fiber._debugSource
110
- updateCover(closestNode)
111
- }, 30),
112
- )
113
- document.addEventListener(
114
- 'click',
115
- (e) => {
116
- if (!enabled) return
117
- e.stopPropagation()
118
- e.preventDefault()
119
- openEditor()
120
- hideCover()
121
- enabled = false
122
- },
123
- true,
124
- )
125
- document.addEventListener('keydown', (e) => {
126
- if (e.key === 'Alt') {
127
- enabled = true
128
- }
129
- })
130
- document.addEventListener('keyup', (e) => {
131
- if (e.key === 'Alt') {
132
- enabled = false
133
- hideCover()
134
- }
135
- })
136
-
137
- createCover()
89
+ document.addEventListener('mouseover', debounce((e)=>{
90
+ if (!enabled) return;
91
+ const target = e.target;
92
+ const fiber = getFiberWithDebugSourceByTarget(target);
93
+ if (!fiber) return;
94
+ const closestNode = getClosestNodeFromFiber(fiber);
95
+ if (!closestNode) return;
96
+ currentDebugSource = fiber._debugSource;
97
+ updateCover(closestNode);
98
+ }, 30));
99
+ document.addEventListener('click', (e)=>{
100
+ if (!enabled) return;
101
+ e.stopPropagation();
102
+ e.preventDefault();
103
+ openEditor();
104
+ hideCover();
105
+ enabled = false;
106
+ }, true);
107
+ document.addEventListener('keydown', (e)=>{
108
+ if ('Alt' === e.key) enabled = true;
109
+ });
110
+ document.addEventListener('keyup', (e)=>{
111
+ if ('Alt' === e.key) {
112
+ enabled = false;
113
+ hideCover();
114
+ }
115
+ });
116
+ createCover();