@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.
Files changed (193) hide show
  1. package/README.md +12 -69
  2. package/bundlers/vite.d.ts +7 -0
  3. package/bundlers/vite.mjs +1 -0
  4. package/lib/commonjs/autoCapture.js +1 -0
  5. package/lib/commonjs/autoCapture.web.js +1 -0
  6. package/lib/commonjs/capture/assetLifecycle.js +1 -0
  7. package/lib/commonjs/capture/assetLifecycle.web.js +1 -0
  8. package/lib/commonjs/capture/browserAssets.js +1 -0
  9. package/lib/commonjs/capture/expo.js +1 -46
  10. package/lib/commonjs/capture/expo.web.js +1 -0
  11. package/lib/commonjs/capture/install.js +1 -91
  12. package/lib/commonjs/capture/install.web.js +1 -0
  13. package/lib/commonjs/capture/isBuoyAsset.js +1 -23
  14. package/lib/commonjs/capture/measure.js +1 -186
  15. package/lib/commonjs/capture/metroGraph.js +1 -175
  16. package/lib/commonjs/capture/metroGraph.web.js +1 -0
  17. package/lib/commonjs/capture/registry.js +1 -127
  18. package/lib/commonjs/components/AssetDetail.js +1 -211
  19. package/lib/commonjs/components/AssetImage.js +1 -66
  20. package/lib/commonjs/components/AssetRow.js +1 -232
  21. package/lib/commonjs/components/AssetsFilterBar.js +1 -105
  22. package/lib/commonjs/components/AssetsHeader.js +1 -73
  23. package/lib/commonjs/components/AssetsIcon.js +1 -19
  24. package/lib/commonjs/components/AssetsListControls.js +1 -81
  25. package/lib/commonjs/components/AssetsModal.js +1 -378
  26. package/lib/commonjs/components/ScanNotice.js +1 -85
  27. package/lib/commonjs/components/optionalExpoImage.js +1 -16
  28. package/lib/commonjs/components/optionalExpoImage.web.js +1 -11
  29. package/lib/commonjs/export.js +1 -62
  30. package/lib/commonjs/format.js +1 -59
  31. package/lib/commonjs/hooks/useAssetRecords.js +1 -22
  32. package/lib/commonjs/hooks/useAssetScanStatus.js +1 -28
  33. package/lib/commonjs/index.js +1 -313
  34. package/lib/commonjs/preset.js +1 -39
  35. package/lib/commonjs/remote.js +1 -68
  36. package/lib/commonjs/state.js +1 -51
  37. package/lib/commonjs/store/assetStore.js +1 -256
  38. package/lib/commonjs/store/baseline.js +1 -175
  39. package/lib/commonjs/store/insights.js +1 -120
  40. package/lib/commonjs/sync/assetsSyncAdapter.js +1 -157
  41. package/lib/commonjs/types.js +0 -1
  42. package/lib/commonjs/utils/deviceScale.js +1 -50
  43. package/lib/commonjs/utils/testIDs.js +1 -110
  44. package/lib/module/autoCapture.js +1 -0
  45. package/lib/module/autoCapture.web.js +1 -0
  46. package/lib/module/capture/assetLifecycle.js +1 -0
  47. package/lib/module/capture/assetLifecycle.web.js +1 -0
  48. package/lib/module/capture/browserAssets.js +1 -0
  49. package/lib/module/capture/expo.js +1 -41
  50. package/lib/module/capture/expo.web.js +1 -0
  51. package/lib/module/capture/install.js +1 -85
  52. package/lib/module/capture/install.web.js +1 -0
  53. package/lib/module/capture/isBuoyAsset.js +1 -18
  54. package/lib/module/capture/measure.js +1 -179
  55. package/lib/module/capture/metroGraph.js +1 -168
  56. package/lib/module/capture/metroGraph.web.js +1 -0
  57. package/lib/module/capture/registry.js +1 -120
  58. package/lib/module/components/AssetDetail.js +1 -207
  59. package/lib/module/components/AssetImage.js +1 -62
  60. package/lib/module/components/AssetRow.js +1 -228
  61. package/lib/module/components/AssetsFilterBar.js +1 -101
  62. package/lib/module/components/AssetsHeader.js +1 -69
  63. package/lib/module/components/AssetsIcon.js +1 -12
  64. package/lib/module/components/AssetsListControls.js +1 -77
  65. package/lib/module/components/AssetsModal.js +1 -373
  66. package/lib/module/components/ScanNotice.js +1 -81
  67. package/lib/module/components/optionalExpoImage.js +1 -12
  68. package/lib/module/components/optionalExpoImage.web.js +1 -7
  69. package/lib/module/export.js +1 -57
  70. package/lib/module/format.js +1 -51
  71. package/lib/module/hooks/useAssetRecords.js +1 -18
  72. package/lib/module/hooks/useAssetScanStatus.js +1 -23
  73. package/lib/module/index.js +1 -63
  74. package/lib/module/preset.js +1 -35
  75. package/lib/module/remote.js +1 -61
  76. package/lib/module/state.js +1 -47
  77. package/lib/module/store/assetStore.js +1 -240
  78. package/lib/module/store/baseline.js +1 -167
  79. package/lib/module/store/insights.js +1 -116
  80. package/lib/module/sync/assetsSyncAdapter.js +1 -153
  81. package/lib/module/types.js +0 -1
  82. package/lib/module/utils/deviceScale.js +1 -46
  83. package/lib/module/utils/testIDs.js +1 -99
  84. package/lib/typescript/autoCapture.d.ts +2 -0
  85. package/lib/typescript/autoCapture.web.d.ts +2 -0
  86. package/lib/typescript/capture/assetLifecycle.d.ts +3 -0
  87. package/lib/typescript/capture/assetLifecycle.web.d.ts +2 -0
  88. package/lib/typescript/capture/browserAssets.d.ts +13 -0
  89. package/lib/typescript/capture/expo.web.d.ts +3 -0
  90. package/lib/typescript/capture/install.web.d.ts +6 -0
  91. package/lib/typescript/capture/measure.d.ts +0 -10
  92. package/lib/typescript/capture/metroGraph.web.d.ts +12 -0
  93. package/lib/typescript/components/optionalExpoImage.web.d.ts +1 -1
  94. package/lib/typescript/index.d.ts +3 -0
  95. package/lib/typescript/types.d.ts +2 -1
  96. package/lib/web/index.mjs +3 -0
  97. package/package.json +46 -7
  98. package/lib/commonjs/capture/expo.js.map +0 -1
  99. package/lib/commonjs/capture/install.js.map +0 -1
  100. package/lib/commonjs/capture/isBuoyAsset.js.map +0 -1
  101. package/lib/commonjs/capture/measure.js.map +0 -1
  102. package/lib/commonjs/capture/metroGraph.js.map +0 -1
  103. package/lib/commonjs/capture/registry.js.map +0 -1
  104. package/lib/commonjs/components/AssetDetail.js.map +0 -1
  105. package/lib/commonjs/components/AssetImage.js.map +0 -1
  106. package/lib/commonjs/components/AssetRow.js.map +0 -1
  107. package/lib/commonjs/components/AssetsFilterBar.js.map +0 -1
  108. package/lib/commonjs/components/AssetsHeader.js.map +0 -1
  109. package/lib/commonjs/components/AssetsIcon.js.map +0 -1
  110. package/lib/commonjs/components/AssetsListControls.js.map +0 -1
  111. package/lib/commonjs/components/AssetsModal.js.map +0 -1
  112. package/lib/commonjs/components/ScanNotice.js.map +0 -1
  113. package/lib/commonjs/components/optionalExpoImage.js.map +0 -1
  114. package/lib/commonjs/components/optionalExpoImage.web.js.map +0 -1
  115. package/lib/commonjs/export.js.map +0 -1
  116. package/lib/commonjs/format.js.map +0 -1
  117. package/lib/commonjs/hooks/useAssetRecords.js.map +0 -1
  118. package/lib/commonjs/hooks/useAssetScanStatus.js.map +0 -1
  119. package/lib/commonjs/index.js.map +0 -1
  120. package/lib/commonjs/preset.js.map +0 -1
  121. package/lib/commonjs/remote.js.map +0 -1
  122. package/lib/commonjs/state.js.map +0 -1
  123. package/lib/commonjs/store/assetStore.js.map +0 -1
  124. package/lib/commonjs/store/baseline.js.map +0 -1
  125. package/lib/commonjs/store/insights.js.map +0 -1
  126. package/lib/commonjs/sync/assetsSyncAdapter.js.map +0 -1
  127. package/lib/commonjs/types.js.map +0 -1
  128. package/lib/commonjs/utils/deviceScale.js.map +0 -1
  129. package/lib/commonjs/utils/testIDs.js.map +0 -1
  130. package/lib/module/capture/expo.js.map +0 -1
  131. package/lib/module/capture/install.js.map +0 -1
  132. package/lib/module/capture/isBuoyAsset.js.map +0 -1
  133. package/lib/module/capture/measure.js.map +0 -1
  134. package/lib/module/capture/metroGraph.js.map +0 -1
  135. package/lib/module/capture/registry.js.map +0 -1
  136. package/lib/module/components/AssetDetail.js.map +0 -1
  137. package/lib/module/components/AssetImage.js.map +0 -1
  138. package/lib/module/components/AssetRow.js.map +0 -1
  139. package/lib/module/components/AssetsFilterBar.js.map +0 -1
  140. package/lib/module/components/AssetsHeader.js.map +0 -1
  141. package/lib/module/components/AssetsIcon.js.map +0 -1
  142. package/lib/module/components/AssetsListControls.js.map +0 -1
  143. package/lib/module/components/AssetsModal.js.map +0 -1
  144. package/lib/module/components/ScanNotice.js.map +0 -1
  145. package/lib/module/components/optionalExpoImage.js.map +0 -1
  146. package/lib/module/components/optionalExpoImage.web.js.map +0 -1
  147. package/lib/module/export.js.map +0 -1
  148. package/lib/module/format.js.map +0 -1
  149. package/lib/module/hooks/useAssetRecords.js.map +0 -1
  150. package/lib/module/hooks/useAssetScanStatus.js.map +0 -1
  151. package/lib/module/index.js.map +0 -1
  152. package/lib/module/preset.js.map +0 -1
  153. package/lib/module/remote.js.map +0 -1
  154. package/lib/module/state.js.map +0 -1
  155. package/lib/module/store/assetStore.js.map +0 -1
  156. package/lib/module/store/baseline.js.map +0 -1
  157. package/lib/module/store/insights.js.map +0 -1
  158. package/lib/module/sync/assetsSyncAdapter.js.map +0 -1
  159. package/lib/module/types.js.map +0 -1
  160. package/lib/module/utils/deviceScale.js.map +0 -1
  161. package/lib/module/utils/testIDs.js.map +0 -1
  162. package/lib/typescript/capture/expo.d.ts.map +0 -1
  163. package/lib/typescript/capture/install.d.ts.map +0 -1
  164. package/lib/typescript/capture/isBuoyAsset.d.ts.map +0 -1
  165. package/lib/typescript/capture/measure.d.ts.map +0 -1
  166. package/lib/typescript/capture/metroGraph.d.ts.map +0 -1
  167. package/lib/typescript/capture/registry.d.ts.map +0 -1
  168. package/lib/typescript/components/AssetDetail.d.ts.map +0 -1
  169. package/lib/typescript/components/AssetImage.d.ts.map +0 -1
  170. package/lib/typescript/components/AssetRow.d.ts.map +0 -1
  171. package/lib/typescript/components/AssetsFilterBar.d.ts.map +0 -1
  172. package/lib/typescript/components/AssetsHeader.d.ts.map +0 -1
  173. package/lib/typescript/components/AssetsIcon.d.ts.map +0 -1
  174. package/lib/typescript/components/AssetsListControls.d.ts.map +0 -1
  175. package/lib/typescript/components/AssetsModal.d.ts.map +0 -1
  176. package/lib/typescript/components/ScanNotice.d.ts.map +0 -1
  177. package/lib/typescript/components/optionalExpoImage.d.ts.map +0 -1
  178. package/lib/typescript/components/optionalExpoImage.web.d.ts.map +0 -1
  179. package/lib/typescript/export.d.ts.map +0 -1
  180. package/lib/typescript/format.d.ts.map +0 -1
  181. package/lib/typescript/hooks/useAssetRecords.d.ts.map +0 -1
  182. package/lib/typescript/hooks/useAssetScanStatus.d.ts.map +0 -1
  183. package/lib/typescript/index.d.ts.map +0 -1
  184. package/lib/typescript/preset.d.ts.map +0 -1
  185. package/lib/typescript/remote.d.ts.map +0 -1
  186. package/lib/typescript/state.d.ts.map +0 -1
  187. package/lib/typescript/store/assetStore.d.ts.map +0 -1
  188. package/lib/typescript/store/baseline.d.ts.map +0 -1
  189. package/lib/typescript/store/insights.d.ts.map +0 -1
  190. package/lib/typescript/sync/assetsSyncAdapter.d.ts.map +0 -1
  191. package/lib/typescript/types.d.ts.map +0 -1
  192. package/lib/typescript/utils/deviceScale.d.ts.map +0 -1
  193. package/lib/typescript/utils/testIDs.d.ts.map +0 -1
@@ -1,157 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.assetsSyncAdapter = void 0;
7
- var _install = require("../capture/install");
8
- var _measure = require("../capture/measure");
9
- var _assetStore = require("../store/assetStore");
10
- var _baseline = require("../store/baseline");
11
- var _insights = require("../store/insights");
12
- /**
13
- * Sync adapter for the Assets tool, consumed by @buoy-gg/external-sync's
14
- * `useExternalSync` (structurally matches its ToolSyncAdapter interface so
15
- * this package doesn't need a dependency on it — same pattern as images).
16
- * Exposes the asset inventory to the desktop dashboard and the MCP server.
17
- */
18
-
19
- const KINDS = ["image", "font", "video", "audio", "data", "other"];
20
- function toWire(record) {
21
- return {
22
- id: record.id,
23
- key: record.key,
24
- registryId: record.registryId ?? null,
25
- name: record.name,
26
- type: record.type,
27
- kind: record.kind,
28
- hash: record.hash ?? null,
29
- location: record.httpServerLocation ?? null,
30
- width: record.width ?? null,
31
- height: record.height ?? null,
32
- scales: record.scales,
33
- uri: record.resolvedUri ?? null,
34
- loaded: record.loaded,
35
- sizeBytes: record.sizeSource === "measured" ? record.sizeBytes ?? null : (0, _assetStore.estDecodedBytes)(record) || null,
36
- sizeSource: record.sizeSource ?? null
37
- };
38
- }
39
- function requireRecord(params) {
40
- const id = params?.id;
41
- if (typeof id !== "number") throw new Error("Missing numeric `id` param");
42
- const record = (0, _assetStore.getRecord)(id);
43
- if (!record) {
44
- throw new Error(`Asset record ${id} not found — re-run the list action for current ids.`);
45
- }
46
- return record;
47
- }
48
-
49
- /** Largest-first is the useful default for an inventory. */
50
- function bySizeDesc(a, b) {
51
- return (b.sizeBytes ?? (0, _assetStore.estDecodedBytes)(b)) - (a.sizeBytes ?? (0, _assetStore.estDecodedBytes)(a));
52
- }
53
- function overview() {
54
- const snapshot = (0, _assetStore.getSnapshot)();
55
- return {
56
- stats: (0, _assetStore.computeStats)(snapshot),
57
- scanStatus: (0, _install.getScanStatus)(),
58
- insights: (0, _insights.computeInsights)(snapshot),
59
- diff: (0, _baseline.getDiff)(),
60
- records: [...snapshot].sort(bySizeDesc)
61
- };
62
- }
63
- const assetsSyncAdapter = exports.assetsSyncAdapter = {
64
- version: 1,
65
- getSnapshot: () => {
66
- const {
67
- records,
68
- ...rest
69
- } = overview();
70
- return {
71
- ...rest,
72
- records: records.slice(0, 200).map(toWire)
73
- };
74
- },
75
- subscribe: onChange => (0, _assetStore.subscribe)(onChange),
76
- actions: {
77
- /** List assets, largest first. Params: { limit?, kind?, loadedOnly? }. */
78
- list: params => {
79
- const p = params ?? {};
80
- const limit = Math.min(Math.max(p.limit ?? 50, 1), 500);
81
- const {
82
- records,
83
- ...rest
84
- } = overview();
85
- let filtered = records;
86
- if (p.kind) {
87
- if (!KINDS.includes(p.kind)) {
88
- throw new Error(`kind must be one of: ${KINDS.join(", ")}`);
89
- }
90
- filtered = filtered.filter(r => r.kind === p.kind);
91
- }
92
- if (p.loadedOnly) filtered = filtered.filter(r => r.loaded);
93
- return {
94
- ...rest,
95
- total: filtered.length,
96
- records: filtered.slice(0, limit).map(toWire)
97
- };
98
- },
99
- /** Full detail for one asset. Params: { id }. */
100
- getDetail: params => {
101
- const record = requireRecord(params);
102
- return {
103
- ...toWire(record),
104
- origin: record.origin,
105
- fileSystemLocation: record.fileSystemLocation ?? null,
106
- files: record.files ?? null,
107
- sizesByScale: record.sizesByScale ?? null,
108
- estDecodedBytes: (0, _assetStore.estDecodedBytes)(record) || null
109
- };
110
- },
111
- /** Re-walk the registry, merge the Metro graph, refresh fonts, measure sizes. */
112
- rescan: async () => {
113
- const status = await (0, _install.rescan)();
114
- return {
115
- ok: true,
116
- scanStatus: status
117
- };
118
- },
119
- /** (Re-)measure byte sizes from the dev server. */
120
- measureSizes: async () => {
121
- const result = await (0, _measure.measureSizes)();
122
- return {
123
- ok: result.measured > 0,
124
- ...result
125
- };
126
- },
127
- /** Persist the current inventory as the comparison baseline. */
128
- saveBaseline: async () => {
129
- const baseline = await (0, _baseline.saveBaseline)();
130
- return {
131
- ok: true,
132
- savedAt: baseline.savedAt,
133
- assets: Object.keys(baseline.entries).length
134
- };
135
- },
136
- /** Drop the saved baseline. */
137
- clearBaseline: async () => {
138
- await (0, _baseline.clearBaseline)();
139
- return {
140
- ok: true,
141
- message: "Baseline cleared"
142
- };
143
- },
144
- /** Change vs the saved baseline (null when no baseline exists). */
145
- getDiff: () => (0, _baseline.getDiff)(),
146
- /** Wipe the store (next rescan rebuilds it). */
147
- clearRecords: () => {
148
- (0, _assetStore.clearRecords)();
149
- return {
150
- ok: true,
151
- message: "Inventory cleared — rescan to rebuild"
152
- };
153
- },
154
- getScanStatus: () => (0, _install.getScanStatus)()
155
- }
156
- };
157
- //# sourceMappingURL=assetsSyncAdapter.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.assetsSyncAdapter=void 0;var _install=require("../capture/install");var _measure=require("../capture/measure");var _assetStore=require("../store/assetStore");var _baseline=require("../store/baseline");var _insights=require("../store/insights");const KINDS=["image","font","video","audio","data","other"];function toWire(e){return{id:e.id,key:e.key,registryId:e.registryId??null,name:e.name,type:e.type,kind:e.kind,hash:e.hash??null,location:e.httpServerLocation??null,width:e.width??null,height:e.height??null,scales:e.scales,uri:e.resolvedUri??null,loaded:e.loaded,sizeBytes:e.sizeSource==="measured"?e.sizeBytes??null:(0,_assetStore.estDecodedBytes)(e)||null,sizeSource:e.sizeSource??null}}function requireRecord(e){const t=e?.id;if(typeof t!=="number")throw new Error("Missing numeric `id` param");const i=(0,_assetStore.getRecord)(t);if(!i){throw new Error(`Asset record ${t} not found \u2014 re-run the list action for current ids.`)}return i}function bySizeDesc(e,t){return(t.sizeBytes??(0,_assetStore.estDecodedBytes)(t))-(e.sizeBytes??(0,_assetStore.estDecodedBytes)(e))}function overview(){const e=(0,_assetStore.getSnapshot)();return{stats:(0,_assetStore.computeStats)(e),scanStatus:(0,_install.getScanStatus)(),insights:(0,_insights.computeInsights)(e),diff:(0,_baseline.getDiff)(),records:[...e].sort(bySizeDesc)}}const assetsSyncAdapter=exports.assetsSyncAdapter={version:1,getSnapshot:()=>{const{records:e,...t}=overview();return{...t,records:e.slice(0,200).map(toWire)}},subscribe:e=>(0,_assetStore.subscribe)(e),actions:{list:e=>{const t=e??{};const i=Math.min(Math.max(t.limit??50,1),500);const{records:r,...a}=overview();let s=r;if(t.kind){if(!KINDS.includes(t.kind)){throw new Error(`kind must be one of: ${KINDS.join(", ")}`)}s=s.filter(n=>n.kind===t.kind)}if(t.loadedOnly)s=s.filter(n=>n.loaded);return{...a,total:s.length,records:s.slice(0,i).map(toWire)}},getDetail:e=>{const t=requireRecord(e);return{...toWire(t),origin:t.origin,fileSystemLocation:t.fileSystemLocation??null,files:t.files??null,sizesByScale:t.sizesByScale??null,estDecodedBytes:(0,_assetStore.estDecodedBytes)(t)||null}},rescan:async()=>{const e=await(0,_install.rescan)();return{ok:true,scanStatus:e}},measureSizes:async()=>{const e=await(0,_measure.measureSizes)();return{ok:e.measured>0,...e}},saveBaseline:async()=>{const e=await(0,_baseline.saveBaseline)();return{ok:true,savedAt:e.savedAt,assets:Object.keys(e.entries).length}},clearBaseline:async()=>{await(0,_baseline.clearBaseline)();return{ok:true,message:"Baseline cleared"}},getDiff:()=>(0,_baseline.getDiff)(),clearRecords:()=>{(0,_assetStore.clearRecords)();return{ok:true,message:"Inventory cleared \u2014 rescan to rebuild"}},getScanStatus:()=>(0,_install.getScanStatus)()}};
@@ -1,2 +1 @@
1
1
  "use strict";
2
- //# sourceMappingURL=types.js.map
@@ -1,50 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.effectivePixelRatio = effectivePixelRatio;
7
- exports.pickScale = pickScale;
8
- var _state = require("../state");
9
- /**
10
- * Which scale variant this device would actually use.
11
- *
12
- * Shared by the decoded-memory estimate and the scale-gap insight so the two
13
- * can't disagree about the same asset — they were written apart and did.
14
- */
15
-
16
- /**
17
- * PixelRatio, or the DEVICE's when this store is a dashboard mirror.
18
- *
19
- * A desktop dashboard renders another machine's inventory, and its own
20
- * PixelRatio has nothing to do with which variant the phone will pick.
21
- */
22
- function effectivePixelRatio() {
23
- const mirror = (0, _state.assetsState)().mirrorPixelRatio;
24
- if (mirror != null) return mirror;
25
- try {
26
- return require("react-native").PixelRatio.get();
27
- } catch {
28
- return 2;
29
- }
30
- }
31
-
32
- /**
33
- * The variant React Native would resolve, by AssetSourceResolver's rule: the
34
- * smallest scale that covers the device, or the largest available when none
35
- * does.
36
- *
37
- * Not simply "the biggest one shipped". An asset with @1x…@4x variants on a
38
- * @3x phone decodes at 3, and calling it 4 overstates its memory by 78% —
39
- * on exactly the never-loaded assets this tool exists to point at, since a
40
- * loaded one carries the scale RN already picked.
41
- */
42
- function pickScale(scales, deviceScale) {
43
- if (!scales.length) return 1;
44
- const ordered = [...scales].sort((a, b) => a - b);
45
- for (const scale of ordered) {
46
- if (scale >= deviceScale) return scale;
47
- }
48
- return ordered[ordered.length - 1];
49
- }
50
- //# sourceMappingURL=deviceScale.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.effectivePixelRatio=effectivePixelRatio;exports.pickScale=pickScale;var _state=require("../state");function effectivePixelRatio(){const e=(0,_state.assetsState)().mirrorPixelRatio;if(e!=null)return e;try{return require("react-native").PixelRatio.get()}catch{return 2}}function pickScale(e,i){if(!e.length)return 1;const r=[...e].sort((t,o)=>t-o);for(const t of r){if(t>=i)return t}return r[r.length-1]}
@@ -1,110 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ASSETS_TEST_IDS = void 0;
7
- exports.assetBadgeTestID = assetBadgeTestID;
8
- exports.assetDetailRowTestID = assetDetailRowTestID;
9
- exports.assetFilterTestID = assetFilterTestID;
10
- exports.assetFindingTestID = assetFindingTestID;
11
- exports.assetFontChipTestID = assetFontChipTestID;
12
- exports.assetRowTestID = assetRowTestID;
13
- exports.assetSlug = assetSlug;
14
- /**
15
- * Automation handles for the Assets tool.
16
- *
17
- * Every handle the tool renders is built here rather than inlined at the call
18
- * site, for the same reason the highlight tool does it: the ids for rows,
19
- * badges, filter chips and detail fields are DERIVED from data, and a suite
20
- * that reimplements the derivation is a suite that can drift from the tool
21
- * without either side failing. `detox-e2e/assets/fixture.js` mirrors these
22
- * rules in CommonJS (the tests can't import TypeScript) and asserts the two
23
- * still agree before any flow trusts a handle.
24
- *
25
- * Naming: `buoy-assets-<area>[-<detail>]`, one prefix for the whole tool.
26
- */
27
-
28
- /**
29
- * Lowercase, hyphen-joined, never empty.
30
- *
31
- * Shared by rows, badges, filter chips and detail fields so one asset's row
32
- * handle and its detail handles are slugged the same way — `back-icon.png`
33
- * becomes `back-icon-png` everywhere it appears.
34
- */
35
- function assetSlug(value) {
36
- return String(value).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "unknown";
37
- }
38
-
39
- /**
40
- * One inventory row, addressed by filename rather than by store id.
41
- *
42
- * The store's numeric ids are assigned in first-sighting order and are NOT
43
- * stable: clearing the inventory and rescanning renumbers everything, and the
44
- * order the registry walk and the Metro graph merge in depends on what the app
45
- * has evaluated so far. A handle built from those makes a test that passes
46
- * only on the run that recorded it.
47
- *
48
- * The tradeoff is that two assets with the same filename in different
49
- * directories collide. That's a real ambiguity rather than a hidden one —
50
- * Detox reports it as "multiple elements matched", which names the problem —
51
- * and it's the same tradeoff the row itself makes, since the row shows the
52
- * filename and not the path.
53
- */
54
- function assetRowTestID(name, type) {
55
- return `buoy-assets-row-${assetSlug(`${name}.${type}`)}`;
56
- }
57
-
58
- /** A finding badge inside a row: `…-badge-low-res`, `…-badge-dup`. */
59
- function assetBadgeTestID(name, type, label) {
60
- return `${assetRowTestID(name, type)}-badge-${assetSlug(label)}`;
61
- }
62
-
63
- /** A kind/status filter chip: `buoy-assets-filter-font`, `…-filter-unused`. */
64
- function assetFilterTestID(filter) {
65
- return `buoy-assets-filter-${assetSlug(filter)}`;
66
- }
67
-
68
- /** One label/value pair in the detail view: `buoy-assets-detail-row-hash`. */
69
- function assetDetailRowTestID(label) {
70
- return `buoy-assets-detail-row-${assetSlug(label)}`;
71
- }
72
-
73
- /** A loaded font-family chip: `buoy-assets-font-ionicons`. */
74
- function assetFontChipTestID(family) {
75
- return `buoy-assets-font-${assetSlug(family)}`;
76
- }
77
-
78
- /** Fixed handles — everything that isn't derived from a record. */
79
- const ASSETS_TEST_IDS = exports.ASSETS_TEST_IDS = {
80
- // header
81
- title: "buoy-assets-title",
82
- copy: "buoy-assets-copy",
83
- clear: "buoy-assets-clear",
84
- // list chrome
85
- list: "buoy-assets-list",
86
- search: "buoy-assets-search",
87
- sort: "buoy-assets-sort",
88
- filterBar: "buoy-assets-filter-bar",
89
- notice: "buoy-assets-notice",
90
- noticeText: "buoy-assets-notice-text",
91
- discoverySpinner: "buoy-assets-discovery-spinner",
92
- retry: "buoy-assets-retry",
93
- fonts: "buoy-assets-fonts",
94
- fontsTitle: "buoy-assets-fonts-title",
95
- empty: "buoy-assets-empty",
96
- emptyTitle: "buoy-assets-empty-title",
97
- emptyText: "buoy-assets-empty-text",
98
- // detail
99
- detail: "buoy-assets-detail",
100
- detailScroll: "buoy-assets-detail-scroll",
101
- detailPreview: "buoy-assets-detail-preview",
102
- detailFontPreview: "buoy-assets-detail-font-preview",
103
- detailFindings: "buoy-assets-detail-findings"
104
- };
105
-
106
- /** One finding sentence in the detail view, by position. */
107
- function assetFindingTestID(index) {
108
- return `buoy-assets-detail-finding-${index}`;
109
- }
110
- //# sourceMappingURL=testIDs.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ASSETS_TEST_IDS=void 0;exports.assetBadgeTestID=assetBadgeTestID;exports.assetDetailRowTestID=assetDetailRowTestID;exports.assetFilterTestID=assetFilterTestID;exports.assetFindingTestID=assetFindingTestID;exports.assetFontChipTestID=assetFontChipTestID;exports.assetRowTestID=assetRowTestID;exports.assetSlug=assetSlug;function assetSlug(s){return String(s).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"unknown"}function assetRowTestID(s,e){return`buoy-assets-row-${assetSlug(`${s}.${e}`)}`}function assetBadgeTestID(s,e,t){return`${assetRowTestID(s,e)}-badge-${assetSlug(t)}`}function assetFilterTestID(s){return`buoy-assets-filter-${assetSlug(s)}`}function assetDetailRowTestID(s){return`buoy-assets-detail-row-${assetSlug(s)}`}function assetFontChipTestID(s){return`buoy-assets-font-${assetSlug(s)}`}const ASSETS_TEST_IDS=exports.ASSETS_TEST_IDS={title:"buoy-assets-title",copy:"buoy-assets-copy",clear:"buoy-assets-clear",list:"buoy-assets-list",search:"buoy-assets-search",sort:"buoy-assets-sort",filterBar:"buoy-assets-filter-bar",notice:"buoy-assets-notice",noticeText:"buoy-assets-notice-text",discoverySpinner:"buoy-assets-discovery-spinner",retry:"buoy-assets-retry",fonts:"buoy-assets-fonts",fontsTitle:"buoy-assets-fonts-title",empty:"buoy-assets-empty",emptyTitle:"buoy-assets-empty-title",emptyText:"buoy-assets-empty-text",detail:"buoy-assets-detail",detailScroll:"buoy-assets-detail-scroll",detailPreview:"buoy-assets-detail-preview",detailFontPreview:"buoy-assets-detail-font-preview",detailFindings:"buoy-assets-detail-findings"};function assetFindingTestID(s){return`buoy-assets-detail-finding-${s}`}
@@ -0,0 +1 @@
1
+ "use strict";import{installAssetCapture as t}from"./capture/install";t();
@@ -0,0 +1 @@
1
+ "use strict";export{};
@@ -0,0 +1 @@
1
+ "use strict";export function startBrowserAssetCapture(){return()=>{}}
@@ -0,0 +1 @@
1
+ "use strict";import{installAssetCapture as r,stopBrowserAssetCapture as s}from"./install.web";let e=0;export function startBrowserAssetCapture(){if(typeof document==="undefined")return()=>{};if(++e===1)r();let t=true;return()=>{if(t){t=false;if(--e===0)s()}}}
@@ -0,0 +1 @@
1
+ "use strict";import{assetsState as c}from"../state";import{upsertRecord as a,updateRecord as d}from"../store/assetStore";let o=[];export function registerBrowserAssetManifest(e){o=e;if(typeof document!=="undefined")scanBrowserAssets()}export function getBrowserAssetManifest(){return o}export async function loadBrowserAssetManifest(e){const t=await fetch(e);if(!t.ok)throw new Error(`Asset manifest returned HTTP ${t.status}.`);const r=await t.json();if(!Array.isArray(r)||r.some(n=>!n||typeof n.url!=="string"))throw new Error("An asset manifest must contain an array of assets with URL strings.");registerBrowserAssetManifest(r)}function s(e,t){let r;try{r=new URL(e.url,document.baseURI)}catch{return}const n=r.pathname.split("/").pop()??"";const i=n.includes(".")?n.split(".").pop().toLowerCase():"other";const u=a({key:r.href,name:n.slice(0,-(i.length+1))||n,type:i,origin:t?"browser":"graph",resolvedUri:r.href,resolvedScale:1,scales:[1],hash:e.hash,loaded:t,width:e.width,height:e.height});if(u&&e.bytes!==void 0&&e.bytes>=0)d(u.id,{sizeBytes:e.bytes,sizesByScale:{"1":e.bytes},sizeSource:"measured"})}export function captureBrowserResource(e){if(e.initiatorType==="fetch"||e.initiatorType==="xmlhttprequest")return;s({url:e.name,bytes:e.encodedBodySize>0?e.encodedBodySize:void 0},true)}export function scanBrowserAssets(){if(typeof document==="undefined"||c().captureDisabled)return;o.forEach(t=>s(t,false));performance.getEntriesByType("resource").forEach(t=>captureBrowserResource(t));document.querySelectorAll("img").forEach(t=>{if(!t.closest("[data-buoy-root]")&&t.currentSrc)s({url:t.currentSrc,width:t.naturalWidth||void 0,height:t.naturalHeight||void 0},t.complete&&t.naturalWidth>0)});const e=c();e.graphSupported=o.length>0;e.graphCount=o.length>0?o.length:null;e.measuredCount=e.records.filter(t=>t.sizeBytes!==void 0).length;e.lastScanAt=Date.now()}
@@ -1,41 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * Expo enrichment — all optional, all read through globalThis.expo guards so
5
- * bare RN apps (no expo-modules) silently get none of it and no imports are
6
- * added for anyone.
7
- */
8
-
9
- function expoModules() {
10
- return globalThis.expo?.modules;
11
- }
12
-
13
- /**
14
- * Every loaded font family — build-time embedded (config plugin / UIAppFonts /
15
- * android assets/fonts) AND runtime Font.loadAsync, straight from the native
16
- * module Expo documents as a stable global. [] when unavailable (bare RN).
17
- */
18
- export function getLoadedFontFamilies() {
19
- try {
20
- const fonts = expoModules()?.ExpoFontLoader?.getLoadedFonts?.();
21
- return Array.isArray(fonts) ? [...new Set(fonts)].sort() : [];
22
- } catch {
23
- return [];
24
- }
25
- }
26
-
27
- /**
28
- * expo-updates' per-file-hash → local URI map: the COMPLETE shipped asset set
29
- * in Expo Go / OTA environments, independent of what JS has evaluated.
30
- * null when not running in an updates-managed environment.
31
- */
32
- export function getLocalAssets() {
33
- try {
34
- const map = expoModules()?.ExpoUpdates?.localAssets;
35
- if (map && typeof map === "object" && Object.keys(map).length > 0) return map;
36
- return null;
37
- } catch {
38
- return null;
39
- }
40
- }
41
- //# sourceMappingURL=expo.js.map
1
+ "use strict";function e(){return globalThis.expo?.modules}export function getLoadedFontFamilies(){try{const t=e()?.ExpoFontLoader?.getLoadedFonts?.();return Array.isArray(t)?[...new Set(t)].sort():[]}catch{return[]}}export function getLocalAssets(){try{const t=e()?.ExpoUpdates?.localAssets;if(t&&typeof t==="object"&&Object.keys(t).length>0)return t;return null}catch{return null}}
@@ -0,0 +1 @@
1
+ "use strict";export function getLoadedFontFamilies(){if(typeof document==="undefined"||!document.fonts)return[];const t=new Set;document.fonts.forEach(e=>{if(e.status==="loaded")t.add(e.family.replace(/^['"]|['"]$/g,""))});return[...t].sort()}export function getLocalAssets(){return null}
@@ -1,85 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * Capture install + scan orchestration.
5
- *
6
- * installAssetCapture() is cheap and synchronous (registry walk + patch) and
7
- * runs at package import. The expensive passes — Metro graph fetch and byte
8
- * measurement — run in rescan(), triggered when the modal opens or via the
9
- * `rescan` sync action, so merely installing Buoy never hits the network.
10
- */
11
-
12
- import { assetsState } from "../state";
13
- import { invalidate, removeBuoyRecords } from "../store/assetStore";
14
- import { getLoadedFontFamilies, getLocalAssets } from "./expo";
15
- import { measureSizes } from "./measure";
16
- import { fetchAssetGraph, getDevServerOrigin } from "./metroGraph";
17
- import { getRegistryModule, patchRegisterAsset, walkRegistry } from "./registry";
18
- export function installAssetCapture() {
19
- const s = assetsState();
20
- if (s.captureDisabled || s.installed) return;
21
- s.installed = true;
22
- s.registryAvailable = getRegistryModule() != null;
23
- s.patched = patchRegisterAsset();
24
- walkRegistry();
25
- refreshEnrichment();
26
- s.lastScanAt = Date.now();
27
- invalidate();
28
- }
29
- function refreshEnrichment() {
30
- const s = assetsState();
31
- s.fontFamilies = getLoadedFontFamilies();
32
- const localAssets = getLocalAssets();
33
- s.localAssetCount = localAssets ? Object.keys(localAssets).length : null;
34
- }
35
-
36
- /**
37
- * Full scan: registry re-walk (catches anything the patch missed), Metro
38
- * graph merge (dev), Expo enrichment refresh, then size measurement.
39
- */
40
- export async function rescan() {
41
- const s = assetsState();
42
- if (s.captureDisabled) return getScanStatus();
43
- if (s.scanPromise) return s.scanPromise;
44
- s.scanPromise = runScan();
45
- try {
46
- return await s.scanPromise;
47
- } finally {
48
- s.scanPromise = undefined;
49
- }
50
- }
51
- async function runScan() {
52
- const s = assetsState();
53
- removeBuoyRecords();
54
- installAssetCapture();
55
- walkRegistry();
56
- refreshEnrichment();
57
- await fetchAssetGraph();
58
- s.lastScanAt = Date.now();
59
- invalidate();
60
- void measureSizes();
61
- return getScanStatus();
62
- }
63
- export function getScanStatus() {
64
- const s = assetsState();
65
- // Mirrors report the synced DEVICE's status, not the dashboard's.
66
- if (s.mirrorScanStatus) return s.mirrorScanStatus;
67
- let registryCount = 0;
68
- for (const record of s.records) if (record.registryId != null) registryCount++;
69
- return {
70
- registryAvailable: s.registryAvailable,
71
- patched: s.patched,
72
- registryCount,
73
- graphSupported: s.graphSupported || getDevServerOrigin() != null,
74
- graphCount: s.graphCount,
75
- graphError: s.graphError,
76
- graphFetchInFlight: s.graphFetchInFlight,
77
- graphFetchStartedAt: s.graphFetchStartedAt ?? null,
78
- lastScanAt: s.lastScanAt,
79
- measuring: s.measuring,
80
- measuredCount: s.measuredCount,
81
- fontFamilies: s.fontFamilies,
82
- localAssetCount: s.localAssetCount
83
- };
84
- }
85
- //# sourceMappingURL=install.js.map
1
+ "use strict";import{assetsState as e}from"../state";import{invalidate as s,removeBuoyRecords as i}from"../store/assetStore";import{getLoadedFontFamilies as c,getLocalAssets as l}from"./expo";import{measureSizes as u}from"./measure";import{fetchAssetGraph as p,getDevServerOrigin as m}from"./metroGraph";import{getRegistryModule as g,patchRegisterAsset as f,walkRegistry as a}from"./registry";export function installAssetCapture(){const t=e();if(t.captureDisabled||t.installed)return;t.installed=true;t.registryAvailable=g()!=null;t.patched=f();a();n();t.lastScanAt=Date.now();s()}function n(){const t=e();t.fontFamilies=c();const r=l();t.localAssetCount=r?Object.keys(r).length:null}export async function rescan(){const t=e();if(t.captureDisabled)return getScanStatus();if(t.scanPromise)return t.scanPromise;t.scanPromise=h();try{return await t.scanPromise}finally{t.scanPromise=void 0}}async function h(){const t=e();i();installAssetCapture();a();n();await p();t.lastScanAt=Date.now();s();void u();return getScanStatus()}export function getScanStatus(){const t=e();if(t.mirrorScanStatus)return t.mirrorScanStatus;let r=0;for(const o of t.records)if(o.registryId!=null)r++;return{registryAvailable:t.registryAvailable,patched:t.patched,registryCount:r,graphSupported:t.graphSupported||m()!=null,graphCount:t.graphCount,graphError:t.graphError,graphFetchInFlight:t.graphFetchInFlight,graphFetchStartedAt:t.graphFetchStartedAt??null,lastScanAt:t.lastScanAt,measuring:t.measuring,measuredCount:t.measuredCount,fontFamilies:t.fontFamilies,localAssetCount:t.localAssetCount}}
@@ -0,0 +1 @@
1
+ "use strict";import{assetsState as t}from"../state";import{invalidate as s}from"../store/assetStore";import{captureBrowserResource as u,scanBrowserAssets as n}from"./browserAssets";import{getLoadedFontFamilies as o}from"./expo";let r;export function installAssetCapture(){const e=t();if(typeof document==="undefined"||e.captureDisabled||e.installed)return;e.installed=true;e.registryAvailable=true;if(typeof PerformanceObserver!=="undefined"){r=new PerformanceObserver(a=>{if(t().captureDisabled){stopBrowserAssetCapture();return}a.getEntries().forEach(i=>u(i))});try{r.observe({type:"resource",buffered:true});e.patched=true}catch{r.disconnect();r=void 0}}n();e.fontFamilies=o();s()}export function stopBrowserAssetCapture(){r?.disconnect();r=void 0;t().installed=false;t().patched=false}export async function rescan(){installAssetCapture();n();t().fontFamilies=o();s();return getScanStatus()}export function getScanStatus(){const e=t();return e.mirrorScanStatus??{registryAvailable:e.registryAvailable,patched:e.patched,registryCount:e.records.filter(a=>a.loaded).length,graphSupported:e.graphSupported,graphCount:e.graphCount,graphError:null,graphFetchInFlight:false,graphFetchStartedAt:null,lastScanAt:e.lastScanAt,measuring:false,measuredCount:e.measuredCount,fontFamilies:e.fontFamilies,localAssetCount:null,browser:true}}
@@ -1,18 +1 @@
1
- "use strict";
2
-
3
- /** Identify Buoy-owned resources by package location, never by asset name. */
4
- export function isBuoyAssetPath(value) {
5
- if (!value) return false;
6
- let path = value;
7
- try {
8
- path = decodeURIComponent(path);
9
- } catch {
10
- // Keep readable path segments when an unrelated escape is malformed.
11
- }
12
- path = path.replace(/\\/g, "/");
13
- return /(?:^|\/)node_modules\/@buoy-gg\/[^/]+(?:\/|$)/.test(path) || /(?:^|\/)buoy-packages\/packages\/[^/]+(?:\/|$)/.test(path) || /(?:^|\/)packages\/floating-tools-core\/(?:src|lib\/(?:module|commonjs))\/icons\/assets(?:\/|$)/.test(path);
14
- }
15
- export function isBuoyAsset(asset) {
16
- return [asset.key, asset.httpServerLocation, asset.fileSystemLocation, ...(asset.files ?? [])].some(isBuoyAssetPath);
17
- }
18
- //# sourceMappingURL=isBuoyAsset.js.map
1
+ "use strict";export function isBuoyAssetPath(e){if(!e)return false;let t=e;try{t=decodeURIComponent(t)}catch{}t=t.replace(/\\/g,"/");return/(?:^|\/)node_modules\/@buoy-gg\/[^/]+(?:\/|$)/.test(t)||/(?:^|\/)buoy-packages\/packages\/[^/]+(?:\/|$)/.test(t)||/(?:^|\/)packages\/floating-tools-core\/(?:src|lib\/(?:module|commonjs))\/icons\/assets(?:\/|$)/.test(t)}export function isBuoyAsset(e){return[e.key,e.httpServerLocation,e.fileSystemLocation,...e.files??[]].some(isBuoyAssetPath)}