@buoy-gg/assets 7.0.16

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.
Files changed (179) hide show
  1. package/LICENSE +58 -0
  2. package/README.md +55 -0
  3. package/lib/commonjs/capture/expo.js +46 -0
  4. package/lib/commonjs/capture/expo.js.map +1 -0
  5. package/lib/commonjs/capture/install.js +78 -0
  6. package/lib/commonjs/capture/install.js.map +1 -0
  7. package/lib/commonjs/capture/measure.js +186 -0
  8. package/lib/commonjs/capture/measure.js.map +1 -0
  9. package/lib/commonjs/capture/metroGraph.js +148 -0
  10. package/lib/commonjs/capture/metroGraph.js.map +1 -0
  11. package/lib/commonjs/capture/registry.js +124 -0
  12. package/lib/commonjs/capture/registry.js.map +1 -0
  13. package/lib/commonjs/components/AssetDetail.js +205 -0
  14. package/lib/commonjs/components/AssetDetail.js.map +1 -0
  15. package/lib/commonjs/components/AssetRow.js +246 -0
  16. package/lib/commonjs/components/AssetRow.js.map +1 -0
  17. package/lib/commonjs/components/AssetsFilterBar.js +92 -0
  18. package/lib/commonjs/components/AssetsFilterBar.js.map +1 -0
  19. package/lib/commonjs/components/AssetsHeader.js +66 -0
  20. package/lib/commonjs/components/AssetsHeader.js.map +1 -0
  21. package/lib/commonjs/components/AssetsIcon.js +19 -0
  22. package/lib/commonjs/components/AssetsIcon.js.map +1 -0
  23. package/lib/commonjs/components/AssetsListControls.js +94 -0
  24. package/lib/commonjs/components/AssetsListControls.js.map +1 -0
  25. package/lib/commonjs/components/AssetsModal.js +338 -0
  26. package/lib/commonjs/components/AssetsModal.js.map +1 -0
  27. package/lib/commonjs/components/BaselineBar.js +110 -0
  28. package/lib/commonjs/components/BaselineBar.js.map +1 -0
  29. package/lib/commonjs/export.js +62 -0
  30. package/lib/commonjs/export.js.map +1 -0
  31. package/lib/commonjs/format.js +59 -0
  32. package/lib/commonjs/format.js.map +1 -0
  33. package/lib/commonjs/hooks/useAssetRecords.js +22 -0
  34. package/lib/commonjs/hooks/useAssetRecords.js.map +1 -0
  35. package/lib/commonjs/index.js +260 -0
  36. package/lib/commonjs/index.js.map +1 -0
  37. package/lib/commonjs/package.json +1 -0
  38. package/lib/commonjs/preset.js +45 -0
  39. package/lib/commonjs/preset.js.map +1 -0
  40. package/lib/commonjs/remote.js +65 -0
  41. package/lib/commonjs/remote.js.map +1 -0
  42. package/lib/commonjs/state.js +51 -0
  43. package/lib/commonjs/state.js.map +1 -0
  44. package/lib/commonjs/store/assetStore.js +234 -0
  45. package/lib/commonjs/store/assetStore.js.map +1 -0
  46. package/lib/commonjs/store/baseline.js +165 -0
  47. package/lib/commonjs/store/baseline.js.map +1 -0
  48. package/lib/commonjs/store/insights.js +129 -0
  49. package/lib/commonjs/store/insights.js.map +1 -0
  50. package/lib/commonjs/sync/assetsSyncAdapter.js +157 -0
  51. package/lib/commonjs/sync/assetsSyncAdapter.js.map +1 -0
  52. package/lib/commonjs/types.js +2 -0
  53. package/lib/commonjs/types.js.map +1 -0
  54. package/lib/module/capture/expo.js +41 -0
  55. package/lib/module/capture/expo.js.map +1 -0
  56. package/lib/module/capture/install.js +72 -0
  57. package/lib/module/capture/install.js.map +1 -0
  58. package/lib/module/capture/measure.js +179 -0
  59. package/lib/module/capture/measure.js.map +1 -0
  60. package/lib/module/capture/metroGraph.js +141 -0
  61. package/lib/module/capture/metroGraph.js.map +1 -0
  62. package/lib/module/capture/registry.js +117 -0
  63. package/lib/module/capture/registry.js.map +1 -0
  64. package/lib/module/components/AssetDetail.js +201 -0
  65. package/lib/module/components/AssetDetail.js.map +1 -0
  66. package/lib/module/components/AssetRow.js +242 -0
  67. package/lib/module/components/AssetRow.js.map +1 -0
  68. package/lib/module/components/AssetsFilterBar.js +88 -0
  69. package/lib/module/components/AssetsFilterBar.js.map +1 -0
  70. package/lib/module/components/AssetsHeader.js +62 -0
  71. package/lib/module/components/AssetsHeader.js.map +1 -0
  72. package/lib/module/components/AssetsIcon.js +12 -0
  73. package/lib/module/components/AssetsIcon.js.map +1 -0
  74. package/lib/module/components/AssetsListControls.js +90 -0
  75. package/lib/module/components/AssetsListControls.js.map +1 -0
  76. package/lib/module/components/AssetsModal.js +333 -0
  77. package/lib/module/components/AssetsModal.js.map +1 -0
  78. package/lib/module/components/BaselineBar.js +106 -0
  79. package/lib/module/components/BaselineBar.js.map +1 -0
  80. package/lib/module/export.js +57 -0
  81. package/lib/module/export.js.map +1 -0
  82. package/lib/module/format.js +51 -0
  83. package/lib/module/format.js.map +1 -0
  84. package/lib/module/hooks/useAssetRecords.js +18 -0
  85. package/lib/module/hooks/useAssetRecords.js.map +1 -0
  86. package/lib/module/index.js +59 -0
  87. package/lib/module/index.js.map +1 -0
  88. package/lib/module/preset.js +40 -0
  89. package/lib/module/preset.js.map +1 -0
  90. package/lib/module/remote.js +58 -0
  91. package/lib/module/remote.js.map +1 -0
  92. package/lib/module/state.js +47 -0
  93. package/lib/module/state.js.map +1 -0
  94. package/lib/module/store/assetStore.js +219 -0
  95. package/lib/module/store/assetStore.js.map +1 -0
  96. package/lib/module/store/baseline.js +157 -0
  97. package/lib/module/store/baseline.js.map +1 -0
  98. package/lib/module/store/insights.js +125 -0
  99. package/lib/module/store/insights.js.map +1 -0
  100. package/lib/module/sync/assetsSyncAdapter.js +153 -0
  101. package/lib/module/sync/assetsSyncAdapter.js.map +1 -0
  102. package/lib/module/types.js +2 -0
  103. package/lib/module/types.js.map +1 -0
  104. package/lib/typescript/capture/expo.d.ts +18 -0
  105. package/lib/typescript/capture/expo.d.ts.map +1 -0
  106. package/lib/typescript/capture/install.d.ts +17 -0
  107. package/lib/typescript/capture/install.d.ts.map +1 -0
  108. package/lib/typescript/capture/measure.d.ts +38 -0
  109. package/lib/typescript/capture/measure.d.ts.map +1 -0
  110. package/lib/typescript/capture/metroGraph.d.ts +33 -0
  111. package/lib/typescript/capture/metroGraph.d.ts.map +1 -0
  112. package/lib/typescript/capture/registry.d.ts +45 -0
  113. package/lib/typescript/capture/registry.d.ts.map +1 -0
  114. package/lib/typescript/components/AssetDetail.d.ts +17 -0
  115. package/lib/typescript/components/AssetDetail.d.ts.map +1 -0
  116. package/lib/typescript/components/AssetRow.d.ts +32 -0
  117. package/lib/typescript/components/AssetRow.d.ts.map +1 -0
  118. package/lib/typescript/components/AssetsFilterBar.d.ts +16 -0
  119. package/lib/typescript/components/AssetsFilterBar.d.ts.map +1 -0
  120. package/lib/typescript/components/AssetsHeader.d.ts +22 -0
  121. package/lib/typescript/components/AssetsHeader.d.ts.map +1 -0
  122. package/lib/typescript/components/AssetsIcon.d.ts +9 -0
  123. package/lib/typescript/components/AssetsIcon.d.ts.map +1 -0
  124. package/lib/typescript/components/AssetsListControls.d.ts +18 -0
  125. package/lib/typescript/components/AssetsListControls.d.ts.map +1 -0
  126. package/lib/typescript/components/AssetsModal.d.ts +24 -0
  127. package/lib/typescript/components/AssetsModal.d.ts.map +1 -0
  128. package/lib/typescript/components/BaselineBar.d.ts +13 -0
  129. package/lib/typescript/components/BaselineBar.d.ts.map +1 -0
  130. package/lib/typescript/export.d.ts +8 -0
  131. package/lib/typescript/export.d.ts.map +1 -0
  132. package/lib/typescript/format.d.ts +13 -0
  133. package/lib/typescript/format.d.ts.map +1 -0
  134. package/lib/typescript/hooks/useAssetRecords.d.ts +11 -0
  135. package/lib/typescript/hooks/useAssetRecords.d.ts.map +1 -0
  136. package/lib/typescript/index.d.ts +26 -0
  137. package/lib/typescript/index.d.ts.map +1 -0
  138. package/lib/typescript/preset.d.ts +38 -0
  139. package/lib/typescript/preset.d.ts.map +1 -0
  140. package/lib/typescript/remote.d.ts +17 -0
  141. package/lib/typescript/remote.d.ts.map +1 -0
  142. package/lib/typescript/state.d.ts +41 -0
  143. package/lib/typescript/state.d.ts.map +1 -0
  144. package/lib/typescript/store/assetStore.d.ts +51 -0
  145. package/lib/typescript/store/assetStore.d.ts.map +1 -0
  146. package/lib/typescript/store/baseline.d.ts +22 -0
  147. package/lib/typescript/store/baseline.d.ts.map +1 -0
  148. package/lib/typescript/store/insights.d.ts +7 -0
  149. package/lib/typescript/store/insights.d.ts.map +1 -0
  150. package/lib/typescript/sync/assetsSyncAdapter.d.ts +83 -0
  151. package/lib/typescript/sync/assetsSyncAdapter.d.ts.map +1 -0
  152. package/lib/typescript/types.d.ts +162 -0
  153. package/lib/typescript/types.d.ts.map +1 -0
  154. package/package.json +77 -0
  155. package/src/capture/expo.ts +45 -0
  156. package/src/capture/install.ts +73 -0
  157. package/src/capture/measure.ts +167 -0
  158. package/src/capture/metroGraph.ts +146 -0
  159. package/src/capture/registry.ts +134 -0
  160. package/src/components/AssetDetail.tsx +207 -0
  161. package/src/components/AssetRow.tsx +243 -0
  162. package/src/components/AssetsFilterBar.tsx +99 -0
  163. package/src/components/AssetsHeader.tsx +75 -0
  164. package/src/components/AssetsIcon.tsx +9 -0
  165. package/src/components/AssetsListControls.tsx +101 -0
  166. package/src/components/AssetsModal.tsx +368 -0
  167. package/src/components/BaselineBar.tsx +98 -0
  168. package/src/export.ts +108 -0
  169. package/src/format.ts +53 -0
  170. package/src/hooks/useAssetRecords.ts +26 -0
  171. package/src/index.tsx +87 -0
  172. package/src/preset.tsx +35 -0
  173. package/src/remote.ts +65 -0
  174. package/src/state.ts +84 -0
  175. package/src/store/assetStore.ts +209 -0
  176. package/src/store/baseline.ts +152 -0
  177. package/src/store/insights.ts +145 -0
  178. package/src/sync/assetsSyncAdapter.ts +151 -0
  179. package/src/types.ts +160 -0
@@ -0,0 +1,207 @@
1
+ /**
2
+ * AssetDetail — full metadata for one asset: preview, identity, dimensions,
3
+ * per-scale sizes, resolution info, and which audit findings apply.
4
+ *
5
+ * Image previews render through the numeric registry id (works in every
6
+ * environment); fonts render a pangram with fontFamily set to the asset name
7
+ * — a best-effort guess (family ≠ filename for many fonts) that falls back
8
+ * to the system font silently when it misses.
9
+ */
10
+
11
+ import { Image, ScrollView, StyleSheet, Text, View } from "react-native";
12
+ import { macOSColors } from "@buoy-gg/shared-ui";
13
+ import { displaySource } from "../capture/measure";
14
+ import { formatBytes, formatDimensions, formatScales } from "../format";
15
+ import { estDecodedBytes } from "../store/assetStore";
16
+ import type { AssetRecord, AssetsInsights } from "../types";
17
+
18
+ interface AssetDetailProps {
19
+ record: AssetRecord;
20
+ insights: AssetsInsights;
21
+ }
22
+
23
+ function Row({ label, value }: { label: string; value: string }) {
24
+ return (
25
+ <View style={styles.kvRow}>
26
+ <Text style={styles.kvLabel}>{label}</Text>
27
+ <Text style={styles.kvValue} selectable>
28
+ {value}
29
+ </Text>
30
+ </View>
31
+ );
32
+ }
33
+
34
+ function Preview({ record }: { record: AssetRecord }) {
35
+ if (record.kind === "image") {
36
+ const source = displaySource(record);
37
+ if (source == null) return null;
38
+ return (
39
+ <View style={styles.previewBox}>
40
+ <Image
41
+ testID="buoy-internal-assets-preview"
42
+ source={source}
43
+ style={styles.previewImage}
44
+ resizeMode="contain"
45
+ />
46
+ </View>
47
+ );
48
+ }
49
+ if (record.kind === "font") {
50
+ return (
51
+ <View style={styles.previewBox}>
52
+ <Text style={[styles.fontPreview, { fontFamily: record.name }]}>
53
+ The quick brown fox jumps over the lazy dog 0123456789
54
+ </Text>
55
+ </View>
56
+ );
57
+ }
58
+ return null;
59
+ }
60
+
61
+ export function AssetDetail({ record, insights }: AssetDetailProps) {
62
+ const findings: string[] = [];
63
+ if (insights.neverLoaded.includes(record.id)) {
64
+ findings.push("Never loaded — shipped in the bundle but no code required it");
65
+ }
66
+ if (insights.scaleGaps.includes(record.id)) {
67
+ findings.push("Scale gap — no variant covers this device's pixel ratio");
68
+ }
69
+ if (insights.webpCandidates.includes(record.id)) {
70
+ findings.push("WebP candidate — large png/jpeg, converting typically saves 20–40%");
71
+ }
72
+ const duplicate = insights.duplicates.find((d) => d.ids.includes(record.id));
73
+ if (duplicate) {
74
+ findings.push(
75
+ `Duplicate content — identical bytes shipped ${duplicate.ids.length} times`
76
+ );
77
+ }
78
+ if (insights.overDecode.includes(record.id)) {
79
+ findings.push(
80
+ "Decodes larger than 2× this entire screen — resize the source, no view can need this many pixels"
81
+ );
82
+ }
83
+ if (insights.heavyGifs.includes(record.id)) {
84
+ findings.push(
85
+ "Heavy GIF — every frame decodes into memory; a video or Lottie is typically ~90% smaller"
86
+ );
87
+ }
88
+ if (insights.heavyFonts.includes(record.id)) {
89
+ findings.push(
90
+ "Heavy font — likely an unsubset icon font; subsetting to used glyphs usually saves most of it"
91
+ );
92
+ }
93
+ if (insights.scaleAnomalies.includes(record.id)) {
94
+ findings.push(
95
+ "Scale anomaly — a higher-resolution variant is smaller in bytes than a lower one; check the exports"
96
+ );
97
+ }
98
+
99
+ const estimate = estDecodedBytes(record);
100
+
101
+ return (
102
+ <ScrollView style={styles.scroll} contentContainerStyle={styles.content}>
103
+ <Preview record={record} />
104
+
105
+ {findings.length > 0 ? (
106
+ <View style={styles.findings}>
107
+ {findings.map((finding) => (
108
+ <Text key={finding} style={styles.findingText}>
109
+ {finding}
110
+ </Text>
111
+ ))}
112
+ </View>
113
+ ) : null}
114
+
115
+ <Row label="Name" value={`${record.name}.${record.type}`} />
116
+ <Row label="Kind" value={record.kind} />
117
+ <Row
118
+ label="Status"
119
+ value={record.loaded ? "Loaded (registered at runtime)" : "In bundle, never loaded"}
120
+ />
121
+ {record.kind === "image" ? (
122
+ <Row label="Dimensions" value={`${formatDimensions(record)} (logical)`} />
123
+ ) : null}
124
+ {record.kind === "image" && record.scales.length ? (
125
+ <Row label="Scales" value={formatScales(record.scales)} />
126
+ ) : null}
127
+
128
+ {record.sizesByScale
129
+ ? Object.entries(record.sizesByScale).map(([scale, bytes]) => (
130
+ <Row key={scale} label={`Size @${scale}x`} value={formatBytes(bytes)} />
131
+ ))
132
+ : null}
133
+ {record.sizeBytes != null && record.sizeSource === "measured" ? (
134
+ <Row label="Total size" value={formatBytes(record.sizeBytes)} />
135
+ ) : null}
136
+ {estimate > 0 ? (
137
+ <Row label="Decoded memory" value={`~${formatBytes(estimate)} (RGBA)`} />
138
+ ) : null}
139
+
140
+ {record.registryId != null ? (
141
+ <Row label="Registry id" value={String(record.registryId)} />
142
+ ) : null}
143
+ {record.hash ? <Row label="Hash" value={record.hash} /> : null}
144
+ {record.httpServerLocation ? (
145
+ <Row label="Location" value={record.httpServerLocation} />
146
+ ) : null}
147
+ {record.fileSystemLocation ? (
148
+ <Row label="Source dir" value={record.fileSystemLocation} />
149
+ ) : null}
150
+ {record.resolvedUri ? <Row label="Resolved URI" value={record.resolvedUri} /> : null}
151
+ </ScrollView>
152
+ );
153
+ }
154
+
155
+ const styles = StyleSheet.create({
156
+ scroll: {
157
+ flex: 1,
158
+ },
159
+ content: {
160
+ padding: 12,
161
+ gap: 8,
162
+ },
163
+ previewBox: {
164
+ borderRadius: 8,
165
+ backgroundColor: macOSColors.background.input,
166
+ padding: 12,
167
+ alignItems: "center",
168
+ justifyContent: "center",
169
+ minHeight: 96,
170
+ },
171
+ previewImage: {
172
+ width: "100%",
173
+ height: 140,
174
+ },
175
+ fontPreview: {
176
+ color: macOSColors.text.primary,
177
+ fontSize: 16,
178
+ textAlign: "center",
179
+ },
180
+ findings: {
181
+ borderRadius: 8,
182
+ borderWidth: 1,
183
+ borderColor: macOSColors.border.default,
184
+ backgroundColor: macOSColors.background.card,
185
+ padding: 10,
186
+ gap: 6,
187
+ },
188
+ findingText: {
189
+ color: macOSColors.text.secondary,
190
+ fontSize: 11,
191
+ lineHeight: 15,
192
+ },
193
+ kvRow: {
194
+ gap: 2,
195
+ },
196
+ kvLabel: {
197
+ color: macOSColors.text.muted,
198
+ fontSize: 9,
199
+ fontWeight: "700",
200
+ letterSpacing: 0.5,
201
+ textTransform: "uppercase",
202
+ },
203
+ kvValue: {
204
+ color: macOSColors.text.primary,
205
+ fontSize: 12,
206
+ },
207
+ });
@@ -0,0 +1,243 @@
1
+ /**
2
+ * AssetRow — one bundled asset as a family-style card (matching the network
3
+ * tool's rows): rounded card, colored accent edge per kind, thumbnail, name,
4
+ * quiet metadata, bold right-aligned size, and finding badges ONLY when a
5
+ * finding exists. A thin proportional bar along the card bottom makes the
6
+ * heavy assets feel heavy at a glance.
7
+ *
8
+ * Thumbnails render through the NUMERIC registry id when available — that
9
+ * routes through resolveAssetSource natively, so it works in dev, iOS
10
+ * release (file://) and Android release (bare resource id) alike. They carry
11
+ * the buoy-internal testID so the images tool never records our own UI.
12
+ */
13
+
14
+ import { Image, StyleSheet, Text, TouchableOpacity, View } from "react-native";
15
+ import { macOSColors } from "@buoy-gg/shared-ui";
16
+ import { displaySource } from "../capture/measure";
17
+ import {
18
+ formatDimensions,
19
+ formatScales,
20
+ formatSize,
21
+ KIND_COLORS,
22
+ KIND_LABELS,
23
+ } from "../format";
24
+ import { estDecodedBytes } from "../store/assetStore";
25
+ import type { AssetRecord } from "../types";
26
+
27
+ /** Which audit findings apply to this record (drives the row badges). */
28
+ export interface AssetRowFlags {
29
+ scaleGap: boolean;
30
+ scaleAnomaly: boolean;
31
+ duplicate: boolean;
32
+ webp: boolean;
33
+ oversize: boolean;
34
+ heavy: boolean;
35
+ }
36
+
37
+ interface AssetRowProps {
38
+ record: AssetRecord;
39
+ flags: AssetRowFlags;
40
+ /** This record's size relative to the largest in the list (0–1). */
41
+ sizeFraction: number;
42
+ onPress: (id: number) => void;
43
+ }
44
+
45
+ function Badge({ label, color }: { label: string; color?: string }) {
46
+ // Quiet chip: legibility from light-gray text on a neutral fill. Only the
47
+ // serious tiers (red) and WEBP (blue) carry a small dot; the rest are plain.
48
+ return (
49
+ <View style={styles.badgePill}>
50
+ {color ? <View style={[styles.badgeDot, { backgroundColor: color }]} /> : null}
51
+ <Text style={styles.badgePillText}>{label}</Text>
52
+ </View>
53
+ );
54
+ }
55
+
56
+ export function AssetRow({ record, flags, sizeFraction, onPress }: AssetRowProps) {
57
+ const accent = KIND_COLORS[record.kind];
58
+ const thumbSource = record.kind === "image" ? displaySource(record) : null;
59
+
60
+ const badges: Array<{ label: string; color?: string }> = [];
61
+ if (!record.loaded) badges.push({ label: "UNUSED" });
62
+ if (flags.oversize) badges.push({ label: "OVERSIZE", color: macOSColors.semantic.error });
63
+ if (flags.duplicate) badges.push({ label: "DUP" });
64
+ if (flags.heavy) badges.push({ label: "HEAVY" });
65
+ if (flags.scaleAnomaly) badges.push({ label: "BAD SCALE", color: macOSColors.semantic.error });
66
+ else if (flags.scaleGap) badges.push({ label: "LOW-RES" });
67
+ if (flags.webp) badges.push({ label: "WEBP", color: macOSColors.semantic.info });
68
+
69
+ return (
70
+ <TouchableOpacity
71
+ style={styles.card}
72
+ testID={`buoy-asset-row-${record.id}`}
73
+ onPress={() => onPress(record.id)}
74
+ activeOpacity={0.7}
75
+ >
76
+ <View style={styles.body}>
77
+ <View style={styles.thumbBox}>
78
+ {thumbSource != null ? (
79
+ <Image
80
+ testID="buoy-internal-assets-thumb"
81
+ source={thumbSource}
82
+ style={styles.thumb}
83
+ resizeMode="contain"
84
+ />
85
+ ) : (
86
+ <Text style={[styles.thumbFallback, { color: accent }]}>
87
+ {KIND_LABELS[record.kind]}
88
+ </Text>
89
+ )}
90
+ </View>
91
+
92
+ <View style={styles.main}>
93
+ <Text style={styles.name} numberOfLines={1}>
94
+ {record.name}
95
+ <Text style={styles.ext}>.{record.type}</Text>
96
+ </Text>
97
+ <View style={styles.metaRow}>
98
+ {record.kind === "image" && record.width != null ? (
99
+ <Text style={styles.meta}>{formatDimensions(record)}</Text>
100
+ ) : null}
101
+ {/* Scale variants only mean something for images. */}
102
+ {record.kind === "image" && record.scales.length ? (
103
+ <Text style={styles.meta}>{formatScales(record.scales)}</Text>
104
+ ) : null}
105
+ </View>
106
+ </View>
107
+
108
+ <View style={styles.right}>
109
+ <Text style={styles.size}>
110
+ {formatSize(record, estDecodedBytes(record))}
111
+ </Text>
112
+ {badges.length ? (
113
+ <View style={styles.badgeRow}>
114
+ {badges.slice(0, 3).map((b) => (
115
+ <Badge key={b.label} label={b.label} color={b.color} />
116
+ ))}
117
+ </View>
118
+ ) : null}
119
+ </View>
120
+ </View>
121
+
122
+ {sizeFraction > 0 ? (
123
+ <View style={styles.sizeTrack}>
124
+ <View
125
+ style={[
126
+ styles.sizeFill,
127
+ {
128
+ backgroundColor: accent,
129
+ width: `${Math.max(2, Math.round(sizeFraction * 100))}%`,
130
+ },
131
+ ]}
132
+ />
133
+ </View>
134
+ ) : null}
135
+ </TouchableOpacity>
136
+ );
137
+ }
138
+
139
+ const styles = StyleSheet.create({
140
+ card: {
141
+ marginHorizontal: 10,
142
+ marginTop: 6,
143
+ borderRadius: 10,
144
+ backgroundColor: macOSColors.background.card,
145
+ borderWidth: 1,
146
+ borderColor: macOSColors.border.default,
147
+ overflow: "hidden",
148
+ },
149
+ body: {
150
+ flexDirection: "row",
151
+ alignItems: "center",
152
+ paddingVertical: 8,
153
+ paddingHorizontal: 12,
154
+ gap: 10,
155
+ },
156
+ thumbBox: {
157
+ width: 40,
158
+ height: 40,
159
+ borderRadius: 8,
160
+ // Light plate so dark glyph assets stay visible on the dark card.
161
+ backgroundColor: "rgba(255,255,255,0.10)",
162
+ borderWidth: 1,
163
+ borderColor: macOSColors.border.default,
164
+ alignItems: "center",
165
+ justifyContent: "center",
166
+ overflow: "hidden",
167
+ },
168
+ thumb: {
169
+ width: 34,
170
+ height: 34,
171
+ },
172
+ thumbFallback: {
173
+ fontSize: 9,
174
+ fontWeight: "700",
175
+ letterSpacing: 0.5,
176
+ },
177
+ main: {
178
+ flex: 1,
179
+ gap: 3,
180
+ },
181
+ name: {
182
+ color: macOSColors.text.primary,
183
+ fontSize: 12,
184
+ fontWeight: "600",
185
+ },
186
+ ext: {
187
+ color: macOSColors.text.muted,
188
+ fontWeight: "400",
189
+ },
190
+ metaRow: {
191
+ flexDirection: "row",
192
+ alignItems: "center",
193
+ gap: 8,
194
+ },
195
+ meta: {
196
+ color: macOSColors.text.secondary,
197
+ fontSize: 10,
198
+ fontVariant: ["tabular-nums"],
199
+ },
200
+ right: {
201
+ alignItems: "flex-end",
202
+ gap: 4,
203
+ },
204
+ size: {
205
+ color: macOSColors.text.primary,
206
+ fontSize: 12,
207
+ fontWeight: "700",
208
+ fontVariant: ["tabular-nums"],
209
+ },
210
+ badgeRow: {
211
+ flexDirection: "row",
212
+ gap: 4,
213
+ },
214
+ badgePill: {
215
+ flexDirection: "row",
216
+ alignItems: "center",
217
+ gap: 4,
218
+ backgroundColor: "rgba(255,255,255,0.06)",
219
+ borderRadius: 4,
220
+ paddingHorizontal: 6,
221
+ paddingVertical: 2.5,
222
+ },
223
+ badgeDot: {
224
+ width: 5,
225
+ height: 5,
226
+ borderRadius: 2.5,
227
+ },
228
+ badgePillText: {
229
+ color: macOSColors.text.secondary,
230
+ fontSize: 9,
231
+ fontWeight: "600",
232
+ letterSpacing: 0.3,
233
+ },
234
+ sizeTrack: {
235
+ height: 2,
236
+ backgroundColor: "transparent",
237
+ },
238
+ sizeFill: {
239
+ height: 2,
240
+ opacity: 0.45,
241
+ borderTopRightRadius: 2,
242
+ },
243
+ });
@@ -0,0 +1,99 @@
1
+ /**
2
+ * AssetsFilterBar — kind filter pills with counts, styled like the network
3
+ * tool's bordered pills: outlined, kind-accent-colored when active. Wrapping
4
+ * row, not a horizontal ScrollView (same height-measurement pitfall the
5
+ * images tool documents).
6
+ */
7
+
8
+ import { StyleSheet, Text, TouchableOpacity, View } from "react-native";
9
+ import { macOSColors } from "@buoy-gg/shared-ui";
10
+ import { KIND_COLORS, KIND_LABELS } from "../format";
11
+ import type { AssetKind, AssetsStats } from "../types";
12
+
13
+ export type AssetFilter = "all" | "unused" | AssetKind;
14
+
15
+ interface AssetsFilterBarProps {
16
+ stats: AssetsStats;
17
+ filter: AssetFilter;
18
+ onChange: (filter: AssetFilter) => void;
19
+ }
20
+
21
+ export function AssetsFilterBar({ stats, filter, onChange }: AssetsFilterBarProps) {
22
+ const chips: Array<{ key: AssetFilter; label: string; accent: string }> = [
23
+ { key: "all", label: `ALL ${stats.total}`, accent: macOSColors.text.secondary },
24
+ ];
25
+ for (const kind of Object.keys(stats.byKind) as AssetKind[]) {
26
+ const entry = stats.byKind[kind];
27
+ if (entry.count > 0) {
28
+ chips.push({
29
+ key: kind,
30
+ label: `${KIND_LABELS[kind]} ${entry.count}`,
31
+ accent: KIND_COLORS[kind],
32
+ });
33
+ }
34
+ }
35
+ if (stats.neverLoaded > 0) {
36
+ // Amber, not semantic.warning — the bright yellow reads as an alarm.
37
+ chips.push({
38
+ key: "unused",
39
+ label: `UNUSED ${stats.neverLoaded}`,
40
+ accent: "#FF9F1C",
41
+ });
42
+ }
43
+ if (chips.length <= 1) return null;
44
+
45
+ return (
46
+ <View style={styles.bar}>
47
+ {chips.map((chip) => {
48
+ const active = chip.key === filter;
49
+ return (
50
+ <TouchableOpacity
51
+ key={chip.key}
52
+ style={[
53
+ styles.chip,
54
+ active && {
55
+ borderColor: chip.accent,
56
+ backgroundColor: `${chip.accent}1A`,
57
+ },
58
+ ]}
59
+ // Tapping the active chip again untoggles back to ALL.
60
+ onPress={() => onChange(active ? "all" : chip.key)}
61
+ >
62
+ <Text
63
+ style={[
64
+ styles.chipText,
65
+ { color: active ? chip.accent : macOSColors.text.secondary },
66
+ ]}
67
+ >
68
+ {chip.label}
69
+ </Text>
70
+ </TouchableOpacity>
71
+ );
72
+ })}
73
+ </View>
74
+ );
75
+ }
76
+
77
+ const styles = StyleSheet.create({
78
+ bar: {
79
+ flexDirection: "row",
80
+ flexWrap: "wrap",
81
+ gap: 6,
82
+ paddingHorizontal: 10,
83
+ paddingVertical: 8,
84
+ },
85
+ chip: {
86
+ borderWidth: 1,
87
+ borderColor: macOSColors.border.default,
88
+ backgroundColor: macOSColors.background.card,
89
+ borderRadius: 999,
90
+ paddingHorizontal: 10,
91
+ paddingVertical: 5,
92
+ },
93
+ chipText: {
94
+ fontSize: 10,
95
+ fontWeight: "700",
96
+ letterSpacing: 0.4,
97
+ lineHeight: 13,
98
+ },
99
+ });
@@ -0,0 +1,75 @@
1
+ /**
2
+ * AssetsHeader — shared ModalHeader wiring, matching the Images/Console
3
+ * header pattern. List mode shows inventory totals plus the shared
4
+ * ToolbarCopyButton (full markdown report); detail mode shows back
5
+ * navigation and the single-asset report.
6
+ */
7
+
8
+ import {
9
+ ModalHeader,
10
+ ToolbarClearButton,
11
+ ToolbarCopyButton,
12
+ } from "@buoy-gg/shared-ui";
13
+ import { formatBytes } from "../format";
14
+ import type { AssetsStats } from "../types";
15
+
16
+ interface AssetsHeaderProps {
17
+ stats: AssetsStats;
18
+ /** Size measurement in progress — suppress the (partial) byte total. */
19
+ measuring: boolean;
20
+ detailOpen: boolean;
21
+ detailIndex?: number;
22
+ detailTotal?: number;
23
+ onCloseDetail: () => void;
24
+ onClear: () => void;
25
+ getReport: () => string;
26
+ onBack?: () => void;
27
+ }
28
+
29
+ export function AssetsHeader({
30
+ stats,
31
+ measuring,
32
+ detailOpen,
33
+ detailIndex = -1,
34
+ detailTotal = 0,
35
+ onCloseDetail,
36
+ onClear,
37
+ getReport,
38
+ onBack,
39
+ }: AssetsHeaderProps) {
40
+ if (detailOpen) {
41
+ const counter =
42
+ detailIndex >= 0 && detailTotal > 0
43
+ ? `${detailIndex + 1} of ${detailTotal}`
44
+ : undefined;
45
+ return (
46
+ <ModalHeader>
47
+ <ModalHeader.Navigation onBack={onCloseDetail} />
48
+ <ModalHeader.Content title="Asset detail" subtitle={counter} />
49
+ <ModalHeader.Actions>
50
+ <ToolbarCopyButton value={getReport} />
51
+ </ModalHeader.Actions>
52
+ </ModalHeader>
53
+ );
54
+ }
55
+
56
+ const subtitleParts = [`${stats.total} assets`];
57
+ // A mid-measure byte total reads as nonsense ("653 B+") — wait it out.
58
+ if (stats.totalBytes > 0 && !measuring) {
59
+ const partial = stats.measuredCount < stats.total ? "+" : "";
60
+ subtitleParts.push(`${formatBytes(stats.totalBytes)}${partial}`);
61
+ }
62
+ if (stats.neverLoaded > 0) subtitleParts.push(`${stats.neverLoaded} never loaded`);
63
+ if (stats.fontFamilies > 0) subtitleParts.push(`${stats.fontFamilies} fonts`);
64
+
65
+ return (
66
+ <ModalHeader>
67
+ {onBack ? <ModalHeader.Navigation onBack={onBack} /> : null}
68
+ <ModalHeader.Content title="Assets" subtitle={subtitleParts.join(" · ")} />
69
+ <ModalHeader.Actions>
70
+ <ToolbarCopyButton value={getReport} />
71
+ <ToolbarClearButton onPress={onClear} />
72
+ </ModalHeader.Actions>
73
+ </ModalHeader>
74
+ );
75
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * AssetsIcon — re-exported from the Buoy Icon Format.
3
+ *
4
+ * The artwork lives in shared/icons/assets.json and is generated into
5
+ * @buoy-gg/floating-tools-core, so React Native, the desktop dashboard and
6
+ * Flutter all render the same drawing. Edit the JSON, then `pnpm icons`.
7
+ */
8
+
9
+ export { AssetsIcon, ASSETS_ICON_COLOR } from "@buoy-gg/shared-ui";