react-native-bundle-discovery-ui 2.7.0-rc.0 → 2.7.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/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # react-native-bundle-discovery-ui
2
+
3
+ ## 2.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#16](https://github.com/retyui/react-native-bundle-discovery/pull/16) [`ac2af30`](https://github.com/retyui/react-native-bundle-discovery/commit/ac2af3063e3c4031ee026b58d4039e56f7152383) Thanks [@retyui](https://github.com/retyui)! - Rewrite in TypeScript and ship compiled JavaScript from `dist/` (with type definitions for `react-native-bundle-discovery` and the Rozenite plugin). Package entry points are unchanged; deep imports of internal files (e.g. `react-native-bundle-discovery/webpack.js`, `react-native-bundle-discovery-ui/.discoveryrc.js`) moved under `dist/`.
package/dist/bin.js CHANGED
@@ -14,120 +14,186 @@ chalk = require_rolldown_runtime.__toESM(chalk);
14
14
  let _discoveryjs_cli_lib_shared_utils_js = require("@discoveryjs/cli/lib/shared/utils.js");
15
15
  //#region src/build.ts
16
16
  function buildHtmlPage(filePath, output, clean, singleFile, verbose) {
17
- if (verbose) console.info(`Building HTML page from file: ${chalk.default.green(filePath)} options: ${JSON.stringify({
18
- output,
19
- clean,
20
- singleFile
21
- }, null, 2)}`);
22
- if (!filePath) {
23
- console.error(`Usage: '${chalk.default.green("npx react-native-bundle-discovery build <path-to-file>")}', Please provide a path to a JSON file.`);
24
- process.exit(1);
25
- }
26
- const jsonFilePath = node_path.default.resolve(process.cwd(), filePath);
27
- if (verbose) console.info(`Loading JSON file from: ${chalk.default.green(jsonFilePath)}, base directory: ${chalk.default.green(process.cwd())}`);
28
- let fullJsonPath;
29
- try {
30
- fullJsonPath = require.resolve(jsonFilePath);
31
- } catch (err) {
32
- console.error(`❌Error loading file: ${chalk.default.red(jsonFilePath)}\n\n`);
33
- console.error(err.message);
34
- process.exit(1);
35
- }
36
- const configFile = node_path.default.resolve(__dirname, "./.tmp.js");
37
- if (verbose) console.info(`Creating temporary config file at: ${chalk.default.green(configFile)}, for discovery.js`);
38
- const transformRcdoctor = node_path.default.join(__dirname, "rsdoctor.js");
39
- node_fs.default.writeFileSync(configFile, `const {transformRSDoctorData} = require("${transformRcdoctor}");
40
- module.exports = ${JSON.stringify({
41
- ...require_discoveryrc,
42
- data: "<tmp>"
43
- }, null, 1).replace(`"<tmp>"`, require_src.isRsdoctorReportPath(fullJsonPath) ? `() => transformRSDoctorData(require("${fullJsonPath}"))` : `() => require("${fullJsonPath}")`)};`);
44
- if (verbose) console.info(`Building HTML page with options:`, {
45
- output,
46
- clean,
47
- singleFile
48
- });
49
- const _config = {
50
- name: "Bundle Discovery",
51
- mode: "single",
52
- colorScheme: "auto",
53
- download: true,
54
- upload: false,
55
- embed: false,
56
- encodings: false
57
- };
58
- const _options = {
59
- singleFile,
60
- clean,
61
- output,
62
- cache: true,
63
- cachedir: node_path.default.resolve(__dirname, "./.discoveryjs-cache"),
64
- checkCacheTtl: false,
65
- minify: true,
66
- dataCompression: true,
67
- sourcemap: false,
68
- embed: "by-config",
69
- experimentalJsonxl: false,
70
- scriptFormat: "esm",
71
- scriptExternal: [],
72
- data: true,
73
- excludeModelOnDataFail: false,
74
- prettyData: false,
75
- modelDownload: false,
76
- modelDataUpload: true,
77
- modelResetCache: false,
78
- serveOnlyAssets: true,
79
- dev: true,
80
- config: configFile,
81
- configFile
82
- };
83
- return (0, _discoveryjs_cli.build)(_options, _config, configFile).then(() => {
84
- console.log(`========================================`);
85
- console.log(`✅ HTML page built successfully at: ${chalk.default.green(node_path.default.resolve(output, "index.html").replace(`${process.cwd()}/`, ""))}`);
86
- console.log(`========================================`);
87
- });
17
+ if (verbose)
18
+ console.info(
19
+ `Building HTML page from file: ${chalk.default.green(filePath)} options: ${JSON.stringify(
20
+ {
21
+ output,
22
+ clean,
23
+ singleFile,
24
+ },
25
+ null,
26
+ 2,
27
+ )}`,
28
+ );
29
+ if (!filePath) {
30
+ console.error(
31
+ `Usage: '${chalk.default.green("npx react-native-bundle-discovery build <path-to-file>")}', Please provide a path to a JSON file.`,
32
+ );
33
+ process.exit(1);
34
+ }
35
+ const jsonFilePath = node_path.default.resolve(process.cwd(), filePath);
36
+ if (verbose)
37
+ console.info(
38
+ `Loading JSON file from: ${chalk.default.green(jsonFilePath)}, base directory: ${chalk.default.green(process.cwd())}`,
39
+ );
40
+ let fullJsonPath;
41
+ try {
42
+ fullJsonPath = require.resolve(jsonFilePath);
43
+ } catch (err) {
44
+ console.error(
45
+ `❌Error loading file: ${chalk.default.red(jsonFilePath)}\n\n`,
46
+ );
47
+ console.error(err.message);
48
+ process.exit(1);
49
+ }
50
+ const configFile = node_path.default.resolve(__dirname, "./.tmp.js");
51
+ if (verbose)
52
+ console.info(
53
+ `Creating temporary config file at: ${chalk.default.green(configFile)}, for discovery.js`,
54
+ );
55
+ const transformRcdoctor = node_path.default.join(__dirname, "rsdoctor.js");
56
+ node_fs.default.writeFileSync(
57
+ configFile,
58
+ `const {transformRSDoctorData} = require("${transformRcdoctor}");
59
+ module.exports = ${JSON.stringify(
60
+ {
61
+ ...require_discoveryrc,
62
+ data: "<tmp>",
63
+ },
64
+ null,
65
+ 1,
66
+ ).replace(
67
+ `"<tmp>"`,
68
+ require_src.isRsdoctorReportPath(fullJsonPath)
69
+ ? `() => transformRSDoctorData(require("${fullJsonPath}"))`
70
+ : `() => require("${fullJsonPath}")`,
71
+ )};`,
72
+ );
73
+ if (verbose)
74
+ console.info(`Building HTML page with options:`, {
75
+ output,
76
+ clean,
77
+ singleFile,
78
+ });
79
+ const _config = {
80
+ name: "Bundle Discovery",
81
+ mode: "single",
82
+ colorScheme: "auto",
83
+ download: true,
84
+ upload: false,
85
+ embed: false,
86
+ encodings: false,
87
+ };
88
+ const _options = {
89
+ singleFile,
90
+ clean,
91
+ output,
92
+ cache: true,
93
+ cachedir: node_path.default.resolve(__dirname, "./.discoveryjs-cache"),
94
+ checkCacheTtl: false,
95
+ minify: true,
96
+ dataCompression: true,
97
+ sourcemap: false,
98
+ embed: "by-config",
99
+ experimentalJsonxl: false,
100
+ scriptFormat: "esm",
101
+ scriptExternal: [],
102
+ data: true,
103
+ excludeModelOnDataFail: false,
104
+ prettyData: false,
105
+ modelDownload: false,
106
+ modelDataUpload: true,
107
+ modelResetCache: false,
108
+ serveOnlyAssets: true,
109
+ dev: true,
110
+ config: configFile,
111
+ configFile,
112
+ };
113
+ return (0, _discoveryjs_cli.build)(_options, _config, configFile).then(() => {
114
+ console.log(`========================================`);
115
+ console.log(
116
+ `✅ HTML page built successfully at: ${chalk.default.green(node_path.default.resolve(output, "index.html").replace(`${process.cwd()}/`, ""))}`,
117
+ );
118
+ console.log(`========================================`);
119
+ });
88
120
  }
89
121
  //#endregion
90
122
  //#region src/server.ts
91
123
  function serve(filePath, port, verbose) {
92
- const PORT = process.env.PORT || port;
93
- if (verbose) console.info(`start server with file: ${filePath} on port: ${port} ${process.env.PORT ? `(${chalk.default.yellow("PORT")} env)` : ""}`);
94
- if (!filePath) {
95
- console.error(`Usage: '${chalk.default.green("npx react-native-bundle-discovery server <path-to-file>")}', Please provide a path to a JSON file.`);
96
- process.exit(1);
97
- }
98
- const jsonFilePath = node_path.default.resolve(process.cwd(), filePath);
99
- if (verbose) console.info(`Loading JSON file from: ${chalk.default.green(jsonFilePath)}, base directory: ${chalk.default.green(process.cwd())}`);
100
- let fullJsonPath;
101
- try {
102
- fullJsonPath = require.resolve(jsonFilePath);
103
- } catch (err) {
104
- console.error(`❌Error loading file: ${chalk.default.red(jsonFilePath)}\n\n`);
105
- console.error(err.message);
106
- process.exit(1);
107
- }
108
- const configFile = node_path.default.resolve(__dirname, "./.tmp.js");
109
- if (verbose) console.info(`Creating temporary config file at: ${chalk.default.green(configFile)}, for discovery.js`);
110
- const transformRcdoctor = node_path.default.join(__dirname, "rsdoctor.js");
111
- node_fs.default.writeFileSync(configFile, `const {transformRSDoctorData} = require("${transformRcdoctor}");
112
- module.exports = ${JSON.stringify({
113
- ...require_discoveryrc,
114
- data: "<tmp>"
115
- }, null, 1).replace(`"<tmp>"`, require_src.isRsdoctorReportPath(fullJsonPath) ? `() => transformRSDoctorData(require("${fullJsonPath}"))` : `() => require("${fullJsonPath}")`)};`);
116
- if (verbose) console.info(`Running server with config: ${chalk.default.green(configFile)}`);
117
- return (0, _discoveryjs_cli_lib_shared_utils_js.silent)(() => (0, _discoveryjs_cli.createServer)({
118
- cache: false,
119
- minify: true,
120
- dev: false,
121
- config: configFile,
122
- configFile
123
- }).then((server) => server.listen(PORT, () => {
124
- console.log(`[react-native-bundle-discovery]: 🚀 Server listen on ${chalk.default.green.underline(chalk.default.green(`http://localhost:${PORT}`))}`);
125
- })));
124
+ const PORT = process.env.PORT || port;
125
+ if (verbose)
126
+ console.info(
127
+ `start server with file: ${filePath} on port: ${port} ${process.env.PORT ? `(${chalk.default.yellow("PORT")} env)` : ""}`,
128
+ );
129
+ if (!filePath) {
130
+ console.error(
131
+ `Usage: '${chalk.default.green("npx react-native-bundle-discovery server <path-to-file>")}', Please provide a path to a JSON file.`,
132
+ );
133
+ process.exit(1);
134
+ }
135
+ const jsonFilePath = node_path.default.resolve(process.cwd(), filePath);
136
+ if (verbose)
137
+ console.info(
138
+ `Loading JSON file from: ${chalk.default.green(jsonFilePath)}, base directory: ${chalk.default.green(process.cwd())}`,
139
+ );
140
+ let fullJsonPath;
141
+ try {
142
+ fullJsonPath = require.resolve(jsonFilePath);
143
+ } catch (err) {
144
+ console.error(
145
+ `❌Error loading file: ${chalk.default.red(jsonFilePath)}\n\n`,
146
+ );
147
+ console.error(err.message);
148
+ process.exit(1);
149
+ }
150
+ const configFile = node_path.default.resolve(__dirname, "./.tmp.js");
151
+ if (verbose)
152
+ console.info(
153
+ `Creating temporary config file at: ${chalk.default.green(configFile)}, for discovery.js`,
154
+ );
155
+ const transformRcdoctor = node_path.default.join(__dirname, "rsdoctor.js");
156
+ node_fs.default.writeFileSync(
157
+ configFile,
158
+ `const {transformRSDoctorData} = require("${transformRcdoctor}");
159
+ module.exports = ${JSON.stringify(
160
+ {
161
+ ...require_discoveryrc,
162
+ data: "<tmp>",
163
+ },
164
+ null,
165
+ 1,
166
+ ).replace(
167
+ `"<tmp>"`,
168
+ require_src.isRsdoctorReportPath(fullJsonPath)
169
+ ? `() => transformRSDoctorData(require("${fullJsonPath}"))`
170
+ : `() => require("${fullJsonPath}")`,
171
+ )};`,
172
+ );
173
+ if (verbose)
174
+ console.info(
175
+ `Running server with config: ${chalk.default.green(configFile)}`,
176
+ );
177
+ return (0, _discoveryjs_cli_lib_shared_utils_js.silent)(() =>
178
+ (0, _discoveryjs_cli.createServer)({
179
+ cache: false,
180
+ minify: true,
181
+ dev: false,
182
+ config: configFile,
183
+ configFile,
184
+ }).then((server) =>
185
+ server.listen(PORT, () => {
186
+ console.log(
187
+ `[react-native-bundle-discovery]: 🚀 Server listen on ${chalk.default.green.underline(chalk.default.green(`http://localhost:${PORT}`))}`,
188
+ );
189
+ }),
190
+ ),
191
+ );
126
192
  }
127
193
  //#endregion
128
194
  //#region src/bin.ts
129
195
  function printHelp() {
130
- console.log(`react-native-bundle-discovery-ui
196
+ console.log(`react-native-bundle-discovery-ui
131
197
 
132
198
  Usage:
133
199
  react-native-bundle-discovery-ui <file> [port] [--verbose] # <- server can be omitted
@@ -149,54 +215,57 @@ Options:
149
215
  `);
150
216
  }
151
217
  function fail(message) {
152
- console.error(message);
153
- console.error("Use --help to see usage.");
154
- process.exit(1);
218
+ console.error(message);
219
+ console.error("Use --help to see usage.");
220
+ process.exit(1);
155
221
  }
156
222
  function main() {
157
- const argv = (0, minimist.default)(process.argv.slice(2), {
158
- alias: {
159
- v: "verbose",
160
- h: "help",
161
- o: "output",
162
- c: "clean",
163
- s: "single-file",
164
- p: "port"
165
- },
166
- boolean: [
167
- "verbose",
168
- "help",
169
- "clean",
170
- "single-file"
171
- ],
172
- string: ["output"],
173
- default: {
174
- clean: true,
175
- "single-file": true
176
- }
177
- });
178
- const command = argv._[0];
179
- const isServerCommand = command === "server";
180
- const isBuildCommand = command === "build";
181
- const isImplicitServerCommand = Boolean(command) && !isServerCommand && !isBuildCommand;
182
- if (argv.help || !command) {
183
- printHelp();
184
- process.exit(0);
185
- }
186
- if (isServerCommand || isImplicitServerCommand) {
187
- const file = isImplicitServerCommand ? argv._[0] : argv._[1];
188
- if (!file) fail("Missing required argument: <file>");
189
- const rawPort = argv.port ?? (isImplicitServerCommand ? argv._[1] : argv._[2]) ?? 8079;
190
- const port = Number(rawPort);
191
- if (!Number.isFinite(port)) fail(`Invalid port: ${rawPort}`);
192
- return serve(file, port, Boolean(argv.verbose));
193
- }
194
- if (isBuildCommand) {
195
- const file = argv._[1];
196
- if (!file) fail("Missing required argument: <file>");
197
- return buildHtmlPage(file, argv.output, argv.clean, argv["single-file"], Boolean(argv.verbose));
198
- }
199
- fail(`Unknown command: ${command}`);
223
+ const argv = (0, minimist.default)(process.argv.slice(2), {
224
+ alias: {
225
+ v: "verbose",
226
+ h: "help",
227
+ o: "output",
228
+ c: "clean",
229
+ s: "single-file",
230
+ p: "port",
231
+ },
232
+ boolean: ["verbose", "help", "clean", "single-file"],
233
+ string: ["output"],
234
+ default: {
235
+ clean: true,
236
+ "single-file": true,
237
+ },
238
+ });
239
+ const command = argv._[0];
240
+ const isServerCommand = command === "server";
241
+ const isBuildCommand = command === "build";
242
+ const isImplicitServerCommand =
243
+ Boolean(command) && !isServerCommand && !isBuildCommand;
244
+ if (argv.help || !command) {
245
+ printHelp();
246
+ process.exit(0);
247
+ }
248
+ if (isServerCommand || isImplicitServerCommand) {
249
+ const file = isImplicitServerCommand ? argv._[0] : argv._[1];
250
+ if (!file) fail("Missing required argument: <file>");
251
+ const rawPort =
252
+ argv.port ?? (isImplicitServerCommand ? argv._[1] : argv._[2]) ?? 8079;
253
+ const port = Number(rawPort);
254
+ if (!Number.isFinite(port)) fail(`Invalid port: ${rawPort}`);
255
+ return serve(file, port, Boolean(argv.verbose));
256
+ }
257
+ if (isBuildCommand) {
258
+ const file = argv._[1];
259
+ if (!file) fail("Missing required argument: <file>");
260
+ return buildHtmlPage(
261
+ file,
262
+ argv.output,
263
+ argv.clean,
264
+ argv["single-file"],
265
+ Boolean(argv.verbose),
266
+ );
267
+ }
268
+ fail(`Unknown command: ${command}`);
200
269
  }
201
270
  main();
202
271
  //#endregion
@@ -6,18 +6,32 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
8
  var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
15
- }
16
- return to;
9
+ if ((from && typeof from === "object") || typeof from === "function")
10
+ for (
11
+ var keys = __getOwnPropNames(from), i = 0, n = keys.length, key;
12
+ i < n;
13
+ i++
14
+ ) {
15
+ key = keys[i];
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, {
18
+ get: ((k) => from[k]).bind(null, key),
19
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
20
+ });
21
+ }
22
+ return to;
17
23
  };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
19
- value: mod,
20
- enumerable: true
21
- }) : target, mod));
24
+ var __toESM = (mod, isNodeMode, target) => (
25
+ (target = mod != null ? __create(__getProtoOf(mod)) : {}),
26
+ __copyProps(
27
+ isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default")
28
+ ? __defProp(target, "default", {
29
+ value: mod,
30
+ enumerable: true,
31
+ })
32
+ : target,
33
+ mod,
34
+ )
35
+ );
22
36
  //#endregion
23
37
  exports.__toESM = __toESM;