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,27 @@
1
1
  //#region src/client/queryHelpers.ts
2
2
  const helpers = {
3
- prettifyMap: /* @__PURE__ */ new Map(),
4
- prettifyJS(sourceStr) {
5
- if (helpers.prettifyMap.has(sourceStr)) return helpers.prettifyMap.get(sourceStr);
6
- const prettier = require("prettier/standalone");
7
- const prettierPluginBabel = require("prettier/plugins/babel");
8
- const prettierPluginEstree = require("prettier/plugins/estree");
9
- return prettier.format(sourceStr, {
10
- parser: "babel",
11
- plugins: [prettierPluginBabel, prettierPluginEstree]
12
- }).then((formatted) => {
13
- helpers.prettifyMap.set(sourceStr, formatted);
14
- return formatted;
15
- }).catch(() => {
16
- return sourceStr;
17
- });
18
- },
19
- askChatGPTAboutPackages() {
20
- return `https://chat.openai.com/?prompt=${encodeURIComponent(`I have a list of JavaScript packages from my React Native bundle (see below). I want to optimize bundle size by identifying similar or redundant packages — such as multiple versions of similar libraries (e.g., lodash, lodash-es, underscore, etc.), duplicate utilities, or overlapping functionality (e.g., date libraries like moment, dayjs, date-fns).
3
+ prettifyMap: /* @__PURE__ */ new Map(),
4
+ prettifyJS(sourceStr) {
5
+ if (helpers.prettifyMap.has(sourceStr))
6
+ return helpers.prettifyMap.get(sourceStr);
7
+ const prettier = require("prettier/standalone");
8
+ const prettierPluginBabel = require("prettier/plugins/babel");
9
+ const prettierPluginEstree = require("prettier/plugins/estree");
10
+ return prettier
11
+ .format(sourceStr, {
12
+ parser: "babel",
13
+ plugins: [prettierPluginBabel, prettierPluginEstree],
14
+ })
15
+ .then((formatted) => {
16
+ helpers.prettifyMap.set(sourceStr, formatted);
17
+ return formatted;
18
+ })
19
+ .catch(() => {
20
+ return sourceStr;
21
+ });
22
+ },
23
+ askChatGPTAboutPackages() {
24
+ return `https://chat.openai.com/?prompt=${encodeURIComponent(`I have a list of JavaScript packages from my React Native bundle (see below). I want to optimize bundle size by identifying similar or redundant packages — such as multiple versions of similar libraries (e.g., lodash, lodash-es, underscore, etc.), duplicate utilities, or overlapping functionality (e.g., date libraries like moment, dayjs, date-fns).
21
25
 
22
26
  Please do the following:
23
27
 
@@ -25,258 +29,296 @@ Please do the following:
25
29
  2. For each group, suggest which one to keep and which ones to consider removing.
26
30
  3. For each group, provide a regex string that can be used to filter those packages from the list (e.g., in grep, find, or search tools).
27
31
  4. Keep the output concise and copy-paste friendly.`)}`;
28
- },
29
- plural(count, [singular, plural]) {
30
- return count === 1 ? singular : plural;
31
- },
32
- pluralWithCount(count, [singular, plural]) {
33
- return `${count} ${helpers.plural(count, [singular, plural])}`;
34
- },
35
- pluralBadge(count, [singular, plural], prefix = "") {
36
- return {
37
- text: prefix + count,
38
- postfix: helpers.plural(count, [singular, plural])
39
- };
40
- },
41
- getModulesName(path) {
42
- const modules = path.split("node_modules/");
43
- const [folder, subFolder] = modules[modules.length - 1].split("/");
44
- if (folder.startsWith("@")) return `${folder}/${subFolder}`;
45
- return folder;
46
- },
47
- getBestNetworkGraphSize(module, params) {
48
- let maxParentDepth = 0;
49
- let itemsCount = 0;
50
- do {
51
- maxParentDepth++;
52
- itemsCount = helpers.getNetworkGraph(module, {
53
- ...params,
54
- maxParentDepth
55
- }).data.length;
56
- if (itemsCount < 10) {
57
- const limit = itemsCount - 1;
58
- return limit > 2 ? limit : 2;
59
- }
60
- } while (maxParentDepth < 6);
61
- return maxParentDepth;
62
- },
63
- getNetworkGraph(module, { maxParentDepth = 2, omitVisitedModules = true } = {}) {
64
- const queue = [{
65
- module,
66
- parentId: "",
67
- level: 0
68
- }];
69
- const visited = /* @__PURE__ */ new Set();
70
- const result = [];
71
- let entryPointPath = null;
72
- const data = [];
73
- while (queue.length > 0) {
74
- const { module: currentModule, parentId, level } = queue.shift();
75
- if (level >= Number(maxParentDepth)) break;
76
- const id = currentModule.path;
77
- if (omitVisitedModules) {
78
- if (visited.has(id)) continue;
79
- visited.add(id);
80
- }
81
- if (parentId) {
82
- const isEntryPoint = currentModule.dependents.length === 0;
83
- result.push({
84
- isEntryPoint,
85
- id,
86
- parentId
87
- });
88
- data.push([parentId, id]);
89
- if (isEntryPoint) entryPointPath = id;
90
- }
91
- if (Array.isArray(currentModule.dependents)) for (const dependentModule of currentModule.dependents) queue.push({
92
- module: dependentModule,
93
- parentId: id,
94
- level: level + 1
95
- });
96
- }
97
- if (!entryPointPath) {
98
- for (const item of result) if (item.isEntryPoint) {
99
- entryPointPath = item.id;
100
- break;
101
- }
102
- }
103
- return {
104
- entryPointPath,
105
- data
106
- };
107
- },
108
- getExtColor(extName) {
109
- const colors = {
110
- js: "#f1e05a50",
111
- ts: "#2b748950",
112
- tsx: "#2b748950",
113
- json: "#e34c2650",
114
- svg: "#e69f0d50",
115
- css: "#563d7c50",
116
- png: "#e44b2350"
117
- };
118
- return colors[extName] ?? colors.js;
119
- },
120
- getFileExtension(filename) {
121
- const idx = filename.lastIndexOf(".");
122
- return idx === -1 ? "js" : filename.slice(idx + 1);
123
- },
124
- formatDate(isoDate) {
125
- return isoDate ? new Date(isoDate).toISOString().slice(0, 10) : "";
126
- },
127
- timeAgo(isoDate) {
128
- if (!isoDate) return "";
129
- const days = Math.floor((Date.now() - new Date(isoDate).getTime()) / 864e5);
130
- const [count, unit] = days >= 365 ? [Math.floor(days / 365), ["year", "years"]] : days >= 30 ? [Math.floor(days / 30), ["month", "months"]] : [days, ["day", "days"]];
131
- return count === 0 ? "today" : `${helpers.pluralWithCount(count, unit)} ago`;
132
- },
133
- toFixed(value, fractionDigits = 2) {
134
- return Number(value).toFixed(fractionDigits);
135
- },
136
- percent(value, fractionDigits = 2) {
137
- return `${(100 * value).toFixed(fractionDigits)}%`;
138
- },
139
- formatBytes(bytes, decimals) {
140
- if (bytes == 0) return "0 Bytes";
141
- const k = 1024, dm = decimals || 2, sizes = [
142
- "Bytes",
143
- "KB",
144
- "MB",
145
- "GB",
146
- "TB",
147
- "PB",
148
- "EB",
149
- "ZB",
150
- "YB"
151
- ], i = Math.floor(Math.log(bytes) / Math.log(k));
152
- return `${parseFloat((bytes / k ** i).toFixed(dm))} ${sizes[i]}`;
153
- },
154
- isPackageImport(moduleName) {
155
- return moduleName?.[0] !== ".";
156
- },
157
- transformFilesList(files, rootFolder, type) {
158
- const nodeModulesMap = {
159
- children: {},
160
- size: 0
161
- };
162
- const sourceCodeMap = {
163
- children: {},
164
- size: 0
165
- };
166
- files.forEach(({ path, size }) => {
167
- if (path === "__prelude__") path = "node_modules/__prelude__";
168
- if (path === "__runtime__") path = "node_modules/__runtime__";
169
- const shortPath = path.replace(`${rootFolder}/`, "");
170
- const isNodeModule = shortPath.includes("node_modules/");
171
- const parts = shortenPath(shortPath, nodeModulesMap).split("/");
172
- let current = (isNodeModule ? nodeModulesMap : sourceCodeMap).children;
173
- parts.forEach((part, index) => {
174
- if (!current[part]) current[part] = {
175
- size: 0,
176
- children: {}
177
- };
178
- if (index === parts.length - 1) {
179
- current[part].size = size;
180
- current[part].path = shortPath;
181
- current[part].fullPath = path;
182
- }
183
- current = current[part].children;
184
- });
185
- });
186
- if (type === "foamtree") {
187
- sumSizes(nodeModulesMap);
188
- sumSizes(sourceCodeMap);
189
- const sourceCodeGroup = toGroups(sourceCodeMap, "Source Code");
190
- const nodeModulesGroup = nodeModulesMap?.children?.node_modules ? toGroups(nodeModulesMap.children.node_modules, "node_modules") : {};
191
- if (!sourceCodeGroup.groups) return nodeModulesGroup;
192
- if (!nodeModulesGroup.groups) return sourceCodeGroup;
193
- const topLevelNode = { groups: [sourceCodeGroup, nodeModulesGroup] };
194
- topLevelNode.weight = topLevelNode.groups.reduce((acc, group) => acc + group.weight, 0);
195
- return topLevelNode;
196
- }
197
- if (type === "highcharts-treemap") {
198
- const ROOT_ID_1 = "~";
199
- const ROOT_ID_2 = ".";
200
- return [{
201
- id: ROOT_ID_1,
202
- name: "node_modules"
203
- }, {
204
- id: ROOT_ID_2,
205
- name: "Source Code"
206
- }].concat(flattenTree(nodeModulesMap.children.node_modules, ROOT_ID_1)).concat(flattenTree(sourceCodeMap, ROOT_ID_2));
207
- }
208
- throw new Error(`Unsupported type: ${type}`);
209
- }
32
+ },
33
+ plural(count, [singular, plural]) {
34
+ return count === 1 ? singular : plural;
35
+ },
36
+ pluralWithCount(count, [singular, plural]) {
37
+ return `${count} ${helpers.plural(count, [singular, plural])}`;
38
+ },
39
+ pluralBadge(count, [singular, plural], prefix = "") {
40
+ return {
41
+ text: prefix + count,
42
+ postfix: helpers.plural(count, [singular, plural]),
43
+ };
44
+ },
45
+ getModulesName(path) {
46
+ const modules = path.split("node_modules/");
47
+ const [folder, subFolder] = modules[modules.length - 1].split("/");
48
+ if (folder.startsWith("@")) return `${folder}/${subFolder}`;
49
+ return folder;
50
+ },
51
+ getBestNetworkGraphSize(module, params) {
52
+ let maxParentDepth = 0;
53
+ let itemsCount = 0;
54
+ do {
55
+ maxParentDepth++;
56
+ itemsCount = helpers.getNetworkGraph(module, {
57
+ ...params,
58
+ maxParentDepth,
59
+ }).data.length;
60
+ if (itemsCount < 10) {
61
+ const limit = itemsCount - 1;
62
+ return limit > 2 ? limit : 2;
63
+ }
64
+ } while (maxParentDepth < 6);
65
+ return maxParentDepth;
66
+ },
67
+ getNetworkGraph(
68
+ module,
69
+ { maxParentDepth = 2, omitVisitedModules = true } = {},
70
+ ) {
71
+ const queue = [
72
+ {
73
+ module,
74
+ parentId: "",
75
+ level: 0,
76
+ },
77
+ ];
78
+ const visited = /* @__PURE__ */ new Set();
79
+ const result = [];
80
+ let entryPointPath = null;
81
+ const data = [];
82
+ while (queue.length > 0) {
83
+ const { module: currentModule, parentId, level } = queue.shift();
84
+ if (level >= Number(maxParentDepth)) break;
85
+ const id = currentModule.path;
86
+ if (omitVisitedModules) {
87
+ if (visited.has(id)) continue;
88
+ visited.add(id);
89
+ }
90
+ if (parentId) {
91
+ const isEntryPoint = currentModule.dependents.length === 0;
92
+ result.push({
93
+ isEntryPoint,
94
+ id,
95
+ parentId,
96
+ });
97
+ data.push([parentId, id]);
98
+ if (isEntryPoint) entryPointPath = id;
99
+ }
100
+ if (Array.isArray(currentModule.dependents))
101
+ for (const dependentModule of currentModule.dependents)
102
+ queue.push({
103
+ module: dependentModule,
104
+ parentId: id,
105
+ level: level + 1,
106
+ });
107
+ }
108
+ if (!entryPointPath) {
109
+ for (const item of result)
110
+ if (item.isEntryPoint) {
111
+ entryPointPath = item.id;
112
+ break;
113
+ }
114
+ }
115
+ return {
116
+ entryPointPath,
117
+ data,
118
+ };
119
+ },
120
+ getExtColor(extName) {
121
+ const colors = {
122
+ js: "#f1e05a50",
123
+ ts: "#2b748950",
124
+ tsx: "#2b748950",
125
+ json: "#e34c2650",
126
+ svg: "#e69f0d50",
127
+ css: "#563d7c50",
128
+ png: "#e44b2350",
129
+ };
130
+ return colors[extName] ?? colors.js;
131
+ },
132
+ getFileExtension(filename) {
133
+ const idx = filename.lastIndexOf(".");
134
+ return idx === -1 ? "js" : filename.slice(idx + 1);
135
+ },
136
+ formatDate(isoDate) {
137
+ return isoDate ? new Date(isoDate).toISOString().slice(0, 10) : "";
138
+ },
139
+ timeAgo(isoDate) {
140
+ if (!isoDate) return "";
141
+ const days = Math.floor((Date.now() - new Date(isoDate).getTime()) / 864e5);
142
+ const [count, unit] =
143
+ days >= 365
144
+ ? [Math.floor(days / 365), ["year", "years"]]
145
+ : days >= 30
146
+ ? [Math.floor(days / 30), ["month", "months"]]
147
+ : [days, ["day", "days"]];
148
+ return count === 0
149
+ ? "today"
150
+ : `${helpers.pluralWithCount(count, unit)} ago`;
151
+ },
152
+ toFixed(value, fractionDigits = 2) {
153
+ return Number(value).toFixed(fractionDigits);
154
+ },
155
+ percent(value, fractionDigits = 2) {
156
+ return `${(100 * value).toFixed(fractionDigits)}%`;
157
+ },
158
+ formatBytes(bytes, decimals) {
159
+ if (bytes == 0) return "0 Bytes";
160
+ const k = 1024,
161
+ dm = decimals || 2,
162
+ sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"],
163
+ i = Math.floor(Math.log(bytes) / Math.log(k));
164
+ return `${parseFloat((bytes / k ** i).toFixed(dm))} ${sizes[i]}`;
165
+ },
166
+ isPackageImport(moduleName) {
167
+ return moduleName?.[0] !== ".";
168
+ },
169
+ transformFilesList(files, rootFolder, type) {
170
+ const nodeModulesMap = {
171
+ children: {},
172
+ size: 0,
173
+ };
174
+ const sourceCodeMap = {
175
+ children: {},
176
+ size: 0,
177
+ };
178
+ files.forEach(({ path, size }) => {
179
+ if (path === "__prelude__") path = "node_modules/__prelude__";
180
+ if (path === "__runtime__") path = "node_modules/__runtime__";
181
+ const shortPath = path.replace(`${rootFolder}/`, "");
182
+ const isNodeModule = shortPath.includes("node_modules/");
183
+ const parts = shortenPath(shortPath, nodeModulesMap).split("/");
184
+ let current = (isNodeModule ? nodeModulesMap : sourceCodeMap).children;
185
+ parts.forEach((part, index) => {
186
+ if (!current[part])
187
+ current[part] = {
188
+ size: 0,
189
+ children: {},
190
+ };
191
+ if (index === parts.length - 1) {
192
+ current[part].size = size;
193
+ current[part].path = shortPath;
194
+ current[part].fullPath = path;
195
+ }
196
+ current = current[part].children;
197
+ });
198
+ });
199
+ if (type === "foamtree") {
200
+ sumSizes(nodeModulesMap);
201
+ sumSizes(sourceCodeMap);
202
+ const sourceCodeGroup = toGroups(sourceCodeMap, "Source Code");
203
+ const nodeModulesGroup = nodeModulesMap?.children?.node_modules
204
+ ? toGroups(nodeModulesMap.children.node_modules, "node_modules")
205
+ : {};
206
+ if (!sourceCodeGroup.groups) return nodeModulesGroup;
207
+ if (!nodeModulesGroup.groups) return sourceCodeGroup;
208
+ const topLevelNode = { groups: [sourceCodeGroup, nodeModulesGroup] };
209
+ topLevelNode.weight = topLevelNode.groups.reduce(
210
+ (acc, group) => acc + group.weight,
211
+ 0,
212
+ );
213
+ return topLevelNode;
214
+ }
215
+ if (type === "highcharts-treemap") {
216
+ const ROOT_ID_1 = "~";
217
+ const ROOT_ID_2 = ".";
218
+ return [
219
+ {
220
+ id: ROOT_ID_1,
221
+ name: "node_modules",
222
+ },
223
+ {
224
+ id: ROOT_ID_2,
225
+ name: "Source Code",
226
+ },
227
+ ]
228
+ .concat(flattenTree(nodeModulesMap.children.node_modules, ROOT_ID_1))
229
+ .concat(flattenTree(sourceCodeMap, ROOT_ID_2));
230
+ }
231
+ throw new Error(`Unsupported type: ${type}`);
232
+ },
210
233
  };
211
- function flattenTree(node, parentId, prevWasSkipped = false, lvl = 0, result = [], overrideParentId) {
212
- const nodeChildrenCount = Object.keys(node.children);
213
- for (const key of nodeChildrenCount) {
214
- const childNode = node.children[key];
215
- const childId = `${parentId}/${key}`;
216
- const childrenCount = Object.keys(childNode.children).length;
217
- const hasChildren = childrenCount > 0;
218
- const item = {
219
- id: childId,
220
- name: prevWasSkipped ? parentId : key,
221
- parent: overrideParentId ?? parentId
222
- };
223
- if (!hasChildren) item.value = childNode.size;
224
- if (lvl === 0) item.color = Highcharts.getOptions().colors[randomInt(0, 9)];
225
- const skipThisNode = nodeChildrenCount.length === 1 && childrenCount === 1;
226
- if (!skipThisNode) result.push(item);
227
- flattenTree(childNode, childId, skipThisNode, lvl + 1, result, skipThisNode ? overrideParentId ?? parentId : void 0);
228
- }
229
- return result;
234
+ function flattenTree(
235
+ node,
236
+ parentId,
237
+ prevWasSkipped = false,
238
+ lvl = 0,
239
+ result = [],
240
+ overrideParentId,
241
+ ) {
242
+ const nodeChildrenCount = Object.keys(node.children);
243
+ for (const key of nodeChildrenCount) {
244
+ const childNode = node.children[key];
245
+ const childId = `${parentId}/${key}`;
246
+ const childrenCount = Object.keys(childNode.children).length;
247
+ const hasChildren = childrenCount > 0;
248
+ const item = {
249
+ id: childId,
250
+ name: prevWasSkipped ? parentId : key,
251
+ parent: overrideParentId ?? parentId,
252
+ };
253
+ if (!hasChildren) item.value = childNode.size;
254
+ if (lvl === 0) item.color = Highcharts.getOptions().colors[randomInt(0, 9)];
255
+ const skipThisNode = nodeChildrenCount.length === 1 && childrenCount === 1;
256
+ if (!skipThisNode) result.push(item);
257
+ flattenTree(
258
+ childNode,
259
+ childId,
260
+ skipThisNode,
261
+ lvl + 1,
262
+ result,
263
+ skipThisNode ? (overrideParentId ?? parentId) : void 0,
264
+ );
265
+ }
266
+ return result;
230
267
  }
231
268
  function sumSizes(node) {
232
- const isFile = Object.keys(node.children).length === 0;
233
- let totalFiles = isFile ? 1 : 0;
234
- let totalSize = node.size || 0;
235
- for (const key in node.children) {
236
- const result = sumSizes(node.children[key]);
237
- totalSize += result.totalSize;
238
- totalFiles += result.totalFiles;
239
- }
240
- node.type = isFile ? "file" : "folder";
241
- node.size = totalSize;
242
- node.files = totalFiles;
243
- return {
244
- totalSize,
245
- totalFiles
246
- };
269
+ const isFile = Object.keys(node.children).length === 0;
270
+ let totalFiles = isFile ? 1 : 0;
271
+ let totalSize = node.size || 0;
272
+ for (const key in node.children) {
273
+ const result = sumSizes(node.children[key]);
274
+ totalSize += result.totalSize;
275
+ totalFiles += result.totalFiles;
276
+ }
277
+ node.type = isFile ? "file" : "folder";
278
+ node.size = totalSize;
279
+ node.files = totalFiles;
280
+ return {
281
+ totalSize,
282
+ totalFiles,
283
+ };
247
284
  }
248
285
  function toGroups(node, label) {
249
- const keys = Object.keys(node.children);
250
- const common = {
251
- label,
252
- weight: node.size,
253
- fullPath: node.fullPath,
254
- files: node.files,
255
- type: node.type,
256
- size: helpers.formatBytes(node.size)
257
- };
258
- if (keys.length === 0) return common;
259
- return Object.assign(common, { groups: keys.map((key) => toGroups(node.children[key], key)) });
286
+ const keys = Object.keys(node.children);
287
+ const common = {
288
+ label,
289
+ weight: node.size,
290
+ fullPath: node.fullPath,
291
+ files: node.files,
292
+ type: node.type,
293
+ size: helpers.formatBytes(node.size),
294
+ };
295
+ if (keys.length === 0) return common;
296
+ return Object.assign(common, {
297
+ groups: keys.map((key) => toGroups(node.children[key], key)),
298
+ });
260
299
  }
261
300
  function randomInt(min, max) {
262
- return Math.floor(Math.random() * (max - min + 1)) + min;
301
+ return Math.floor(Math.random() * (max - min + 1)) + min;
263
302
  }
264
303
  const nm = "node_modules/";
265
304
  function shortenPath(path, nodeModulesMap) {
266
- if (path.startsWith(`${nm}.pnpm/`)) path = path.replaceAll(`${nm}.pnpm/`, "");
267
- const index = path.lastIndexOf(nm);
268
- if (index > 0) {
269
- const pathWithoutNestedNM = path.slice(index);
270
- const firstSlash = pathWithoutNestedNM.indexOf("/");
271
- const secondSlash = pathWithoutNestedNM.indexOf("/", firstSlash + 1);
272
- const pkgName = secondSlash === -1 ? pathWithoutNestedNM.slice(firstSlash + 1) : pathWithoutNestedNM.slice(firstSlash + 1, secondSlash);
273
- if (nodeModulesMap?.children?.node_modules?.children?.[pkgName]) {
274
- const parentPackage = helpers.getModulesName(path.slice(0, index));
275
- return `${nm + parentPackage} ~ ${pathWithoutNestedNM.slice(13)}`;
276
- }
277
- return pathWithoutNestedNM;
278
- }
279
- return path;
305
+ if (path.startsWith(`${nm}.pnpm/`)) path = path.replaceAll(`${nm}.pnpm/`, "");
306
+ const index = path.lastIndexOf(nm);
307
+ if (index > 0) {
308
+ const pathWithoutNestedNM = path.slice(index);
309
+ const firstSlash = pathWithoutNestedNM.indexOf("/");
310
+ const secondSlash = pathWithoutNestedNM.indexOf("/", firstSlash + 1);
311
+ const pkgName =
312
+ secondSlash === -1
313
+ ? pathWithoutNestedNM.slice(firstSlash + 1)
314
+ : pathWithoutNestedNM.slice(firstSlash + 1, secondSlash);
315
+ if (nodeModulesMap?.children?.node_modules?.children?.[pkgName]) {
316
+ const parentPackage = helpers.getModulesName(path.slice(0, index));
317
+ return `${nm + parentPackage} ~ ${pathWithoutNestedNM.slice(13)}`;
318
+ }
319
+ return pathWithoutNestedNM;
320
+ }
321
+ return path;
280
322
  }
281
323
  //#endregion
282
324
  module.exports = helpers;
@@ -2,8 +2,8 @@ const require_prepare = require("./prepare.js");
2
2
  const require_queryHelpers = require("./queryHelpers.js");
3
3
  //#region src/client/setup.ts
4
4
  function setup({ addQueryHelpers, setPrepare }) {
5
- addQueryHelpers(require_queryHelpers);
6
- setPrepare(require_prepare);
5
+ addQueryHelpers(require_queryHelpers);
6
+ setPrepare(require_prepare);
7
7
  }
8
8
  //#endregion
9
9
  module.exports = setup;
@@ -1,15 +1,17 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  //#region src/client/views/_theme.ts
3
3
  function isDark() {
4
- const isSystemDarkMode = window?.matchMedia?.("(prefers-color-scheme: dark)")?.matches;
5
- const userMode = localStorage.getItem("discoveryjs:color-scheme");
6
- return userMode === "auto" ? isSystemDarkMode : userMode === "dark";
4
+ const isSystemDarkMode = window?.matchMedia?.(
5
+ "(prefers-color-scheme: dark)",
6
+ )?.matches;
7
+ const userMode = localStorage.getItem("discoveryjs:color-scheme");
8
+ return userMode === "auto" ? isSystemDarkMode : userMode === "dark";
7
9
  }
8
10
  function doTheming(el) {
9
- const dark = isDark();
10
- el.classList.add("highcharts-light");
11
- el.classList[!dark ? "add" : "remove"]("my-light");
12
- el.classList[dark ? "add" : "remove"]("highcharts-dark");
11
+ const dark = isDark();
12
+ el.classList.add("highcharts-light");
13
+ el.classList[!dark ? "add" : "remove"]("my-light");
14
+ el.classList[dark ? "add" : "remove"]("highcharts-dark");
13
15
  }
14
16
  if (isDark()) require("../../../vendors/high-contrast-dark.js");
15
17
  //#endregion