@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
package/LICENSE ADDED
@@ -0,0 +1,58 @@
1
+ PROPRIETARY SOFTWARE LICENSE
2
+
3
+ Copyright (c) 2024-present Buoy. All rights reserved.
4
+
5
+ This software and its source code are proprietary and confidential.
6
+
7
+ NOTICE: This is NOT open source software. This software is licensed,
8
+ not sold, and is protected by copyright laws and international treaties.
9
+
10
+ TERMS AND CONDITIONS:
11
+
12
+ 1. LICENSE GRANT
13
+ Subject to the terms of this Agreement and payment of applicable fees,
14
+ Buoy grants you a limited, non-exclusive, non-transferable license
15
+ to use the compiled software packages in your applications.
16
+
17
+ 2. RESTRICTIONS
18
+ You may NOT:
19
+ - Copy, modify, or distribute the source code
20
+ - Reverse engineer, decompile, or disassemble the software
21
+ - Remove or alter any proprietary notices or labels
22
+ - Sublicense, rent, lease, or lend the software
23
+ - Use the software to create competing products
24
+ - Share access credentials with unauthorized parties
25
+
26
+ 3. OWNERSHIP
27
+ React Buoy retains all right, title, and interest in the software,
28
+ including all intellectual property rights. This license does not
29
+ grant you any rights to trademarks or service marks.
30
+
31
+ 4. TERMINATION
32
+ This license is effective until terminated. Your rights under this
33
+ license will terminate automatically without notice if you fail to
34
+ comply with any of its terms. Upon termination, you must cease all
35
+ use and destroy all copies of the software.
36
+
37
+ 5. DISCLAIMER OF WARRANTIES
38
+ THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
39
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
40
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT.
41
+
42
+ 6. LIMITATION OF LIABILITY
43
+ IN NO EVENT SHALL BUOY BE LIABLE FOR ANY INDIRECT, INCIDENTAL,
44
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR IN
45
+ CONNECTION WITH THIS LICENSE OR THE USE OF THE SOFTWARE.
46
+
47
+ 7. GOVERNING LAW
48
+ This Agreement shall be governed by and construed in accordance with
49
+ the laws of the United States, without regard to its conflict of
50
+ law provisions.
51
+
52
+ For licensing inquiries and subscription information:
53
+ - Website: https://buoy.gg
54
+ - Email: AustinLovesWorking@gmail.com
55
+
56
+ Unauthorized reproduction or distribution of this software, or any
57
+ portion of it, may result in severe civil and criminal penalties,
58
+ and will be prosecuted to the maximum extent possible under the law.
package/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # @buoy-gg/assets
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@buoy-gg/assets?style=flat-square&labelColor=1c1c1c&color=10B981)](https://www.npmjs.com/package/@buoy-gg/assets) [![npm downloads](https://img.shields.io/npm/dm/@buoy-gg/assets?style=flat-square&labelColor=1c1c1c&color=10B981)](https://www.npmjs.com/package/@buoy-gg/assets)
4
+
5
+ **See everything your app ships — every bundled image, font, video and audio file, with sizes, duplicate detection, and the ones nobody ever loads.**
6
+
7
+ Part of [Buoy](https://github.com/Buoy-gg/buoy) — devtools that live inside your React Native app. Install it and it auto-appears in the floating menu from [`@buoy-gg/core`](https://www.npmjs.com/package/@buoy-gg/core).
8
+
9
+ How many megabytes of images are you shipping? Is that hero PNG in the bundle twice? React Native gives you no inventory of your bundled assets — the usual answer is unzipping a release build and spelunking through APK Analyzer after the bloat already shipped. This tool is that inventory, live in your app. Pure JS, zero configuration — no register import, no config.
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npm install @buoy-gg/core @buoy-gg/assets
15
+ ```
16
+
17
+ ## Quick start
18
+
19
+ ```tsx
20
+ import { FloatingDevTools } from "@buoy-gg/core";
21
+
22
+ export default function App() {
23
+ return (
24
+ <>
25
+ <YourApp />
26
+ <FloatingDevTools />
27
+ </>
28
+ );
29
+ }
30
+ ```
31
+
32
+ The ASSETS tool appears in the menu. Open it and browse everything the app ships, largest first.
33
+
34
+ ## What you get
35
+
36
+ - **The whole inventory, largest first** — every bundled asset with a thumbnail, dimensions, `@1x/@2x/@3x` scale coverage, and its size. Filter by kind, search by name, sort by size/name/type
37
+ - **Real byte sizes** — in dev, every scale variant is measured from the Metro server; release builds still get decoded-memory estimates
38
+ - **Shipped-but-never-loaded detection** — the tool diffs the full bundle graph against what actually registered at runtime. Static grep tools can't know what's *loaded*; this does
39
+ - **Duplicate content** — identical bytes shipped under different names, flagged by content hash (one of the cheapest app-size wins there is)
40
+ - **Baseline diff** — save a baseline, make your change, and see exactly what it added: new assets, removed assets, grown assets, net bytes. App-size regression prevention without CI tooling
41
+ - **Audit findings** — images that decode larger than the device screen, heavy GIFs (every frame decodes into memory), unsubset icon fonts, WebP conversion candidates, missing/broken scale variants
42
+ - **Loaded font families** — build-time embedded and runtime loaded (via the expo-font native module when present)
43
+ - **Markdown report** — the full inventory with findings, ready to paste into an issue or PR
44
+
45
+ ## How it relates to @buoy-gg/images
46
+
47
+ [`@buoy-gg/images`](https://www.npmjs.com/package/@buoy-gg/images) shows what your app **renders** at runtime — per-load cache verdicts, timings, failures. This tool shows what your app **ships** in the bundle. They complement each other: images finds the slow load; assets finds the megabytes you never needed to ship.
48
+
49
+ ## Desktop & AI
50
+
51
+ The same live session streams to [Buoy Desktop](https://github.com/Buoy-gg/Buoy-Desktop) (free, macOS/Windows/Linux) and to Claude Code or Cursor via the [Buoy MCP server](https://buoy.gg/buoy/latest/docs/mcp) — `get_assets` for the inventory and findings, `asset_action` for rescans and the baseline workflow.
52
+
53
+ ## Free vs Pro
54
+
55
+ Every tool is free. [Pro](https://buoy.gg/pricing) unlocks production builds, the MCP server, and unlimited capture. Every weekend, Pro features unlock free for everyone.
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getLoadedFontFamilies = getLoadedFontFamilies;
7
+ exports.getLocalAssets = getLocalAssets;
8
+ /**
9
+ * Expo enrichment — all optional, all read through globalThis.expo guards so
10
+ * bare RN apps (no expo-modules) silently get none of it and no imports are
11
+ * added for anyone.
12
+ */
13
+
14
+ function expoModules() {
15
+ return globalThis.expo?.modules;
16
+ }
17
+
18
+ /**
19
+ * Every loaded font family — build-time embedded (config plugin / UIAppFonts /
20
+ * android assets/fonts) AND runtime Font.loadAsync, straight from the native
21
+ * module Expo documents as a stable global. [] when unavailable (bare RN).
22
+ */
23
+ function getLoadedFontFamilies() {
24
+ try {
25
+ const fonts = expoModules()?.ExpoFontLoader?.getLoadedFonts?.();
26
+ return Array.isArray(fonts) ? [...fonts].sort() : [];
27
+ } catch {
28
+ return [];
29
+ }
30
+ }
31
+
32
+ /**
33
+ * expo-updates' per-file-hash → local URI map: the COMPLETE shipped asset set
34
+ * in Expo Go / OTA environments, independent of what JS has evaluated.
35
+ * null when not running in an updates-managed environment.
36
+ */
37
+ function getLocalAssets() {
38
+ try {
39
+ const map = expoModules()?.ExpoUpdates?.localAssets;
40
+ if (map && typeof map === "object" && Object.keys(map).length > 0) return map;
41
+ return null;
42
+ } catch {
43
+ return null;
44
+ }
45
+ }
46
+ //# sourceMappingURL=expo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["expoModules","globalThis","expo","modules","getLoadedFontFamilies","fonts","ExpoFontLoader","getLoadedFonts","Array","isArray","sort","getLocalAssets","map","ExpoUpdates","localAssets","Object","keys","length"],"sourceRoot":"../../../src","sources":["capture/expo.ts"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;;AASA,SAASA,WAAWA,CAAA,EAA0B;EAC5C,OAAQC,UAAU,CAA2BC,IAAI,EAAEC,OAAO;AAC5D;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,qBAAqBA,CAAA,EAAa;EAChD,IAAI;IACF,MAAMC,KAAK,GAAGL,WAAW,CAAC,CAAC,EAAEM,cAAc,EAAEC,cAAc,GAAG,CAAC;IAC/D,OAAOC,KAAK,CAACC,OAAO,CAACJ,KAAK,CAAC,GAAG,CAAC,GAAGA,KAAK,CAAC,CAACK,IAAI,CAAC,CAAC,GAAG,EAAE;EACtD,CAAC,CAAC,MAAM;IACN,OAAO,EAAE;EACX;AACF;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,cAAcA,CAAA,EAAkC;EAC9D,IAAI;IACF,MAAMC,GAAG,GAAGZ,WAAW,CAAC,CAAC,EAAEa,WAAW,EAAEC,WAAW;IACnD,IAAIF,GAAG,IAAI,OAAOA,GAAG,KAAK,QAAQ,IAAIG,MAAM,CAACC,IAAI,CAACJ,GAAG,CAAC,CAACK,MAAM,GAAG,CAAC,EAAE,OAAOL,GAAG;IAC7E,OAAO,IAAI;EACb,CAAC,CAAC,MAAM;IACN,OAAO,IAAI;EACb;AACF","ignoreList":[]}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getScanStatus = getScanStatus;
7
+ exports.installAssetCapture = installAssetCapture;
8
+ exports.rescan = rescan;
9
+ var _state = require("../state");
10
+ var _assetStore = require("../store/assetStore");
11
+ var _expo = require("./expo");
12
+ var _measure = require("./measure");
13
+ var _metroGraph = require("./metroGraph");
14
+ var _registry = require("./registry");
15
+ /**
16
+ * Capture install + scan orchestration.
17
+ *
18
+ * installAssetCapture() is cheap and synchronous (registry walk + patch) and
19
+ * runs at package import. The expensive passes — Metro graph fetch and byte
20
+ * measurement — run in rescan(), triggered when the modal opens or via the
21
+ * `rescan` sync action, so merely installing Buoy never hits the network.
22
+ */
23
+
24
+ function installAssetCapture() {
25
+ const s = (0, _state.assetsState)();
26
+ if (s.captureDisabled || s.installed) return;
27
+ s.installed = true;
28
+ s.registryAvailable = (0, _registry.getRegistryModule)() != null;
29
+ s.patched = (0, _registry.patchRegisterAsset)();
30
+ (0, _registry.walkRegistry)();
31
+ refreshEnrichment();
32
+ s.lastScanAt = Date.now();
33
+ (0, _assetStore.invalidate)();
34
+ }
35
+ function refreshEnrichment() {
36
+ const s = (0, _state.assetsState)();
37
+ s.fontFamilies = (0, _expo.getLoadedFontFamilies)();
38
+ const localAssets = (0, _expo.getLocalAssets)();
39
+ s.localAssetCount = localAssets ? Object.keys(localAssets).length : null;
40
+ }
41
+
42
+ /**
43
+ * Full scan: registry re-walk (catches anything the patch missed), Metro
44
+ * graph merge (dev), Expo enrichment refresh, then size measurement.
45
+ */
46
+ async function rescan() {
47
+ const s = (0, _state.assetsState)();
48
+ if (s.captureDisabled) return getScanStatus();
49
+ installAssetCapture();
50
+ (0, _registry.walkRegistry)();
51
+ refreshEnrichment();
52
+ await (0, _metroGraph.fetchAssetGraph)();
53
+ s.lastScanAt = Date.now();
54
+ (0, _assetStore.invalidate)();
55
+ void (0, _measure.measureSizes)();
56
+ return getScanStatus();
57
+ }
58
+ function getScanStatus() {
59
+ const s = (0, _state.assetsState)();
60
+ // Mirrors report the synced DEVICE's status, not the dashboard's.
61
+ if (s.mirrorScanStatus) return s.mirrorScanStatus;
62
+ let registryCount = 0;
63
+ for (const record of s.records) if (record.registryId != null) registryCount++;
64
+ return {
65
+ registryAvailable: s.registryAvailable,
66
+ patched: s.patched,
67
+ registryCount,
68
+ graphSupported: s.graphSupported || (0, _metroGraph.getDevServerOrigin)() != null,
69
+ graphCount: s.graphCount,
70
+ graphError: s.graphError,
71
+ lastScanAt: s.lastScanAt,
72
+ measuring: s.measuring,
73
+ measuredCount: s.measuredCount,
74
+ fontFamilies: s.fontFamilies,
75
+ localAssetCount: s.localAssetCount
76
+ };
77
+ }
78
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_state","require","_assetStore","_expo","_measure","_metroGraph","_registry","installAssetCapture","s","assetsState","captureDisabled","installed","registryAvailable","getRegistryModule","patched","patchRegisterAsset","walkRegistry","refreshEnrichment","lastScanAt","Date","now","invalidate","fontFamilies","getLoadedFontFamilies","localAssets","getLocalAssets","localAssetCount","Object","keys","length","rescan","getScanStatus","fetchAssetGraph","measureSizes","mirrorScanStatus","registryCount","record","records","registryId","graphSupported","getDevServerOrigin","graphCount","graphError","measuring","measuredCount"],"sourceRoot":"../../../src","sources":["capture/install.ts"],"mappings":";;;;;;;;AASA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AAdA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUO,SAASM,mBAAmBA,CAAA,EAAS;EAC1C,MAAMC,CAAC,GAAG,IAAAC,kBAAW,EAAC,CAAC;EACvB,IAAID,CAAC,CAACE,eAAe,IAAIF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,IAAID,CAAC,CAAC0B,gBAAgB,EAAE,OAAO1B,CAAC,CAAC0B,gBAAgB;EACjD,IAAIC,aAAa,GAAG,CAAC;EACrB,KAAK,MAAMC,MAAM,IAAI5B,CAAC,CAAC6B,OAAO,EAAE,IAAID,MAAM,CAACE,UAAU,IAAI,IAAI,EAAEH,aAAa,EAAE;EAC9E,OAAO;IACLvB,iBAAiB,EAAEJ,CAAC,CAACI,iBAAiB;IACtCE,OAAO,EAAEN,CAAC,CAACM,OAAO;IAClBqB,aAAa;IACbI,cAAc,EAAE/B,CAAC,CAAC+B,cAAc,IAAI,IAAAC,8BAAkB,EAAC,CAAC,IAAI,IAAI;IAChEC,UAAU,EAAEjC,CAAC,CAACiC,UAAU;IACxBC,UAAU,EAAElC,CAAC,CAACkC,UAAU;IACxBxB,UAAU,EAAEV,CAAC,CAACU,UAAU;IACxByB,SAAS,EAAEnC,CAAC,CAACmC,SAAS;IACtBC,aAAa,EAAEpC,CAAC,CAACoC,aAAa;IAC9BtB,YAAY,EAAEd,CAAC,CAACc,YAAY;IAC5BI,eAAe,EAAElB,CAAC,CAACkB;EACrB,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,186 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.displaySource = displaySource;
7
+ exports.measureSizes = measureSizes;
8
+ exports.previewURL = previewURL;
9
+ exports.variantURLs = variantURLs;
10
+ var _state = require("../state");
11
+ var _assetStore = require("../store/assetStore");
12
+ var _metroGraph = require("./metroGraph");
13
+ /**
14
+ * Byte-size measurement.
15
+ *
16
+ * Dev only in practice: each scale variant is fetched from the Metro dev
17
+ * server (HEAD first for Content-Length, GET-blob fallback since Metro
18
+ * doesn't reliably answer HEAD) and the per-variant sizes are summed onto
19
+ * the record. Android release resource ids and iOS file:// URIs are not
20
+ * measurable from JS — those records keep `estDecodedBytes` as their only
21
+ * size signal and the UI marks them as estimates.
22
+ */
23
+
24
+ const CONCURRENCY = 4;
25
+
26
+ /**
27
+ * Best displayable URL for a record: the resolved runtime URI, or (dev) the
28
+ * same dev-server URL the measurement pass uses — this is what gives graph-
29
+ * only (never-loaded) images real thumbnails.
30
+ */
31
+ function previewURL(record) {
32
+ if (record.resolvedUri) return record.resolvedUri;
33
+ const variants = variantURLs(record);
34
+ return variants.length ? variants[0].url : null;
35
+ }
36
+
37
+ /**
38
+ * Image source for thumbnails/previews. On device the NUMERIC registry id is
39
+ * preferred (resolves natively — works for Android release resource ids too).
40
+ * On dashboard mirrors that id belongs to the DEVICE's registry and rn-web
41
+ * throws "asset with ID N could not be found" — use the device's http(s)
42
+ * URL instead (the Metro dev server is reachable from the desktop).
43
+ */
44
+ function displaySource(record) {
45
+ const mirror = (0, _state.assetsState)().captureDisabled;
46
+ if (!mirror && record.registryId != null) return record.registryId;
47
+ const uri = previewURL(record);
48
+ if (!uri) return null;
49
+ if (mirror && !/^https?:\/\//.test(uri)) return null;
50
+ return {
51
+ uri
52
+ };
53
+ }
54
+
55
+ /** All scale-variant URLs for a record, derived without re-encoding pitfalls. */
56
+ function variantURLs(record) {
57
+ const scales = record.scales.length ? record.scales : [1];
58
+
59
+ // Preferred: string surgery on the URL resolveAssetSource already proved
60
+ // works (handles Expo's ?unstable_path= form and monorepo rewrites).
61
+ const resolved = record.resolvedUri;
62
+ if (resolved && /^https?:\/\//.test(resolved) && record.resolvedScale != null) {
63
+ const pickedSuffix = record.resolvedScale === 1 ? "" : `@${record.resolvedScale}x`;
64
+ const marker = `${pickedSuffix}.${record.type}`;
65
+ if (resolved.includes(marker) || pickedSuffix === "") {
66
+ return scales.map(scale => {
67
+ const suffix = scale === 1 ? "" : `@${scale}x`;
68
+ const url = (pickedSuffix === "" ? resolved.replace(`.${record.type}`, `${suffix}.${record.type}`) : resolved.replace(marker, `${suffix}.${record.type}`)).replace(/ /g, "%20"); // RN's asset path builder doesn't encode spaces
69
+ return {
70
+ scale,
71
+ url
72
+ };
73
+ });
74
+ }
75
+ }
76
+
77
+ // Graph-only records: rebuild the dev-server URL the way Metro's
78
+ // AssetSourceResolver does (plain concatenation), encoding only spaces —
79
+ // full encodeURI would double-encode Expo's pre-escaped unstable_path.
80
+ const origin = (0, _metroGraph.getDevServerOrigin)();
81
+ if (!origin || !record.httpServerLocation) return [];
82
+ return scales.map(scale => {
83
+ const suffix = scale === 1 ? "" : `@${scale}x`;
84
+ const path = `${record.httpServerLocation}/${record.name}${suffix}.${record.type}`;
85
+ const sep = path.includes("?") ? "&" : "?";
86
+ const url = `${origin}${path}${sep}platform=${platformName()}${record.hash ? `&hash=${record.hash}` : ""}`.replace(/ /g, "%20");
87
+ return {
88
+ scale,
89
+ url
90
+ };
91
+ });
92
+ }
93
+ function platformName() {
94
+ try {
95
+ return require("react-native").Platform.OS;
96
+ } catch {
97
+ return "ios";
98
+ }
99
+ }
100
+ async function fetchSize(url) {
101
+ try {
102
+ const head = await fetch(url, {
103
+ method: "HEAD"
104
+ });
105
+ if (head.ok) {
106
+ const length = Number(head.headers.get("content-length"));
107
+ if (Number.isFinite(length) && length > 0) return length;
108
+ }
109
+ } catch {
110
+ // fall through to GET
111
+ }
112
+ try {
113
+ const response = await fetch(url);
114
+ if (!response.ok) return null;
115
+ const blob = await response.blob();
116
+ return blob.size > 0 ? blob.size : null;
117
+ } catch {
118
+ return null;
119
+ }
120
+ }
121
+ async function measureRecord(record) {
122
+ const variants = variantURLs(record);
123
+ if (!variants.length) {
124
+ (0, _assetStore.updateRecord)(record.id, {
125
+ sizeSource: "estimate"
126
+ });
127
+ return;
128
+ }
129
+ const sizesByScale = {};
130
+ let total = 0;
131
+ for (const {
132
+ scale,
133
+ url
134
+ } of variants) {
135
+ const size = await fetchSize(url);
136
+ if (size != null) {
137
+ sizesByScale[String(scale)] = size;
138
+ total += size;
139
+ }
140
+ }
141
+ if (total > 0) {
142
+ (0, _assetStore.updateRecord)(record.id, {
143
+ sizesByScale,
144
+ sizeBytes: total,
145
+ sizeSource: "measured"
146
+ });
147
+ } else {
148
+ (0, _assetStore.updateRecord)(record.id, {
149
+ sizeSource: "estimate"
150
+ });
151
+ }
152
+ }
153
+
154
+ /** Measure every unmeasured record; safe to re-run (skips measured ones). */
155
+ async function measureSizes() {
156
+ const s = (0, _state.assetsState)();
157
+ if (s.measuring) return {
158
+ measured: s.measuredCount,
159
+ total: (0, _assetStore.getSnapshot)().length
160
+ };
161
+ const pending = (0, _assetStore.getSnapshot)().filter(r => r.sizeSource !== "measured");
162
+ s.measuring = true;
163
+ (0, _assetStore.invalidate)();
164
+ try {
165
+ let index = 0;
166
+ const worker = async () => {
167
+ for (;;) {
168
+ const next = pending[index++];
169
+ if (!next) return;
170
+ await measureRecord(next);
171
+ s.measuredCount = (0, _assetStore.getSnapshot)().filter(r => r.sizeSource === "measured").length;
172
+ }
173
+ };
174
+ await Promise.all(Array.from({
175
+ length: Math.min(CONCURRENCY, pending.length)
176
+ }, worker));
177
+ } finally {
178
+ s.measuring = false;
179
+ (0, _assetStore.invalidate)();
180
+ }
181
+ return {
182
+ measured: s.measuredCount,
183
+ total: (0, _assetStore.getSnapshot)().length
184
+ };
185
+ }
186
+ //# sourceMappingURL=measure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_state","require","_assetStore","_metroGraph","CONCURRENCY","previewURL","record","resolvedUri","variants","variantURLs","length","url","displaySource","mirror","assetsState","captureDisabled","registryId","uri","test","scales","resolved","resolvedScale","pickedSuffix","marker","type","includes","map","scale","suffix","replace","origin","getDevServerOrigin","httpServerLocation","path","name","sep","platformName","hash","Platform","OS","fetchSize","head","fetch","method","ok","Number","headers","get","isFinite","response","blob","size","measureRecord","updateRecord","id","sizeSource","sizesByScale","total","String","sizeBytes","measureSizes","s","measuring","measured","measuredCount","getSnapshot","pending","filter","r","invalidate","index","worker","next","Promise","all","Array","from","Math","min"],"sourceRoot":"../../../src","sources":["capture/measure.ts"],"mappings":";;;;;;;;;AAWA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,O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GAAG,IAAI;EAClB,IAAAO,sBAAU,EAAC,CAAC;EACZ,IAAI;IACF,IAAIC,KAAK,GAAG,CAAC;IACb,MAAMC,MAAM,GAAG,MAAAA,CAAA,KAAY;MACzB,SAAS;QACP,MAAMC,IAAI,GAAGN,OAAO,CAACI,KAAK,EAAE,CAAC;QAC7B,IAAI,CAACE,IAAI,EAAE;QACX,MAAMpB,aAAa,CAACoB,IAAI,CAAC;QACzBX,CAAC,CAACG,aAAa,GAAG,IAAAC,uBAAW,EAAC,CAAC,CAACE,MAAM,CACnCC,CAAC,IAAKA,CAAC,CAACb,UAAU,KAAK,UAC1B,CAAC,CAAC7C,MAAM;MACV;IACF,CAAC;IACD,MAAM+D,OAAO,CAACC,GAAG,CACfC,KAAK,CAACC,IAAI,CAAC;MAAElE,MAAM,EAAEmE,IAAI,CAACC,GAAG,CAAC1E,WAAW,EAAE8D,OAAO,CAACxD,MAAM;IAAE,CAAC,EAAE6D,MAAM,CACtE,CAAC;EACH,CAAC,SAAS;IACRV,CAAC,CAACC,SAAS,GAAG,KAAK;IACnB,IAAAO,sBAAU,EAAC,CAAC;EACd;EACA,OAAO;IACLN,QAAQ,EAAEF,CAAC,CAACG,aAAa;IACzBP,KAAK,EAAE,IAAAQ,uBAAW,EAAC,CAAC,CAACvD;EACvB,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.fetchAssetGraph = fetchAssetGraph;
7
+ exports.getDevServerOrigin = getDevServerOrigin;
8
+ exports.getGraphURLCandidates = getGraphURLCandidates;
9
+ exports.getScriptURL = getScriptURL;
10
+ var _state = require("../state");
11
+ var _assetStore = require("../store/assetStore");
12
+ /**
13
+ * Metro dev-server graph fetch.
14
+ *
15
+ * The dev server serves `<entry>.assets` next to `<entry>.bundle` — the full
16
+ * dependency graph's AssetData[], INCLUDING assets never required at runtime
17
+ * and the `fileSystemLocation`/`files` fields Metro strips from runtime
18
+ * records. Deriving the URL by swapping `.bundle` → `.assets` on the running
19
+ * bundle's scriptURL keeps the entry path and platform/dev query params
20
+ * intact for both RN CLI (index.bundle) and Expo (…/entry.bundle) layouts.
21
+ *
22
+ * Graph-only records (in the graph, not the registry) are exactly the
23
+ * "shipped but never loaded" set. Dev-only: no server, no graph.
24
+ */
25
+
26
+ function getScriptURL() {
27
+ try {
28
+ const {
29
+ NativeModules
30
+ } = require("react-native");
31
+ const sourceCode = NativeModules?.SourceCode;
32
+ const url = sourceCode?.getConstants?.().scriptURL ?? sourceCode?.scriptURL;
33
+ return typeof url === "string" ? url : null;
34
+ } catch {
35
+ return null;
36
+ }
37
+ }
38
+
39
+ /** http(s) origin of the Metro dev server, or null when running embedded. */
40
+ function getDevServerOrigin() {
41
+ const scriptURL = getScriptURL();
42
+ const match = scriptURL?.match(/^https?:\/\/[^/]+/);
43
+ return match ? match[0] : null;
44
+ }
45
+
46
+ /**
47
+ * Candidate graph URLs, most-likely first. The straight `.bundle`→`.assets`
48
+ * swap works for RN CLI, but Expo dev builds serve a VIRTUAL entry
49
+ * (.expo/.virtual-metro-entry.bundle) that only exists for .bundle requests —
50
+ * its .assets twin 404s — so the real entry modules are tried next, keeping
51
+ * the original query string (platform/dev/etc.) intact.
52
+ */
53
+ function getGraphURLCandidates() {
54
+ const scriptURL = getScriptURL();
55
+ if (!scriptURL || !/^https?:\/\//.test(scriptURL)) return [];
56
+ const origin = getDevServerOrigin();
57
+ const queryIndex = scriptURL.indexOf("?");
58
+ const query = queryIndex >= 0 ? scriptURL.slice(queryIndex) : "?platform=ios&dev=true";
59
+ const candidates = [];
60
+ if (scriptURL.includes(".bundle")) {
61
+ candidates.push(scriptURL.replace(".bundle", ".assets"));
62
+ }
63
+ if (origin) {
64
+ candidates.push(`${origin}/node_modules/expo-router/entry.assets${query}`, `${origin}/node_modules/expo/AppEntry.assets${query}`, `${origin}/index.assets${query}`);
65
+ }
66
+ return candidates;
67
+ }
68
+
69
+ /** Fetch the full asset graph from the dev server and merge it into the store. */
70
+ async function fetchAssetGraph() {
71
+ const s = (0, _state.assetsState)();
72
+ const candidates = getGraphURLCandidates();
73
+ if (!candidates.length) {
74
+ s.graphSupported = false;
75
+ s.graphError = "No Metro dev server (embedded bundle)";
76
+ (0, _assetStore.invalidate)();
77
+ return {
78
+ ok: false,
79
+ message: s.graphError
80
+ };
81
+ }
82
+ if (s.graphFetchInFlight) return {
83
+ ok: false,
84
+ message: "Graph fetch already running"
85
+ };
86
+ s.graphFetchInFlight = true;
87
+ try {
88
+ let data = null;
89
+ let lastError = "";
90
+ for (const url of candidates) {
91
+ try {
92
+ const response = await fetch(url);
93
+ if (!response.ok) {
94
+ lastError = `Metro responded ${response.status} for ${url}`;
95
+ continue;
96
+ }
97
+ const parsed = await response.json();
98
+ if (Array.isArray(parsed)) {
99
+ data = parsed;
100
+ break;
101
+ }
102
+ lastError = "Unexpected .assets payload shape";
103
+ } catch (error) {
104
+ lastError = String(error?.message ?? error);
105
+ }
106
+ }
107
+ if (!Array.isArray(data)) throw new Error(lastError || "No graph endpoint answered");
108
+ const graph = data;
109
+ for (const asset of graph) {
110
+ if (!asset || typeof asset.name !== "string" || typeof asset.type !== "string") {
111
+ continue;
112
+ }
113
+ (0, _assetStore.upsertRecord)({
114
+ key: (0, _assetStore.assetKey)(asset.httpServerLocation, asset.name, asset.type),
115
+ name: asset.name,
116
+ type: asset.type,
117
+ origin: "graph",
118
+ hash: asset.hash,
119
+ httpServerLocation: asset.httpServerLocation,
120
+ width: asset.width ?? undefined,
121
+ height: asset.height ?? undefined,
122
+ scales: asset.scales,
123
+ fileSystemLocation: asset.fileSystemLocation,
124
+ files: asset.files,
125
+ fileHashes: asset.fileHashes
126
+ });
127
+ }
128
+ s.graphSupported = true;
129
+ s.graphCount = graph.length;
130
+ s.graphError = null;
131
+ (0, _assetStore.invalidate)();
132
+ return {
133
+ ok: true,
134
+ count: graph.length
135
+ };
136
+ } catch (error) {
137
+ s.graphSupported = getDevServerOrigin() != null;
138
+ s.graphError = String(error?.message ?? error);
139
+ (0, _assetStore.invalidate)();
140
+ return {
141
+ ok: false,
142
+ message: s.graphError
143
+ };
144
+ } finally {
145
+ s.graphFetchInFlight = false;
146
+ }
147
+ }
148
+ //# sourceMappingURL=metroGraph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_state","require","_assetStore","getScriptURL","NativeModules","sourceCode","SourceCode","url","getConstants","scriptURL","getDevServerOrigin","match","getGraphURLCandidates","test","origin","queryIndex","indexOf","query","slice","candidates","includes","push","replace","fetchAssetGraph","s","assetsState","length","graphSupported","graphError","invalidate","ok","message","graphFetchInFlight","data","lastError","response","fetch","status","parsed","json","Array","isArray","error","String","Error","graph","asset","name","type","upsertRecord","key","assetKey","httpServerLocation","hash","width","undefined","height","scales","fileSystemLocation","files","fileHashes","graphCount","count"],"sourceRoot":"../../../src","sources":["capture/metroGraph.ts"],"mappings":";;;;;;;;;AAcA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmBO,SAASE,YAAYA,CAAA,EAAkB;EAC5C,IAAI;IACF,MAAM;MAAEC;IAAc,CAAC,GAAGH,OAAO,CAAC,cAAc,CAAC;IACjD,MAAMI,UAAU,GAAGD,aAAa,EAAEE,UAAU;IAC5C,MAAMC,GAAY,GAChBF,UAAU,EAAEG,YAAY,GAAG,CAAC,CAACC,SAAS,IAAIJ,UAAU,EAAEI,SAAS;IACjE,OAAO,OAAOF,GAAG,KAAK,QAAQ,GAAGA,GAAG,GAAG,IAAI;EAC7C,CAAC,CAAC,MAAM;IACN,OAAO,IAAI;EACb;AACF;;AAEA;AACO,SAASG,kBAAkBA,CAAA,EAAkB;EAClD,MAAMD,SAAS,GAAGN,YAAY,CAAC,CAAC;EAChC,MAAMQ,KAAK,GAAGF,SAAS,EAAEE,KAAK,CAAC,mBAAmB,C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