@buoy-gg/assets 7.0.38 → 7.0.39

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 (161) hide show
  1. package/lib/commonjs/capture/expo.js +46 -1
  2. package/lib/commonjs/capture/expo.js.map +1 -0
  3. package/lib/commonjs/capture/install.js +91 -1
  4. package/lib/commonjs/capture/install.js.map +1 -0
  5. package/lib/commonjs/capture/isBuoyAsset.js +23 -1
  6. package/lib/commonjs/capture/isBuoyAsset.js.map +1 -0
  7. package/lib/commonjs/capture/measure.js +186 -1
  8. package/lib/commonjs/capture/measure.js.map +1 -0
  9. package/lib/commonjs/capture/metroGraph.js +175 -1
  10. package/lib/commonjs/capture/metroGraph.js.map +1 -0
  11. package/lib/commonjs/capture/registry.js +127 -1
  12. package/lib/commonjs/capture/registry.js.map +1 -0
  13. package/lib/commonjs/components/AssetDetail.js +211 -1
  14. package/lib/commonjs/components/AssetDetail.js.map +1 -0
  15. package/lib/commonjs/components/AssetImage.js +66 -1
  16. package/lib/commonjs/components/AssetImage.js.map +1 -0
  17. package/lib/commonjs/components/AssetRow.js +232 -1
  18. package/lib/commonjs/components/AssetRow.js.map +1 -0
  19. package/lib/commonjs/components/AssetsFilterBar.js +105 -1
  20. package/lib/commonjs/components/AssetsFilterBar.js.map +1 -0
  21. package/lib/commonjs/components/AssetsHeader.js +73 -1
  22. package/lib/commonjs/components/AssetsHeader.js.map +1 -0
  23. package/lib/commonjs/components/AssetsIcon.js +19 -1
  24. package/lib/commonjs/components/AssetsIcon.js.map +1 -0
  25. package/lib/commonjs/components/AssetsListControls.js +81 -1
  26. package/lib/commonjs/components/AssetsListControls.js.map +1 -0
  27. package/lib/commonjs/components/AssetsModal.js +378 -1
  28. package/lib/commonjs/components/AssetsModal.js.map +1 -0
  29. package/lib/commonjs/components/ScanNotice.js +85 -1
  30. package/lib/commonjs/components/ScanNotice.js.map +1 -0
  31. package/lib/commonjs/components/optionalExpoImage.js +16 -1
  32. package/lib/commonjs/components/optionalExpoImage.js.map +1 -0
  33. package/lib/commonjs/components/optionalExpoImage.web.js +11 -1
  34. package/lib/commonjs/components/optionalExpoImage.web.js.map +1 -0
  35. package/lib/commonjs/export.js +62 -1
  36. package/lib/commonjs/export.js.map +1 -0
  37. package/lib/commonjs/format.js +59 -1
  38. package/lib/commonjs/format.js.map +1 -0
  39. package/lib/commonjs/hooks/useAssetRecords.js +22 -1
  40. package/lib/commonjs/hooks/useAssetRecords.js.map +1 -0
  41. package/lib/commonjs/hooks/useAssetScanStatus.js +28 -1
  42. package/lib/commonjs/hooks/useAssetScanStatus.js.map +1 -0
  43. package/lib/commonjs/index.js +313 -1
  44. package/lib/commonjs/index.js.map +1 -0
  45. package/lib/commonjs/preset.js +39 -1
  46. package/lib/commonjs/preset.js.map +1 -0
  47. package/lib/commonjs/remote.js +68 -1
  48. package/lib/commonjs/remote.js.map +1 -0
  49. package/lib/commonjs/state.js +51 -1
  50. package/lib/commonjs/state.js.map +1 -0
  51. package/lib/commonjs/store/assetStore.js +256 -1
  52. package/lib/commonjs/store/assetStore.js.map +1 -0
  53. package/lib/commonjs/store/baseline.js +175 -1
  54. package/lib/commonjs/store/baseline.js.map +1 -0
  55. package/lib/commonjs/store/insights.js +120 -1
  56. package/lib/commonjs/store/insights.js.map +1 -0
  57. package/lib/commonjs/sync/assetsSyncAdapter.js +157 -1
  58. package/lib/commonjs/sync/assetsSyncAdapter.js.map +1 -0
  59. package/lib/commonjs/types.js +2 -1
  60. package/lib/commonjs/types.js.map +1 -0
  61. package/lib/commonjs/utils/deviceScale.js +50 -1
  62. package/lib/commonjs/utils/deviceScale.js.map +1 -0
  63. package/lib/commonjs/utils/testIDs.js +110 -1
  64. package/lib/commonjs/utils/testIDs.js.map +1 -0
  65. package/lib/module/capture/expo.js +41 -1
  66. package/lib/module/capture/expo.js.map +1 -0
  67. package/lib/module/capture/install.js +85 -1
  68. package/lib/module/capture/install.js.map +1 -0
  69. package/lib/module/capture/isBuoyAsset.js +18 -1
  70. package/lib/module/capture/isBuoyAsset.js.map +1 -0
  71. package/lib/module/capture/measure.js +179 -1
  72. package/lib/module/capture/measure.js.map +1 -0
  73. package/lib/module/capture/metroGraph.js +168 -1
  74. package/lib/module/capture/metroGraph.js.map +1 -0
  75. package/lib/module/capture/registry.js +120 -1
  76. package/lib/module/capture/registry.js.map +1 -0
  77. package/lib/module/components/AssetDetail.js +207 -1
  78. package/lib/module/components/AssetDetail.js.map +1 -0
  79. package/lib/module/components/AssetImage.js +62 -1
  80. package/lib/module/components/AssetImage.js.map +1 -0
  81. package/lib/module/components/AssetRow.js +228 -1
  82. package/lib/module/components/AssetRow.js.map +1 -0
  83. package/lib/module/components/AssetsFilterBar.js +101 -1
  84. package/lib/module/components/AssetsFilterBar.js.map +1 -0
  85. package/lib/module/components/AssetsHeader.js +69 -1
  86. package/lib/module/components/AssetsHeader.js.map +1 -0
  87. package/lib/module/components/AssetsIcon.js +12 -1
  88. package/lib/module/components/AssetsIcon.js.map +1 -0
  89. package/lib/module/components/AssetsListControls.js +77 -1
  90. package/lib/module/components/AssetsListControls.js.map +1 -0
  91. package/lib/module/components/AssetsModal.js +373 -1
  92. package/lib/module/components/AssetsModal.js.map +1 -0
  93. package/lib/module/components/ScanNotice.js +81 -1
  94. package/lib/module/components/ScanNotice.js.map +1 -0
  95. package/lib/module/components/optionalExpoImage.js +12 -1
  96. package/lib/module/components/optionalExpoImage.js.map +1 -0
  97. package/lib/module/components/optionalExpoImage.web.js +7 -1
  98. package/lib/module/components/optionalExpoImage.web.js.map +1 -0
  99. package/lib/module/export.js +57 -1
  100. package/lib/module/export.js.map +1 -0
  101. package/lib/module/format.js +51 -1
  102. package/lib/module/format.js.map +1 -0
  103. package/lib/module/hooks/useAssetRecords.js +18 -1
  104. package/lib/module/hooks/useAssetRecords.js.map +1 -0
  105. package/lib/module/hooks/useAssetScanStatus.js +23 -1
  106. package/lib/module/hooks/useAssetScanStatus.js.map +1 -0
  107. package/lib/module/index.js +63 -1
  108. package/lib/module/index.js.map +1 -0
  109. package/lib/module/preset.js +35 -1
  110. package/lib/module/preset.js.map +1 -0
  111. package/lib/module/remote.js +61 -1
  112. package/lib/module/remote.js.map +1 -0
  113. package/lib/module/state.js +47 -1
  114. package/lib/module/state.js.map +1 -0
  115. package/lib/module/store/assetStore.js +240 -1
  116. package/lib/module/store/assetStore.js.map +1 -0
  117. package/lib/module/store/baseline.js +167 -1
  118. package/lib/module/store/baseline.js.map +1 -0
  119. package/lib/module/store/insights.js +116 -1
  120. package/lib/module/store/insights.js.map +1 -0
  121. package/lib/module/sync/assetsSyncAdapter.js +153 -1
  122. package/lib/module/sync/assetsSyncAdapter.js.map +1 -0
  123. package/lib/module/types.js +2 -1
  124. package/lib/module/types.js.map +1 -0
  125. package/lib/module/utils/deviceScale.js +46 -1
  126. package/lib/module/utils/deviceScale.js.map +1 -0
  127. package/lib/module/utils/testIDs.js +99 -1
  128. package/lib/module/utils/testIDs.js.map +1 -0
  129. package/lib/typescript/capture/expo.d.ts.map +1 -0
  130. package/lib/typescript/capture/install.d.ts.map +1 -0
  131. package/lib/typescript/capture/isBuoyAsset.d.ts.map +1 -0
  132. package/lib/typescript/capture/measure.d.ts.map +1 -0
  133. package/lib/typescript/capture/metroGraph.d.ts.map +1 -0
  134. package/lib/typescript/capture/registry.d.ts.map +1 -0
  135. package/lib/typescript/components/AssetDetail.d.ts.map +1 -0
  136. package/lib/typescript/components/AssetImage.d.ts.map +1 -0
  137. package/lib/typescript/components/AssetRow.d.ts.map +1 -0
  138. package/lib/typescript/components/AssetsFilterBar.d.ts.map +1 -0
  139. package/lib/typescript/components/AssetsHeader.d.ts.map +1 -0
  140. package/lib/typescript/components/AssetsIcon.d.ts.map +1 -0
  141. package/lib/typescript/components/AssetsListControls.d.ts.map +1 -0
  142. package/lib/typescript/components/AssetsModal.d.ts.map +1 -0
  143. package/lib/typescript/components/ScanNotice.d.ts.map +1 -0
  144. package/lib/typescript/components/optionalExpoImage.d.ts.map +1 -0
  145. package/lib/typescript/components/optionalExpoImage.web.d.ts.map +1 -0
  146. package/lib/typescript/export.d.ts.map +1 -0
  147. package/lib/typescript/format.d.ts.map +1 -0
  148. package/lib/typescript/hooks/useAssetRecords.d.ts.map +1 -0
  149. package/lib/typescript/hooks/useAssetScanStatus.d.ts.map +1 -0
  150. package/lib/typescript/index.d.ts.map +1 -0
  151. package/lib/typescript/preset.d.ts.map +1 -0
  152. package/lib/typescript/remote.d.ts.map +1 -0
  153. package/lib/typescript/state.d.ts.map +1 -0
  154. package/lib/typescript/store/assetStore.d.ts.map +1 -0
  155. package/lib/typescript/store/baseline.d.ts.map +1 -0
  156. package/lib/typescript/store/insights.d.ts.map +1 -0
  157. package/lib/typescript/sync/assetsSyncAdapter.d.ts.map +1 -0
  158. package/lib/typescript/types.d.ts.map +1 -0
  159. package/lib/typescript/utils/deviceScale.d.ts.map +1 -0
  160. package/lib/typescript/utils/testIDs.d.ts.map +1 -0
  161. package/package.json +2 -2
@@ -1 +1,127 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getRegistryModule=getRegistryModule,exports.patchRegisterAsset=patchRegisterAsset,exports.resolveRegistryAsset=resolveRegistryAsset,exports.upsertFromPackagerAsset=upsertFromPackagerAsset,exports.walkRegistry=walkRegistry;var _assetStore=require("../store/assetStore");let cachedRegistry;function getRegistryModule(){if(void 0!==cachedRegistry)return cachedRegistry;let e=null;try{e=require("@react-native/assets-registry/registry")}catch{try{e=require("react-native/Libraries/Image/AssetRegistry")}catch{e=null}}return cachedRegistry=e&&"function"==typeof e.getAssetByID?e:null,cachedRegistry}function resolveRegistryAsset(e){try{const{Image:t}=require("react-native"),r=t.resolveAssetSource(e);if(r&&"string"==typeof r.uri)return{uri:r.uri,scale:r.scale??1}}catch{}return null}function upsertFromPackagerAsset(e,t){const r=resolveRegistryAsset(e);return(0,_assetStore.upsertRecord)({key:(0,_assetStore.assetKey)(t.httpServerLocation,t.name,t.type),name:t.name,type:t.type,origin:"registry",registryId:e,hash:t.hash,httpServerLocation:t.httpServerLocation,width:t.width??void 0,height:t.height??void 0,scales:t.scales,resolvedUri:r?.uri,resolvedScale:r?.scale,loaded:!0})}function walkRegistry(){const e=getRegistryModule();if(!e)return 0;let t=0;for(;;){const r=e.getAssetByID(t+1);if(!r)break;t++,upsertFromPackagerAsset(t,r)}return t}const PATCH_MARKER="__buoyAssetsPatched";function patchRegisterAsset(){const e=getRegistryModule();if(!e)return!1;const t=e.registerAsset;if(t[PATCH_MARKER])return!0;const r=r=>{const s=t.call(e,r);try{upsertFromPackagerAsset(s,r)}catch{}return s};r[PATCH_MARKER]=!0;try{e.registerAsset=r}catch{return!1}return!0}
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getRegistryModule = getRegistryModule;
7
+ exports.patchRegisterAsset = patchRegisterAsset;
8
+ exports.resolveRegistryAsset = resolveRegistryAsset;
9
+ exports.upsertFromPackagerAsset = upsertFromPackagerAsset;
10
+ exports.walkRegistry = walkRegistry;
11
+ var _assetStore = require("../store/assetStore");
12
+ /**
13
+ * Runtime access to @react-native/assets-registry.
14
+ *
15
+ * Asset ids are contiguous 1..N (`assets.push` return value), so a plain
16
+ * getAssetByID walk enumerates every asset registered so far — including
17
+ * everything registered BEFORE this tool was evaluated. That's why, unlike
18
+ * the images tool, there is no "must be the first import" requirement here:
19
+ * the walk backfills whatever the patch missed.
20
+ *
21
+ * registerAsset is patched (plain non-frozen CommonJS export, looked up at
22
+ * call time by Metro's generated asset modules) purely for LIVE updates as
23
+ * lazily-required assets register later.
24
+ */
25
+
26
+ /** Runtime shape of a registry entry (fileSystemLocation/files are stripped by Metro). */
27
+
28
+ let cachedRegistry;
29
+ function getRegistryModule() {
30
+ if (cachedRegistry !== undefined) return cachedRegistry;
31
+ let mod = null;
32
+ try {
33
+ mod = require("@react-native/assets-registry/registry");
34
+ } catch {
35
+ // Old RN layouts (< 0.72) don't ship @react-native/assets-registry as a
36
+ // resolvable package — the registry only exists at this deep path. RN's
37
+ // deep-import deprecation warning fires when this executes, but it only
38
+ // executes on those old layouts, where there is no other way in.
39
+ try {
40
+ mod = require("react-native/Libraries/Image/AssetRegistry");
41
+ } catch {
42
+ mod = null;
43
+ }
44
+ }
45
+ cachedRegistry = mod && typeof mod.getAssetByID === "function" ? mod : null;
46
+ return cachedRegistry;
47
+ }
48
+
49
+ /** resolveAssetSource(id) → this environment's URI (dev URL / file:// / res id). */
50
+ function resolveRegistryAsset(registryId) {
51
+ try {
52
+ const {
53
+ Image
54
+ } = require("react-native");
55
+ const resolved = Image.resolveAssetSource(registryId);
56
+ if (resolved && typeof resolved.uri === "string") {
57
+ return {
58
+ uri: resolved.uri,
59
+ scale: resolved.scale ?? 1
60
+ };
61
+ }
62
+ } catch {
63
+ // resolution is enrichment — never let it break the walk
64
+ }
65
+ return null;
66
+ }
67
+ function upsertFromPackagerAsset(registryId, asset) {
68
+ const resolved = resolveRegistryAsset(registryId);
69
+ return (0, _assetStore.upsertRecord)({
70
+ key: (0, _assetStore.assetKey)(asset.httpServerLocation, asset.name, asset.type),
71
+ name: asset.name,
72
+ type: asset.type,
73
+ origin: "registry",
74
+ registryId,
75
+ hash: asset.hash,
76
+ httpServerLocation: asset.httpServerLocation,
77
+ width: asset.width ?? undefined,
78
+ height: asset.height ?? undefined,
79
+ scales: asset.scales,
80
+ resolvedUri: resolved?.uri,
81
+ resolvedScale: resolved?.scale,
82
+ loaded: true
83
+ });
84
+ }
85
+
86
+ /** Enumerate every asset registered so far. Returns the highest id seen. */
87
+ function walkRegistry() {
88
+ const registry = getRegistryModule();
89
+ if (!registry) return 0;
90
+ let id = 0;
91
+ for (;;) {
92
+ const asset = registry.getAssetByID(id + 1);
93
+ if (!asset) break;
94
+ id++;
95
+ upsertFromPackagerAsset(id, asset);
96
+ }
97
+ return id;
98
+ }
99
+ const PATCH_MARKER = "__buoyAssetsPatched";
100
+
101
+ /**
102
+ * Wrap registerAsset so future registrations stream in live. Safe to call
103
+ * more than once (marker guard); the walk covers anything registered before.
104
+ */
105
+ function patchRegisterAsset() {
106
+ const registry = getRegistryModule();
107
+ if (!registry) return false;
108
+ const original = registry.registerAsset;
109
+ if (original[PATCH_MARKER]) return true;
110
+ const wrapped = asset => {
111
+ const id = original.call(registry, asset);
112
+ try {
113
+ upsertFromPackagerAsset(id, asset);
114
+ } catch {
115
+ // never break app asset registration
116
+ }
117
+ return id;
118
+ };
119
+ wrapped[PATCH_MARKER] = true;
120
+ try {
121
+ registry.registerAsset = wrapped;
122
+ } catch {
123
+ return false;
124
+ }
125
+ return true;
126
+ }
127
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_assetStore","require","cachedRegistry","getRegistryModule","undefined","mod","getAssetByID","resolveRegistryAsset","registryId","Image","resolved","resolveAssetSource","uri","scale","upsertFromPackagerAsset","asset","upsertRecord","key","assetKey","httpServerLocation","name","type","origin","hash","width","height","scales","resolvedUri","resolvedScale","loaded","walkRegistry","registry","id","PATCH_MARKER","patchRegisterAsset","original","registerAsset","wrapped","call"],"sourceRoot":"../../../src","sources":["capture/registry.ts"],"mappings":";;;;;;;;;;AAcA,IAAAA,WAAA,GAAAC,OAAA;AAdA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;;AAiBA,IAAIC,cAAiD;AAE9C,SAASC,iBAAiBA,CAAA,EAA0B;EACzD,IAAID,cAAc,KAAKE,SAAS,EAAE,OAAOF,cAAc;EACvD,IAAIG,GAA0B,GAAG,IAAI;EACrC,IAAI;IACFA,GAAG,GAAGJ,OAAO,CAAC,wCAAwC,CAAC;EACzD,CAAC,CAAC,MAAM;IACN;IACA;IACA;IACA;IACA,IAAI;MACFI,GAAG,GAAGJ,OAAO,CAAC,4CAA4C,CAAC;IAC7D,CAAC,CAAC,MAAM;MACNI,GAAG,GAAG,IAAI;IACZ;EACF;EACAH,cAAc,GACZG,GAAG,IAAI,OAAOA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EACV,CAAC,CAAC;AACJ;;AAEA;AACO,SAASC,YAAYA,CAAA,EAAW;EACrC,MAAMC,QAAQ,GAAG5B,iBAAiB,CAAC,CAAC;EACpC,IAAI,CAAC4B,QAAQ,EAAE,OAAO,CAAC;EACvB,IAAIC,EAAE,GAAG,CAAC;EACV,SAAS;IACP,MAAMjB,KAAK,GAAGgB,QAAQ,CAACzB,YAAY,CAAC0B,EAAE,GAAG,CAAC,CAAC;IAC3C,IAAI,CAACjB,KAAK,EAAE;IACZiB,EAAE,EAAE;IACJlB,uBAAuB,CAACkB,EAAE,EAAEjB,KAAK,CAAC;EACpC;EACA,OAAOiB,EAAE;AACX;AAEA,MAAMC,YAAY,GAAG,qBAAqB;;AAE1C;AACA;AACA;AACA;AACO,SAASC,kBAAkBA,CAAA,EAAY;EAC5C,MAAMH,QAAQ,GAAG5B,iBAAiB,CAAC,CAAC;EACpC,IAAI,CAAC4B,QAAQ,EAAE,OAAO,KAAK;EAC3B,MAAMI,QAAQ,GAAGJ,QAAQ,CAACK,aAAa;EACvC,IAAKD,QAAQ,CAAwCF,YAAY,CAAC,EAAE,OAAO,IAAI;EAC/E,MAAMI,OAAO,GAAItB,KAAoB,IAAa;IAChD,MAAMiB,EAAE,GAAGG,QAAQ,CAACG,IAAI,CAACP,QAAQ,EAAEhB,KAAK,CAAC;IACzC,IAAI;MACFD,uBAAuB,CAACkB,EAAE,EAAEjB,KAAK,CAAC;IACpC,CAAC,CAAC,MAAM;MACN;IAAA;IAEF,OAAOiB,EAAE;EACX,CAAC;EACAK,OAAO,CAAwCJ,YAAY,CAAC,GAAG,IAAI;EACpE,IAAI;IACFF,QAAQ,CAACK,aAAa,GAAGC,OAAO;EAClC,CAAC,CAAC,MAAM;IACN,OAAO,KAAK;EACd;EACA,OAAO,IAAI;AACb","ignoreList":[]}
@@ -1 +1,211 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AssetDetail=AssetDetail;var _reactNative=require("react-native"),_sharedUi=require("@buoy-gg/shared-ui"),_AssetImage=require("./AssetImage"),_format=require("../format"),_assetStore=require("../store/assetStore"),_testIDs=require("../utils/testIDs"),_jsxRuntime=require("react/jsx-runtime");function Row({label:e,value:t}){const s=(0,_testIDs.assetDetailRowTestID)(e);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.kvRow,testID:s,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.kvLabel,children:e}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.kvValue,selectable:!0,testID:`${s}-value`,children:t})]})}function Preview({record:e}){return"image"===e.kind?(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.previewBox,testID:_testIDs.ASSETS_TEST_IDS.detailPreview,children:(0,_jsxRuntime.jsx)(_AssetImage.AssetImage,{testID:"buoy-internal-assets-preview",record:e,style:styles.previewImage})}):"font"===e.kind?(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.previewBox,testID:_testIDs.ASSETS_TEST_IDS.detailFontPreview,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.fontPreview,{fontFamily:e.name}],children:"The quick brown fox jumps over the lazy dog 0123456789"})}):null}function AssetDetail({record:e,insights:t}){const s=[];t.neverLoaded.includes(e.id)&&s.push("Not observed in the runtime registry this app run. This does not prove the asset is unused."),t.scaleGaps.includes(e.id)&&s.push("Scale gap — no variant covers this device's pixel ratio"),t.webpCandidates.includes(e.id)&&s.push("WebP candidate — large png/jpeg, converting typically saves 20–40%");const i=t.duplicates.find(t=>t.ids.includes(e.id));i&&s.push(`Duplicate content — identical bytes shipped ${i.ids.length} times`),t.overDecode.includes(e.id)&&s.push("Decodes larger than 2× this entire screen — resize the source, no view can need this many pixels"),t.heavyGifs.includes(e.id)&&s.push("Heavy GIF — every frame decodes into memory; a video or Lottie is typically ~90% smaller"),t.heavyFonts.includes(e.id)&&s.push("Heavy font — likely an unsubset icon font; subsetting to used glyphs usually saves most of it"),t.scaleAnomalies.includes(e.id)&&s.push("Scale anomaly — a higher-resolution variant is smaller in bytes than a lower one; check the exports");const l=(0,_assetStore.estDecodedBytes)(e);return(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{style:styles.scroll,contentContainerStyle:styles.content,testID:_testIDs.ASSETS_TEST_IDS.detailScroll,children:[(0,_jsxRuntime.jsx)(Preview,{record:e}),s.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.findings,testID:_testIDs.ASSETS_TEST_IDS.detailFindings,children:s.map((e,t)=>(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.findingText,testID:(0,_testIDs.assetFindingTestID)(t),children:e},e))}):null,(0,_jsxRuntime.jsx)(Row,{label:"Name",value:`${e.name}.${e.type}`}),(0,_jsxRuntime.jsx)(Row,{label:"Kind",value:e.kind}),(0,_jsxRuntime.jsx)(Row,{label:"Status",value:e.loaded?"Loaded (registered at runtime)":"Not observed in the runtime registry"}),"image"===e.kind?(0,_jsxRuntime.jsx)(Row,{label:"Dimensions",value:`${(0,_format.formatDimensions)(e)} (logical)`}):null,"image"===e.kind&&e.scales.length?(0,_jsxRuntime.jsx)(Row,{label:"Scales",value:(0,_format.formatScales)(e.scales)}):null,e.sizesByScale?Object.entries(e.sizesByScale).map(([e,t])=>(0,_jsxRuntime.jsx)(Row,{label:`Size @${e}x`,value:(0,_format.formatBytes)(t)},e)):null,null!=e.sizeBytes&&"measured"===e.sizeSource?(0,_jsxRuntime.jsx)(Row,{label:"Total size",value:(0,_format.formatBytes)(e.sizeBytes)}):null,l>0?(0,_jsxRuntime.jsx)(Row,{label:"Decoded memory",value:`~${(0,_format.formatBytes)(l)} (RGBA)`}):null,null!=e.registryId?(0,_jsxRuntime.jsx)(Row,{label:"Registry id",value:String(e.registryId)}):null,e.hash?(0,_jsxRuntime.jsx)(Row,{label:"Hash",value:e.hash}):null,e.httpServerLocation?(0,_jsxRuntime.jsx)(Row,{label:"Location",value:e.httpServerLocation}):null,e.fileSystemLocation?(0,_jsxRuntime.jsx)(Row,{label:"Source dir",value:e.fileSystemLocation}):null,e.resolvedUri?(0,_jsxRuntime.jsx)(Row,{label:"Resolved URI",value:e.resolvedUri}):null]})}const styles=_reactNative.StyleSheet.create({scroll:{flex:1},content:{padding:12,gap:8},previewBox:{borderRadius:8,backgroundColor:_sharedUi.night.color.bg,padding:12,alignItems:"center",justifyContent:"center",minHeight:96},previewImage:{width:"100%",height:140},fontPreview:{color:_sharedUi.night.color.text,fontSize:16,textAlign:"center"},findings:{borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.border,backgroundColor:_sharedUi.night.color.surface,padding:10,gap:6},findingText:{color:_sharedUi.night.color.textSecondary,fontSize:11,lineHeight:15},kvRow:{gap:2},kvLabel:{color:_sharedUi.night.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5,textTransform:"uppercase"},kvValue:{color:_sharedUi.night.color.text,fontSize:12}});
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.AssetDetail = AssetDetail;
7
+ var _reactNative = require("react-native");
8
+ var _sharedUi = require("@buoy-gg/shared-ui");
9
+ var _AssetImage = require("./AssetImage");
10
+ var _format = require("../format");
11
+ var _assetStore = require("../store/assetStore");
12
+ var _testIDs = require("../utils/testIDs");
13
+ var _jsxRuntime = require("react/jsx-runtime");
14
+ /**
15
+ * AssetDetail — full metadata for one asset: preview, identity, dimensions,
16
+ * per-scale sizes, resolution info, and which audit findings apply.
17
+ *
18
+ * Image previews use registry ids or asset URLs, with optional expo-image for
19
+ * native SVGs; fonts render a pangram with fontFamily set to the asset name
20
+ * — a best-effort guess (family ≠ filename for many fonts) that falls back
21
+ * to the system font silently when it misses.
22
+ */
23
+
24
+ function Row({
25
+ label,
26
+ value
27
+ }) {
28
+ const testID = (0, _testIDs.assetDetailRowTestID)(label);
29
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
30
+ style: styles.kvRow,
31
+ testID: testID,
32
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
33
+ style: styles.kvLabel,
34
+ children: label
35
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
36
+ style: styles.kvValue,
37
+ selectable: true,
38
+ testID: `${testID}-value`,
39
+ children: value
40
+ })]
41
+ });
42
+ }
43
+ function Preview({
44
+ record
45
+ }) {
46
+ if (record.kind === "image") {
47
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
48
+ style: styles.previewBox,
49
+ testID: _testIDs.ASSETS_TEST_IDS.detailPreview,
50
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_AssetImage.AssetImage, {
51
+ testID: "buoy-internal-assets-preview",
52
+ record: record,
53
+ style: styles.previewImage
54
+ })
55
+ });
56
+ }
57
+ if (record.kind === "font") {
58
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
59
+ style: styles.previewBox,
60
+ testID: _testIDs.ASSETS_TEST_IDS.detailFontPreview,
61
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
62
+ style: [styles.fontPreview, {
63
+ fontFamily: record.name
64
+ }],
65
+ children: "The quick brown fox jumps over the lazy dog 0123456789"
66
+ })
67
+ });
68
+ }
69
+ return null;
70
+ }
71
+ function AssetDetail({
72
+ record,
73
+ insights
74
+ }) {
75
+ const findings = [];
76
+ if (insights.neverLoaded.includes(record.id)) {
77
+ findings.push("Not observed in the runtime registry this app run. This does not prove the asset is unused.");
78
+ }
79
+ if (insights.scaleGaps.includes(record.id)) {
80
+ findings.push("Scale gap — no variant covers this device's pixel ratio");
81
+ }
82
+ if (insights.webpCandidates.includes(record.id)) {
83
+ findings.push("WebP candidate — large png/jpeg, converting typically saves 20–40%");
84
+ }
85
+ const duplicate = insights.duplicates.find(d => d.ids.includes(record.id));
86
+ if (duplicate) {
87
+ findings.push(`Duplicate content — identical bytes shipped ${duplicate.ids.length} times`);
88
+ }
89
+ if (insights.overDecode.includes(record.id)) {
90
+ findings.push("Decodes larger than 2× this entire screen — resize the source, no view can need this many pixels");
91
+ }
92
+ if (insights.heavyGifs.includes(record.id)) {
93
+ findings.push("Heavy GIF — every frame decodes into memory; a video or Lottie is typically ~90% smaller");
94
+ }
95
+ if (insights.heavyFonts.includes(record.id)) {
96
+ findings.push("Heavy font — likely an unsubset icon font; subsetting to used glyphs usually saves most of it");
97
+ }
98
+ if (insights.scaleAnomalies.includes(record.id)) {
99
+ findings.push("Scale anomaly — a higher-resolution variant is smaller in bytes than a lower one; check the exports");
100
+ }
101
+ const estimate = (0, _assetStore.estDecodedBytes)(record);
102
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.ScrollView, {
103
+ style: styles.scroll,
104
+ contentContainerStyle: styles.content,
105
+ testID: _testIDs.ASSETS_TEST_IDS.detailScroll,
106
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Preview, {
107
+ record: record
108
+ }), findings.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
109
+ style: styles.findings,
110
+ testID: _testIDs.ASSETS_TEST_IDS.detailFindings,
111
+ children: findings.map((finding, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
112
+ style: styles.findingText,
113
+ testID: (0, _testIDs.assetFindingTestID)(index),
114
+ children: finding
115
+ }, finding))
116
+ }) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
117
+ label: "Name",
118
+ value: `${record.name}.${record.type}`
119
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
120
+ label: "Kind",
121
+ value: record.kind
122
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
123
+ label: "Status",
124
+ value: record.loaded ? "Loaded (registered at runtime)" : "Not observed in the runtime registry"
125
+ }), record.kind === "image" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
126
+ label: "Dimensions",
127
+ value: `${(0, _format.formatDimensions)(record)} (logical)`
128
+ }) : null, record.kind === "image" && record.scales.length ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
129
+ label: "Scales",
130
+ value: (0, _format.formatScales)(record.scales)
131
+ }) : null, record.sizesByScale ? Object.entries(record.sizesByScale).map(([scale, bytes]) => /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
132
+ label: `Size @${scale}x`,
133
+ value: (0, _format.formatBytes)(bytes)
134
+ }, scale)) : null, record.sizeBytes != null && record.sizeSource === "measured" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
135
+ label: "Total size",
136
+ value: (0, _format.formatBytes)(record.sizeBytes)
137
+ }) : null, estimate > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
138
+ label: "Decoded memory",
139
+ value: `~${(0, _format.formatBytes)(estimate)} (RGBA)`
140
+ }) : null, record.registryId != null ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
141
+ label: "Registry id",
142
+ value: String(record.registryId)
143
+ }) : null, record.hash ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
144
+ label: "Hash",
145
+ value: record.hash
146
+ }) : null, record.httpServerLocation ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
147
+ label: "Location",
148
+ value: record.httpServerLocation
149
+ }) : null, record.fileSystemLocation ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
150
+ label: "Source dir",
151
+ value: record.fileSystemLocation
152
+ }) : null, record.resolvedUri ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
153
+ label: "Resolved URI",
154
+ value: record.resolvedUri
155
+ }) : null]
156
+ });
157
+ }
158
+ const styles = _reactNative.StyleSheet.create({
159
+ scroll: {
160
+ flex: 1
161
+ },
162
+ content: {
163
+ padding: 12,
164
+ gap: 8
165
+ },
166
+ previewBox: {
167
+ borderRadius: 8,
168
+ backgroundColor: _sharedUi.night.color.bg,
169
+ padding: 12,
170
+ alignItems: "center",
171
+ justifyContent: "center",
172
+ minHeight: 96
173
+ },
174
+ previewImage: {
175
+ width: "100%",
176
+ height: 140
177
+ },
178
+ fontPreview: {
179
+ color: _sharedUi.night.color.text,
180
+ fontSize: 16,
181
+ textAlign: "center"
182
+ },
183
+ findings: {
184
+ borderRadius: 8,
185
+ borderWidth: 1,
186
+ borderColor: _sharedUi.night.color.border,
187
+ backgroundColor: _sharedUi.night.color.surface,
188
+ padding: 10,
189
+ gap: 6
190
+ },
191
+ findingText: {
192
+ color: _sharedUi.night.color.textSecondary,
193
+ fontSize: 11,
194
+ lineHeight: 15
195
+ },
196
+ kvRow: {
197
+ gap: 2
198
+ },
199
+ kvLabel: {
200
+ color: _sharedUi.night.color.textTertiary,
201
+ fontSize: 9,
202
+ fontWeight: "700",
203
+ letterSpacing: 0.5,
204
+ textTransform: "uppercase"
205
+ },
206
+ kvValue: {
207
+ color: _sharedUi.night.color.text,
208
+ fontSize: 12
209
+ }
210
+ });
211
+ //# sourceMappingURL=AssetDetail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","_sharedUi","_AssetImage","_format","_assetStore","_testIDs","_jsxRuntime","Row","label","value","testID","assetDetailRowTestID","jsxs","View","style","styles","kvRow","children","jsx","Text","kvLabel","kvValue","selectable","Preview","record","kind","previewBox","ASSETS_TEST_IDS","detailPreview","AssetImage","previewImage","detailFontPreview","fontPreview","fontFamily","name","AssetDetail","insights","findings","neverLoaded","includes","id","push","scaleGaps","webpCandidates","duplicate","duplicates","find","d","ids","length","overDecode","heavyGifs","heavyFonts","scaleAnomalies","estimate","estDecodedBytes","ScrollView","scroll","contentContainerStyle","content","detailScroll","detailFindings","map","finding","index","findingText","assetFindingTestID","type","loaded","formatDimensions","scales","formatScales","sizesByScale","Object","entries","scale","bytes","formatBytes","sizeBytes","sizeSource","registryId","String","hash","httpServerLocation","fileSystemLocation","resolvedUri","StyleSheet","create","flex","padding","gap","borderRadius","backgroundColor","night","color","bg","alignItems","justifyContent","minHeight","width","height","text","fontSize","textAlign","borderWidth","borderColor","border","surface","textSecondary","lineHeight","textTertiary","fontWeight","letterSpacing","textTransform"],"sourceRoot":"../../../src","sources":["components/AssetDetail.tsx"],"mappings":";;;;;;AAUA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAI0B,IAAAM,WAAA,GAAAN,OAAA;AAnB1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmBA,SAASO,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAAwC,CAAC,EAAE;EAC/D,MAAMC,MAAM,GAAG,IAAAC,6BAAoB,EAACH,KAAK,CAAC;EAC1C,oBACE,IAAAF,WAAA,CAAAM,IAAA,EAACb,YAAA,CAAAc,IAAI;IAACC,KAAK,EAAEC,MAAM,CAACC,KAAM;IAACN,MAAM,EAAEA,MAAO;IAAAO,QAAA,gBACxC,IAAAX,WAAA,CAAAY,GAAA,EAACnB,YAAA,CAAAoB,IAAI;MAACL,KAAK,EAAEC,MAAM,CAACK,OAAQ;MAAAH,QAAA,EAAET;IAAK,CAAO,CAAC,eAC3C,IAAAF,WAAA,CAAAY,GAAA,EAACnB,YAAA,CAAAoB,IAAI;MAACL,KAAK,EAAEC,MAAM,CAACM,OAAQ;MAACC,UAAU;MAACZ,MAAM,EAAE,GAAGA,MAAM,QAAS;MAAAO,QAAA,EAC/DR;IAAK,CACF,CAAC;EAAA,CACH,CAAC;AAEX;AAEA,SAASc,OAAOA,CAAC;EAAEC;AAAgC,CAAC,EAAE;EACpD,IAAIA,MAAM,CAACC,IAAI,KAAK,OAAO,EAAE;IAC3B,oBACE,IAAAnB,WAAA,CAAAY,GAAA,EAACnB,YAAA,CAAAc,IAAI;MAACC,KAAK,EAAEC,MAAM,CAACW,UAAW;MAAChB,MAAM,EAAEiB,wBAAe,CAACC,aAAc;MAAAX,QA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AQ,EAAE,EAAE;IACZO,UAAU,EAAE;EACd,CAAC;EACD7F,KAAK,EAAE;IACL0E,GAAG,EAAE;EACP,CAAC;EACDtE,OAAO,EAAE;IACP0E,KAAK,EAAED,eAAK,CAACC,KAAK,CAACgB,YAAY;IAC/BR,QAAQ,EAAE,CAAC;IACXS,UAAU,EAAE,KAAK;IACjBC,aAAa,EAAE,GAAG;IAClBC,aAAa,EAAE;EACjB,CAAC;EACD5F,OAAO,EAAE;IACPyE,KAAK,EAAED,eAAK,CAACC,KAAK,CAACO,IAAI;IACvBC,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC","ignoreList":[]}
@@ -1 +1,66 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AssetImage=AssetImage;var _react=require("react"),_reactNative=require("react-native"),_sharedUi=require("@buoy-gg/shared-ui"),_measure=require("../capture/measure"),_optionalExpoImage=require("./optionalExpoImage"),_jsxRuntime=require("react/jsx-runtime");function AssetImage({record:e,style:t,testID:r,compact:a=!1}){const s=(0,_measure.displaySource)(e),i="svg"===e.type.toLowerCase(),n=i&&"web"!==_reactNative.Platform.OS?(0,_optionalExpoImage.getExpoPreviewImage)():null,o=`${e.key}:${e.hash??""}:${"number"==typeof s?s:s?.uri??""}`,[c,l]=(0,_react.useState)(null);if(null==s||c===o||i&&"web"!==_reactNative.Platform.OS&&!n){const e=i?"SVG preview unavailable":"Image preview unavailable";return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[t,styles.fallback],accessibilityLabel:e,testID:`${r}-unavailable`,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.text,children:a?i?"SVG":"IMG":e})})}const u=()=>l(o);return n?(0,_jsxRuntime.jsx)(n,{source:s,style:t,contentFit:"contain",onError:u,testID:r}):(0,_jsxRuntime.jsx)(_reactNative.Image,{source:s,style:t,resizeMode:"contain",onError:u,testID:r})}const styles=_reactNative.StyleSheet.create({fallback:{alignItems:"center",justifyContent:"center"},text:{color:_sharedUi.night.color.textSecondary,fontSize:10,textAlign:"center"}});
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.AssetImage = AssetImage;
7
+ var _react = require("react");
8
+ var _reactNative = require("react-native");
9
+ var _sharedUi = require("@buoy-gg/shared-ui");
10
+ var _measure = require("../capture/measure");
11
+ var _optionalExpoImage = require("./optionalExpoImage");
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+ function AssetImage({
14
+ record,
15
+ style,
16
+ testID,
17
+ compact = false
18
+ }) {
19
+ const source = (0, _measure.displaySource)(record);
20
+ const svg = record.type.toLowerCase() === "svg";
21
+ const ExpoImage = svg && _reactNative.Platform.OS !== "web" ? (0, _optionalExpoImage.getExpoPreviewImage)() : null;
22
+ const sourceKey = `${record.key}:${record.hash ?? ""}:${typeof source === "number" ? source : source?.uri ?? ""}`;
23
+ const [failedSource, setFailedSource] = (0, _react.useState)(null);
24
+ const unavailable = source == null || failedSource === sourceKey || svg && _reactNative.Platform.OS !== "web" && !ExpoImage;
25
+ if (unavailable) {
26
+ const label = svg ? "SVG preview unavailable" : "Image preview unavailable";
27
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
28
+ style: [style, styles.fallback],
29
+ accessibilityLabel: label,
30
+ testID: `${testID}-unavailable`,
31
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
32
+ style: styles.text,
33
+ children: compact ? svg ? "SVG" : "IMG" : label
34
+ })
35
+ });
36
+ }
37
+ const onError = () => setFailedSource(sourceKey);
38
+ if (ExpoImage) {
39
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(ExpoImage, {
40
+ source: source,
41
+ style: style,
42
+ contentFit: "contain",
43
+ onError: onError,
44
+ testID: testID
45
+ });
46
+ }
47
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
48
+ source: source,
49
+ style: style,
50
+ resizeMode: "contain",
51
+ onError: onError,
52
+ testID: testID
53
+ });
54
+ }
55
+ const styles = _reactNative.StyleSheet.create({
56
+ fallback: {
57
+ alignItems: "center",
58
+ justifyContent: "center"
59
+ },
60
+ text: {
61
+ color: _sharedUi.night.color.textSecondary,
62
+ fontSize: 10,
63
+ textAlign: "center"
64
+ }
65
+ });
66
+ //# sourceMappingURL=AssetImage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_reactNative","_sharedUi","_measure","_optionalExpoImage","_jsxRuntime","AssetImage","record","style","testID","compact","source","displaySource","svg","type","toLowerCase","ExpoImage","Platform","OS","getExpoPreviewImage","sourceKey","key","hash","uri","failedSource","setFailedSource","useState","unavailable","label","jsx","View","styles","fallback","accessibilityLabel","children","Text","text","onError","contentFit","Image","resizeMode","StyleSheet","create","alignItems","justifyContent","color","night","textSecondary","fontSize","textAlign"],"sourceRoot":"../../../src","sources":["components/AssetImage.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAEA,IAAAI,kBAAA,GAAAJ,OAAA;AAA0D,IAAAK,WAAA,GAAAL,OAAA;AAEnD,SAASM,UAAUA,CAAC;EAAEC,MAAM;EAAEC,KAAK;EAAEC,MAAM;EAAEC,OAAO,GAAG;AAK9D,CAAC,EAAE;EACD,MAAMC,MAAM,GAAG,IAAAC,sBAAa,EAACL,MAAM,CAAC;EACpC,MAAMM,GAAG,GAAGN,MAAM,CAACO,IAAI,CAACC,WAAW,CAAC,CAAC,KAAK,KAAK;EAC/C,MAAMC,SAAS,GAAGH,GAAG,IAAII,qBAAQ,CAACC,EAAE,KAAK,KAAK,GAAG,IAAAC,sCAAmB,EAAC,CAAC,GAAG,IAAI;EAC7E,MAAMC,SAAS,GAAG,GAAGb,MAAM,CAACc,GAAG,IAAId,MAAM,CAACe,IAAI,IAAI,EAAE,IAAI,OAAOX,MAAM,KAAK,Q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