@buoy-gg/assets 7.0.40 → 7.0.42
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/README.md +12 -69
- package/bundlers/vite.d.ts +7 -0
- package/bundlers/vite.mjs +1 -0
- package/lib/commonjs/autoCapture.js +1 -0
- package/lib/commonjs/autoCapture.web.js +1 -0
- package/lib/commonjs/capture/assetLifecycle.js +1 -0
- package/lib/commonjs/capture/assetLifecycle.web.js +1 -0
- package/lib/commonjs/capture/browserAssets.js +1 -0
- package/lib/commonjs/capture/expo.js +1 -46
- package/lib/commonjs/capture/expo.web.js +1 -0
- package/lib/commonjs/capture/install.js +1 -91
- package/lib/commonjs/capture/install.web.js +1 -0
- package/lib/commonjs/capture/isBuoyAsset.js +1 -23
- package/lib/commonjs/capture/measure.js +1 -186
- package/lib/commonjs/capture/metroGraph.js +1 -175
- package/lib/commonjs/capture/metroGraph.web.js +1 -0
- package/lib/commonjs/capture/registry.js +1 -127
- package/lib/commonjs/components/AssetDetail.js +1 -211
- package/lib/commonjs/components/AssetImage.js +1 -66
- package/lib/commonjs/components/AssetRow.js +1 -232
- package/lib/commonjs/components/AssetsFilterBar.js +1 -105
- package/lib/commonjs/components/AssetsHeader.js +1 -73
- package/lib/commonjs/components/AssetsIcon.js +1 -19
- package/lib/commonjs/components/AssetsListControls.js +1 -81
- package/lib/commonjs/components/AssetsModal.js +1 -378
- package/lib/commonjs/components/ScanNotice.js +1 -85
- package/lib/commonjs/components/optionalExpoImage.js +1 -16
- package/lib/commonjs/components/optionalExpoImage.web.js +1 -11
- package/lib/commonjs/export.js +1 -62
- package/lib/commonjs/format.js +1 -59
- package/lib/commonjs/hooks/useAssetRecords.js +1 -22
- package/lib/commonjs/hooks/useAssetScanStatus.js +1 -28
- package/lib/commonjs/index.js +1 -313
- package/lib/commonjs/preset.js +1 -39
- package/lib/commonjs/remote.js +1 -68
- package/lib/commonjs/state.js +1 -51
- package/lib/commonjs/store/assetStore.js +1 -256
- package/lib/commonjs/store/baseline.js +1 -175
- package/lib/commonjs/store/insights.js +1 -120
- package/lib/commonjs/sync/assetsSyncAdapter.js +1 -157
- package/lib/commonjs/types.js +0 -1
- package/lib/commonjs/utils/deviceScale.js +1 -50
- package/lib/commonjs/utils/testIDs.js +1 -110
- package/lib/module/autoCapture.js +1 -0
- package/lib/module/autoCapture.web.js +1 -0
- package/lib/module/capture/assetLifecycle.js +1 -0
- package/lib/module/capture/assetLifecycle.web.js +1 -0
- package/lib/module/capture/browserAssets.js +1 -0
- package/lib/module/capture/expo.js +1 -41
- package/lib/module/capture/expo.web.js +1 -0
- package/lib/module/capture/install.js +1 -85
- package/lib/module/capture/install.web.js +1 -0
- package/lib/module/capture/isBuoyAsset.js +1 -18
- package/lib/module/capture/measure.js +1 -179
- package/lib/module/capture/metroGraph.js +1 -168
- package/lib/module/capture/metroGraph.web.js +1 -0
- package/lib/module/capture/registry.js +1 -120
- package/lib/module/components/AssetDetail.js +1 -207
- package/lib/module/components/AssetImage.js +1 -62
- package/lib/module/components/AssetRow.js +1 -228
- package/lib/module/components/AssetsFilterBar.js +1 -101
- package/lib/module/components/AssetsHeader.js +1 -69
- package/lib/module/components/AssetsIcon.js +1 -12
- package/lib/module/components/AssetsListControls.js +1 -77
- package/lib/module/components/AssetsModal.js +1 -373
- package/lib/module/components/ScanNotice.js +1 -81
- package/lib/module/components/optionalExpoImage.js +1 -12
- package/lib/module/components/optionalExpoImage.web.js +1 -7
- package/lib/module/export.js +1 -57
- package/lib/module/format.js +1 -51
- package/lib/module/hooks/useAssetRecords.js +1 -18
- package/lib/module/hooks/useAssetScanStatus.js +1 -23
- package/lib/module/index.js +1 -63
- package/lib/module/preset.js +1 -35
- package/lib/module/remote.js +1 -61
- package/lib/module/state.js +1 -47
- package/lib/module/store/assetStore.js +1 -240
- package/lib/module/store/baseline.js +1 -167
- package/lib/module/store/insights.js +1 -116
- package/lib/module/sync/assetsSyncAdapter.js +1 -153
- package/lib/module/types.js +0 -1
- package/lib/module/utils/deviceScale.js +1 -46
- package/lib/module/utils/testIDs.js +1 -99
- package/lib/typescript/autoCapture.d.ts +2 -0
- package/lib/typescript/autoCapture.web.d.ts +2 -0
- package/lib/typescript/capture/assetLifecycle.d.ts +3 -0
- package/lib/typescript/capture/assetLifecycle.web.d.ts +2 -0
- package/lib/typescript/capture/browserAssets.d.ts +13 -0
- package/lib/typescript/capture/expo.web.d.ts +3 -0
- package/lib/typescript/capture/install.web.d.ts +6 -0
- package/lib/typescript/capture/measure.d.ts +0 -10
- package/lib/typescript/capture/metroGraph.web.d.ts +12 -0
- package/lib/typescript/components/optionalExpoImage.web.d.ts +1 -1
- package/lib/typescript/index.d.ts +3 -0
- package/lib/typescript/types.d.ts +2 -1
- package/lib/web/index.mjs +3 -0
- package/package.json +46 -7
- package/lib/commonjs/capture/expo.js.map +0 -1
- package/lib/commonjs/capture/install.js.map +0 -1
- package/lib/commonjs/capture/isBuoyAsset.js.map +0 -1
- package/lib/commonjs/capture/measure.js.map +0 -1
- package/lib/commonjs/capture/metroGraph.js.map +0 -1
- package/lib/commonjs/capture/registry.js.map +0 -1
- package/lib/commonjs/components/AssetDetail.js.map +0 -1
- package/lib/commonjs/components/AssetImage.js.map +0 -1
- package/lib/commonjs/components/AssetRow.js.map +0 -1
- package/lib/commonjs/components/AssetsFilterBar.js.map +0 -1
- package/lib/commonjs/components/AssetsHeader.js.map +0 -1
- package/lib/commonjs/components/AssetsIcon.js.map +0 -1
- package/lib/commonjs/components/AssetsListControls.js.map +0 -1
- package/lib/commonjs/components/AssetsModal.js.map +0 -1
- package/lib/commonjs/components/ScanNotice.js.map +0 -1
- package/lib/commonjs/components/optionalExpoImage.js.map +0 -1
- package/lib/commonjs/components/optionalExpoImage.web.js.map +0 -1
- package/lib/commonjs/export.js.map +0 -1
- package/lib/commonjs/format.js.map +0 -1
- package/lib/commonjs/hooks/useAssetRecords.js.map +0 -1
- package/lib/commonjs/hooks/useAssetScanStatus.js.map +0 -1
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/preset.js.map +0 -1
- package/lib/commonjs/remote.js.map +0 -1
- package/lib/commonjs/state.js.map +0 -1
- package/lib/commonjs/store/assetStore.js.map +0 -1
- package/lib/commonjs/store/baseline.js.map +0 -1
- package/lib/commonjs/store/insights.js.map +0 -1
- package/lib/commonjs/sync/assetsSyncAdapter.js.map +0 -1
- package/lib/commonjs/types.js.map +0 -1
- package/lib/commonjs/utils/deviceScale.js.map +0 -1
- package/lib/commonjs/utils/testIDs.js.map +0 -1
- package/lib/module/capture/expo.js.map +0 -1
- package/lib/module/capture/install.js.map +0 -1
- package/lib/module/capture/isBuoyAsset.js.map +0 -1
- package/lib/module/capture/measure.js.map +0 -1
- package/lib/module/capture/metroGraph.js.map +0 -1
- package/lib/module/capture/registry.js.map +0 -1
- package/lib/module/components/AssetDetail.js.map +0 -1
- package/lib/module/components/AssetImage.js.map +0 -1
- package/lib/module/components/AssetRow.js.map +0 -1
- package/lib/module/components/AssetsFilterBar.js.map +0 -1
- package/lib/module/components/AssetsHeader.js.map +0 -1
- package/lib/module/components/AssetsIcon.js.map +0 -1
- package/lib/module/components/AssetsListControls.js.map +0 -1
- package/lib/module/components/AssetsModal.js.map +0 -1
- package/lib/module/components/ScanNotice.js.map +0 -1
- package/lib/module/components/optionalExpoImage.js.map +0 -1
- package/lib/module/components/optionalExpoImage.web.js.map +0 -1
- package/lib/module/export.js.map +0 -1
- package/lib/module/format.js.map +0 -1
- package/lib/module/hooks/useAssetRecords.js.map +0 -1
- package/lib/module/hooks/useAssetScanStatus.js.map +0 -1
- package/lib/module/index.js.map +0 -1
- package/lib/module/preset.js.map +0 -1
- package/lib/module/remote.js.map +0 -1
- package/lib/module/state.js.map +0 -1
- package/lib/module/store/assetStore.js.map +0 -1
- package/lib/module/store/baseline.js.map +0 -1
- package/lib/module/store/insights.js.map +0 -1
- package/lib/module/sync/assetsSyncAdapter.js.map +0 -1
- package/lib/module/types.js.map +0 -1
- package/lib/module/utils/deviceScale.js.map +0 -1
- package/lib/module/utils/testIDs.js.map +0 -1
- package/lib/typescript/capture/expo.d.ts.map +0 -1
- package/lib/typescript/capture/install.d.ts.map +0 -1
- package/lib/typescript/capture/isBuoyAsset.d.ts.map +0 -1
- package/lib/typescript/capture/measure.d.ts.map +0 -1
- package/lib/typescript/capture/metroGraph.d.ts.map +0 -1
- package/lib/typescript/capture/registry.d.ts.map +0 -1
- package/lib/typescript/components/AssetDetail.d.ts.map +0 -1
- package/lib/typescript/components/AssetImage.d.ts.map +0 -1
- package/lib/typescript/components/AssetRow.d.ts.map +0 -1
- package/lib/typescript/components/AssetsFilterBar.d.ts.map +0 -1
- package/lib/typescript/components/AssetsHeader.d.ts.map +0 -1
- package/lib/typescript/components/AssetsIcon.d.ts.map +0 -1
- package/lib/typescript/components/AssetsListControls.d.ts.map +0 -1
- package/lib/typescript/components/AssetsModal.d.ts.map +0 -1
- package/lib/typescript/components/ScanNotice.d.ts.map +0 -1
- package/lib/typescript/components/optionalExpoImage.d.ts.map +0 -1
- package/lib/typescript/components/optionalExpoImage.web.d.ts.map +0 -1
- package/lib/typescript/export.d.ts.map +0 -1
- package/lib/typescript/format.d.ts.map +0 -1
- package/lib/typescript/hooks/useAssetRecords.d.ts.map +0 -1
- package/lib/typescript/hooks/useAssetScanStatus.d.ts.map +0 -1
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/preset.d.ts.map +0 -1
- package/lib/typescript/remote.d.ts.map +0 -1
- package/lib/typescript/state.d.ts.map +0 -1
- package/lib/typescript/store/assetStore.d.ts.map +0 -1
- package/lib/typescript/store/baseline.d.ts.map +0 -1
- package/lib/typescript/store/insights.d.ts.map +0 -1
- package/lib/typescript/sync/assetsSyncAdapter.d.ts.map +0 -1
- package/lib/typescript/types.d.ts.map +0 -1
- package/lib/typescript/utils/deviceScale.d.ts.map +0 -1
- package/lib/typescript/utils/testIDs.d.ts.map +0 -1
|
@@ -1,378 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.AssetsModal = AssetsModal;
|
|
7
|
-
exports.AssetsToolView = AssetsToolView;
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
var _reactNative = require("react-native");
|
|
10
|
-
var _sharedUi = require("@buoy-gg/shared-ui");
|
|
11
|
-
var _install = require("../capture/install");
|
|
12
|
-
var _export = require("../export");
|
|
13
|
-
var _useAssetRecords = require("../hooks/useAssetRecords");
|
|
14
|
-
var _useAssetScanStatus = require("../hooks/useAssetScanStatus");
|
|
15
|
-
var _remote = require("../remote");
|
|
16
|
-
var _assetStore = require("../store/assetStore");
|
|
17
|
-
var _baseline = require("../store/baseline");
|
|
18
|
-
var _AssetDetail = require("./AssetDetail");
|
|
19
|
-
var _AssetRow = require("./AssetRow");
|
|
20
|
-
var _AssetsFilterBar = require("./AssetsFilterBar");
|
|
21
|
-
var _AssetsHeader = require("./AssetsHeader");
|
|
22
|
-
var _AssetsListControls = require("./AssetsListControls");
|
|
23
|
-
var _ScanNotice = require("./ScanNotice");
|
|
24
|
-
var _testIDs = require("../utils/testIDs");
|
|
25
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
26
|
-
/**
|
|
27
|
-
* AssetsModal — bottom-sheet wrapper rendered by FloatingDevTools when the
|
|
28
|
-
* Assets tool is opened. Inventory list (largest first) → tap for detail.
|
|
29
|
-
* Opening triggers a full rescan (registry walk + Metro graph + size
|
|
30
|
-
* measurement); merely installing the package never hits the network.
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
function FontFamilies({
|
|
34
|
-
names
|
|
35
|
-
}) {
|
|
36
|
-
const families = [...new Set(names)];
|
|
37
|
-
if (!families.length) return null;
|
|
38
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
39
|
-
style: styles.fontsBox,
|
|
40
|
-
testID: _testIDs.ASSETS_TEST_IDS.fonts,
|
|
41
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, {
|
|
42
|
-
style: styles.fontsTitle,
|
|
43
|
-
testID: _testIDs.ASSETS_TEST_IDS.fontsTitle,
|
|
44
|
-
children: ["LOADED FONT FAMILIES (", families.length, ")"]
|
|
45
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
46
|
-
style: styles.fontsWrap,
|
|
47
|
-
children: families.map(family => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
48
|
-
style: styles.fontChip,
|
|
49
|
-
testID: (0, _testIDs.assetFontChipTestID)(family),
|
|
50
|
-
children: family
|
|
51
|
-
}, family))
|
|
52
|
-
})]
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
function EmptyState({
|
|
56
|
-
duplicates = false
|
|
57
|
-
}) {
|
|
58
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.ToolEmptyState, {
|
|
59
|
-
testID: _testIDs.ASSETS_TEST_IDS.empty
|
|
60
|
-
// scanning: a scan ran and found nothing — the copy says "try Rescan".
|
|
61
|
-
,
|
|
62
|
-
otto: "scanning",
|
|
63
|
-
title: duplicates ? "No duplicates found" : "No assets found yet",
|
|
64
|
-
message: duplicates ? "No assets in this view share a content hash." : "Every bundled asset — images, fonts, video, audio — appears here with sizes, scale coverage, and runtime registration status. Try Rescan after navigating around the app."
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/** Largest first — measured bytes, falling back to decoded estimate. */
|
|
69
|
-
function bySizeDesc(a, b) {
|
|
70
|
-
return (b.sizeBytes ?? (0, _assetStore.estDecodedBytes)(b)) - (a.sizeBytes ?? (0, _assetStore.estDecodedBytes)(a));
|
|
71
|
-
}
|
|
72
|
-
const COMPARATORS = {
|
|
73
|
-
size: bySizeDesc,
|
|
74
|
-
name: (a, b) => a.name.localeCompare(b.name) || a.type.localeCompare(b.type),
|
|
75
|
-
type: (a, b) => a.type.localeCompare(b.type) || bySizeDesc(a, b)
|
|
76
|
-
};
|
|
77
|
-
function AssetsModal({
|
|
78
|
-
visible,
|
|
79
|
-
onClose,
|
|
80
|
-
onBack,
|
|
81
|
-
onMinimize,
|
|
82
|
-
persistenceKey,
|
|
83
|
-
inline = false
|
|
84
|
-
}) {
|
|
85
|
-
// Safety net: the index import normally installed this already.
|
|
86
|
-
(0, _install.installAssetCapture)();
|
|
87
|
-
const {
|
|
88
|
-
records,
|
|
89
|
-
stats,
|
|
90
|
-
insights
|
|
91
|
-
} = (0, _useAssetRecords.useAssetRecords)();
|
|
92
|
-
const status = (0, _useAssetScanStatus.useAssetScanStatus)();
|
|
93
|
-
const [remoteError, setRemoteError] = (0, _react.useState)(false);
|
|
94
|
-
(0, _react.useEffect)(() => {
|
|
95
|
-
setRemoteError(false);
|
|
96
|
-
}, [status.graphFetchInFlight, status.lastScanAt]);
|
|
97
|
-
const retry = () => {
|
|
98
|
-
setRemoteError(false);
|
|
99
|
-
const remote = (0, _remote.remoteAssetsDispatch)();
|
|
100
|
-
if (remote) void remote("rescan").catch(() => setRemoteError(true));else void (0, _install.rescan)();
|
|
101
|
-
};
|
|
102
|
-
const [selectedId, setSelectedId] = (0, _react.useState)(null);
|
|
103
|
-
const [filter, setFilter] = (0, _react.useState)("all");
|
|
104
|
-
const [query, setQuery] = (0, _react.useState)("");
|
|
105
|
-
const [sort, setSort] = (0, _react.useState)("size");
|
|
106
|
-
const selected = selectedId != null ? (0, _assetStore.getRecord)(selectedId) : undefined;
|
|
107
|
-
|
|
108
|
-
// Full scan on open — locally on device, forwarded on dashboard mirrors.
|
|
109
|
-
// The baseline load is async and re-renders through the store emit.
|
|
110
|
-
(0, _react.useEffect)(() => {
|
|
111
|
-
if (!visible) return;
|
|
112
|
-
void (0, _baseline.loadBaseline)();
|
|
113
|
-
setRemoteError(false);
|
|
114
|
-
const remote = (0, _remote.remoteAssetsDispatch)();
|
|
115
|
-
if (remote) {
|
|
116
|
-
remote("rescan").catch(() => setRemoteError(true));
|
|
117
|
-
} else {
|
|
118
|
-
void (0, _install.rescan)();
|
|
119
|
-
}
|
|
120
|
-
}, [visible]);
|
|
121
|
-
const duplicateIds = new Set(insights.duplicates.flatMap(group => group.ids));
|
|
122
|
-
const sorted = [...records].sort(COMPARATORS[sort]);
|
|
123
|
-
const trimmedQuery = query.trim().toLowerCase();
|
|
124
|
-
const filtered = sorted.filter(r => {
|
|
125
|
-
if (filter === "unused" && r.loaded) return false;
|
|
126
|
-
if (filter === "duplicates" && !duplicateIds.has(r.id)) return false;
|
|
127
|
-
if (filter !== "all" && filter !== "unused" && filter !== "duplicates" && r.kind !== filter) return false;
|
|
128
|
-
if (trimmedQuery && !`${r.name}.${r.type}`.toLowerCase().includes(trimmedQuery)) {
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
|
-
return true;
|
|
132
|
-
});
|
|
133
|
-
const selectedIndex = selected ? filtered.findIndex(r => r.id === selected.id) : -1;
|
|
134
|
-
const stepTo = index => {
|
|
135
|
-
const target = filtered[index];
|
|
136
|
-
if (target) setSelectedId(target.id);
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
// Set lookups so each row's badge checks are O(1).
|
|
140
|
-
const flagSets = {
|
|
141
|
-
scaleGaps: new Set(insights.scaleGaps),
|
|
142
|
-
scaleAnomalies: new Set(insights.scaleAnomalies),
|
|
143
|
-
duplicates: duplicateIds,
|
|
144
|
-
webpCandidates: new Set(insights.webpCandidates),
|
|
145
|
-
overDecode: new Set(insights.overDecode),
|
|
146
|
-
heavy: new Set([...insights.heavyGifs, ...insights.heavyFonts])
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
// The proportional size bar is relative to the largest asset in view.
|
|
150
|
-
let maxBytes = 0;
|
|
151
|
-
for (const r of filtered) {
|
|
152
|
-
const bytes = r.sizeBytes ?? (0, _assetStore.estDecodedBytes)(r);
|
|
153
|
-
if (bytes > maxBytes) maxBytes = bytes;
|
|
154
|
-
}
|
|
155
|
-
const getReport = () => selected ? (0, _export.formatAssetMarkdown)(selected) : (0, _export.formatInventoryMarkdown)(sorted, stats, insights, (0, _install.getScanStatus)(), (0, _baseline.getDiff)());
|
|
156
|
-
const headerContent = /*#__PURE__*/(0, _jsxRuntime.jsx)(_AssetsHeader.AssetsHeader, {
|
|
157
|
-
stats: stats,
|
|
158
|
-
measuring: status.measuring,
|
|
159
|
-
discovering: status.graphFetchInFlight,
|
|
160
|
-
detailOpen: selected != null,
|
|
161
|
-
detailIndex: selectedIndex,
|
|
162
|
-
detailTotal: filtered.length,
|
|
163
|
-
onCloseDetail: () => setSelectedId(null),
|
|
164
|
-
onClear: _assetStore.clearRecords,
|
|
165
|
-
getReport: getReport,
|
|
166
|
-
onBack: onBack
|
|
167
|
-
});
|
|
168
|
-
const body = selected ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
169
|
-
style: styles.detailContainer,
|
|
170
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_AssetDetail.AssetDetail, {
|
|
171
|
-
record: selected,
|
|
172
|
-
insights: insights
|
|
173
|
-
}), selectedIndex >= 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.EventStepperFooter, {
|
|
174
|
-
currentIndex: selectedIndex,
|
|
175
|
-
totalItems: filtered.length,
|
|
176
|
-
itemLabel: "Asset",
|
|
177
|
-
onPrevious: () => stepTo(selectedIndex - 1),
|
|
178
|
-
onNext: () => stepTo(selectedIndex + 1)
|
|
179
|
-
}) : null]
|
|
180
|
-
}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
181
|
-
style: styles.listContainer,
|
|
182
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_AssetsFilterBar.AssetsFilterBar, {
|
|
183
|
-
stats: stats,
|
|
184
|
-
duplicateCount: duplicateIds.size,
|
|
185
|
-
filter: filter,
|
|
186
|
-
onChange: next => {
|
|
187
|
-
setFilter(next);
|
|
188
|
-
if (next === "duplicates") setQuery("");
|
|
189
|
-
}
|
|
190
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_AssetsListControls.AssetsListControls, {
|
|
191
|
-
query: query,
|
|
192
|
-
onQueryChange: setQuery,
|
|
193
|
-
sort: sort,
|
|
194
|
-
onSortChange: setSort
|
|
195
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScanNotice.ScanNotice, {
|
|
196
|
-
status: status,
|
|
197
|
-
total: stats.total,
|
|
198
|
-
onRetry: retry
|
|
199
|
-
}), remoteError && !status.graphFetchInFlight ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
200
|
-
style: styles.notice,
|
|
201
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
202
|
-
style: styles.noticeText,
|
|
203
|
-
children: "Couldn't request an asset scan from the device."
|
|
204
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
|
205
|
-
accessibilityRole: "button",
|
|
206
|
-
onPress: retry,
|
|
207
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
208
|
-
style: styles.retryText,
|
|
209
|
-
children: "Retry"
|
|
210
|
-
})
|
|
211
|
-
})]
|
|
212
|
-
}) : null, filter === "unused" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
213
|
-
style: styles.notice,
|
|
214
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
215
|
-
style: styles.noticeText,
|
|
216
|
-
children: "Not seen in React Native's asset registry this app run. Assets loaded through other paths may appear here; this does not prove they are unused."
|
|
217
|
-
})
|
|
218
|
-
}) : null, filter === "font" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(FontFamilies, {
|
|
219
|
-
names: status.fontFamilies
|
|
220
|
-
}) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.FlatList, {
|
|
221
|
-
testID: _testIDs.ASSETS_TEST_IDS.list,
|
|
222
|
-
data: filtered,
|
|
223
|
-
keyExtractor: item => String(item.id),
|
|
224
|
-
contentContainerStyle: styles.listContent,
|
|
225
|
-
renderItem: ({
|
|
226
|
-
item
|
|
227
|
-
}) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_AssetRow.AssetRow, {
|
|
228
|
-
record: item,
|
|
229
|
-
flags: {
|
|
230
|
-
scaleGap: flagSets.scaleGaps.has(item.id),
|
|
231
|
-
scaleAnomaly: flagSets.scaleAnomalies.has(item.id),
|
|
232
|
-
duplicate: flagSets.duplicates.has(item.id),
|
|
233
|
-
webp: flagSets.webpCandidates.has(item.id),
|
|
234
|
-
oversize: flagSets.overDecode.has(item.id),
|
|
235
|
-
heavy: flagSets.heavy.has(item.id)
|
|
236
|
-
},
|
|
237
|
-
sizeFraction: maxBytes > 0 ? (item.sizeBytes ?? (0, _assetStore.estDecodedBytes)(item)) / maxBytes : 0
|
|
238
|
-
// Guarded: programmatic invocations (automation) can call this
|
|
239
|
-
// with an event object instead of an id.
|
|
240
|
-
,
|
|
241
|
-
onPress: id => setSelectedId(typeof id === "number" ? id : null)
|
|
242
|
-
}),
|
|
243
|
-
ListEmptyComponent: status.graphFetchInFlight ? null : /*#__PURE__*/(0, _jsxRuntime.jsx)(EmptyState, {
|
|
244
|
-
duplicates: filter === "duplicates"
|
|
245
|
-
})
|
|
246
|
-
})]
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
// The ONLY difference between phone and desktop is which shell the header
|
|
250
|
-
// and body go in (same pattern as ImagesModal).
|
|
251
|
-
if (inline) {
|
|
252
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
253
|
-
style: styles.inlineRoot,
|
|
254
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
255
|
-
style: styles.inlineHeader,
|
|
256
|
-
..._sharedUi.windowDragProps,
|
|
257
|
-
children: headerContent
|
|
258
|
-
}), body]
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.JsModal, {
|
|
262
|
-
visible: visible,
|
|
263
|
-
onClose: onClose,
|
|
264
|
-
onMinimize: onMinimize,
|
|
265
|
-
persistenceKey: persistenceKey,
|
|
266
|
-
header: {
|
|
267
|
-
showToggleButton: true,
|
|
268
|
-
customContent: headerContent
|
|
269
|
-
},
|
|
270
|
-
enablePersistence: true,
|
|
271
|
-
initialMode: "bottomSheet",
|
|
272
|
-
disableScrollWrapper: true,
|
|
273
|
-
children: body
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* The same Assets tool rendered INLINE for hosts that place tools in a panel
|
|
279
|
-
* rather than a modal (the desktop dashboard). One implementation only.
|
|
280
|
-
*/
|
|
281
|
-
function AssetsToolView(props = {}) {
|
|
282
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(AssetsModal, {
|
|
283
|
-
...props,
|
|
284
|
-
inline: true,
|
|
285
|
-
visible: true,
|
|
286
|
-
onClose: () => {}
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
const styles = _reactNative.StyleSheet.create({
|
|
290
|
-
inlineRoot: {
|
|
291
|
-
flex: 1,
|
|
292
|
-
minHeight: 0,
|
|
293
|
-
// Transparent so the desktop workbench's hoisted sky (one field spanning
|
|
294
|
-
// sidebar + panel) shows through — the shell paints its base beneath it.
|
|
295
|
-
backgroundColor: "transparent"
|
|
296
|
-
},
|
|
297
|
-
inlineHeader: {
|
|
298
|
-
paddingHorizontal: 12,
|
|
299
|
-
paddingVertical: 8,
|
|
300
|
-
borderBottomWidth: 1,
|
|
301
|
-
borderBottomColor: _sharedUi.macOSColors.border.default,
|
|
302
|
-
// Clear, like Bench — the host's hoisted sky shows through the header.
|
|
303
|
-
backgroundColor: "transparent"
|
|
304
|
-
},
|
|
305
|
-
listContainer: {
|
|
306
|
-
flex: 1
|
|
307
|
-
},
|
|
308
|
-
listContent: {
|
|
309
|
-
paddingBottom: 16
|
|
310
|
-
},
|
|
311
|
-
detailContainer: {
|
|
312
|
-
flex: 1
|
|
313
|
-
},
|
|
314
|
-
notice: {
|
|
315
|
-
marginHorizontal: 10,
|
|
316
|
-
marginBottom: 8,
|
|
317
|
-
padding: 10,
|
|
318
|
-
borderRadius: 8,
|
|
319
|
-
borderWidth: 1,
|
|
320
|
-
borderColor: _sharedUi.night.color.border,
|
|
321
|
-
backgroundColor: _sharedUi.night.color.surface,
|
|
322
|
-
gap: 4
|
|
323
|
-
},
|
|
324
|
-
noticeText: {
|
|
325
|
-
color: _sharedUi.night.color.textSecondary,
|
|
326
|
-
fontSize: 11
|
|
327
|
-
},
|
|
328
|
-
retryText: {
|
|
329
|
-
color: _sharedUi.night.color.text,
|
|
330
|
-
fontSize: 12,
|
|
331
|
-
paddingVertical: 6
|
|
332
|
-
},
|
|
333
|
-
fontsBox: {
|
|
334
|
-
marginHorizontal: 10,
|
|
335
|
-
marginTop: 8,
|
|
336
|
-
padding: 10,
|
|
337
|
-
borderRadius: 8,
|
|
338
|
-
backgroundColor: _sharedUi.night.color.surface,
|
|
339
|
-
gap: 6
|
|
340
|
-
},
|
|
341
|
-
fontsTitle: {
|
|
342
|
-
color: _sharedUi.night.color.textTertiary,
|
|
343
|
-
fontSize: 9,
|
|
344
|
-
fontWeight: "700",
|
|
345
|
-
letterSpacing: 0.5
|
|
346
|
-
},
|
|
347
|
-
fontsWrap: {
|
|
348
|
-
flexDirection: "row",
|
|
349
|
-
flexWrap: "wrap",
|
|
350
|
-
gap: 6
|
|
351
|
-
},
|
|
352
|
-
fontChip: {
|
|
353
|
-
color: _sharedUi.night.color.textSecondary,
|
|
354
|
-
fontSize: 10,
|
|
355
|
-
backgroundColor: _sharedUi.night.color.bg,
|
|
356
|
-
borderRadius: 999,
|
|
357
|
-
paddingHorizontal: 8,
|
|
358
|
-
paddingVertical: 3,
|
|
359
|
-
overflow: "hidden"
|
|
360
|
-
},
|
|
361
|
-
empty: {
|
|
362
|
-
alignItems: "center",
|
|
363
|
-
padding: 32,
|
|
364
|
-
gap: 8
|
|
365
|
-
},
|
|
366
|
-
emptyTitle: {
|
|
367
|
-
color: _sharedUi.night.color.text,
|
|
368
|
-
fontSize: 13,
|
|
369
|
-
fontWeight: "600"
|
|
370
|
-
},
|
|
371
|
-
emptyText: {
|
|
372
|
-
color: _sharedUi.night.color.textSecondary,
|
|
373
|
-
fontSize: 11,
|
|
374
|
-
textAlign: "center",
|
|
375
|
-
lineHeight: 16
|
|
376
|
-
}
|
|
377
|
-
});
|
|
378
|
-
//# sourceMappingURL=AssetsModal.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.AssetsModal=AssetsModal;exports.AssetsToolView=AssetsToolView;var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _install=require("../capture/install");var _export=require("../export");var _useAssetRecords=require("../hooks/useAssetRecords");var _useAssetScanStatus=require("../hooks/useAssetScanStatus");var _remote=require("../remote");var _assetStore=require("../store/assetStore");var _baseline=require("../store/baseline");var _AssetDetail=require("./AssetDetail");var _AssetRow=require("./AssetRow");var _AssetsFilterBar=require("./AssetsFilterBar");var _AssetsHeader=require("./AssetsHeader");var _AssetsListControls=require("./AssetsListControls");var _ScanNotice=require("./ScanNotice");var _testIDs=require("../utils/testIDs");var _jsxRuntime=require("react/jsx-runtime");function FontFamilies({names:t}){const s=[...new Set(t)];if(!s.length)return null;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.fontsBox,testID:_testIDs.ASSETS_TEST_IDS.fonts,children:[(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.fontsTitle,testID:_testIDs.ASSETS_TEST_IDS.fontsTitle,children:["LOADED FONT FAMILIES (",s.length,")"]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.fontsWrap,children:s.map(d=>(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.fontChip,testID:(0,_testIDs.assetFontChipTestID)(d),children:d},d))})]})}function EmptyState({duplicates:t=false}){return(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{testID:_testIDs.ASSETS_TEST_IDS.empty,otto:"scanning",title:t?"No duplicates found":"No assets found yet",message:t?"No assets in this view share a content hash.":"Every bundled asset \u2014 images, fonts, video, audio \u2014 appears here with sizes, scale coverage, and runtime registration status. Try Rescan after navigating around the app."})}function bySizeDesc(t,s){return(s.sizeBytes??(0,_assetStore.estDecodedBytes)(s))-(t.sizeBytes??(0,_assetStore.estDecodedBytes)(t))}const COMPARATORS={size:bySizeDesc,name:(t,s)=>t.name.localeCompare(s.name)||t.type.localeCompare(s.type),type:(t,s)=>t.type.localeCompare(s.type)||bySizeDesc(t,s)};function AssetsModal({visible:t,onClose:s,onBack:d,onMinimize:j,persistenceKey:I,inline:_=false}){(0,_install.installAssetCapture)();const{records:R,stats:p,insights:o}=(0,_useAssetRecords.useAssetRecords)();const n=(0,_useAssetScanStatus.useAssetScanStatus)();const[z,u]=(0,_react.useState)(false);(0,_react.useEffect)(()=>{u(false)},[n.graphFetchInFlight,n.lastScanAt]);const S=()=>{u(false);const e=(0,_remote.remoteAssetsDispatch)();if(e)void e("rescan").catch(()=>u(true));else void(0,_install.rescan)()};const[x,f]=(0,_react.useState)(null);const[r,F]=(0,_react.useState)("all");const[m,v]=(0,_react.useState)("");const[A,q]=(0,_react.useState)("size");const i=x!=null?(0,_assetStore.getRecord)(x):void 0;(0,_react.useEffect)(()=>{if(!t)return;void(0,_baseline.loadBaseline)();u(false);const e=(0,_remote.remoteAssetsDispatch)();if(e){e("rescan").catch(()=>u(true))}else{void(0,_install.rescan)()}},[t]);const y=new Set(o.duplicates.flatMap(e=>e.ids));const C=[...R].sort(COMPARATORS[A]);const T=m.trim().toLowerCase();const l=C.filter(e=>{if(r==="unused"&&e.loaded)return false;if(r==="duplicates"&&!y.has(e.id))return false;if(r!=="all"&&r!=="unused"&&r!=="duplicates"&&e.kind!==r)return false;if(T&&!`${e.name}.${e.type}`.toLowerCase().includes(T)){return false}return true});const h=i?l.findIndex(e=>e.id===i.id):-1;const w=e=>{const a=l[e];if(a)f(a.id)};const c={scaleGaps:new Set(o.scaleGaps),scaleAnomalies:new Set(o.scaleAnomalies),duplicates:y,webpCandidates:new Set(o.webpCandidates),overDecode:new Set(o.overDecode),heavy:new Set([...o.heavyGifs,...o.heavyFonts])};let g=0;for(const e of l){const a=e.sizeBytes??(0,_assetStore.estDecodedBytes)(e);if(a>g)g=a}const B=()=>i?(0,_export.formatAssetMarkdown)(i):(0,_export.formatInventoryMarkdown)(C,p,o,(0,_install.getScanStatus)(),(0,_baseline.getDiff)());const b=(0,_jsxRuntime.jsx)(_AssetsHeader.AssetsHeader,{stats:p,measuring:n.measuring,discovering:n.graphFetchInFlight,detailOpen:i!=null,detailIndex:h,detailTotal:l.length,onCloseDetail:()=>f(null),onClear:_assetStore.clearRecords,getReport:B,onBack:d});const D=i?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.detailContainer,children:[(0,_jsxRuntime.jsx)(_AssetDetail.AssetDetail,{record:i,insights:o}),h>=0?(0,_jsxRuntime.jsx)(_sharedUi.EventStepperFooter,{currentIndex:h,totalItems:l.length,itemLabel:"Asset",onPrevious:()=>w(h-1),onNext:()=>w(h+1)}):null]}):(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.listContainer,children:[(0,_jsxRuntime.jsx)(_AssetsFilterBar.AssetsFilterBar,{stats:p,duplicateCount:y.size,filter:r,onChange:e=>{F(e);if(e==="duplicates")v("")}}),(0,_jsxRuntime.jsx)(_AssetsListControls.AssetsListControls,{query:m,onQueryChange:v,sort:A,onSortChange:q}),(0,_jsxRuntime.jsx)(_ScanNotice.ScanNotice,{status:n,total:p.total,onRetry:S}),z&&!n.graphFetchInFlight?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.notice,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.noticeText,children:"Couldn't request an asset scan from the device."}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{accessibilityRole:"button",onPress:S,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.retryText,children:"Retry"})})]}):null,r==="unused"?(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.notice,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.noticeText,children:"Not seen in React Native's asset registry this app run. Assets loaded through other paths may appear here; this does not prove they are unused."})}):null,r==="font"?(0,_jsxRuntime.jsx)(FontFamilies,{names:n.fontFamilies}):null,(0,_jsxRuntime.jsx)(_reactNative.FlatList,{testID:_testIDs.ASSETS_TEST_IDS.list,data:l,keyExtractor:e=>String(e.id),contentContainerStyle:styles.listContent,renderItem:({item:e})=>(0,_jsxRuntime.jsx)(_AssetRow.AssetRow,{record:e,flags:{scaleGap:c.scaleGaps.has(e.id),scaleAnomaly:c.scaleAnomalies.has(e.id),duplicate:c.duplicates.has(e.id),webp:c.webpCandidates.has(e.id),oversize:c.overDecode.has(e.id),heavy:c.heavy.has(e.id)},sizeFraction:g>0?(e.sizeBytes??(0,_assetStore.estDecodedBytes)(e))/g:0,onPress:a=>f(typeof a==="number"?a:null)}),ListEmptyComponent:n.graphFetchInFlight?null:(0,_jsxRuntime.jsx)(EmptyState,{duplicates:r==="duplicates"})})]});if(_){return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.inlineRoot,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.inlineHeader,..._sharedUi.windowDragProps,children:b}),D]})}return(0,_jsxRuntime.jsx)(_sharedUi.JsModal,{visible:t,onClose:s,onMinimize:j,persistenceKey:I,header:{showToggleButton:true,customContent:b},enablePersistence:true,initialMode:"bottomSheet",disableScrollWrapper:true,children:D})}function AssetsToolView(t={}){return(0,_jsxRuntime.jsx)(AssetsModal,{...t,inline:true,visible:true,onClose:()=>{}})}const styles=_reactNative.StyleSheet.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:_sharedUi.macOSColors.border.default,backgroundColor:"transparent"},listContainer:{flex:1},listContent:{paddingBottom:16},detailContainer:{flex:1},notice:{marginHorizontal:10,marginBottom:8,padding:10,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.border,backgroundColor:_sharedUi.night.color.surface,gap:4},noticeText:{color:_sharedUi.night.color.textSecondary,fontSize:11},retryText:{color:_sharedUi.night.color.text,fontSize:12,paddingVertical:6},fontsBox:{marginHorizontal:10,marginTop:8,padding:10,borderRadius:8,backgroundColor:_sharedUi.night.color.surface,gap:6},fontsTitle:{color:_sharedUi.night.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5},fontsWrap:{flexDirection:"row",flexWrap:"wrap",gap:6},fontChip:{color:_sharedUi.night.color.textSecondary,fontSize:10,backgroundColor:_sharedUi.night.color.bg,borderRadius:999,paddingHorizontal:8,paddingVertical:3,overflow:"hidden"},empty:{alignItems:"center",padding:32,gap:8},emptyTitle:{color:_sharedUi.night.color.text,fontSize:13,fontWeight:"600"},emptyText:{color:_sharedUi.night.color.textSecondary,fontSize:11,textAlign:"center",lineHeight:16}});
|
|
@@ -1,85 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ScanNotice = ScanNotice;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _reactNative = require("react-native");
|
|
9
|
-
var _sharedUi = require("@buoy-gg/shared-ui");
|
|
10
|
-
var _testIDs = require("../utils/testIDs");
|
|
11
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
-
function ScanNotice({
|
|
13
|
-
status,
|
|
14
|
-
total,
|
|
15
|
-
onRetry
|
|
16
|
-
}) {
|
|
17
|
-
const [slow, setSlow] = (0, _react.useState)(false);
|
|
18
|
-
(0, _react.useEffect)(() => {
|
|
19
|
-
setSlow(false);
|
|
20
|
-
if (!status.graphFetchInFlight) return;
|
|
21
|
-
// Start locally for older snapshots that omit the device timestamp.
|
|
22
|
-
const elapsed = status.graphFetchStartedAt == null ? 0 : Math.max(0, Date.now() - status.graphFetchStartedAt);
|
|
23
|
-
const timer = setTimeout(() => setSlow(true), Math.max(0, 8_000 - elapsed));
|
|
24
|
-
return () => clearTimeout(timer);
|
|
25
|
-
}, [status.graphFetchInFlight, status.graphFetchStartedAt]);
|
|
26
|
-
const notices = [];
|
|
27
|
-
if (status.graphFetchInFlight) {
|
|
28
|
-
notices.push(`Finding assets… ${total} found so far.`);
|
|
29
|
-
if (slow) notices.push("Still finding assets. This is taking longer than usual.");
|
|
30
|
-
}
|
|
31
|
-
if (!status.registryAvailable) {
|
|
32
|
-
notices.push("The asset registry is unavailable in this environment.");
|
|
33
|
-
}
|
|
34
|
-
if (!status.graphFetchInFlight && !status.graphSupported && status.graphError) {
|
|
35
|
-
notices.push("Showing runtime-registered assets only. A development server is needed to find more assets and measure their sizes.");
|
|
36
|
-
}
|
|
37
|
-
const failed = !status.graphFetchInFlight && status.graphSupported && !!status.graphError;
|
|
38
|
-
if (failed) notices.push(`Couldn't finish finding assets. Showing ${total} assets found so far.`);
|
|
39
|
-
if (status.measuring && !status.graphFetchInFlight) notices.push("Checking asset sizes…");
|
|
40
|
-
if (notices.length === 0) return null;
|
|
41
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
42
|
-
style: styles.notice,
|
|
43
|
-
testID: _testIDs.ASSETS_TEST_IDS.notice,
|
|
44
|
-
children: [status.graphFetchInFlight ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
|
|
45
|
-
size: "small",
|
|
46
|
-
color: _sharedUi.night.color.textSecondary,
|
|
47
|
-
accessibilityLabel: "Finding assets",
|
|
48
|
-
testID: _testIDs.ASSETS_TEST_IDS.discoverySpinner
|
|
49
|
-
}) : null, notices.map(n => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
50
|
-
style: styles.noticeText,
|
|
51
|
-
testID: _testIDs.ASSETS_TEST_IDS.noticeText,
|
|
52
|
-
children: n
|
|
53
|
-
}, n)), failed ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
|
54
|
-
accessibilityRole: "button",
|
|
55
|
-
onPress: onRetry,
|
|
56
|
-
testID: _testIDs.ASSETS_TEST_IDS.retry,
|
|
57
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
58
|
-
style: styles.retryText,
|
|
59
|
-
children: "Retry"
|
|
60
|
-
})
|
|
61
|
-
}) : null]
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
const styles = _reactNative.StyleSheet.create({
|
|
65
|
-
notice: {
|
|
66
|
-
marginHorizontal: 10,
|
|
67
|
-
marginBottom: 8,
|
|
68
|
-
padding: 10,
|
|
69
|
-
borderRadius: 8,
|
|
70
|
-
borderWidth: 1,
|
|
71
|
-
borderColor: _sharedUi.night.color.border,
|
|
72
|
-
backgroundColor: _sharedUi.night.color.surface,
|
|
73
|
-
gap: 4
|
|
74
|
-
},
|
|
75
|
-
noticeText: {
|
|
76
|
-
color: _sharedUi.night.color.textSecondary,
|
|
77
|
-
fontSize: 11
|
|
78
|
-
},
|
|
79
|
-
retryText: {
|
|
80
|
-
color: _sharedUi.night.color.text,
|
|
81
|
-
fontSize: 12,
|
|
82
|
-
paddingVertical: 6
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
//# sourceMappingURL=ScanNotice.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ScanNotice=ScanNotice;var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _testIDs=require("../utils/testIDs");var _jsxRuntime=require("react/jsx-runtime");function ScanNotice({status:e,total:i,onRetry:s}){const[a,n]=(0,_react.useState)(false);(0,_react.useEffect)(()=>{n(false);if(!e.graphFetchInFlight)return;const t=e.graphFetchStartedAt==null?0:Math.max(0,Date.now()-e.graphFetchStartedAt);const h=setTimeout(()=>n(true),Math.max(0,8e3-t));return()=>clearTimeout(h)},[e.graphFetchInFlight,e.graphFetchStartedAt]);const r=[];if(e.browser&&!e.graphSupported)r.push("Showing resources this page has loaded. Add an asset manifest to include files the page has not requested.");if(e.graphFetchInFlight){r.push(`Finding assets\u2026 ${i} found so far.`);if(a)r.push("Still finding assets. This is taking longer than usual.")}if(!e.registryAvailable){r.push("The asset registry is unavailable in this environment.")}if(!e.graphFetchInFlight&&!e.graphSupported&&e.graphError){r.push("Showing runtime-registered assets only. A development server is needed to find more assets and measure their sizes.")}const o=!e.graphFetchInFlight&&e.graphSupported&&!!e.graphError;if(o)r.push(`Couldn't finish finding assets. Showing ${i} assets found so far.`);if(e.measuring&&!e.graphFetchInFlight)r.push("Checking asset sizes\u2026");if(r.length===0)return null;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.notice,testID:_testIDs.ASSETS_TEST_IDS.notice,children:[e.graphFetchInFlight?(0,_jsxRuntime.jsx)(_reactNative.ActivityIndicator,{size:"small",color:_sharedUi.night.color.textSecondary,accessibilityLabel:"Finding assets",testID:_testIDs.ASSETS_TEST_IDS.discoverySpinner}):null,r.map(t=>(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.noticeText,testID:_testIDs.ASSETS_TEST_IDS.noticeText,children:t},t)),o?(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{accessibilityRole:"button",onPress:s,testID:_testIDs.ASSETS_TEST_IDS.retry,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.retryText,children:"Retry"})}):null]})}const styles=_reactNative.StyleSheet.create({notice:{marginHorizontal:10,marginBottom:8,padding:10,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.border,backgroundColor:_sharedUi.night.color.surface,gap:4},noticeText:{color:_sharedUi.night.color.textSecondary,fontSize:11},retryText:{color:_sharedUi.night.color.text,fontSize:12,paddingVertical:6}});
|
|
@@ -1,16 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getExpoPreviewImage = getExpoPreviewImage;
|
|
7
|
-
let ExpoImage = null;
|
|
8
|
-
try {
|
|
9
|
-
ExpoImage = require("expo-image").Image ?? null;
|
|
10
|
-
} catch {
|
|
11
|
-
// Optional peer: the package or its native module may be unavailable.
|
|
12
|
-
}
|
|
13
|
-
function getExpoPreviewImage() {
|
|
14
|
-
return ExpoImage;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=optionalExpoImage.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getExpoPreviewImage=getExpoPreviewImage;let ExpoImage=null;try{ExpoImage=require("expo-image").Image??null}catch{}function getExpoPreviewImage(){return ExpoImage}
|
|
@@ -1,11 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getExpoPreviewImage = getExpoPreviewImage;
|
|
7
|
-
/** Browser image elements already support SVG. */
|
|
8
|
-
function getExpoPreviewImage() {
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=optionalExpoImage.web.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getExpoPreviewImage=getExpoPreviewImage;function getExpoPreviewImage(){return null}
|
package/lib/commonjs/export.js
CHANGED
|
@@ -1,62 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.formatAssetMarkdown = formatAssetMarkdown;
|
|
7
|
-
exports.formatInventoryMarkdown = formatInventoryMarkdown;
|
|
8
|
-
var _format = require("./format");
|
|
9
|
-
var _assetStore = require("./store/assetStore");
|
|
10
|
-
/**
|
|
11
|
-
* Markdown reports for the shared ToolbarCopyButton — the paste-into-your-
|
|
12
|
-
* issue-tracker view of the inventory.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
function formatAssetMarkdown(record) {
|
|
16
|
-
const lines = [`# Asset: ${record.name}.${record.type}`, "", `- Kind: ${record.kind}`, `- Status: ${record.loaded ? "loaded at runtime" : "not observed in the runtime registry"}`];
|
|
17
|
-
if (record.kind === "image") lines.push(`- Dimensions: ${(0, _format.formatDimensions)(record)} (logical)`);
|
|
18
|
-
if (record.scales.length) lines.push(`- Scales: ${(0, _format.formatScales)(record.scales)}`);
|
|
19
|
-
if (record.sizeBytes != null && record.sizeSource === "measured") {
|
|
20
|
-
lines.push(`- Size (all variants): ${(0, _format.formatBytes)(record.sizeBytes)}`);
|
|
21
|
-
}
|
|
22
|
-
const estimate = (0, _assetStore.estDecodedBytes)(record);
|
|
23
|
-
if (estimate > 0) lines.push(`- Decoded memory: ~${(0, _format.formatBytes)(estimate)}`);
|
|
24
|
-
if (record.hash) lines.push(`- Hash: ${record.hash}`);
|
|
25
|
-
if (record.httpServerLocation) lines.push(`- Location: ${record.httpServerLocation}`);
|
|
26
|
-
if (record.fileSystemLocation) lines.push(`- Source dir: ${record.fileSystemLocation}`);
|
|
27
|
-
if (record.resolvedUri) lines.push(`- Resolved URI: ${record.resolvedUri}`);
|
|
28
|
-
return lines.join("\n");
|
|
29
|
-
}
|
|
30
|
-
function formatInventoryMarkdown(records, stats, insights, scanStatus, diff) {
|
|
31
|
-
const lines = ["# Asset inventory", "", `${stats.total} assets · ${stats.loaded} loaded · ${stats.neverLoaded} not observed` + (stats.totalBytes > 0 ? ` · ${(0, _format.formatBytes)(stats.totalBytes)} measured (${stats.measuredCount}/${stats.total})` : "")];
|
|
32
|
-
if (scanStatus.fontFamilies.length) {
|
|
33
|
-
lines.push(`Fonts loaded: ${scanStatus.fontFamilies.join(", ")}`);
|
|
34
|
-
}
|
|
35
|
-
if (!scanStatus.graphSupported) {
|
|
36
|
-
lines.push(scanStatus.graphError ? `_Metro bundle graph unavailable (${scanStatus.graphError}) — runtime-registered assets only._` : "_No Metro bundle graph — runtime-registered assets only (release build)._");
|
|
37
|
-
}
|
|
38
|
-
if (diff) {
|
|
39
|
-
const net = diff.netBytes != null ? `${diff.netBytes >= 0 ? "+" : "−"}${(0, _format.formatBytes)(Math.abs(diff.netBytes))} net` : "net size unknown";
|
|
40
|
-
lines.push("", `## Since baseline (${new Date(diff.baselineSavedAt).toISOString()})`, `- ${diff.added.length} added · ${diff.removed.length} removed · ${diff.grown.length} grew · ${net}`);
|
|
41
|
-
for (const gone of diff.removed.slice(0, 20)) {
|
|
42
|
-
lines.push(`- removed: ${gone.name}.${gone.type}`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
const findings = [];
|
|
46
|
-
if (insights.neverLoaded.length) findings.push(`- ${insights.neverLoaded.length} shipped but not observed`);
|
|
47
|
-
if (insights.duplicates.length) findings.push(`- ${insights.duplicates.length} duplicate content groups`);
|
|
48
|
-
if (insights.webpCandidates.length) findings.push(`- ${insights.webpCandidates.length} WebP conversion candidates`);
|
|
49
|
-
if (insights.scaleGaps.length) findings.push(`- ${insights.scaleGaps.length} scale-coverage gaps`);
|
|
50
|
-
if (insights.overDecode.length) findings.push(`- ${insights.overDecode.length} images decoding larger than 2× the screen`);
|
|
51
|
-
if (insights.heavyGifs.length) findings.push(`- ${insights.heavyGifs.length} heavy GIFs (convert to video/Lottie)`);
|
|
52
|
-
if (insights.heavyFonts.length) findings.push(`- ${insights.heavyFonts.length} heavy fonts (subset candidates)`);
|
|
53
|
-
if (insights.scaleAnomalies.length) findings.push(`- ${insights.scaleAnomalies.length} scale-variant anomalies (check exports)`);
|
|
54
|
-
if (findings.length) lines.push("", "## Findings", ...findings);
|
|
55
|
-
lines.push("", "## Assets (largest first)", "", "| Asset | Kind | Dimensions | Scales | Size | Loaded |", "| --- | --- | --- | --- | --- | --- |");
|
|
56
|
-
for (const r of records) {
|
|
57
|
-
const size = r.sizeBytes != null && r.sizeSource === "measured" ? (0, _format.formatBytes)(r.sizeBytes) : (0, _assetStore.estDecodedBytes)(r) > 0 ? `~${(0, _format.formatBytes)((0, _assetStore.estDecodedBytes)(r))}` : "—";
|
|
58
|
-
lines.push(`| ${r.name}.${r.type} | ${r.kind} | ${r.kind === "image" ? (0, _format.formatDimensions)(r) : "—"} | ${(0, _format.formatScales)(r.scales)} | ${size} | ${r.loaded ? "yes" : "NO"} |`);
|
|
59
|
-
}
|
|
60
|
-
return lines.join("\n");
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=export.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.formatAssetMarkdown=formatAssetMarkdown;exports.formatInventoryMarkdown=formatInventoryMarkdown;var _format=require("./format");var _assetStore=require("./store/assetStore");function formatAssetMarkdown(e){const s=[`# Asset: ${e.name}.${e.type}`,"",`- Kind: ${e.kind}`,`- Status: ${e.loaded?"loaded at runtime":"not observed in the runtime registry"}`];if(e.kind==="image")s.push(`- Dimensions: ${(0,_format.formatDimensions)(e)} (logical)`);if(e.scales.length)s.push(`- Scales: ${(0,_format.formatScales)(e.scales)}`);if(e.sizeBytes!=null&&e.sizeSource==="measured"){s.push(`- Size (all variants): ${(0,_format.formatBytes)(e.sizeBytes)}`)}const t=(0,_assetStore.estDecodedBytes)(e);if(t>0)s.push(`- Decoded memory: ~${(0,_format.formatBytes)(t)}`);if(e.hash)s.push(`- Hash: ${e.hash}`);if(e.httpServerLocation)s.push(`- Location: ${e.httpServerLocation}`);if(e.fileSystemLocation)s.push(`- Source dir: ${e.fileSystemLocation}`);if(e.resolvedUri)s.push(`- Resolved URI: ${e.resolvedUri}`);return s.join("\n")}function formatInventoryMarkdown(e,s,t,r,a){const l=["# Asset inventory","",`${s.total} assets \xB7 ${s.loaded} loaded \xB7 ${s.neverLoaded} not observed`+(s.totalBytes>0?` \xB7 ${(0,_format.formatBytes)(s.totalBytes)} measured (${s.measuredCount}/${s.total})`:"")];if(r.fontFamilies.length){l.push(`Fonts loaded: ${r.fontFamilies.join(", ")}`)}if(!r.graphSupported){l.push(r.graphError?`_Metro bundle graph unavailable (${r.graphError}) \u2014 runtime-registered assets only._`:"_No Metro bundle graph \u2014 runtime-registered assets only (release build)._")}if(a){const n=a.netBytes!=null?`${a.netBytes>=0?"+":"\u2212"}${(0,_format.formatBytes)(Math.abs(a.netBytes))} net`:"net size unknown";l.push("",`## Since baseline (${new Date(a.baselineSavedAt).toISOString()})`,`- ${a.added.length} added \xB7 ${a.removed.length} removed \xB7 ${a.grown.length} grew \xB7 ${n}`);for(const i of a.removed.slice(0,20)){l.push(`- removed: ${i.name}.${i.type}`)}}const o=[];if(t.neverLoaded.length)o.push(`- ${t.neverLoaded.length} shipped but not observed`);if(t.duplicates.length)o.push(`- ${t.duplicates.length} duplicate content groups`);if(t.webpCandidates.length)o.push(`- ${t.webpCandidates.length} WebP conversion candidates`);if(t.scaleGaps.length)o.push(`- ${t.scaleGaps.length} scale-coverage gaps`);if(t.overDecode.length)o.push(`- ${t.overDecode.length} images decoding larger than 2\xD7 the screen`);if(t.heavyGifs.length)o.push(`- ${t.heavyGifs.length} heavy GIFs (convert to video/Lottie)`);if(t.heavyFonts.length)o.push(`- ${t.heavyFonts.length} heavy fonts (subset candidates)`);if(t.scaleAnomalies.length)o.push(`- ${t.scaleAnomalies.length} scale-variant anomalies (check exports)`);if(o.length)l.push("","## Findings",...o);l.push("","## Assets (largest first)","","| Asset | Kind | Dimensions | Scales | Size | Loaded |","| --- | --- | --- | --- | --- | --- |");for(const n of e){const i=n.sizeBytes!=null&&n.sizeSource==="measured"?(0,_format.formatBytes)(n.sizeBytes):(0,_assetStore.estDecodedBytes)(n)>0?`~${(0,_format.formatBytes)((0,_assetStore.estDecodedBytes)(n))}`:"\u2014";l.push(`| ${n.name}.${n.type} | ${n.kind} | ${n.kind==="image"?(0,_format.formatDimensions)(n):"\u2014"} | ${(0,_format.formatScales)(n.scales)} | ${i} | ${n.loaded?"yes":"NO"} |`)}return l.join("\n")}
|
package/lib/commonjs/format.js
CHANGED
|
@@ -1,59 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.KIND_LABELS = exports.KIND_COLORS = void 0;
|
|
7
|
-
exports.formatBytes = formatBytes;
|
|
8
|
-
exports.formatDimensions = formatDimensions;
|
|
9
|
-
exports.formatScales = formatScales;
|
|
10
|
-
exports.formatSize = formatSize;
|
|
11
|
-
/**
|
|
12
|
-
* Shared formatting helpers for rows, detail view, and markdown export.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
function formatBytes(bytes) {
|
|
16
|
-
if (bytes == null || bytes <= 0) return "—";
|
|
17
|
-
if (bytes < 1024) return `${bytes} B`;
|
|
18
|
-
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
19
|
-
return `${(bytes / (1024 * 1024)).toFixed(2)} MB`;
|
|
20
|
-
}
|
|
21
|
-
function formatScales(scales) {
|
|
22
|
-
const unique = [...new Set(scales)].sort((a, b) => a - b);
|
|
23
|
-
if (!unique.length) return "—";
|
|
24
|
-
if (unique.length === 1) return `@${unique[0]}x`;
|
|
25
|
-
if (unique.length <= 3) return unique.map(s => `@${s}x`).join(" ");
|
|
26
|
-
return `@${unique[0]}x–@${unique[unique.length - 1]}x`;
|
|
27
|
-
}
|
|
28
|
-
function formatDimensions(record) {
|
|
29
|
-
if (record.width == null || record.height == null) return "—";
|
|
30
|
-
return `${Math.round(record.width)}×${Math.round(record.height)}`;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/** Display size: measured bytes, or "~" decoded estimate for unmeasured images. */
|
|
34
|
-
function formatSize(record, estDecoded) {
|
|
35
|
-
if (record.sizeBytes != null && record.sizeSource === "measured") {
|
|
36
|
-
return formatBytes(record.sizeBytes);
|
|
37
|
-
}
|
|
38
|
-
if (estDecoded > 0) return `~${formatBytes(estDecoded)}`;
|
|
39
|
-
return "—";
|
|
40
|
-
}
|
|
41
|
-
const KIND_LABELS = exports.KIND_LABELS = {
|
|
42
|
-
image: "IMG",
|
|
43
|
-
font: "FONT",
|
|
44
|
-
video: "VID",
|
|
45
|
-
audio: "AUD",
|
|
46
|
-
data: "DATA",
|
|
47
|
-
other: "MISC"
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/** Family accent per kind — the card's left edge, like network's method bar. */
|
|
51
|
-
const KIND_COLORS = exports.KIND_COLORS = {
|
|
52
|
-
image: "#2DD4BF",
|
|
53
|
-
font: "#C084FC",
|
|
54
|
-
video: "#FF9F1C",
|
|
55
|
-
audio: "#FF3366",
|
|
56
|
-
data: "#00D4FF",
|
|
57
|
-
other: "#8E8E93"
|
|
58
|
-
};
|
|
59
|
-
//# sourceMappingURL=format.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.KIND_LABELS=exports.KIND_COLORS=void 0;exports.formatBytes=formatBytes;exports.formatDimensions=formatDimensions;exports.formatScales=formatScales;exports.formatSize=formatSize;function formatBytes(t){if(t==null||t<=0)return"\u2014";if(t<1024)return`${t} B`;if(t<1024*1024)return`${(t/1024).toFixed(1)} KB`;return`${(t/(1024*1024)).toFixed(2)} MB`}function formatScales(t){const e=[...new Set(t)].sort((n,r)=>n-r);if(!e.length)return"\u2014";if(e.length===1)return`@${e[0]}x`;if(e.length<=3)return e.map(n=>`@${n}x`).join(" ");return`@${e[0]}x\u2013@${e[e.length-1]}x`}function formatDimensions(t){if(t.width==null||t.height==null)return"\u2014";return`${Math.round(t.width)}\xD7${Math.round(t.height)}`}function formatSize(t,e){if(t.sizeBytes!=null&&t.sizeSource==="measured"){return formatBytes(t.sizeBytes)}if(e>0)return`~${formatBytes(e)}`;return"\u2014"}const KIND_LABELS=exports.KIND_LABELS={image:"IMG",font:"FONT",video:"VID",audio:"AUD",data:"DATA",other:"MISC"};const KIND_COLORS=exports.KIND_COLORS={image:"#2DD4BF",font:"#C084FC",video:"#FF9F1C",audio:"#FF3366",data:"#00D4FF",other:"#8E8E93"};
|