react-native-bundle-discovery-ui 2.6.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/lib/build.js DELETED
@@ -1,123 +0,0 @@
1
- const fs = require("fs");
2
- const path = require("path");
3
- const chalk = require("chalk");
4
- const { build } = require("@discoveryjs/cli");
5
- const config = require("../.discoveryrc.js");
6
- const { isRsdoctorReportPath } = require("./isRsdoctorReport.js");
7
-
8
- function buildHtmlPage(filePath, output, clean, singleFile, verbose) {
9
- if (verbose) {
10
- console.info(
11
- `Building HTML page from file: ${chalk.green(filePath)} options: ${JSON.stringify(
12
- { output, clean, singleFile },
13
- null,
14
- 2,
15
- )}`,
16
- );
17
- }
18
-
19
- if (!filePath) {
20
- console.error(
21
- `Usage: '${chalk.green("npx react-native-bundle-discovery build <path-to-file>")}', Please provide a path to a JSON file.`,
22
- );
23
- process.exit(1);
24
- }
25
-
26
- const jsonFilePath = path.resolve(process.cwd(), filePath);
27
- if (verbose) {
28
- console.info(
29
- `Loading JSON file from: ${chalk.green(jsonFilePath)}, base directory: ${chalk.green(process.cwd())}`,
30
- );
31
- }
32
-
33
- let fullJsonPath;
34
-
35
- try {
36
- fullJsonPath = require.resolve(jsonFilePath);
37
- } catch (err) {
38
- console.error(`❌Error loading file: ${chalk.red(jsonFilePath)}\n\n`);
39
- console.error(err.message);
40
- process.exit(1);
41
- }
42
-
43
- const configFile = path.resolve(__dirname, "./.tmp.js");
44
-
45
- if (verbose) {
46
- console.info(
47
- `Creating temporary config file at: ${chalk.green(configFile)}, for discovery.js`,
48
- );
49
- }
50
- const transformRcdoctor = require.resolve("./rsdoctor.js");
51
- fs.writeFileSync(
52
- configFile,
53
- `const {transformRSDoctorData} = require("${transformRcdoctor}");
54
- module.exports = ${JSON.stringify(
55
- { ...config, data: "<tmp>" },
56
- null,
57
- 1,
58
- ).replace(
59
- `"<tmp>"`,
60
- isRsdoctorReportPath(fullJsonPath)
61
- ? `() => transformRSDoctorData(require("${fullJsonPath}"))`
62
- : `() => require("${fullJsonPath}")`,
63
- )};`,
64
- );
65
-
66
- if (verbose) {
67
- console.info(`Building HTML page with options:`, {
68
- output,
69
- clean,
70
- singleFile,
71
- });
72
- }
73
-
74
- const _config = {
75
- name: "Bundle Discovery",
76
- mode: "single",
77
- // models: [ [Object] ],
78
- colorScheme: "auto",
79
- download: true,
80
- upload: false,
81
- embed: false,
82
- encodings: false,
83
- };
84
- const _options = {
85
- singleFile,
86
- clean,
87
- output,
88
- //
89
- cache: true,
90
- cachedir: path.resolve(__dirname, "./.discoveryjs-cache"),
91
- checkCacheTtl: false,
92
- minify: true,
93
- dataCompression: true,
94
- sourcemap: false,
95
- embed: "by-config",
96
- experimentalJsonxl: false,
97
- scriptFormat: "esm",
98
- scriptExternal: [],
99
- data: true,
100
- excludeModelOnDataFail: false,
101
- prettyData: false,
102
- modelDownload: false,
103
- modelDataUpload: true,
104
- modelResetCache: false,
105
- serveOnlyAssets: true,
106
- dev: true,
107
- config: configFile,
108
- configFile: configFile,
109
- };
110
- return build(_options, _config, configFile).then((result) => {
111
- console.log(`========================================`);
112
- console.log(
113
- `✅ HTML page built successfully at: ${chalk.green(
114
- path.resolve(output, "index.html").replace(process.cwd() + "/", ""),
115
- )}`,
116
- );
117
- console.log(`========================================`);
118
- });
119
- }
120
-
121
- module.exports = {
122
- buildHtmlPage,
123
- };
package/lib/server.js DELETED
@@ -1,90 +0,0 @@
1
- const fs = require("fs");
2
- const path = require("path");
3
- const chalk = require("chalk");
4
- const { createServer } = require("@discoveryjs/cli");
5
- const { silent } = require("@discoveryjs/cli/lib/shared/utils.js");
6
- const config = require("../.discoveryrc.js");
7
- const { isRsdoctorReportPath } = require("./isRsdoctorReport.js");
8
-
9
- function serve(filePath, port, verbose) {
10
- const PORT = process.env.PORT || port;
11
-
12
- if (verbose) {
13
- console.info(
14
- `start server with file: ${filePath} on port: ${port} ${process.env.PORT ? `(${chalk.yellow("PORT")} env)` : ""}`,
15
- );
16
- }
17
-
18
- if (!filePath) {
19
- console.error(
20
- `Usage: '${chalk.green("npx react-native-bundle-discovery server <path-to-file>")}', Please provide a path to a JSON file.`,
21
- );
22
- process.exit(1);
23
- }
24
-
25
- const jsonFilePath = path.resolve(process.cwd(), filePath);
26
- if (verbose) {
27
- console.info(
28
- `Loading JSON file from: ${chalk.green(jsonFilePath)}, base directory: ${chalk.green(process.cwd())}`,
29
- );
30
- }
31
-
32
- let fullJsonPath;
33
-
34
- try {
35
- fullJsonPath = require.resolve(jsonFilePath);
36
- } catch (err) {
37
- console.error(`❌Error loading file: ${chalk.red(jsonFilePath)}\n\n`);
38
- console.error(err.message);
39
- process.exit(1);
40
- }
41
-
42
- const configFile = path.resolve(__dirname, "./.tmp.js");
43
-
44
- if (verbose) {
45
- console.info(
46
- `Creating temporary config file at: ${chalk.green(configFile)}, for discovery.js`,
47
- );
48
- }
49
- const transformRcdoctor = require.resolve("./rsdoctor.js");
50
- fs.writeFileSync(
51
- configFile,
52
- `const {transformRSDoctorData} = require("${transformRcdoctor}");
53
- module.exports = ${JSON.stringify(
54
- { ...config, data: "<tmp>" },
55
- null,
56
- 1,
57
- ).replace(
58
- `"<tmp>"`,
59
- isRsdoctorReportPath(fullJsonPath)
60
- ? `() => transformRSDoctorData(require("${fullJsonPath}"))`
61
- : `() => require("${fullJsonPath}")`,
62
- )};`,
63
- );
64
-
65
- if (verbose) {
66
- console.info(`Running server with config: ${chalk.green(configFile)}`);
67
- }
68
-
69
- return silent(() =>
70
- createServer({
71
- cache: false,
72
- minify: true,
73
- dev: false,
74
- config: configFile,
75
- configFile,
76
- }).then((server) =>
77
- server.listen(PORT, () => {
78
- console.log(
79
- `[react-native-bundle-discovery]: 🚀 Server listen on ${chalk.green.underline(
80
- chalk.green(`http://localhost:${PORT}`),
81
- )}`,
82
- );
83
- }),
84
- ),
85
- );
86
- }
87
-
88
- module.exports = {
89
- serve,
90
- };
package/prepare.js DELETED
@@ -1,102 +0,0 @@
1
- function getDuplicateId(path) {
2
- const uniqueNodeModulePath = path.split("node_modules/").pop();
3
- const ids = [uniqueNodeModulePath];
4
-
5
- // Special case for lodash
6
- if (
7
- uniqueNodeModulePath.startsWith("lodash.") ||
8
- uniqueNodeModulePath.startsWith("lodash-es/")
9
- ) {
10
- // node_modules/lodash.debounce/index.js => node_modules/lodash/debounce.js
11
- // node_modules/lodash-es/get.js => node_modules/lodash/get.js
12
- const uniqueLodashPath = uniqueNodeModulePath
13
- .replace("lodash-es/", "lodash/")
14
- .replace("lodash.", "lodash/")
15
- .replace("/index.js", ".js");
16
-
17
- ids.push(uniqueLodashPath);
18
- }
19
-
20
- return ids;
21
- }
22
-
23
- function prepare(data) {
24
- // data.modules = data.modules.slice(875, 880); TODO for debugging a formtree chart
25
- let moduleMap = new Map();
26
- let duplicatesMap = new Map();
27
- let allLodashModules = new Set();
28
-
29
- data.packages.forEach((pkg) => {
30
- pkg.path = pkg.absolutePath.replace(data.rootFolder + "/", "");
31
- });
32
- data.modules.forEach((m) => {
33
- // 0. Data transformation
34
- m.absolutePath = m.path;
35
- if (m.absolutePath === data.entryPoint) {
36
- m.isEntry = true;
37
- }
38
- m.path = m.path.replace(data.rootFolder + "/", "");
39
- m.dependencies.forEach((d) => {
40
- d.path = d.absolutePath.replace(data.rootFolder + "/", "");
41
- });
42
-
43
- // 1. Duplicates
44
- m._tmp_ids = getDuplicateId(m.path);
45
- m.duplicates = [];
46
- m._tmp_ids.forEach((id) => {
47
- if (!duplicatesMap.has(id)) {
48
- duplicatesMap.set(id, []);
49
- }
50
- duplicatesMap.get(id).push(m);
51
- });
52
- // lodash/*
53
- // lodash-es/*
54
- // lodash.*
55
- if (m.path.includes("node_modules/lodash")) {
56
- allLodashModules.add(m);
57
- }
58
-
59
- // 2. Dependencies
60
- m.dependents = [];
61
- moduleMap.set(m.absolutePath, m);
62
-
63
- // 3. Other
64
- // 3.1 Format prelude
65
- if (m.path === "__prelude__") {
66
- m.source.code = m.source.code
67
- .replaceAll(";", ";\n\n")
68
- .replaceAll(",", ",\n ");
69
- }
70
- });
71
-
72
- data.modules.forEach((m) => {
73
- // 1. Duplicates
74
- m._tmp_ids.forEach((id) => {
75
- const duplicates = duplicatesMap.get(id);
76
- if (duplicates.length > 1) {
77
- m.duplicates.push(...duplicates.filter((d) => d !== m));
78
- }
79
- });
80
-
81
- // lodash/index.js is a special case (as index.js includes all lodash functions)
82
- if (m.path.endsWith("node_modules/lodash/index.js")) {
83
- m.duplicates.push(...allLodashModules);
84
- }
85
- delete m._tmp_ids;
86
-
87
- // 2. Dependencies
88
- m.dependencies.forEach((dependency) => {
89
- const dependentModule = moduleMap.get(dependency.absolutePath);
90
- if (dependentModule) {
91
- dependentModule.dependents.push(m); //add to the dependent module directly
92
- }
93
- });
94
- });
95
-
96
- allLodashModules = null;
97
- moduleMap = null;
98
- duplicatesMap = null;
99
- return data;
100
- }
101
-
102
- module.exports = prepare;
package/setup.js DELETED
@@ -1,12 +0,0 @@
1
- const prepare = require("./prepare");
2
- const queryHelpers = require("./queryHelpers");
3
-
4
- module.exports = function setup({
5
- defineObjectMarker,
6
- addQueryHelpers,
7
- setPrepare,
8
- }) {
9
- // extend queries with custom methods
10
- addQueryHelpers(queryHelpers);
11
- setPrepare(prepare);
12
- };
package/views/_theme.js DELETED
@@ -1,35 +0,0 @@
1
- function isDark() {
2
- const isSystemDarkMode = window?.matchMedia?.(
3
- "(prefers-color-scheme: dark)",
4
- )?.matches;
5
- const userMode = localStorage.getItem("discoveryjs:color-scheme");
6
- return userMode === "auto" ? isSystemDarkMode : userMode === "dark";
7
- }
8
-
9
- function doTheming(el) {
10
- const dark = isDark();
11
- el.classList.add("highcharts-light");
12
- el.classList[!dark ? "add" : "remove"]("my-light");
13
- el.classList[dark ? "add" : "remove"]("highcharts-dark");
14
- }
15
-
16
- // apply theme on import
17
- if (isDark()) {
18
- // require("highcharts/themes/dark-unica"); // no
19
- // require("highcharts/themes/brand-dark");
20
- // require("highcharts/themes/dark-blue");
21
- // require("highcharts/themes/dark-green");
22
- require("../vendors/high-contrast-dark.js");
23
- } else {
24
- // require("highcharts/themes/avocado");
25
- // require("highcharts/themes/brand-light");
26
- // require("highcharts/themes/gray");
27
- // require("highcharts/themes/grid-light"); // no
28
- // require("highcharts/themes/grid");
29
- // require("highcharts/themes/high-contrast-light");
30
- // require("highcharts/themes/sand-signika"); // no
31
- // require("highcharts/themes/skies");
32
- // require("highcharts/themes/sunset");
33
- }
34
-
35
- module.exports = { doTheming };
package/views/global.css DELETED
@@ -1,169 +0,0 @@
1
- hr{
2
- border: 1px solid rgb(222 222 222);
3
- margin-top: 1rem;
4
- margin-bottom: 1rem;
5
- }
6
-
7
- .inline-block{
8
- display: inline-block;
9
- }
10
- .discovery-content>.page-default{
11
- height: 100%;
12
- overflow: hidden;
13
- padding-top: 16px;
14
- padding-bottom: 16px;
15
- }
16
- .view-tabs-content>.view-content-filter>.view-input{
17
- padding-top: 12px;
18
- padding-bottom: 12px;
19
- margin: 0;
20
- background-color: var(--discovery-background-color);
21
- position: sticky;
22
- top: 0;
23
- z-index: 1;
24
- }
25
- .main-tabs{
26
- height: calc(100% - 20px);
27
- margin-top: 12px;
28
- }
29
- .main-tabs .view-tabs-content{
30
- height: calc(100% - 32px);
31
- }
32
- .foamtree-filter,
33
- .view-foamtree{
34
- width: 100%;
35
- height: 100%;
36
- }
37
- .foamtree-filter>.content{
38
- height: calc(100% - 60px);
39
- width: 100%;
40
- }
41
- .tooltip {
42
- position: absolute;
43
- z-index: 10;
44
- display: none;
45
- background-color: #fff;
46
- border: 1px solid #ccc;
47
- padding: 5px;
48
- border-radius: 5px;
49
- box-shadow: 0 0 5px #ccc;
50
- }
51
- .tooltip-name{
52
- text-transform: capitalize;
53
- }
54
- .flex-no-wrap{
55
- flex-wrap: nowrap;
56
- }
57
- .width-50p{
58
- width: 50%;
59
- }
60
- .my-icon{
61
- display: block;
62
- height: 100%;
63
- width: 100%;
64
- }
65
- .my-icon-inline{
66
- display: inline-block;
67
- vertical-align: middle;
68
- margin-left: 4px;
69
- }
70
- .my-icon-12{
71
- width: 12px;
72
- height: 12px;
73
- }
74
- .no-margin{
75
- margin: 0;
76
- }
77
- .two-column>*{
78
- width: 50%;
79
- }
80
- .m-v-8{
81
- margin-top: 8px;
82
- margin-bottom: 8px;
83
- }
84
- .i-duplicate{
85
- display: inline-block;
86
- background: #da444e;
87
- color: #fff;
88
- border-radius: 0.5em;
89
- padding: 0 0.5em;
90
- }
91
- .m-l-0_5em{
92
- margin-left: 0.5em;
93
- }
94
- .m-r-0_3em{
95
- margin-right: 0.3em;
96
- }
97
- .copy-to-clipboard{
98
- /* from: https://tabler.io/icons/icon/clipboard-copy */
99
- background: url('data:image/svg+xml,%3Csvg%20%20xmlns=%22http://www.w3.org/2000/svg%22%20%20width=%2224%22%20%20height=%2224%22%20%20viewBox=%220%200%2024%2024%22%20%20fill=%22none%22%20%20stroke=%22currentColor%22%20%20stroke-width=%222%22%20%20stroke-linecap=%22round%22%20%20stroke-linejoin=%22round%22%20%20class=%22icon%20icon-tabler%20icons-tabler-outline%20icon-tabler-clipboard-copy%22%3E%3Cpath%20stroke=%22none%22%20d=%22M0%200h24v24H0z%22%20fill=%22none%22/%3E%3Cpath%20d=%22M9%205h-2a2%202%200%200%200%20-2%202v12a2%202%200%200%200%202%202h3m9%20-9v-5a2%202%200%200%200%20-2%20-2h-2%22%20/%3E%3Cpath%20d=%22M13%2017v-1a1%201%200%200%201%201%20-1h1m3%200h1a1%201%200%200%201%201%201v1m0%203v1a1%201%200%200%201%20-1%201h-1m-3%200h-1a1%201%200%200%201%20-1%20-1v-1%22%20/%3E%3Cpath%20d=%22M9%203m0%202a2%202%200%200%201%202%20-2h2a2%202%200%200%201%202%202v0a2%202%200%200%201%20-2%202h-2a2%202%200%200%201%20-2%20-2z%22%20/%3E%3C/svg%3E');
100
- background-repeat: no-repeat;
101
- background-position: center;
102
- display: inline-block;
103
- height: 32px;
104
- width: 32px;
105
- }
106
- .copy-to-clipboard::before {
107
- position: absolute;
108
- top: -8px;
109
- font-size: 0.7rem;
110
- border-radius: 4px;
111
- display: inline-block;
112
- padding: 1px 4px;
113
- color: #fff;
114
- left: 78%;
115
- opacity: 0;
116
- transition: opacity 0.3s ease-in-out;
117
- }
118
- .copy-to-clipboard.done::before {
119
- content: "Copied!";
120
- background: green;
121
- opacity: 1;
122
- }
123
- .copy-to-clipboard.err::before {
124
- content: "Error!";
125
- background: red;
126
- opacity: 1;
127
- }
128
- .prettify-checkbox{
129
- position: absolute;
130
- right: 31px;
131
- margin-top: -26px;
132
- z-index: 1;
133
- }
134
- .ask-chatgpt{
135
- color: var(--discovery-view-button-color, #000);
136
- text-decoration: none;
137
- vertical-align: middle;
138
- position: absolute;
139
- z-index: 9;
140
- margin-top: 12px;
141
- margin-left: 105px !important;
142
- height: 35px;
143
- }
144
- .ask-chatgpt::before {
145
- content: '”';
146
- font-size: 2em;
147
- vertical-align: middle;
148
- font-family: math;
149
- margin-right: 0.2em;
150
- display: inline-block;
151
- height: 15px;
152
- }
153
- .packages-content>.view-input{
154
- padding-left: 265px;
155
- }
156
- .copy-before-ask-chatgpt{
157
- width: 95px;
158
- background-position: left center;
159
- padding-left: 25px;
160
- position: absolute;
161
- z-index: 9;
162
- margin-top: 12px;
163
- height: 35px;
164
- }
165
- .bundlejs-badge-img{
166
- line-height: 0;
167
- margin-bottom: -5px;
168
- margin-left: 10px;
169
- }
@@ -1,43 +0,0 @@
1
- import Highcharts from "../vendors/highcharts.js";
2
- import "../vendors/highcharts-networkgraph.js";
3
- import "../vendors/highcharts-exporting.js";
4
-
5
- const { doTheming } = require("./_theme");
6
-
7
- discovery.view.define("highcharts", function (el, config, rawData, context) {
8
- doTheming(el);
9
-
10
- if (Array.isArray(rawData?.options?.series)) {
11
- rawData.options.series.forEach((e) => {
12
- if (e.data?.[0]?.value !== undefined) {
13
- // mutate data by link
14
- e.data = e.data.map((d) => d.value ?? null);
15
- }
16
- });
17
- }
18
-
19
- // console.log({ rawData });
20
-
21
- try {
22
- Highcharts.chart(
23
- el,
24
- Highcharts.merge(
25
- {
26
- // default options
27
- },
28
- rawData.options,
29
- ),
30
- );
31
- } catch (e) {
32
- console.error(e, rawData);
33
- discovery.view.render(
34
- el,
35
- {
36
- view: "alert-danger",
37
- data: '"Error rendering chart, please check the console for more information."',
38
- },
39
- rawData,
40
- context,
41
- );
42
- }
43
- });
File without changes