@buoy-gg/assets 7.0.41 → 7.0.43

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 (204) hide show
  1. package/README.md +12 -73
  2. package/bundlers/vite.mjs +1 -53
  3. package/lib/commonjs/autoCapture.js +1 -5
  4. package/lib/commonjs/autoCapture.web.js +1 -6
  5. package/lib/commonjs/capture/assetLifecycle.js +1 -11
  6. package/lib/commonjs/capture/assetLifecycle.web.js +1 -20
  7. package/lib/commonjs/capture/browserAssets.js +1 -83
  8. package/lib/commonjs/capture/expo.js +1 -46
  9. package/lib/commonjs/capture/expo.web.js +1 -19
  10. package/lib/commonjs/capture/install.js +1 -91
  11. package/lib/commonjs/capture/install.web.js +1 -75
  12. package/lib/commonjs/capture/isBuoyAsset.js +1 -23
  13. package/lib/commonjs/capture/measure.js +1 -187
  14. package/lib/commonjs/capture/metroGraph.js +1 -175
  15. package/lib/commonjs/capture/metroGraph.web.js +1 -27
  16. package/lib/commonjs/capture/registry.js +1 -127
  17. package/lib/commonjs/components/AssetDetail.js +1 -211
  18. package/lib/commonjs/components/AssetImage.js +1 -66
  19. package/lib/commonjs/components/AssetRow.js +1 -232
  20. package/lib/commonjs/components/AssetsFilterBar.js +1 -105
  21. package/lib/commonjs/components/AssetsHeader.js +1 -73
  22. package/lib/commonjs/components/AssetsIcon.js +1 -19
  23. package/lib/commonjs/components/AssetsListControls.js +1 -81
  24. package/lib/commonjs/components/AssetsModal.js +1 -378
  25. package/lib/commonjs/components/ScanNotice.js +1 -86
  26. package/lib/commonjs/components/optionalExpoImage.js +1 -16
  27. package/lib/commonjs/components/optionalExpoImage.web.js +1 -10
  28. package/lib/commonjs/export.js +1 -62
  29. package/lib/commonjs/format.js +1 -59
  30. package/lib/commonjs/hooks/useAssetRecords.js +1 -22
  31. package/lib/commonjs/hooks/useAssetScanStatus.js +1 -28
  32. package/lib/commonjs/index.js +1 -294
  33. package/lib/commonjs/preset.js +1 -39
  34. package/lib/commonjs/remote.js +1 -68
  35. package/lib/commonjs/state.js +1 -51
  36. package/lib/commonjs/store/assetStore.js +1 -256
  37. package/lib/commonjs/store/baseline.js +1 -175
  38. package/lib/commonjs/store/insights.js +1 -120
  39. package/lib/commonjs/sync/assetsSyncAdapter.js +1 -157
  40. package/lib/commonjs/types.js +0 -1
  41. package/lib/commonjs/utils/deviceScale.js +1 -50
  42. package/lib/commonjs/utils/testIDs.js +1 -110
  43. package/lib/module/autoCapture.js +1 -5
  44. package/lib/module/autoCapture.web.js +1 -5
  45. package/lib/module/capture/assetLifecycle.js +1 -7
  46. package/lib/module/capture/assetLifecycle.web.js +1 -16
  47. package/lib/module/capture/browserAssets.js +1 -75
  48. package/lib/module/capture/expo.js +1 -41
  49. package/lib/module/capture/expo.web.js +1 -14
  50. package/lib/module/capture/install.js +1 -85
  51. package/lib/module/capture/install.web.js +1 -68
  52. package/lib/module/capture/isBuoyAsset.js +1 -18
  53. package/lib/module/capture/measure.js +1 -180
  54. package/lib/module/capture/metroGraph.js +1 -168
  55. package/lib/module/capture/metroGraph.web.js +1 -21
  56. package/lib/module/capture/registry.js +1 -120
  57. package/lib/module/components/AssetDetail.js +1 -207
  58. package/lib/module/components/AssetImage.js +1 -62
  59. package/lib/module/components/AssetRow.js +1 -228
  60. package/lib/module/components/AssetsFilterBar.js +1 -101
  61. package/lib/module/components/AssetsHeader.js +1 -69
  62. package/lib/module/components/AssetsIcon.js +1 -12
  63. package/lib/module/components/AssetsListControls.js +1 -77
  64. package/lib/module/components/AssetsModal.js +1 -373
  65. package/lib/module/components/ScanNotice.js +1 -82
  66. package/lib/module/components/optionalExpoImage.js +1 -12
  67. package/lib/module/components/optionalExpoImage.web.js +1 -6
  68. package/lib/module/export.js +1 -57
  69. package/lib/module/format.js +1 -51
  70. package/lib/module/hooks/useAssetRecords.js +1 -18
  71. package/lib/module/hooks/useAssetScanStatus.js +1 -23
  72. package/lib/module/index.js +1 -64
  73. package/lib/module/preset.js +1 -35
  74. package/lib/module/remote.js +1 -61
  75. package/lib/module/state.js +1 -47
  76. package/lib/module/store/assetStore.js +1 -240
  77. package/lib/module/store/baseline.js +1 -167
  78. package/lib/module/store/insights.js +1 -116
  79. package/lib/module/sync/assetsSyncAdapter.js +1 -153
  80. package/lib/module/types.js +0 -1
  81. package/lib/module/utils/deviceScale.js +1 -46
  82. package/lib/module/utils/testIDs.js +1 -99
  83. package/lib/web/index.mjs +3 -4
  84. package/package.json +3 -8
  85. package/lib/commonjs/autoCapture.js.map +0 -1
  86. package/lib/commonjs/autoCapture.web.js.map +0 -1
  87. package/lib/commonjs/capture/assetLifecycle.js.map +0 -1
  88. package/lib/commonjs/capture/assetLifecycle.web.js.map +0 -1
  89. package/lib/commonjs/capture/browserAssets.js.map +0 -1
  90. package/lib/commonjs/capture/expo.js.map +0 -1
  91. package/lib/commonjs/capture/expo.web.js.map +0 -1
  92. package/lib/commonjs/capture/install.js.map +0 -1
  93. package/lib/commonjs/capture/install.web.js.map +0 -1
  94. package/lib/commonjs/capture/isBuoyAsset.js.map +0 -1
  95. package/lib/commonjs/capture/measure.js.map +0 -1
  96. package/lib/commonjs/capture/metroGraph.js.map +0 -1
  97. package/lib/commonjs/capture/metroGraph.web.js.map +0 -1
  98. package/lib/commonjs/capture/registry.js.map +0 -1
  99. package/lib/commonjs/components/AssetDetail.js.map +0 -1
  100. package/lib/commonjs/components/AssetImage.js.map +0 -1
  101. package/lib/commonjs/components/AssetRow.js.map +0 -1
  102. package/lib/commonjs/components/AssetsFilterBar.js.map +0 -1
  103. package/lib/commonjs/components/AssetsHeader.js.map +0 -1
  104. package/lib/commonjs/components/AssetsIcon.js.map +0 -1
  105. package/lib/commonjs/components/AssetsListControls.js.map +0 -1
  106. package/lib/commonjs/components/AssetsModal.js.map +0 -1
  107. package/lib/commonjs/components/ScanNotice.js.map +0 -1
  108. package/lib/commonjs/components/optionalExpoImage.js.map +0 -1
  109. package/lib/commonjs/components/optionalExpoImage.web.js.map +0 -1
  110. package/lib/commonjs/export.js.map +0 -1
  111. package/lib/commonjs/format.js.map +0 -1
  112. package/lib/commonjs/hooks/useAssetRecords.js.map +0 -1
  113. package/lib/commonjs/hooks/useAssetScanStatus.js.map +0 -1
  114. package/lib/commonjs/index.js.map +0 -1
  115. package/lib/commonjs/preset.js.map +0 -1
  116. package/lib/commonjs/remote.js.map +0 -1
  117. package/lib/commonjs/state.js.map +0 -1
  118. package/lib/commonjs/store/assetStore.js.map +0 -1
  119. package/lib/commonjs/store/baseline.js.map +0 -1
  120. package/lib/commonjs/store/insights.js.map +0 -1
  121. package/lib/commonjs/sync/assetsSyncAdapter.js.map +0 -1
  122. package/lib/commonjs/types.js.map +0 -1
  123. package/lib/commonjs/utils/deviceScale.js.map +0 -1
  124. package/lib/commonjs/utils/testIDs.js.map +0 -1
  125. package/lib/module/autoCapture.js.map +0 -1
  126. package/lib/module/autoCapture.web.js.map +0 -1
  127. package/lib/module/capture/assetLifecycle.js.map +0 -1
  128. package/lib/module/capture/assetLifecycle.web.js.map +0 -1
  129. package/lib/module/capture/browserAssets.js.map +0 -1
  130. package/lib/module/capture/expo.js.map +0 -1
  131. package/lib/module/capture/expo.web.js.map +0 -1
  132. package/lib/module/capture/install.js.map +0 -1
  133. package/lib/module/capture/install.web.js.map +0 -1
  134. package/lib/module/capture/isBuoyAsset.js.map +0 -1
  135. package/lib/module/capture/measure.js.map +0 -1
  136. package/lib/module/capture/metroGraph.js.map +0 -1
  137. package/lib/module/capture/metroGraph.web.js.map +0 -1
  138. package/lib/module/capture/registry.js.map +0 -1
  139. package/lib/module/components/AssetDetail.js.map +0 -1
  140. package/lib/module/components/AssetImage.js.map +0 -1
  141. package/lib/module/components/AssetRow.js.map +0 -1
  142. package/lib/module/components/AssetsFilterBar.js.map +0 -1
  143. package/lib/module/components/AssetsHeader.js.map +0 -1
  144. package/lib/module/components/AssetsIcon.js.map +0 -1
  145. package/lib/module/components/AssetsListControls.js.map +0 -1
  146. package/lib/module/components/AssetsModal.js.map +0 -1
  147. package/lib/module/components/ScanNotice.js.map +0 -1
  148. package/lib/module/components/optionalExpoImage.js.map +0 -1
  149. package/lib/module/components/optionalExpoImage.web.js.map +0 -1
  150. package/lib/module/export.js.map +0 -1
  151. package/lib/module/format.js.map +0 -1
  152. package/lib/module/hooks/useAssetRecords.js.map +0 -1
  153. package/lib/module/hooks/useAssetScanStatus.js.map +0 -1
  154. package/lib/module/index.js.map +0 -1
  155. package/lib/module/preset.js.map +0 -1
  156. package/lib/module/remote.js.map +0 -1
  157. package/lib/module/state.js.map +0 -1
  158. package/lib/module/store/assetStore.js.map +0 -1
  159. package/lib/module/store/baseline.js.map +0 -1
  160. package/lib/module/store/insights.js.map +0 -1
  161. package/lib/module/sync/assetsSyncAdapter.js.map +0 -1
  162. package/lib/module/types.js.map +0 -1
  163. package/lib/module/utils/deviceScale.js.map +0 -1
  164. package/lib/module/utils/testIDs.js.map +0 -1
  165. package/lib/typescript/autoCapture.d.ts.map +0 -1
  166. package/lib/typescript/autoCapture.web.d.ts.map +0 -1
  167. package/lib/typescript/capture/assetLifecycle.d.ts.map +0 -1
  168. package/lib/typescript/capture/assetLifecycle.web.d.ts.map +0 -1
  169. package/lib/typescript/capture/browserAssets.d.ts.map +0 -1
  170. package/lib/typescript/capture/expo.d.ts.map +0 -1
  171. package/lib/typescript/capture/expo.web.d.ts.map +0 -1
  172. package/lib/typescript/capture/install.d.ts.map +0 -1
  173. package/lib/typescript/capture/install.web.d.ts.map +0 -1
  174. package/lib/typescript/capture/isBuoyAsset.d.ts.map +0 -1
  175. package/lib/typescript/capture/measure.d.ts.map +0 -1
  176. package/lib/typescript/capture/metroGraph.d.ts.map +0 -1
  177. package/lib/typescript/capture/metroGraph.web.d.ts.map +0 -1
  178. package/lib/typescript/capture/registry.d.ts.map +0 -1
  179. package/lib/typescript/components/AssetDetail.d.ts.map +0 -1
  180. package/lib/typescript/components/AssetImage.d.ts.map +0 -1
  181. package/lib/typescript/components/AssetRow.d.ts.map +0 -1
  182. package/lib/typescript/components/AssetsFilterBar.d.ts.map +0 -1
  183. package/lib/typescript/components/AssetsHeader.d.ts.map +0 -1
  184. package/lib/typescript/components/AssetsIcon.d.ts.map +0 -1
  185. package/lib/typescript/components/AssetsListControls.d.ts.map +0 -1
  186. package/lib/typescript/components/AssetsModal.d.ts.map +0 -1
  187. package/lib/typescript/components/ScanNotice.d.ts.map +0 -1
  188. package/lib/typescript/components/optionalExpoImage.d.ts.map +0 -1
  189. package/lib/typescript/components/optionalExpoImage.web.d.ts.map +0 -1
  190. package/lib/typescript/export.d.ts.map +0 -1
  191. package/lib/typescript/format.d.ts.map +0 -1
  192. package/lib/typescript/hooks/useAssetRecords.d.ts.map +0 -1
  193. package/lib/typescript/hooks/useAssetScanStatus.d.ts.map +0 -1
  194. package/lib/typescript/index.d.ts.map +0 -1
  195. package/lib/typescript/preset.d.ts.map +0 -1
  196. package/lib/typescript/remote.d.ts.map +0 -1
  197. package/lib/typescript/state.d.ts.map +0 -1
  198. package/lib/typescript/store/assetStore.d.ts.map +0 -1
  199. package/lib/typescript/store/baseline.d.ts.map +0 -1
  200. package/lib/typescript/store/insights.d.ts.map +0 -1
  201. package/lib/typescript/sync/assetsSyncAdapter.d.ts.map +0 -1
  202. package/lib/typescript/types.d.ts.map +0 -1
  203. package/lib/typescript/utils/deviceScale.d.ts.map +0 -1
  204. 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}`}
@@ -1,5 +1 @@
1
- "use strict";
2
-
3
- import { installAssetCapture } from './capture/install';
4
- installAssetCapture();
5
- //# sourceMappingURL=autoCapture.js.map
1
+ "use strict";import{installAssetCapture as t}from"./capture/install";t();
@@ -1,5 +1 @@
1
- "use strict";
2
-
3
- // Browser capture starts when the tool host mounts.
4
- export {};
5
- //# sourceMappingURL=autoCapture.web.js.map
1
+ "use strict";export{};
@@ -1,7 +1 @@
1
- "use strict";
2
-
3
- /** Native asset capture starts when the package is imported. */
4
- export function startBrowserAssetCapture() {
5
- return () => {};
6
- }
7
- //# sourceMappingURL=assetLifecycle.js.map
1
+ "use strict";export function startBrowserAssetCapture(){return()=>{}}
@@ -1,16 +1 @@
1
- "use strict";
2
-
3
- import { installAssetCapture, stopBrowserAssetCapture } from './install.web';
4
- let owners = 0;
5
- export function startBrowserAssetCapture() {
6
- if (typeof document === 'undefined') return () => {};
7
- if (++owners === 1) installAssetCapture();
8
- let active = true;
9
- return () => {
10
- if (active) {
11
- active = false;
12
- if (--owners === 0) stopBrowserAssetCapture();
13
- }
14
- };
15
- }
16
- //# sourceMappingURL=assetLifecycle.web.js.map
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()}}}
@@ -1,75 +1 @@
1
- "use strict";
2
-
3
- import { assetsState } from '../state';
4
- import { upsertRecord, updateRecord } from '../store/assetStore';
5
- let manifest = [];
6
- export function registerBrowserAssetManifest(assets) {
7
- manifest = assets;
8
- if (typeof document !== 'undefined') scanBrowserAssets();
9
- }
10
- export function getBrowserAssetManifest() {
11
- return manifest;
12
- }
13
- export async function loadBrowserAssetManifest(url) {
14
- const response = await fetch(url);
15
- if (!response.ok) throw new Error(`Asset manifest returned HTTP ${response.status}.`);
16
- const assets = await response.json();
17
- if (!Array.isArray(assets) || assets.some(asset => !asset || typeof asset.url !== 'string')) throw new Error('An asset manifest must contain an array of assets with URL strings.');
18
- registerBrowserAssetManifest(assets);
19
- }
20
- function upsert(asset, loaded) {
21
- let url;
22
- try {
23
- url = new URL(asset.url, document.baseURI);
24
- } catch {
25
- return;
26
- }
27
- const filename = url.pathname.split('/').pop() ?? '';
28
- const type = filename.includes('.') ? filename.split('.').pop().toLowerCase() : 'other';
29
- const record = upsertRecord({
30
- key: url.href,
31
- name: filename.slice(0, -(type.length + 1)) || filename,
32
- type,
33
- origin: loaded ? 'browser' : 'graph',
34
- resolvedUri: url.href,
35
- resolvedScale: 1,
36
- scales: [1],
37
- hash: asset.hash,
38
- loaded,
39
- width: asset.width,
40
- height: asset.height
41
- });
42
- if (record && asset.bytes !== undefined && asset.bytes >= 0) updateRecord(record.id, {
43
- sizeBytes: asset.bytes,
44
- sizesByScale: {
45
- '1': asset.bytes
46
- },
47
- sizeSource: 'measured'
48
- });
49
- }
50
- export function captureBrowserResource(entry) {
51
- // Fetch/XHR traffic belongs to Network. Styles, fonts and media belong here.
52
- if (entry.initiatorType === 'fetch' || entry.initiatorType === 'xmlhttprequest') return;
53
- upsert({
54
- url: entry.name,
55
- bytes: entry.encodedBodySize > 0 ? entry.encodedBodySize : undefined
56
- }, true);
57
- }
58
- export function scanBrowserAssets() {
59
- if (typeof document === 'undefined' || assetsState().captureDisabled) return;
60
- manifest.forEach(asset => upsert(asset, false));
61
- performance.getEntriesByType('resource').forEach(entry => captureBrowserResource(entry));
62
- document.querySelectorAll('img').forEach(image => {
63
- if (!image.closest('[data-buoy-root]') && image.currentSrc) upsert({
64
- url: image.currentSrc,
65
- width: image.naturalWidth || undefined,
66
- height: image.naturalHeight || undefined
67
- }, image.complete && image.naturalWidth > 0);
68
- });
69
- const state = assetsState();
70
- state.graphSupported = manifest.length > 0;
71
- state.graphCount = manifest.length > 0 ? manifest.length : null;
72
- state.measuredCount = state.records.filter(record => record.sizeBytes !== undefined).length;
73
- state.lastScanAt = Date.now();
74
- }
75
- //# sourceMappingURL=browserAssets.js.map
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}}
@@ -1,14 +1 @@
1
- "use strict";
2
-
3
- export function getLoadedFontFamilies() {
4
- if (typeof document === 'undefined' || !document.fonts) return [];
5
- const families = new Set();
6
- document.fonts.forEach(face => {
7
- if (face.status === 'loaded') families.add(face.family.replace(/^['"]|['"]$/g, ''));
8
- });
9
- return [...families].sort();
10
- }
11
- export function getLocalAssets() {
12
- return null;
13
- }
14
- //# sourceMappingURL=expo.web.js.map
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}}
@@ -1,68 +1 @@
1
- "use strict";
2
-
3
- import { assetsState } from '../state';
4
- import { invalidate } from '../store/assetStore';
5
- import { captureBrowserResource, scanBrowserAssets } from './browserAssets';
6
- import { getLoadedFontFamilies } from './expo';
7
- let observer;
8
- export function installAssetCapture() {
9
- const state = assetsState();
10
- if (typeof document === 'undefined' || state.captureDisabled || state.installed) return;
11
- state.installed = true;
12
- state.registryAvailable = true;
13
- if (typeof PerformanceObserver !== 'undefined') {
14
- observer = new PerformanceObserver(list => {
15
- if (assetsState().captureDisabled) {
16
- stopBrowserAssetCapture();
17
- return;
18
- }
19
- list.getEntries().forEach(entry => captureBrowserResource(entry));
20
- });
21
- try {
22
- observer.observe({
23
- type: 'resource',
24
- buffered: true
25
- });
26
- state.patched = true;
27
- } catch {
28
- observer.disconnect();
29
- observer = undefined;
30
- }
31
- }
32
- scanBrowserAssets();
33
- state.fontFamilies = getLoadedFontFamilies();
34
- invalidate();
35
- }
36
- export function stopBrowserAssetCapture() {
37
- observer?.disconnect();
38
- observer = undefined;
39
- assetsState().installed = false;
40
- assetsState().patched = false;
41
- }
42
- export async function rescan() {
43
- installAssetCapture();
44
- scanBrowserAssets();
45
- assetsState().fontFamilies = getLoadedFontFamilies();
46
- invalidate();
47
- return getScanStatus();
48
- }
49
- export function getScanStatus() {
50
- const state = assetsState();
51
- return state.mirrorScanStatus ?? {
52
- registryAvailable: state.registryAvailable,
53
- patched: state.patched,
54
- registryCount: state.records.filter(record => record.loaded).length,
55
- graphSupported: state.graphSupported,
56
- graphCount: state.graphCount,
57
- graphError: null,
58
- graphFetchInFlight: false,
59
- graphFetchStartedAt: null,
60
- lastScanAt: state.lastScanAt,
61
- measuring: false,
62
- measuredCount: state.measuredCount,
63
- fontFamilies: state.fontFamilies,
64
- localAssetCount: null,
65
- browser: true
66
- };
67
- }
68
- //# sourceMappingURL=install.web.js.map
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}}