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.
@@ -1,23 +1,28 @@
1
1
  const require_pages__common = require("./_common.js");
2
2
  //#region src/client/pages/module.ts
3
3
  function getMetroWarn({ when, href, linkText, content }) {
4
- return {
5
- view: "alert-warning",
6
- when,
7
- className: "m-v-8",
8
- content: [...content, linkText && href ? {
9
- view: "link",
10
- data: {
11
- external: true,
12
- href,
13
- text: linkText
14
- }
15
- } : null].filter(Boolean)
16
- };
4
+ return {
5
+ view: "alert-warning",
6
+ when,
7
+ className: "m-v-8",
8
+ content: [
9
+ ...content,
10
+ linkText && href
11
+ ? {
12
+ view: "link",
13
+ data: {
14
+ external: true,
15
+ href,
16
+ text: linkText,
17
+ },
18
+ }
19
+ : null,
20
+ ].filter(Boolean),
21
+ };
17
22
  }
18
23
  discovery.page.define("module", {
19
- view: "context",
20
- data: `{
24
+ view: "context",
25
+ data: `{
21
26
  $currentModule: $.modules.[path = #.id].pick(0);
22
27
  ...$,
23
28
  currentModule: $currentModule,
@@ -25,119 +30,148 @@ discovery.page.define("module", {
25
30
  isInjectedByMetro: $currentModule.path = '__prelude__' or $currentModule.path has '@react-native/js-polyfills',
26
31
  isWebpackRuntime: $currentModule.path has '__runtime__',
27
32
  }`,
28
- content: [{
29
- view: "h2",
30
- content: [
31
- "text: \"Module: \"",
32
- "text: $.currentModule.path",
33
- require_pages__common.getCopyToClipboardButton({
34
- textToCopy: `$.currentModule.path`,
35
- className: "m-l-0_5em"
36
- })
37
- ]
38
- }, {
39
- view: "tabs",
40
- name: "tabs",
41
- tabs: [
42
- {
43
- value: "mcontent",
44
- text: "Module content"
45
- },
46
- {
47
- value: "networkGraph",
48
- when: "not isInjectedByMetro and not isEntry and not isWebpackRuntime",
49
- text: "Imported by modules"
50
- },
51
- {
52
- value: "mduplicates",
53
- when: "not isInjectedByMetro and not isEntry and not isWebpackRuntime and currentModule.duplicates",
54
- text: "Duplicates"
55
- }
56
- ],
57
- content: {
58
- view: "switch",
59
- content: [
60
- {
61
- when: "#.tabs=\"mcontent\"",
62
- content: [
63
- getMetroWarn({
64
- when: "$.currentModule.path = '__prelude__'",
65
- content: ["html: '<b>__prelude__</b>'", "text: ' is a special runtime code that was generated by the Metro bundler, see: '"],
66
- href: "https://github.com/facebook/metro/blob/f595e9e1c9021ad372b489be8958cc298eb1e0d9/packages/metro/src/lib/getPreludeCode.js#L25-L33",
67
- linkText: "getPreludeCode.js"
68
- }),
69
- getMetroWarn({
70
- when: "$.currentModule.path = '__runtime__'",
71
- content: ["html: '<b>__runtime__</b>'", "text: ' is a special runtime code that was generated by the Webpack/Rspack bundler'"]
72
- }),
73
- getMetroWarn({
74
- when: "$.currentModule.path has '@react-native/js-polyfills'",
75
- content: ["html: '<b>@react-native/js-polyfills/*</b>'", "text: ' is a special package that was injected by the Metro bundler, see: '"],
76
- href: "https://github.com/facebook/react-native/blob/198c6fc81cda67a46fff457cc39eb2a297eddc01/packages/metro-config/src/index.flow.js#L61",
77
- linkText: "rn/metro-config/index.js"
78
- }),
79
- getMetroWarn({
80
- when: "$.currentModule.path has 'metro-runtime'",
81
- content: ["html: '<b>metro-runtime/*</b>'", "text: ' is a special package that was injected by the Metro bundler, see: '"],
82
- href: "https://github.com/facebook/metro/blob/f595e9e1c9021ad372b489be8958cc298eb1e0d9/packages/metro-config/src/defaults/defaults.js#L61-L63",
83
- linkText: "metro-config/index.js"
84
- }),
85
- {
86
- view: "hstack",
87
- className: "flex-no-wrap",
88
- content: [{
89
- view: "block",
90
- className: "width-50p",
91
- content: ["h5: 'Source'", {
92
- view: "source",
93
- syntax: "ts",
94
- source: "=$.currentModule.source.code"
95
- }]
96
- }, {
97
- view: "block",
98
- className: "width-50p",
99
- content: [{
100
- view: "h5",
101
- content: "text:\"Output\""
102
- }, {
103
- view: "context",
104
- modifiers: [{
105
- view: "checkbox",
106
- name: "prettify",
107
- checked: true,
108
- className: "prettify-checkbox",
109
- content: "text:\"Prettify\""
110
- }],
111
- content: [{
112
- view: "source-prettify",
113
- syntax: "ts",
114
- source: "=(#.prettify ? $.currentModule.output.code.prettifyJS() : $.currentModule.output.code)"
115
- }]
116
- }]
117
- }]
118
- }
119
- ]
120
- },
121
- {
122
- when: "#.tabs=\"networkGraph\"",
123
- content: {
124
- view: "context",
125
- context: `{ ...#, maxParentDepth: $.currentModule.getBestNetworkGraphSize() }`,
126
- modifiers: [
127
- "html: '<br/>'",
128
- "text:'Max parent depth: '",
129
- {
130
- view: "input",
131
- name: "maxParentDepth",
132
- className: "inline-block",
133
- htmlType: "number",
134
- htmlMin: 1,
135
- htmlMax: 10
136
- }
137
- ],
138
- content: [{
139
- view: "context",
140
- data: `{
33
+ content: [
34
+ {
35
+ view: "h2",
36
+ content: [
37
+ 'text: "Module: "',
38
+ "text: $.currentModule.path",
39
+ require_pages__common.getCopyToClipboardButton({
40
+ textToCopy: `$.currentModule.path`,
41
+ className: "m-l-0_5em",
42
+ }),
43
+ ],
44
+ },
45
+ {
46
+ view: "tabs",
47
+ name: "tabs",
48
+ tabs: [
49
+ {
50
+ value: "mcontent",
51
+ text: "Module content",
52
+ },
53
+ {
54
+ value: "networkGraph",
55
+ when: "not isInjectedByMetro and not isEntry and not isWebpackRuntime",
56
+ text: "Imported by modules",
57
+ },
58
+ {
59
+ value: "mduplicates",
60
+ when: "not isInjectedByMetro and not isEntry and not isWebpackRuntime and currentModule.duplicates",
61
+ text: "Duplicates",
62
+ },
63
+ ],
64
+ content: {
65
+ view: "switch",
66
+ content: [
67
+ {
68
+ when: '#.tabs="mcontent"',
69
+ content: [
70
+ getMetroWarn({
71
+ when: "$.currentModule.path = '__prelude__'",
72
+ content: [
73
+ "html: '<b>__prelude__</b>'",
74
+ "text: ' is a special runtime code that was generated by the Metro bundler, see: '",
75
+ ],
76
+ href: "https://github.com/facebook/metro/blob/f595e9e1c9021ad372b489be8958cc298eb1e0d9/packages/metro/src/lib/getPreludeCode.js#L25-L33",
77
+ linkText: "getPreludeCode.js",
78
+ }),
79
+ getMetroWarn({
80
+ when: "$.currentModule.path = '__runtime__'",
81
+ content: [
82
+ "html: '<b>__runtime__</b>'",
83
+ "text: ' is a special runtime code that was generated by the Webpack/Rspack bundler'",
84
+ ],
85
+ }),
86
+ getMetroWarn({
87
+ when: "$.currentModule.path has '@react-native/js-polyfills'",
88
+ content: [
89
+ "html: '<b>@react-native/js-polyfills/*</b>'",
90
+ "text: ' is a special package that was injected by the Metro bundler, see: '",
91
+ ],
92
+ href: "https://github.com/facebook/react-native/blob/198c6fc81cda67a46fff457cc39eb2a297eddc01/packages/metro-config/src/index.flow.js#L61",
93
+ linkText: "rn/metro-config/index.js",
94
+ }),
95
+ getMetroWarn({
96
+ when: "$.currentModule.path has 'metro-runtime'",
97
+ content: [
98
+ "html: '<b>metro-runtime/*</b>'",
99
+ "text: ' is a special package that was injected by the Metro bundler, see: '",
100
+ ],
101
+ href: "https://github.com/facebook/metro/blob/f595e9e1c9021ad372b489be8958cc298eb1e0d9/packages/metro-config/src/defaults/defaults.js#L61-L63",
102
+ linkText: "metro-config/index.js",
103
+ }),
104
+ {
105
+ view: "hstack",
106
+ className: "flex-no-wrap",
107
+ content: [
108
+ {
109
+ view: "block",
110
+ className: "width-50p",
111
+ content: [
112
+ "h5: 'Source'",
113
+ {
114
+ view: "source",
115
+ syntax: "ts",
116
+ source: "=$.currentModule.source.code",
117
+ },
118
+ ],
119
+ },
120
+ {
121
+ view: "block",
122
+ className: "width-50p",
123
+ content: [
124
+ {
125
+ view: "h5",
126
+ content: 'text:"Output"',
127
+ },
128
+ {
129
+ view: "context",
130
+ modifiers: [
131
+ {
132
+ view: "checkbox",
133
+ name: "prettify",
134
+ checked: true,
135
+ className: "prettify-checkbox",
136
+ content: 'text:"Prettify"',
137
+ },
138
+ ],
139
+ content: [
140
+ {
141
+ view: "source-prettify",
142
+ syntax: "ts",
143
+ source:
144
+ "=(#.prettify ? $.currentModule.output.code.prettifyJS() : $.currentModule.output.code)",
145
+ },
146
+ ],
147
+ },
148
+ ],
149
+ },
150
+ ],
151
+ },
152
+ ],
153
+ },
154
+ {
155
+ when: '#.tabs="networkGraph"',
156
+ content: {
157
+ view: "context",
158
+ context: `{ ...#, maxParentDepth: $.currentModule.getBestNetworkGraphSize() }`,
159
+ modifiers: [
160
+ "html: '<br/>'",
161
+ "text:'Max parent depth: '",
162
+ {
163
+ view: "input",
164
+ name: "maxParentDepth",
165
+ className: "inline-block",
166
+ htmlType: "number",
167
+ htmlMin: 1,
168
+ htmlMax: 10,
169
+ },
170
+ ],
171
+ content: [
172
+ {
173
+ view: "context",
174
+ data: `{
141
175
  // Vars
142
176
  $tmp: $.currentModule.getNetworkGraph({ maxParentDepth: #.maxParentDepth });
143
177
  $limit: 150;
@@ -148,21 +182,26 @@ discovery.page.define("module", {
148
182
  data: $tmp.data,
149
183
  isGraphTooBig: $tmp.data.size() > $limit,
150
184
  }`,
151
- content: [{
152
- when: "isGraphTooBig",
153
- view: "block",
154
- className: "m-v-8",
155
- content: [{
156
- view: "alert-warning",
157
- data: "\"Amount of dependencies \"+$.data.size()+\" (limit: \"+$.limit+\") are too big to display as a graph :(\""
158
- }]
159
- }, {
160
- view: "hstack",
161
- className: "flex-no-wrap two-column",
162
- content: [{
163
- when: "not isGraphTooBig",
164
- view: "highcharts",
165
- data: `{
185
+ content: [
186
+ {
187
+ when: "isGraphTooBig",
188
+ view: "block",
189
+ className: "m-v-8",
190
+ content: [
191
+ {
192
+ view: "alert-warning",
193
+ data: '"Amount of dependencies "+$.data.size()+" (limit: "+$.limit+") are too big to display as a graph :("',
194
+ },
195
+ ],
196
+ },
197
+ {
198
+ view: "hstack",
199
+ className: "flex-no-wrap two-column",
200
+ content: [
201
+ {
202
+ when: "not isGraphTooBig",
203
+ view: "highcharts",
204
+ data: `{
166
205
  options: {
167
206
  chart: {
168
207
  type: "networkgraph",
@@ -208,12 +247,15 @@ discovery.page.define("module", {
208
247
  },
209
248
  ],
210
249
  },
211
- }`
212
- }, {
213
- view: "block",
214
- content: ["h4: 'Modules that import this file: ' + $.currentModule.path", {
215
- view: "list",
216
- data: `
250
+ }`,
251
+ },
252
+ {
253
+ view: "block",
254
+ content: [
255
+ "h4: 'Modules that import this file: ' + $.currentModule.path",
256
+ {
257
+ view: "list",
258
+ data: `
217
259
  $totalSize: modules.sum(=>output.sizeInBytes);
218
260
  $toModule: => {
219
261
  $deepIdx: $$ + 1;
@@ -225,24 +267,31 @@ discovery.page.define("module", {
225
267
  };
226
268
  $.currentModule.dependents.map(=> $.$toModule(0))
227
269
  `,
228
- emptyText: "⚠️ No importing modules found",
229
- item: {
230
- view: "tree",
231
- expanded: false,
232
- itemConfig: {
233
- content: require_pages__common.getTreeModule({ hasTextMatch: true }),
234
- children: `$.children`
235
- }
236
- }
237
- }]
238
- }]
239
- }]
240
- }]
241
- }
242
- },
243
- {
244
- when: "#.tabs=\"mduplicates\"",
245
- content: require_pages__common.getModulesTree({ data: `
270
+ emptyText: "⚠️ No importing modules found",
271
+ item: {
272
+ view: "tree",
273
+ expanded: false,
274
+ itemConfig: {
275
+ content: require_pages__common.getTreeModule({
276
+ hasTextMatch: true,
277
+ }),
278
+ children: `$.children`,
279
+ },
280
+ },
281
+ },
282
+ ],
283
+ },
284
+ ],
285
+ },
286
+ ],
287
+ },
288
+ ],
289
+ },
290
+ },
291
+ {
292
+ when: '#.tabs="mduplicates"',
293
+ content: require_pages__common.getModulesTree({
294
+ data: `
246
295
  $totalSize: modules.sum(=>output.sizeInBytes);
247
296
  $toModule: => {
248
297
  ext: $.path.getFileExtension(),
@@ -251,10 +300,12 @@ discovery.page.define("module", {
251
300
  percent: ($.output.sizeInBytes / $totalSize).percent(3),
252
301
  };
253
302
  currentModule.duplicates.map(=> $.$toModule())
254
- ` })
255
- }
256
- ]
257
- }
258
- }]
303
+ `,
304
+ }),
305
+ },
306
+ ],
307
+ },
308
+ },
309
+ ],
259
310
  });
260
311
  //#endregion