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,8 +1,8 @@
1
1
  const require_pages__common = require("./_common.js");
2
2
  //#region src/client/pages/package.ts
3
3
  discovery.page.define("package", {
4
- view: "context",
5
- data: `
4
+ view: "context",
5
+ data: `
6
6
  // Tmp variables
7
7
  $currentPkgName: #.id;
8
8
  ${require_pages__common.getPackage(`$pkg: modules.filter(=> path has "node_modules" and path has $currentPkgName)`)}[0];
@@ -24,164 +24,184 @@ discovery.page.define("package", {
24
24
  currentPkgLatestVersion: $pkg.pkgInstances.metadata.latestVersion[0],
25
25
  }
26
26
  `,
27
- content: [
28
- {
29
- view: "block",
30
- content: [
31
- {
32
- view: "h1",
33
- className: "inline-block no-margin",
34
- content: `badge: {
27
+ content: [
28
+ {
29
+ view: "block",
30
+ content: [
31
+ {
32
+ view: "h1",
33
+ className: "inline-block no-margin",
34
+ content: `badge: {
35
35
  text: $.currentPkgWithUniqVer,
36
36
  color: "#fffb5a",
37
- }`
38
- },
39
- {
40
- when: "$.currentPkgCopiesCount > 0",
41
- view: "h2",
42
- className: "inline-block no-margin",
43
- content: [`badge: {
37
+ }`,
38
+ },
39
+ {
40
+ when: "$.currentPkgCopiesCount > 0",
41
+ view: "h2",
42
+ className: "inline-block no-margin",
43
+ content: [
44
+ `badge: {
44
45
  text: '+' + $.currentPkgCopiesCount,
45
46
  postfix: $.currentPkgCopiesCount = 1 ? 'copy' : 'copies',
46
47
  color: "rgba(255, 0, 0, 0.35)"
47
- }`]
48
- },
49
- {
50
- when: "$.currentPkgDeprecated",
51
- view: "h2",
52
- className: "inline-block no-margin",
53
- content: `badge: { text: 'deprecated', color: "rgba(255, 0, 0, 0.35)" }`
54
- },
55
- {
56
- when: "$.currentPkgOutdated",
57
- view: "h2",
58
- className: "inline-block no-margin",
59
- content: `badge: {
48
+ }`,
49
+ ],
50
+ },
51
+ {
52
+ when: "$.currentPkgDeprecated",
53
+ view: "h2",
54
+ className: "inline-block no-margin",
55
+ content: `badge: { text: 'deprecated', color: "rgba(255, 0, 0, 0.35)" }`,
56
+ },
57
+ {
58
+ when: "$.currentPkgOutdated",
59
+ view: "h2",
60
+ className: "inline-block no-margin",
61
+ content: `badge: {
60
62
  prefix: 'latest',
61
63
  text: 'v' + $.currentPkgLatestVersion,
62
64
  color: "rgba(255, 165, 0, 0.35)"
63
- }`
64
- },
65
- require_pages__common.getCopyToClipboardButton({
66
- textToCopy: `$.currentPkg.pkgName`,
67
- className: "m-l-0_5em"
68
- })
69
- ]
70
- },
71
- {
72
- when: "$.currentPkgDeprecated",
73
- view: "list",
74
- data: "$.currentPkgDeprecated",
75
- item: {
76
- view: "alert-danger",
77
- content: [
78
- "html: '<b>Deprecated</b> '",
79
- "text: 'v' + version + (#.data.currentPkgHasCopies ? ' (' + pkgName + ')' : '') + ': '",
80
- "text: metadata.deprecated"
81
- ]
82
- }
83
- },
84
- "html: '<br>'",
85
- {
86
- view: "block",
87
- content: [
88
- "text: 'Links: '",
89
- {
90
- view: "link",
91
- external: true,
92
- data: `{ href: "https://www.npmjs.com/package/" + currentPkgWithUniqVerNpm }`,
93
- content: ["text: 'npmjs.com'", `html: '<span class="my-icon-inline my-icon-12">${require_pages__common.externalLinkHtml}</span>'`]
94
- },
95
- "text: ' '",
96
- {
97
- view: "link",
98
- external: true,
99
- data: `{ href: "https://bundlephobia.com/package/" + currentPkgWithUniqVer }`,
100
- content: ["text: 'bundlephobia.com'", `html: '<span class="my-icon-inline my-icon-12">${require_pages__common.externalLinkHtml}</span>'`]
101
- },
102
- "text: ' '",
103
- {
104
- view: "link",
105
- external: true,
106
- data: `{ href: "https://packagephobia.com/result?p=" + currentPkgWithUniqVer }`,
107
- content: ["text: 'packagephobia.com'", `html: '<span class="my-icon-inline my-icon-12">${require_pages__common.externalLinkHtml}</span>'`]
108
- },
109
- {
110
- view: "link",
111
- external: true,
112
- data: `{ href: "https://bundlejs.com/?q=" + currentPkgWithUniqVer, q: currentPkgWithUniqVer }`,
113
- content: [{
114
- view: "html",
115
- data: `'<img class="bundlejs-badge-img" src="https://deno.bundlejs.com/?q=' + q + '&badge=detailed" />'`
116
- }]
117
- }
118
- ]
119
- },
120
- {
121
- when: "$.currentPkgInstancesWithMetadata",
122
- view: "block",
123
- content: ["h3: 'Versions'", {
124
- view: "table",
125
- data: "$.currentPkgInstancesWithMetadata",
126
- cols: [
127
- {
128
- header: "Path",
129
- content: "text: pkgName"
130
- },
131
- {
132
- header: "Version",
133
- content: "pill-badge:{ text: 'v' + version, color: '#0af' }"
134
- },
135
- {
136
- header: "Published",
137
- data: "metadata.createdAt",
138
- content: [
139
- "text: formatDate()",
140
- "text: ' '",
141
- "pill-badge:{ text: timeAgo() }"
142
- ]
143
- },
144
- {
145
- header: "Latest",
146
- content: [{
147
- view: "link",
148
- external: true,
149
- data: `{
65
+ }`,
66
+ },
67
+ require_pages__common.getCopyToClipboardButton({
68
+ textToCopy: `$.currentPkg.pkgName`,
69
+ className: "m-l-0_5em",
70
+ }),
71
+ ],
72
+ },
73
+ {
74
+ when: "$.currentPkgDeprecated",
75
+ view: "list",
76
+ data: "$.currentPkgDeprecated",
77
+ item: {
78
+ view: "alert-danger",
79
+ content: [
80
+ "html: '<b>Deprecated</b> '",
81
+ "text: 'v' + version + (#.data.currentPkgHasCopies ? ' (' + pkgName + ')' : '') + ': '",
82
+ "text: metadata.deprecated",
83
+ ],
84
+ },
85
+ },
86
+ "html: '<br>'",
87
+ {
88
+ view: "block",
89
+ content: [
90
+ "text: 'Links: '",
91
+ {
92
+ view: "link",
93
+ external: true,
94
+ data: `{ href: "https://www.npmjs.com/package/" + currentPkgWithUniqVerNpm }`,
95
+ content: [
96
+ "text: 'npmjs.com'",
97
+ `html: '<span class="my-icon-inline my-icon-12">${require_pages__common.externalLinkHtml}</span>'`,
98
+ ],
99
+ },
100
+ "text: ' '",
101
+ {
102
+ view: "link",
103
+ external: true,
104
+ data: `{ href: "https://bundlephobia.com/package/" + currentPkgWithUniqVer }`,
105
+ content: [
106
+ "text: 'bundlephobia.com'",
107
+ `html: '<span class="my-icon-inline my-icon-12">${require_pages__common.externalLinkHtml}</span>'`,
108
+ ],
109
+ },
110
+ "text: ' '",
111
+ {
112
+ view: "link",
113
+ external: true,
114
+ data: `{ href: "https://packagephobia.com/result?p=" + currentPkgWithUniqVer }`,
115
+ content: [
116
+ "text: 'packagephobia.com'",
117
+ `html: '<span class="my-icon-inline my-icon-12">${require_pages__common.externalLinkHtml}</span>'`,
118
+ ],
119
+ },
120
+ {
121
+ view: "link",
122
+ external: true,
123
+ data: `{ href: "https://bundlejs.com/?q=" + currentPkgWithUniqVer, q: currentPkgWithUniqVer }`,
124
+ content: [
125
+ {
126
+ view: "html",
127
+ data: `'<img class="bundlejs-badge-img" src="https://deno.bundlejs.com/?q=' + q + '&badge=detailed" />'`,
128
+ },
129
+ ],
130
+ },
131
+ ],
132
+ },
133
+ {
134
+ when: "$.currentPkgInstancesWithMetadata",
135
+ view: "block",
136
+ content: [
137
+ "h3: 'Versions'",
138
+ {
139
+ view: "table",
140
+ data: "$.currentPkgInstancesWithMetadata",
141
+ cols: [
142
+ {
143
+ header: "Path",
144
+ content: "text: pkgName",
145
+ },
146
+ {
147
+ header: "Version",
148
+ content: "pill-badge:{ text: 'v' + version, color: '#0af' }",
149
+ },
150
+ {
151
+ header: "Published",
152
+ data: "metadata.createdAt",
153
+ content: [
154
+ "text: formatDate()",
155
+ "text: ' '",
156
+ "pill-badge:{ text: timeAgo() }",
157
+ ],
158
+ },
159
+ {
160
+ header: "Latest",
161
+ content: [
162
+ {
163
+ view: "link",
164
+ external: true,
165
+ data: `{
150
166
  href: "https://www.npmjs.com/package/" + #.data.currentPkg.pkgName + "/v/" + metadata.latestVersion,
151
167
  text: 'v' + metadata.latestVersion,
152
- }`
153
- }]
154
- },
155
- {
156
- header: "Status",
157
- content: {
158
- view: "switch",
159
- content: [
160
- {
161
- when: "metadata.deprecated",
162
- content: `badge: { text: 'deprecated', color: "rgba(255, 0, 0, 0.35)" }`
163
- },
164
- {
165
- when: "metadata.isLatest",
166
- content: `badge: { text: 'latest', color: "rgba(120, 177, 9, 0.35)" }`
167
- },
168
- { content: `badge: { text: 'outdated', color: "rgba(255, 165, 0, 0.35)" }` }
169
- ]
170
- }
171
- }
172
- ]
173
- }]
174
- },
175
- "html: '<hr>'",
176
- {
177
- view: "block",
178
- content: require_pages__common.getPackageList({
179
- data: "$.currentPkg",
180
- itemPkgName: "text: pkgName",
181
- showCopiesBadge: false,
182
- expanded: true
183
- })
184
- }
185
- ]
168
+ }`,
169
+ },
170
+ ],
171
+ },
172
+ {
173
+ header: "Status",
174
+ content: {
175
+ view: "switch",
176
+ content: [
177
+ {
178
+ when: "metadata.deprecated",
179
+ content: `badge: { text: 'deprecated', color: "rgba(255, 0, 0, 0.35)" }`,
180
+ },
181
+ {
182
+ when: "metadata.isLatest",
183
+ content: `badge: { text: 'latest', color: "rgba(120, 177, 9, 0.35)" }`,
184
+ },
185
+ {
186
+ content: `badge: { text: 'outdated', color: "rgba(255, 165, 0, 0.35)" }`,
187
+ },
188
+ ],
189
+ },
190
+ },
191
+ ],
192
+ },
193
+ ],
194
+ },
195
+ "html: '<hr>'",
196
+ {
197
+ view: "block",
198
+ content: require_pages__common.getPackageList({
199
+ data: "$.currentPkg",
200
+ itemPkgName: "text: pkgName",
201
+ showCopiesBadge: false,
202
+ expanded: true,
203
+ }),
204
+ },
205
+ ],
186
206
  });
187
207
  //#endregion
@@ -1,52 +1,63 @@
1
1
  //#region src/client/prepare.ts
2
2
  function getDuplicateId(path) {
3
- const uniqueNodeModulePath = path.split("node_modules/").pop();
4
- const ids = [uniqueNodeModulePath];
5
- if (uniqueNodeModulePath.startsWith("lodash.") || uniqueNodeModulePath.startsWith("lodash-es/")) {
6
- const uniqueLodashPath = uniqueNodeModulePath.replace("lodash-es/", "lodash/").replace("lodash.", "lodash/").replace("/index.js", ".js");
7
- ids.push(uniqueLodashPath);
8
- }
9
- return ids;
3
+ const uniqueNodeModulePath = path.split("node_modules/").pop();
4
+ const ids = [uniqueNodeModulePath];
5
+ if (
6
+ uniqueNodeModulePath.startsWith("lodash.") ||
7
+ uniqueNodeModulePath.startsWith("lodash-es/")
8
+ ) {
9
+ const uniqueLodashPath = uniqueNodeModulePath
10
+ .replace("lodash-es/", "lodash/")
11
+ .replace("lodash.", "lodash/")
12
+ .replace("/index.js", ".js");
13
+ ids.push(uniqueLodashPath);
14
+ }
15
+ return ids;
10
16
  }
11
17
  function prepare(input) {
12
- const data = input;
13
- const moduleMap = /* @__PURE__ */ new Map();
14
- const duplicatesMap = /* @__PURE__ */ new Map();
15
- const allLodashModules = /* @__PURE__ */ new Set();
16
- data.packages.forEach((pkg) => {
17
- pkg.path = pkg.absolutePath.replace(`${data.rootFolder}/`, "");
18
- });
19
- data.modules.forEach((m) => {
20
- m.absolutePath = m.path;
21
- if (m.absolutePath === data.entryPoint) m.isEntry = true;
22
- m.path = m.path.replace(`${data.rootFolder}/`, "");
23
- m.dependencies.forEach((d) => {
24
- d.path = d.absolutePath.replace(`${data.rootFolder}/`, "");
25
- });
26
- m._tmp_ids = getDuplicateId(m.path);
27
- m.duplicates = [];
28
- m._tmp_ids.forEach((id) => {
29
- if (!duplicatesMap.has(id)) duplicatesMap.set(id, []);
30
- duplicatesMap.get(id).push(m);
31
- });
32
- if (m.path.includes("node_modules/lodash")) allLodashModules.add(m);
33
- m.dependents = [];
34
- moduleMap.set(m.absolutePath, m);
35
- if (m.path === "__prelude__") m.source.code = m.source.code.replaceAll(";", ";\n\n").replaceAll(",", ",\n ");
36
- });
37
- data.modules.forEach((m) => {
38
- m._tmp_ids.forEach((id) => {
39
- const duplicates = duplicatesMap.get(id);
40
- if (duplicates.length > 1) m.duplicates.push(...duplicates.filter((d) => d !== m));
41
- });
42
- if (m.path.endsWith("node_modules/lodash/index.js")) m.duplicates.push(...allLodashModules);
43
- delete m._tmp_ids;
44
- m.dependencies.forEach((dependency) => {
45
- const dependentModule = moduleMap.get(dependency.absolutePath);
46
- if (dependentModule) dependentModule.dependents.push(m);
47
- });
48
- });
49
- return data;
18
+ const data = input;
19
+ const moduleMap = /* @__PURE__ */ new Map();
20
+ const duplicatesMap = /* @__PURE__ */ new Map();
21
+ const allLodashModules = /* @__PURE__ */ new Set();
22
+ data.packages.forEach((pkg) => {
23
+ pkg.path = pkg.absolutePath.replace(`${data.rootFolder}/`, "");
24
+ });
25
+ data.modules.forEach((m) => {
26
+ m.absolutePath = m.path;
27
+ if (m.absolutePath === data.entryPoint) m.isEntry = true;
28
+ m.path = m.path.replace(`${data.rootFolder}/`, "");
29
+ m.dependencies.forEach((d) => {
30
+ d.path = d.absolutePath.replace(`${data.rootFolder}/`, "");
31
+ });
32
+ m._tmp_ids = getDuplicateId(m.path);
33
+ m.duplicates = [];
34
+ m._tmp_ids.forEach((id) => {
35
+ if (!duplicatesMap.has(id)) duplicatesMap.set(id, []);
36
+ duplicatesMap.get(id).push(m);
37
+ });
38
+ if (m.path.includes("node_modules/lodash")) allLodashModules.add(m);
39
+ m.dependents = [];
40
+ moduleMap.set(m.absolutePath, m);
41
+ if (m.path === "__prelude__")
42
+ m.source.code = m.source.code
43
+ .replaceAll(";", ";\n\n")
44
+ .replaceAll(",", ",\n ");
45
+ });
46
+ data.modules.forEach((m) => {
47
+ m._tmp_ids.forEach((id) => {
48
+ const duplicates = duplicatesMap.get(id);
49
+ if (duplicates.length > 1)
50
+ m.duplicates.push(...duplicates.filter((d) => d !== m));
51
+ });
52
+ if (m.path.endsWith("node_modules/lodash/index.js"))
53
+ m.duplicates.push(...allLodashModules);
54
+ delete m._tmp_ids;
55
+ m.dependencies.forEach((dependency) => {
56
+ const dependentModule = moduleMap.get(dependency.absolutePath);
57
+ if (dependentModule) dependentModule.dependents.push(m);
58
+ });
59
+ });
60
+ return data;
50
61
  }
51
62
  //#endregion
52
63
  module.exports = prepare;