@unpackjs/plugin-react 3.1.3 → 3.2.0
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/index.cjs +53 -59
- package/dist/index.js +47 -53
- package/dist/injectScript.js +5 -3
- package/dist-types/click-to-component/index.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
const __rslib_import_meta_url__ = 'undefined' == typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
3
3
|
var __webpack_require__ = {};
|
|
4
4
|
__webpack_require__.n = (module)=>{
|
|
5
5
|
var getter = module && module.__esModule ? ()=>module.default : ()=>module;
|
|
@@ -23,17 +23,17 @@ __webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_expo
|
|
|
23
23
|
pluginReact: ()=>pluginReact,
|
|
24
24
|
PLUGIN_NAME: ()=>PLUGIN_NAME
|
|
25
25
|
});
|
|
26
|
-
|
|
26
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
27
27
|
var external_node_path_default = __webpack_require__.n(external_node_path_namespaceObject);
|
|
28
|
-
|
|
28
|
+
const plugin_react_refresh_namespaceObject = require("@rspack/plugin-react-refresh");
|
|
29
29
|
var plugin_react_refresh_default = __webpack_require__.n(plugin_react_refresh_namespaceObject);
|
|
30
|
-
|
|
30
|
+
const core_namespaceObject = require("@unpackjs/core"), external_node_fs_namespaceObject = require("node:fs");
|
|
31
31
|
var external_node_fs_default = __webpack_require__.n(external_node_fs_namespaceObject);
|
|
32
|
-
|
|
32
|
+
const external_node_http_namespaceObject = require("node:http");
|
|
33
33
|
var external_node_http_default = __webpack_require__.n(external_node_http_namespaceObject);
|
|
34
|
-
|
|
34
|
+
const external_launch_editor_namespaceObject = require("launch-editor");
|
|
35
35
|
var external_launch_editor_default = __webpack_require__.n(external_launch_editor_namespaceObject);
|
|
36
|
-
|
|
36
|
+
const createServer = ()=>new Promise((resolve)=>{
|
|
37
37
|
let server = external_node_http_default().createServer((req, res)=>{
|
|
38
38
|
let params = new URLSearchParams(req.url.slice(1)), file = decodeURIComponent(params.get('file')), line = Number(params.get('line')), column = Number(params.get('column'));
|
|
39
39
|
res.writeHead(200, {
|
|
@@ -49,7 +49,7 @@ let createServer = ()=>new Promise((resolve)=>{
|
|
|
49
49
|
port
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
-
}), core_namespaceObject.
|
|
52
|
+
}), (0, core_namespaceObject.addRestartCleaner)(()=>new Promise((resolve)=>server.close(()=>resolve())));
|
|
53
53
|
}), applyClickToComponentConfig = async ({ config, unpackConfig })=>{
|
|
54
54
|
let { port } = await createServer(), injectScript = external_node_fs_default().readFileSync(external_node_path_default().resolve(__dirname, './injectScript.js'), 'utf-8'), scriptTpl = `
|
|
55
55
|
if (!document.querySelector('#__click-to-component__')) {
|
|
@@ -76,56 +76,50 @@ import '${(0, core_namespaceObject.getPathInJs)(external_node_path_default().res
|
|
|
76
76
|
}
|
|
77
77
|
return config;
|
|
78
78
|
}, applyMpaConfig = ({ config, unpackConfig })=>{
|
|
79
|
-
let tempDirectory = external_node_path_default().join(core_namespaceObject.TEMP_DIR, 'mpa'), userOptions = (0, core_namespaceObject.isPlainObject)(unpackConfig.mpa) ? unpackConfig.mpa : {}, { entry, html } = (()=>{
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
let indexFilePath = external_node_path_default().join(dir, `index${extension}`);
|
|
89
|
-
if (external_node_fs_default().existsSync(indexFilePath)) return indexFilePath;
|
|
90
|
-
}
|
|
91
|
-
return null;
|
|
92
|
-
})(external_node_path_default().join(pagesRoot, filename));
|
|
93
|
-
if (indexFilePath) {
|
|
94
|
-
var _unpackConfig_html, _unpackConfig_html1, _unpackConfig_html2, _unpackConfig_html3, _unpackConfig_html4, _unpackConfig_html5, _unpackConfig_html6, _unpackConfig_html7, _unpackConfig_html8;
|
|
95
|
-
let pageConfig = ((indexPath)=>{
|
|
96
|
-
let filePath = external_node_path_default().join(indexPath, '../config.json'), pageConfig = {};
|
|
97
|
-
return external_node_fs_default().existsSync(filePath) && (pageConfig = JSON.parse(external_node_fs_default().readFileSync(filePath, 'utf-8'))), pageConfig;
|
|
98
|
-
})(indexFilePath), entryName = !0 === userOptions.lowerCase ? filename.toLowerCase() : filename;
|
|
99
|
-
pageConfig.filename && (entryName = pageConfig.filename.slice(0, -5)), entry[entryName] = {
|
|
100
|
-
import: [
|
|
101
|
-
indexFilePath
|
|
102
|
-
]
|
|
103
|
-
}, pageConfig.template && (pageConfig.template = external_node_path_default().join(indexFilePath, '../', pageConfig.template)), html.push({
|
|
104
|
-
template: (null == (_unpackConfig_html = unpackConfig.html) ? void 0 : _unpackConfig_html.template) || void 0,
|
|
105
|
-
templateContent: (null == (_unpackConfig_html1 = unpackConfig.html) ? void 0 : _unpackConfig_html1.templateContent) || ((null == (_unpackConfig_html2 = unpackConfig.html) ? void 0 : _unpackConfig_html2.template) ? void 0 : core_namespaceObject.TEMPLATE_CONTENT),
|
|
106
|
-
minify: !1,
|
|
107
|
-
filename: `${entryName}.html`,
|
|
108
|
-
chunks: [
|
|
109
|
-
entryName
|
|
110
|
-
],
|
|
111
|
-
...pageConfig,
|
|
112
|
-
templateParameters: {
|
|
113
|
-
mountId: null == (_unpackConfig_html3 = unpackConfig.html) ? void 0 : _unpackConfig_html3.mountId,
|
|
114
|
-
title: (0, core_namespaceObject.isFunction)(null == (_unpackConfig_html4 = unpackConfig.html) ? void 0 : _unpackConfig_html4.title) ? null == (_unpackConfig_html5 = unpackConfig.html) ? void 0 : _unpackConfig_html5.title({
|
|
115
|
-
entryName
|
|
116
|
-
}) : (null == (_unpackConfig_html6 = unpackConfig.html) ? void 0 : _unpackConfig_html6.title) || '',
|
|
117
|
-
headTag: (null == (_unpackConfig_html7 = unpackConfig.html) ? void 0 : _unpackConfig_html7.headTag) || '',
|
|
118
|
-
...null == (_unpackConfig_html8 = unpackConfig.html) ? void 0 : _unpackConfig_html8.templateParameters,
|
|
119
|
-
...pageConfig.templateParameters
|
|
120
|
-
}
|
|
121
|
-
});
|
|
79
|
+
let start, entry, html, pagesRoot, tempDirectory = external_node_path_default().join(core_namespaceObject.TEMP_DIR, 'mpa'), userOptions = (0, core_namespaceObject.isPlainObject)(unpackConfig.mpa) ? unpackConfig.mpa : {}, { entry: entry1, html: html1 } = (start = performance.now(), entry = {}, html = [], pagesRoot = external_node_path_default().join(unpackConfig.root, 'src', 'pages'), external_node_fs_default().readdirSync(pagesRoot).forEach((filename)=>{
|
|
80
|
+
if (filename.startsWith('.')) return;
|
|
81
|
+
let indexFilePath = ((dir)=>{
|
|
82
|
+
for (let extension of [
|
|
83
|
+
'.tsx',
|
|
84
|
+
'.jsx'
|
|
85
|
+
]){
|
|
86
|
+
let indexFilePath = external_node_path_default().join(dir, `index${extension}`);
|
|
87
|
+
if (external_node_fs_default().existsSync(indexFilePath)) return indexFilePath;
|
|
122
88
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
89
|
+
return null;
|
|
90
|
+
})(external_node_path_default().join(pagesRoot, filename));
|
|
91
|
+
if (indexFilePath) {
|
|
92
|
+
var _unpackConfig_html, _unpackConfig_html1, _unpackConfig_html2, _unpackConfig_html3, _unpackConfig_html4, _unpackConfig_html5, _unpackConfig_html6, _unpackConfig_html7, _unpackConfig_html8;
|
|
93
|
+
let filePath, pageConfig, pageConfig1 = (filePath = external_node_path_default().join(indexFilePath, '../config.json'), pageConfig = {}, external_node_fs_default().existsSync(filePath) && (pageConfig = JSON.parse(external_node_fs_default().readFileSync(filePath, 'utf-8'))), pageConfig), entryName = !0 === userOptions.lowerCase ? filename.toLowerCase() : filename;
|
|
94
|
+
pageConfig1.filename && (entryName = pageConfig1.filename.slice(0, -5)), entry[entryName] = {
|
|
95
|
+
import: [
|
|
96
|
+
indexFilePath
|
|
97
|
+
]
|
|
98
|
+
}, pageConfig1.template && (pageConfig1.template = external_node_path_default().join(indexFilePath, '../', pageConfig1.template)), html.push({
|
|
99
|
+
template: (null == (_unpackConfig_html = unpackConfig.html) ? void 0 : _unpackConfig_html.template) || void 0,
|
|
100
|
+
templateContent: (null == (_unpackConfig_html1 = unpackConfig.html) ? void 0 : _unpackConfig_html1.templateContent) || ((null == (_unpackConfig_html2 = unpackConfig.html) ? void 0 : _unpackConfig_html2.template) ? void 0 : core_namespaceObject.TEMPLATE_CONTENT),
|
|
101
|
+
minify: !1,
|
|
102
|
+
filename: `${entryName}.html`,
|
|
103
|
+
chunks: [
|
|
104
|
+
entryName
|
|
105
|
+
],
|
|
106
|
+
...pageConfig1,
|
|
107
|
+
templateParameters: {
|
|
108
|
+
mountId: null == (_unpackConfig_html3 = unpackConfig.html) ? void 0 : _unpackConfig_html3.mountId,
|
|
109
|
+
title: (0, core_namespaceObject.isFunction)(null == (_unpackConfig_html4 = unpackConfig.html) ? void 0 : _unpackConfig_html4.title) ? null == (_unpackConfig_html5 = unpackConfig.html) ? void 0 : _unpackConfig_html5.title({
|
|
110
|
+
entryName
|
|
111
|
+
}) : (null == (_unpackConfig_html6 = unpackConfig.html) ? void 0 : _unpackConfig_html6.title) || '',
|
|
112
|
+
headTag: (null == (_unpackConfig_html7 = unpackConfig.html) ? void 0 : _unpackConfig_html7.headTag) || '',
|
|
113
|
+
...null == (_unpackConfig_html8 = unpackConfig.html) ? void 0 : _unpackConfig_html8.templateParameters,
|
|
114
|
+
...pageConfig1.templateParameters
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}), (0, core_namespaceObject.isDevServer)() || core_namespaceObject.logger.info(`collect entries in ${(performance.now() - start).toFixed(2)}ms ${core_namespaceObject.colors.dim('[MPA]')}`), {
|
|
119
|
+
entry,
|
|
120
|
+
html
|
|
121
|
+
});
|
|
122
|
+
return (0, core_namespaceObject.mergeConfig)(config, {
|
|
129
123
|
entry: ((entry)=>{
|
|
130
124
|
var _userOptions_globalImport, _unpackConfig_html;
|
|
131
125
|
let root = unpackConfig.root;
|
|
@@ -143,8 +137,8 @@ ${renderer}
|
|
|
143
137
|
recursive: !0
|
|
144
138
|
}), external_node_fs_default().writeFileSync(filePath, tpl, 'utf-8'), entryConfig.import[0] = filePath;
|
|
145
139
|
}), entry;
|
|
146
|
-
})(
|
|
147
|
-
plugins:
|
|
140
|
+
})(entry1),
|
|
141
|
+
plugins: html1.map((h)=>new core_namespaceObject.rspack.HtmlRspackPlugin(h))
|
|
148
142
|
});
|
|
149
143
|
}, applySplitChunksConfig = ({ config })=>{
|
|
150
144
|
let currentConfig = config.optimization.splitChunks, extraGroups = {};
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { fileURLToPath as __webpack_fileURLToPath__ } from "node:url";
|
|
|
4
4
|
import { dirname as __webpack_dirname__ } from "node:path";
|
|
5
5
|
import node_path from "node:path";
|
|
6
6
|
import plugin_react_refresh from "@rspack/plugin-react-refresh";
|
|
7
|
-
import { TEMPLATE_CONTENT, TEMP_DIR, colors, esVersionToBrowserslist, getPathInJs, getPort, isDev, isDevServer, isFunction, isPlainObject, logger, mergeConfig as core_mergeConfig, removeDir,
|
|
7
|
+
import { TEMPLATE_CONTENT, TEMP_DIR, addRestartCleaner, colors, esVersionToBrowserslist, getPathInJs, getPort, isDev, isDevServer, isFunction, isPlainObject, logger, mergeConfig as core_mergeConfig, removeDir, rspack } from "@unpackjs/core";
|
|
8
8
|
import node_fs from "node:fs";
|
|
9
9
|
import node_http from "node:http";
|
|
10
10
|
import launch_editor from "launch-editor";
|
|
@@ -26,7 +26,7 @@ let applyClickToComponentConfig = async ({ config, unpackConfig })=>{
|
|
|
26
26
|
port
|
|
27
27
|
});
|
|
28
28
|
});
|
|
29
|
-
}),
|
|
29
|
+
}), addRestartCleaner(()=>new Promise((resolve)=>server.close(()=>resolve())));
|
|
30
30
|
}), injectScript = node_fs.readFileSync(node_path.resolve(click_to_component_dirname, './injectScript.js'), 'utf-8'), scriptTpl = `
|
|
31
31
|
if (!document.querySelector('#__click-to-component__')) {
|
|
32
32
|
const script = document.createElement('script')
|
|
@@ -59,56 +59,50 @@ import '${getPathInJs(node_path.resolve(Object.values(config.entry)[0]))}'
|
|
|
59
59
|
var _unpackConfig_performance_chunkSplit, _unpackConfig_performance;
|
|
60
60
|
let config = originalConfig;
|
|
61
61
|
unpackConfig.mpa && (config = (({ config, unpackConfig })=>{
|
|
62
|
-
let tempDirectory = node_path.join(TEMP_DIR, 'mpa'), userOptions = isPlainObject(unpackConfig.mpa) ? unpackConfig.mpa : {}, { entry, html } = (()=>{
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
let indexFilePath = node_path.join(dir, `index${extension}`);
|
|
72
|
-
if (node_fs.existsSync(indexFilePath)) return indexFilePath;
|
|
73
|
-
}
|
|
74
|
-
return null;
|
|
75
|
-
})(node_path.join(pagesRoot, filename));
|
|
76
|
-
if (indexFilePath) {
|
|
77
|
-
var _unpackConfig_html, _unpackConfig_html1, _unpackConfig_html2, _unpackConfig_html3, _unpackConfig_html4, _unpackConfig_html5, _unpackConfig_html6, _unpackConfig_html7, _unpackConfig_html8;
|
|
78
|
-
let pageConfig = ((indexPath)=>{
|
|
79
|
-
let filePath = node_path.join(indexPath, '../config.json'), pageConfig = {};
|
|
80
|
-
return node_fs.existsSync(filePath) && (pageConfig = JSON.parse(node_fs.readFileSync(filePath, 'utf-8'))), pageConfig;
|
|
81
|
-
})(indexFilePath), entryName = !0 === userOptions.lowerCase ? filename.toLowerCase() : filename;
|
|
82
|
-
pageConfig.filename && (entryName = pageConfig.filename.slice(0, -5)), entry[entryName] = {
|
|
83
|
-
import: [
|
|
84
|
-
indexFilePath
|
|
85
|
-
]
|
|
86
|
-
}, pageConfig.template && (pageConfig.template = node_path.join(indexFilePath, '../', pageConfig.template)), html.push({
|
|
87
|
-
template: (null == (_unpackConfig_html = unpackConfig.html) ? void 0 : _unpackConfig_html.template) || void 0,
|
|
88
|
-
templateContent: (null == (_unpackConfig_html1 = unpackConfig.html) ? void 0 : _unpackConfig_html1.templateContent) || ((null == (_unpackConfig_html2 = unpackConfig.html) ? void 0 : _unpackConfig_html2.template) ? void 0 : TEMPLATE_CONTENT),
|
|
89
|
-
minify: !1,
|
|
90
|
-
filename: `${entryName}.html`,
|
|
91
|
-
chunks: [
|
|
92
|
-
entryName
|
|
93
|
-
],
|
|
94
|
-
...pageConfig,
|
|
95
|
-
templateParameters: {
|
|
96
|
-
mountId: null == (_unpackConfig_html3 = unpackConfig.html) ? void 0 : _unpackConfig_html3.mountId,
|
|
97
|
-
title: isFunction(null == (_unpackConfig_html4 = unpackConfig.html) ? void 0 : _unpackConfig_html4.title) ? null == (_unpackConfig_html5 = unpackConfig.html) ? void 0 : _unpackConfig_html5.title({
|
|
98
|
-
entryName
|
|
99
|
-
}) : (null == (_unpackConfig_html6 = unpackConfig.html) ? void 0 : _unpackConfig_html6.title) || '',
|
|
100
|
-
headTag: (null == (_unpackConfig_html7 = unpackConfig.html) ? void 0 : _unpackConfig_html7.headTag) || '',
|
|
101
|
-
...null == (_unpackConfig_html8 = unpackConfig.html) ? void 0 : _unpackConfig_html8.templateParameters,
|
|
102
|
-
...pageConfig.templateParameters
|
|
103
|
-
}
|
|
104
|
-
});
|
|
62
|
+
let start, entry, html, pagesRoot, tempDirectory = node_path.join(TEMP_DIR, 'mpa'), userOptions = isPlainObject(unpackConfig.mpa) ? unpackConfig.mpa : {}, { entry: entry1, html: html1 } = (start = performance.now(), entry = {}, html = [], pagesRoot = node_path.join(unpackConfig.root, 'src', 'pages'), node_fs.readdirSync(pagesRoot).forEach((filename)=>{
|
|
63
|
+
if (filename.startsWith('.')) return;
|
|
64
|
+
let indexFilePath = ((dir)=>{
|
|
65
|
+
for (let extension of [
|
|
66
|
+
'.tsx',
|
|
67
|
+
'.jsx'
|
|
68
|
+
]){
|
|
69
|
+
let indexFilePath = node_path.join(dir, `index${extension}`);
|
|
70
|
+
if (node_fs.existsSync(indexFilePath)) return indexFilePath;
|
|
105
71
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
72
|
+
return null;
|
|
73
|
+
})(node_path.join(pagesRoot, filename));
|
|
74
|
+
if (indexFilePath) {
|
|
75
|
+
var _unpackConfig_html, _unpackConfig_html1, _unpackConfig_html2, _unpackConfig_html3, _unpackConfig_html4, _unpackConfig_html5, _unpackConfig_html6, _unpackConfig_html7, _unpackConfig_html8;
|
|
76
|
+
let filePath, pageConfig, pageConfig1 = (filePath = node_path.join(indexFilePath, '../config.json'), pageConfig = {}, node_fs.existsSync(filePath) && (pageConfig = JSON.parse(node_fs.readFileSync(filePath, 'utf-8'))), pageConfig), entryName = !0 === userOptions.lowerCase ? filename.toLowerCase() : filename;
|
|
77
|
+
pageConfig1.filename && (entryName = pageConfig1.filename.slice(0, -5)), entry[entryName] = {
|
|
78
|
+
import: [
|
|
79
|
+
indexFilePath
|
|
80
|
+
]
|
|
81
|
+
}, pageConfig1.template && (pageConfig1.template = node_path.join(indexFilePath, '../', pageConfig1.template)), html.push({
|
|
82
|
+
template: (null == (_unpackConfig_html = unpackConfig.html) ? void 0 : _unpackConfig_html.template) || void 0,
|
|
83
|
+
templateContent: (null == (_unpackConfig_html1 = unpackConfig.html) ? void 0 : _unpackConfig_html1.templateContent) || ((null == (_unpackConfig_html2 = unpackConfig.html) ? void 0 : _unpackConfig_html2.template) ? void 0 : TEMPLATE_CONTENT),
|
|
84
|
+
minify: !1,
|
|
85
|
+
filename: `${entryName}.html`,
|
|
86
|
+
chunks: [
|
|
87
|
+
entryName
|
|
88
|
+
],
|
|
89
|
+
...pageConfig1,
|
|
90
|
+
templateParameters: {
|
|
91
|
+
mountId: null == (_unpackConfig_html3 = unpackConfig.html) ? void 0 : _unpackConfig_html3.mountId,
|
|
92
|
+
title: isFunction(null == (_unpackConfig_html4 = unpackConfig.html) ? void 0 : _unpackConfig_html4.title) ? null == (_unpackConfig_html5 = unpackConfig.html) ? void 0 : _unpackConfig_html5.title({
|
|
93
|
+
entryName
|
|
94
|
+
}) : (null == (_unpackConfig_html6 = unpackConfig.html) ? void 0 : _unpackConfig_html6.title) || '',
|
|
95
|
+
headTag: (null == (_unpackConfig_html7 = unpackConfig.html) ? void 0 : _unpackConfig_html7.headTag) || '',
|
|
96
|
+
...null == (_unpackConfig_html8 = unpackConfig.html) ? void 0 : _unpackConfig_html8.templateParameters,
|
|
97
|
+
...pageConfig1.templateParameters
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}), isDevServer() || logger.info(`collect entries in ${(performance.now() - start).toFixed(2)}ms ${colors.dim('[MPA]')}`), {
|
|
102
|
+
entry,
|
|
103
|
+
html
|
|
104
|
+
});
|
|
105
|
+
return core_mergeConfig(config, {
|
|
112
106
|
entry: ((entry)=>{
|
|
113
107
|
var _userOptions_globalImport, _unpackConfig_html;
|
|
114
108
|
let root = unpackConfig.root;
|
|
@@ -126,8 +120,8 @@ ${renderer}
|
|
|
126
120
|
recursive: !0
|
|
127
121
|
}), node_fs.writeFileSync(filePath, tpl, 'utf-8'), entryConfig.import[0] = filePath;
|
|
128
122
|
}), entry;
|
|
129
|
-
})(
|
|
130
|
-
plugins:
|
|
123
|
+
})(entry1),
|
|
124
|
+
plugins: html1.map((h)=>new rspack.HtmlRspackPlugin(h))
|
|
131
125
|
});
|
|
132
126
|
})({
|
|
133
127
|
config,
|
package/dist/injectScript.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
const COVER_ID = '__click-to-component__';
|
|
2
|
+
let cover = null, currentDebugSource = null, enabled = !1;
|
|
2
3
|
function debounce(fn, delay = 200) {
|
|
3
4
|
let timer = null;
|
|
4
5
|
return (...args)=>{
|
|
@@ -52,9 +53,10 @@ function getClosestNodeFromFiber(fiber) {
|
|
|
52
53
|
return fiber.stateNode ? fiber.stateNode : getClosestNodeFromFiber(fiber.return);
|
|
53
54
|
}
|
|
54
55
|
function openEditor() {
|
|
56
|
+
let xhr;
|
|
55
57
|
if (!currentDebugSource) return;
|
|
56
|
-
let port = window.CLICK_TO_COMPONENT.port, { fileName, lineNumber, columnNumber } = currentDebugSource, url = "http://localhost:" + port + "/?file=" + fileName + "&line=" + lineNumber + "&column=" + columnNumber
|
|
57
|
-
xhr.open('GET', url, !0), xhr.send(), xhr.addEventListener('error', ()=>{
|
|
58
|
+
let port = window.CLICK_TO_COMPONENT.port, { fileName, lineNumber, columnNumber } = currentDebugSource, url = "http://localhost:" + port + "/?file=" + fileName + "&line=" + lineNumber + "&column=" + columnNumber;
|
|
59
|
+
(xhr = new XMLHttpRequest()).open('GET', url, !0), xhr.send(), xhr.addEventListener('error', ()=>{
|
|
58
60
|
document.createElement('img').src = url;
|
|
59
61
|
});
|
|
60
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/click-to-component/index.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/click-to-component/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,oBAAoB,EAIzB,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAA;AA6BvB,eAAO,MAAM,2BAA2B,GAAU,2BAG/C;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;CAC3B,KAAG,OAAO,CAAC,oBAAoB,CA+B/B,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unpackjs/plugin-react",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "React plugin for Unpack",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@rspack/plugin-react-refresh": "1.
|
|
27
|
+
"@rspack/plugin-react-refresh": "1.5.1",
|
|
28
28
|
"@svgr/webpack": "8.1.0",
|
|
29
29
|
"@swc/helpers": "0.5.17",
|
|
30
|
-
"launch-editor": "2.11.
|
|
30
|
+
"launch-editor": "2.11.1",
|
|
31
31
|
"react-refresh": "0.17.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@unpackjs/core": "3.
|
|
34
|
+
"@unpackjs/core": "3.3.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@unpackjs/core": "3.x"
|