@buoy-gg/images 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 (179) hide show
  1. package/README.md +12 -65
  2. package/lib/commonjs/autoCapture.js +1 -0
  3. package/lib/commonjs/autoCapture.web.js +1 -0
  4. package/lib/commonjs/capture/actions.js +1 -242
  5. package/lib/commonjs/capture/install.js +1 -45
  6. package/lib/commonjs/capture/install.web.js +1 -0
  7. package/lib/commonjs/capture/installExpoImage.js +1 -99
  8. package/lib/commonjs/capture/installRnImage.js +1 -128
  9. package/lib/commonjs/capture/nativeImageModules.js +1 -0
  10. package/lib/commonjs/capture/nativeImageModules.web.js +1 -0
  11. package/lib/commonjs/capture/overrides.js +1 -346
  12. package/lib/commonjs/capture/rnDecoratorEarly.js +1 -0
  13. package/lib/commonjs/capture/savings.js +1 -209
  14. package/lib/commonjs/capture/savings.web.js +1 -0
  15. package/lib/commonjs/capture/shared.js +1 -378
  16. package/lib/commonjs/components/ImageDetail.js +1 -454
  17. package/lib/commonjs/components/ImageDetailFooter.js +1 -158
  18. package/lib/commonjs/components/ImageRow.js +1 -156
  19. package/lib/commonjs/components/ImagesHeader.js +1 -63
  20. package/lib/commonjs/components/ImagesIcon.js +1 -19
  21. package/lib/commonjs/components/ImagesListFooter.js +1 -126
  22. package/lib/commonjs/components/ImagesModal.js +1 -240
  23. package/lib/commonjs/components/ImagesRoot.js +1 -24
  24. package/lib/commonjs/components/ImagesRoot.web.js +1 -0
  25. package/lib/commonjs/components/InsightsBar.js +1 -59
  26. package/lib/commonjs/export.js +1 -81
  27. package/lib/commonjs/format.js +1 -117
  28. package/lib/commonjs/hooks/useImageRecords.js +1 -20
  29. package/lib/commonjs/index.js +1 -261
  30. package/lib/commonjs/preset.js +1 -39
  31. package/lib/commonjs/register.js +1 -19
  32. package/lib/commonjs/registerEarly.js +1 -0
  33. package/lib/commonjs/remote.js +1 -42
  34. package/lib/commonjs/state.js +1 -58
  35. package/lib/commonjs/store/imageEventStore.js +1 -238
  36. package/lib/commonjs/store/insights.js +1 -76
  37. package/lib/commonjs/sync/imagesSyncAdapter.js +1 -360
  38. package/lib/commonjs/types.js +0 -1
  39. package/lib/module/autoCapture.js +1 -0
  40. package/lib/module/autoCapture.web.js +1 -0
  41. package/lib/module/capture/actions.js +1 -229
  42. package/lib/module/capture/install.js +1 -40
  43. package/lib/module/capture/install.web.js +1 -0
  44. package/lib/module/capture/installExpoImage.js +1 -94
  45. package/lib/module/capture/installRnImage.js +1 -122
  46. package/lib/module/capture/nativeImageModules.js +1 -0
  47. package/lib/module/capture/nativeImageModules.web.js +1 -0
  48. package/lib/module/capture/overrides.js +1 -329
  49. package/lib/module/capture/rnDecoratorEarly.js +1 -0
  50. package/lib/module/capture/savings.js +1 -205
  51. package/lib/module/capture/savings.web.js +1 -0
  52. package/lib/module/capture/shared.js +1 -369
  53. package/lib/module/components/ImageDetail.js +1 -450
  54. package/lib/module/components/ImageDetailFooter.js +1 -154
  55. package/lib/module/components/ImageRow.js +1 -152
  56. package/lib/module/components/ImagesHeader.js +1 -59
  57. package/lib/module/components/ImagesIcon.js +1 -12
  58. package/lib/module/components/ImagesListFooter.js +1 -122
  59. package/lib/module/components/ImagesModal.js +1 -235
  60. package/lib/module/components/ImagesRoot.js +1 -20
  61. package/lib/module/components/ImagesRoot.web.js +1 -0
  62. package/lib/module/components/InsightsBar.js +1 -55
  63. package/lib/module/export.js +1 -76
  64. package/lib/module/format.js +1 -108
  65. package/lib/module/hooks/useImageRecords.js +1 -16
  66. package/lib/module/index.js +1 -79
  67. package/lib/module/preset.js +1 -35
  68. package/lib/module/register.js +1 -19
  69. package/lib/module/registerEarly.js +1 -0
  70. package/lib/module/remote.js +1 -36
  71. package/lib/module/state.js +1 -54
  72. package/lib/module/store/imageEventStore.js +1 -221
  73. package/lib/module/store/insights.js +1 -71
  74. package/lib/module/sync/imagesSyncAdapter.js +1 -355
  75. package/lib/module/types.js +0 -1
  76. package/lib/typescript/autoCapture.d.ts +2 -0
  77. package/lib/typescript/autoCapture.web.d.ts +2 -0
  78. package/lib/typescript/capture/actions.d.ts +0 -17
  79. package/lib/typescript/capture/install.web.d.ts +6 -0
  80. package/lib/typescript/capture/installRnImage.d.ts +5 -0
  81. package/lib/typescript/capture/nativeImageModules.d.ts +4 -0
  82. package/lib/typescript/capture/nativeImageModules.web.d.ts +4 -0
  83. package/lib/typescript/capture/rnDecoratorEarly.d.ts +18 -0
  84. package/lib/typescript/capture/savings.web.d.ts +5 -0
  85. package/lib/typescript/components/ImageDetail.d.ts +0 -6
  86. package/lib/typescript/components/ImagesRoot.web.d.ts +2 -0
  87. package/lib/typescript/index.d.ts +1 -1
  88. package/lib/typescript/registerEarly.d.ts +10 -0
  89. package/lib/typescript/sync/imagesSyncAdapter.d.ts +0 -9
  90. package/lib/typescript/types.d.ts +2 -1
  91. package/lib/web/chunks/chunk-TTS5EH4R.mjs +1 -0
  92. package/lib/web/index.mjs +3 -0
  93. package/lib/web/register.mjs +1 -0
  94. package/package.json +52 -6
  95. package/register.js +1 -15
  96. package/lib/commonjs/capture/actions.js.map +0 -1
  97. package/lib/commonjs/capture/install.js.map +0 -1
  98. package/lib/commonjs/capture/installExpoImage.js.map +0 -1
  99. package/lib/commonjs/capture/installRnImage.js.map +0 -1
  100. package/lib/commonjs/capture/overrides.js.map +0 -1
  101. package/lib/commonjs/capture/savings.js.map +0 -1
  102. package/lib/commonjs/capture/shared.js.map +0 -1
  103. package/lib/commonjs/components/ImageDetail.js.map +0 -1
  104. package/lib/commonjs/components/ImageDetailFooter.js.map +0 -1
  105. package/lib/commonjs/components/ImageRow.js.map +0 -1
  106. package/lib/commonjs/components/ImagesHeader.js.map +0 -1
  107. package/lib/commonjs/components/ImagesIcon.js.map +0 -1
  108. package/lib/commonjs/components/ImagesListFooter.js.map +0 -1
  109. package/lib/commonjs/components/ImagesModal.js.map +0 -1
  110. package/lib/commonjs/components/ImagesRoot.js.map +0 -1
  111. package/lib/commonjs/components/InsightsBar.js.map +0 -1
  112. package/lib/commonjs/export.js.map +0 -1
  113. package/lib/commonjs/format.js.map +0 -1
  114. package/lib/commonjs/hooks/useImageRecords.js.map +0 -1
  115. package/lib/commonjs/index.js.map +0 -1
  116. package/lib/commonjs/preset.js.map +0 -1
  117. package/lib/commonjs/register.js.map +0 -1
  118. package/lib/commonjs/remote.js.map +0 -1
  119. package/lib/commonjs/state.js.map +0 -1
  120. package/lib/commonjs/store/imageEventStore.js.map +0 -1
  121. package/lib/commonjs/store/insights.js.map +0 -1
  122. package/lib/commonjs/sync/imagesSyncAdapter.js.map +0 -1
  123. package/lib/commonjs/types.js.map +0 -1
  124. package/lib/module/capture/actions.js.map +0 -1
  125. package/lib/module/capture/install.js.map +0 -1
  126. package/lib/module/capture/installExpoImage.js.map +0 -1
  127. package/lib/module/capture/installRnImage.js.map +0 -1
  128. package/lib/module/capture/overrides.js.map +0 -1
  129. package/lib/module/capture/savings.js.map +0 -1
  130. package/lib/module/capture/shared.js.map +0 -1
  131. package/lib/module/components/ImageDetail.js.map +0 -1
  132. package/lib/module/components/ImageDetailFooter.js.map +0 -1
  133. package/lib/module/components/ImageRow.js.map +0 -1
  134. package/lib/module/components/ImagesHeader.js.map +0 -1
  135. package/lib/module/components/ImagesIcon.js.map +0 -1
  136. package/lib/module/components/ImagesListFooter.js.map +0 -1
  137. package/lib/module/components/ImagesModal.js.map +0 -1
  138. package/lib/module/components/ImagesRoot.js.map +0 -1
  139. package/lib/module/components/InsightsBar.js.map +0 -1
  140. package/lib/module/export.js.map +0 -1
  141. package/lib/module/format.js.map +0 -1
  142. package/lib/module/hooks/useImageRecords.js.map +0 -1
  143. package/lib/module/index.js.map +0 -1
  144. package/lib/module/preset.js.map +0 -1
  145. package/lib/module/register.js.map +0 -1
  146. package/lib/module/remote.js.map +0 -1
  147. package/lib/module/state.js.map +0 -1
  148. package/lib/module/store/imageEventStore.js.map +0 -1
  149. package/lib/module/store/insights.js.map +0 -1
  150. package/lib/module/sync/imagesSyncAdapter.js.map +0 -1
  151. package/lib/module/types.js.map +0 -1
  152. package/lib/typescript/capture/actions.d.ts.map +0 -1
  153. package/lib/typescript/capture/install.d.ts.map +0 -1
  154. package/lib/typescript/capture/installExpoImage.d.ts.map +0 -1
  155. package/lib/typescript/capture/installRnImage.d.ts.map +0 -1
  156. package/lib/typescript/capture/overrides.d.ts.map +0 -1
  157. package/lib/typescript/capture/savings.d.ts.map +0 -1
  158. package/lib/typescript/capture/shared.d.ts.map +0 -1
  159. package/lib/typescript/components/ImageDetail.d.ts.map +0 -1
  160. package/lib/typescript/components/ImageDetailFooter.d.ts.map +0 -1
  161. package/lib/typescript/components/ImageRow.d.ts.map +0 -1
  162. package/lib/typescript/components/ImagesHeader.d.ts.map +0 -1
  163. package/lib/typescript/components/ImagesIcon.d.ts.map +0 -1
  164. package/lib/typescript/components/ImagesListFooter.d.ts.map +0 -1
  165. package/lib/typescript/components/ImagesModal.d.ts.map +0 -1
  166. package/lib/typescript/components/ImagesRoot.d.ts.map +0 -1
  167. package/lib/typescript/components/InsightsBar.d.ts.map +0 -1
  168. package/lib/typescript/export.d.ts.map +0 -1
  169. package/lib/typescript/format.d.ts.map +0 -1
  170. package/lib/typescript/hooks/useImageRecords.d.ts.map +0 -1
  171. package/lib/typescript/index.d.ts.map +0 -1
  172. package/lib/typescript/preset.d.ts.map +0 -1
  173. package/lib/typescript/register.d.ts.map +0 -1
  174. package/lib/typescript/remote.d.ts.map +0 -1
  175. package/lib/typescript/state.d.ts.map +0 -1
  176. package/lib/typescript/store/imageEventStore.d.ts.map +0 -1
  177. package/lib/typescript/store/insights.d.ts.map +0 -1
  178. package/lib/typescript/sync/imagesSyncAdapter.d.ts.map +0 -1
  179. package/lib/typescript/types.d.ts.map +0 -1
@@ -1,454 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ImageDetail = ImageDetail;
7
- var _react = require("react");
8
- var _reactNative = require("react-native");
9
- var _sharedUi = require("@buoy-gg/shared-ui");
10
- var _overrides = require("../capture/overrides");
11
- var _savings = require("../capture/savings");
12
- var _remote = require("../remote");
13
- var _imageEventStore = require("../store/imageEventStore");
14
- var _format = require("../format");
15
- var _jsxRuntime = require("react/jsx-runtime");
16
- /**
17
- * ImageDetail — full record view: preview, source, load timeline, dimensions
18
- * with the oversize verdict + estimated decoded/wasted memory, cache verdict,
19
- * and error details (including HTTP status/headers when the platform provides
20
- * them). Cache actions live here too (expo-image global clears).
21
- */
22
-
23
- function Section({
24
- title,
25
- children
26
- }) {
27
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
28
- style: styles.section,
29
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
30
- style: styles.sectionTitle,
31
- children: title
32
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
33
- style: styles.sectionBody,
34
- children: children
35
- })]
36
- });
37
- }
38
- function Row({
39
- label,
40
- value,
41
- color
42
- }) {
43
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
44
- style: styles.kvRow,
45
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
46
- style: styles.kvLabel,
47
- children: label
48
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
49
- style: [styles.kvValue, color ? {
50
- color
51
- } : null],
52
- selectable: true,
53
- children: value
54
- })]
55
- });
56
- }
57
-
58
- /** expo-image global cache clears (no-ops if expo-image is absent). */
59
- function clearExpoCache(kind) {
60
- // Mirror mode: the caches live on the synced device.
61
- const remote = (0, _remote.remoteImagesDispatch)();
62
- if (remote) {
63
- void remote("clearExpoCaches", {
64
- memory: kind === "memory",
65
- disk: kind === "disk"
66
- });
67
- return;
68
- }
69
- try {
70
- const expo = require("expo-image");
71
- if (kind === "memory") void expo.Image.clearMemoryCache();else void expo.Image.clearDiskCache();
72
- } catch {
73
- // expo-image not installed
74
- }
75
- }
76
-
77
- /** Free-text source swap: test another URL/format/CDN param on the live view. */
78
- function SwapUrlSection({
79
- record
80
- }) {
81
- const [url, setUrl] = (0, _react.useState)(record.uri);
82
- const trimmed = url.trim();
83
- const canApply = record.mounted && trimmed.length > 0 && trimmed !== record.uri;
84
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Section, {
85
- title: "SWAP SOURCE URL",
86
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TextInput, {
87
- style: styles.urlInput,
88
- value: url,
89
- onChangeText: setUrl,
90
- placeholder: "https://\u2026",
91
- placeholderTextColor: _sharedUi.night.color.placeholder,
92
- autoCapitalize: "none",
93
- autoCorrect: false,
94
- multiline: true
95
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
96
- style: styles.actionsRow,
97
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
98
- style: [styles.actionButton, !canApply && styles.actionDisabled],
99
- disabled: !canApply,
100
- onPress: () => (0, _overrides.setOverride)(record.id, {
101
- source: {
102
- type: "url",
103
- uri: trimmed
104
- },
105
- label: "URL swapped"
106
- }),
107
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
108
- style: styles.actionText,
109
- children: "Apply"
110
- })
111
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
112
- style: styles.actionButton,
113
- onPress: () => setUrl(record.uri),
114
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
115
- style: styles.actionText,
116
- children: "Reset field"
117
- })
118
- })]
119
- })]
120
- });
121
- }
122
-
123
- /**
124
- * Real, on-device savings proof: re-encode at displayed size as WebP via
125
- * expo-image-manipulator, report actual bytes, offer an in-place preview.
126
- */
127
- function SavingsSection({
128
- record
129
- }) {
130
- const [busy, setBusy] = (0, _react.useState)(false);
131
- const [result, setResult] = (0, _react.useState)(null);
132
- const run = () => {
133
- setBusy(true);
134
- (0, _savings.proveSavings)(record).then(setResult).catch(error => setResult({
135
- ok: false,
136
- message: String(error?.message ?? error)
137
- })).finally(() => setBusy(false));
138
- };
139
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(Section, {
140
- title: "PROVE SAVINGS (re-encode on device)",
141
- children: result == null ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
142
- style: styles.actionsRow,
143
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
144
- style: styles.actionButton,
145
- onPress: run,
146
- disabled: busy,
147
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
148
- style: styles.actionText,
149
- children: busy ? "Re-encoding…" : "Re-encode at displayed size (WebP)"
150
- })
151
- })
152
- }) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
153
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
154
- label: "Result",
155
- value: result.message || (result.ok ? "done" : "failed"),
156
- color: result.ok ? _sharedUi.macOSColors.semantic.success : _sharedUi.macOSColors.semantic.error
157
- }), result.originalBytes != null ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
158
- label: "Original",
159
- value: `${(0, _format.formatBytes)(result.originalBytes)} (${result.originalBytesSource})`
160
- }) : null, result.optimizedBytes != null ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
161
- label: "Optimized",
162
- value: `${(0, _format.formatBytes)(result.optimizedBytes)} — ${result.optimizedDims?.width}×${result.optimizedDims?.height} WebP`,
163
- color: _sharedUi.macOSColors.semantic.success
164
- }) : null, result.savedBytes != null ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
165
- label: "Saved",
166
- value: `${(0, _format.formatBytes)(result.savedBytes)} (${result.savedPct}%)`,
167
- color: _sharedUi.macOSColors.semantic.success
168
- }) : null, /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
169
- style: styles.actionsRow,
170
- children: [result.ok && result.optimizedUri && record.mounted ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
171
- style: styles.actionButton,
172
- onPress: () => (0, _overrides.setOverride)(record.id, {
173
- source: {
174
- type: "url",
175
- uri: result.optimizedUri
176
- },
177
- label: "Optimized preview"
178
- }),
179
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
180
- style: styles.actionText,
181
- children: "Preview in place"
182
- })
183
- }) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
184
- style: styles.actionButton,
185
- onPress: run,
186
- disabled: busy,
187
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
188
- style: styles.actionText,
189
- children: busy ? "Re-encoding…" : "Re-run"
190
- })
191
- })]
192
- })]
193
- })
194
- });
195
- }
196
- function ImageDetail({
197
- record
198
- }) {
199
- const verdict = (0, _format.sizeVerdict)(record);
200
- const cache = (0, _format.cacheBadge)(record);
201
- const needed = (0, _imageEventStore.neededPixels)(record);
202
- const decoded = (0, _imageEventStore.estDecodedBytes)(record);
203
- const wasted = (0, _imageEventStore.estWastedBytes)(record);
204
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.ScrollView, {
205
- style: styles.container,
206
- contentContainerStyle: styles.content,
207
- children: [record.overrideLabel ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
208
- style: styles.overrideBanner,
209
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, {
210
- style: styles.overrideText,
211
- children: ["Simulation active: ", record.overrideLabel, " \u2014 stats below describe the override, not the original source."]
212
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
213
- onPress: () => (0, _overrides.clearOverride)(record.id),
214
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
215
- style: styles.overrideRestore,
216
- children: "RESTORE"
217
- })
218
- })]
219
- }) : null, record.uri && record.sourceKind !== "data" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
220
- style: styles.previewBox,
221
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
222
- testID: "buoy-internal-images-preview",
223
- source: {
224
- uri: record.uri
225
- },
226
- style: styles.preview,
227
- resizeMode: "contain"
228
- })
229
- }) : null, /*#__PURE__*/(0, _jsxRuntime.jsxs)(Section, {
230
- title: "SOURCE",
231
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
232
- label: "URI",
233
- value: record.uri || "(none)"
234
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
235
- label: "Kind",
236
- value: record.sourceKind
237
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
238
- label: "Library",
239
- value: record.lib === "expo" ? "expo-image" : "RN <Image>"
240
- }), record.hasAltText === false ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
241
- label: "Alt text",
242
- value: "missing \u2014 add alt/accessibilityLabel",
243
- color: _sharedUi.macOSColors.semantic.warning
244
- }) : null, record.mediaType != null ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
245
- label: "Media type",
246
- value: String(record.mediaType)
247
- }) : null, record.isAnimated != null ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
248
- label: "Animated",
249
- value: record.isAnimated ? "yes" : "no"
250
- }) : null]
251
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(Section, {
252
- title: "LOAD",
253
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
254
- label: "Status",
255
- value: record.status,
256
- color: record.status === "error" ? _sharedUi.macOSColors.semantic.error : record.status === "loaded" ? _sharedUi.macOSColors.semantic.success : _sharedUi.macOSColors.semantic.warning
257
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
258
- label: "Duration",
259
- value: (0, _format.formatMs)(record.durationMs)
260
- }), record.displayedAt && record.loadedAt ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
261
- label: "Decode \u2192 display",
262
- value: (0, _format.formatMs)(Math.max(0, record.displayedAt - record.loadedAt))
263
- }) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
264
- label: "Cache",
265
- value: `${cache.label}`,
266
- color: cache.color
267
- }), record.cacheVerdictSource ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
268
- label: "Cache source",
269
- value: record.cacheVerdictSource === "event" ? "reported by expo-image onLoad" : "Image.queryCache after load"
270
- }) : null, record.progressSeen ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
271
- label: "Downloaded",
272
- value: record.bytesTotal ? `${(0, _format.formatBytes)(record.bytesLoaded ?? 0)} / ${(0, _format.formatBytes)(record.bytesTotal)}` : "network transfer observed"
273
- }) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
274
- label: "Load cycles",
275
- value: String(record.loadCount)
276
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
277
- label: "Still mounted",
278
- value: record.mounted ? "yes" : "no"
279
- })]
280
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(Section, {
281
- title: "DIMENSIONS",
282
- children: [record.intrinsic ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
283
- label: "Decoded",
284
- value: `${record.intrinsic.width}×${record.intrinsic.height} px`
285
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
286
- label: "Decoded",
287
- value: "unknown"
288
- }), record.layout ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
289
- label: "Displayed",
290
- value: `${Math.round(record.layout.width)}×${Math.round(record.layout.height)} dp (needs ${needed ? `${needed.width}×${needed.height}` : "?"} px @${Math.round((0, _imageEventStore.effectivePixelRatio)() * 100) / 100}x)`
291
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
292
- label: "Displayed",
293
- value: "no layout yet"
294
- }), verdict.label ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
295
- label: "Verdict",
296
- value: verdict.label,
297
- color: verdict.color
298
- }) : null, decoded > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
299
- label: "Est. decoded memory",
300
- value: (0, _format.formatBytes)(decoded)
301
- }) : null, wasted > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
302
- label: "Est. wasted",
303
- value: `${(0, _format.formatBytes)(wasted)} — resize the source to ${needed ? `${needed.width}×${needed.height}` : "the displayed size"}`,
304
- color: _sharedUi.macOSColors.semantic.warning
305
- }) : null, (record.layoutShifts ?? 0) > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
306
- label: "Layout shifts",
307
- value: `${record.layoutShifts} — box resized after load; reserve explicit width/height`,
308
- color: _sharedUi.macOSColors.semantic.warning
309
- }) : null]
310
- }), record.sourceKind === "network" || record.sourceKind === "asset" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(SavingsSection, {
311
- record: record
312
- }, `savings-${record.id}`) : null, record.status === "error" ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(Section, {
313
- title: "ERROR",
314
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
315
- label: "Message",
316
- value: record.error ?? "unknown",
317
- color: _sharedUi.macOSColors.semantic.error
318
- }), record.errorCode != null ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
319
- label: "HTTP status",
320
- value: String(record.errorCode)
321
- }) : null, record.errorHeaders ? Object.entries(record.errorHeaders).map(([k, v]) => /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
322
- label: k,
323
- value: String(v)
324
- }, k)) : null]
325
- }) : null, record.sourceKind === "network" && record.mounted ? /*#__PURE__*/(0, _jsxRuntime.jsx)(SwapUrlSection, {
326
- record: record
327
- }, record.id) : null, record.lib === "expo" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Section, {
328
- title: "CACHE ACTIONS (expo-image, global)",
329
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
330
- style: styles.actionsRow,
331
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
332
- style: styles.actionButton,
333
- onPress: () => clearExpoCache("memory"),
334
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
335
- style: styles.actionText,
336
- children: "Clear memory cache"
337
- })
338
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
339
- style: styles.actionButton,
340
- onPress: () => clearExpoCache("disk"),
341
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
342
- style: styles.actionText,
343
- children: "Clear disk cache"
344
- })
345
- })]
346
- })
347
- }) : null]
348
- });
349
- }
350
- const styles = _reactNative.StyleSheet.create({
351
- container: {
352
- flex: 1
353
- },
354
- content: {
355
- padding: 12,
356
- gap: 12
357
- },
358
- previewBox: {
359
- height: 140,
360
- borderRadius: 8,
361
- backgroundColor: _sharedUi.night.color.bg,
362
- overflow: "hidden"
363
- },
364
- preview: {
365
- width: "100%",
366
- height: "100%"
367
- },
368
- section: {
369
- gap: 6
370
- },
371
- sectionTitle: {
372
- color: _sharedUi.night.color.textTertiary,
373
- fontSize: 10,
374
- fontWeight: "700",
375
- letterSpacing: 0.8
376
- },
377
- sectionBody: {
378
- backgroundColor: _sharedUi.night.color.surface,
379
- borderRadius: 8,
380
- borderWidth: _reactNative.StyleSheet.hairlineWidth,
381
- borderColor: _sharedUi.night.color.border,
382
- paddingHorizontal: 10,
383
- paddingVertical: 4
384
- },
385
- kvRow: {
386
- flexDirection: "row",
387
- paddingVertical: 5,
388
- gap: 12
389
- },
390
- kvLabel: {
391
- color: _sharedUi.night.color.textSecondary,
392
- fontSize: 11,
393
- width: 110
394
- },
395
- kvValue: {
396
- color: _sharedUi.night.color.text,
397
- fontSize: 11,
398
- flex: 1
399
- },
400
- actionsRow: {
401
- flexDirection: "row",
402
- gap: 8,
403
- paddingVertical: 8
404
- },
405
- actionButton: {
406
- backgroundColor: _sharedUi.night.color.surfaceElevated,
407
- borderRadius: 6,
408
- paddingHorizontal: 10,
409
- paddingVertical: 6,
410
- borderWidth: _reactNative.StyleSheet.hairlineWidth,
411
- borderColor: _sharedUi.night.color.border
412
- },
413
- actionText: {
414
- color: _sharedUi.night.color.text,
415
- fontSize: 11,
416
- fontWeight: "600"
417
- },
418
- actionDisabled: {
419
- opacity: 0.4
420
- },
421
- urlInput: {
422
- color: _sharedUi.night.color.text,
423
- fontSize: 11,
424
- fontFamily: _sharedUi.monoFont,
425
- backgroundColor: _sharedUi.night.color.surfaceElevated,
426
- borderRadius: 6,
427
- borderWidth: _reactNative.StyleSheet.hairlineWidth,
428
- borderColor: _sharedUi.night.color.border,
429
- paddingHorizontal: 8,
430
- paddingVertical: 6,
431
- marginTop: 8
432
- },
433
- overrideBanner: {
434
- flexDirection: "row",
435
- alignItems: "center",
436
- gap: 10,
437
- padding: 10,
438
- borderRadius: 8,
439
- backgroundColor: _sharedUi.night.color.warningSoft
440
- },
441
- overrideText: {
442
- flex: 1,
443
- color: _sharedUi.night.color.warning,
444
- fontSize: 11,
445
- lineHeight: 15
446
- },
447
- overrideRestore: {
448
- color: _sharedUi.night.color.warning,
449
- fontSize: 11,
450
- fontWeight: "700",
451
- letterSpacing: 0.5
452
- }
453
- });
454
- //# sourceMappingURL=ImageDetail.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ImageDetail=ImageDetail;var _nativeImageModules=require("../capture/nativeImageModules");var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _overrides=require("../capture/overrides");var _savings=require("../capture/savings");var _remote=require("../remote");var _imageEventStore=require("../store/imageEventStore");var _format=require("../format");var _jsxRuntime=require("react/jsx-runtime");function Section({title:e,children:l}){return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.section,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.sectionTitle,children:e}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.sectionBody,children:l})]})}function Row({label:e,value:l,color:i}){return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.kvRow,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.kvLabel,children:e}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.kvValue,i?{color:i}:null],selectable:true,children:l})]})}function clearExpoCache(e){const l=(0,_remote.remoteImagesDispatch)();if(l){void l("clearExpoCaches",{memory:e==="memory",disk:e==="disk"});return}try{const i=(0,_nativeImageModules.loadExpoImage)();if(e==="memory")void i.Image.clearMemoryCache();else void i.Image.clearDiskCache()}catch{}}function SwapUrlSection({record:e}){const[l,i]=(0,_react.useState)(e.uri);const t=l.trim();const a=e.mounted&&t.length>0&&t!==e.uri;return(0,_jsxRuntime.jsxs)(Section,{title:"SWAP SOURCE URL",children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{style:styles.urlInput,value:l,onChangeText:i,placeholder:"https://\u2026",placeholderTextColor:_sharedUi.night.color.placeholder,autoCapitalize:"none",autoCorrect:false,multiline:true}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.actionsRow,children:[(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:[styles.actionButton,!a&&styles.actionDisabled],disabled:!a,onPress:()=>(0,_overrides.setOverride)(e.id,{source:{type:"url",uri:t},label:"URL swapped"}),children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.actionText,children:"Apply"})}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:styles.actionButton,onPress:()=>i(e.uri),children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.actionText,children:"Reset field"})})]})]})}function SavingsSection({record:e}){const[l,i]=(0,_react.useState)(false);const[t,a]=(0,_react.useState)(null);const s=()=>{i(true);(0,_savings.proveSavings)(e).then(a).catch(o=>a({ok:false,message:String(o?.message??o)})).finally(()=>i(false))};return(0,_jsxRuntime.jsx)(Section,{title:"PROVE SAVINGS (re-encode on device)",children:t==null?(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.actionsRow,children:(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:styles.actionButton,onPress:s,disabled:l,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.actionText,children:l?"Re-encoding\u2026":"Re-encode at displayed size (WebP)"})})}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(Row,{label:"Result",value:t.message||(t.ok?"done":"failed"),color:t.ok?_sharedUi.macOSColors.semantic.success:_sharedUi.macOSColors.semantic.error}),t.originalBytes!=null?(0,_jsxRuntime.jsx)(Row,{label:"Original",value:`${(0,_format.formatBytes)(t.originalBytes)} (${t.originalBytesSource})`}):null,t.optimizedBytes!=null?(0,_jsxRuntime.jsx)(Row,{label:"Optimized",value:`${(0,_format.formatBytes)(t.optimizedBytes)} \u2014 ${t.optimizedDims?.width}\xD7${t.optimizedDims?.height} WebP`,color:_sharedUi.macOSColors.semantic.success}):null,t.savedBytes!=null?(0,_jsxRuntime.jsx)(Row,{label:"Saved",value:`${(0,_format.formatBytes)(t.savedBytes)} (${t.savedPct}%)`,color:_sharedUi.macOSColors.semantic.success}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.actionsRow,children:[t.ok&&t.optimizedUri&&e.mounted?(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:styles.actionButton,onPress:()=>(0,_overrides.setOverride)(e.id,{source:{type:"url",uri:t.optimizedUri},label:"Optimized preview"}),children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.actionText,children:"Preview in place"})}):null,(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:styles.actionButton,onPress:s,disabled:l,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.actionText,children:l?"Re-encoding\u2026":"Re-run"})})]})]})})}function ImageDetail({record:e}){const l=(0,_format.sizeVerdict)(e);const i=(0,_format.cacheBadge)(e);const t=(0,_imageEventStore.neededPixels)(e);const a=(0,_imageEventStore.estDecodedBytes)(e);const s=(0,_imageEventStore.estWastedBytes)(e);return(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{style:styles.container,contentContainerStyle:styles.content,children:[e.overrideLabel?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.overrideBanner,children:[(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.overrideText,children:["Simulation active: ",e.overrideLabel," \u2014 stats below describe the override, not the original source."]}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:()=>(0,_overrides.clearOverride)(e.id),children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.overrideRestore,children:"RESTORE"})})]}):null,e.uri&&e.sourceKind!=="data"?(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.previewBox,children:(0,_jsxRuntime.jsx)(_reactNative.Image,{testID:"buoy-internal-images-preview",source:{uri:e.uri},style:styles.preview,resizeMode:"contain"})}):null,(0,_jsxRuntime.jsxs)(Section,{title:"SOURCE",children:[(0,_jsxRuntime.jsx)(Row,{label:"URI",value:e.uri||"(none)"}),(0,_jsxRuntime.jsx)(Row,{label:"Kind",value:e.sourceKind}),(0,_jsxRuntime.jsx)(Row,{label:"Library",value:e.lib==="web"?"Browser <img>":e.lib==="expo"?"expo-image":"RN <Image>"}),e.hasAltText===false?(0,_jsxRuntime.jsx)(Row,{label:"Alt text",value:"missing \u2014 add alt/accessibilityLabel",color:_sharedUi.macOSColors.semantic.warning}):null,e.mediaType!=null?(0,_jsxRuntime.jsx)(Row,{label:"Media type",value:String(e.mediaType)}):null,e.isAnimated!=null?(0,_jsxRuntime.jsx)(Row,{label:"Animated",value:e.isAnimated?"yes":"no"}):null]}),(0,_jsxRuntime.jsxs)(Section,{title:"LOAD",children:[(0,_jsxRuntime.jsx)(Row,{label:"Status",value:e.status,color:e.status==="error"?_sharedUi.macOSColors.semantic.error:e.status==="loaded"?_sharedUi.macOSColors.semantic.success:_sharedUi.macOSColors.semantic.warning}),(0,_jsxRuntime.jsx)(Row,{label:"Duration",value:(0,_format.formatMs)(e.durationMs)}),e.displayedAt&&e.loadedAt?(0,_jsxRuntime.jsx)(Row,{label:"Decode \u2192 display",value:(0,_format.formatMs)(Math.max(0,e.displayedAt-e.loadedAt))}):null,(0,_jsxRuntime.jsx)(Row,{label:"Cache",value:`${i.label}`,color:i.color}),e.cacheVerdictSource?(0,_jsxRuntime.jsx)(Row,{label:"Cache source",value:e.cacheVerdictSource==="event"?"reported by expo-image onLoad":"Image.queryCache after load"}):null,e.progressSeen?(0,_jsxRuntime.jsx)(Row,{label:"Downloaded",value:e.bytesTotal?`${(0,_format.formatBytes)(e.bytesLoaded??0)} / ${(0,_format.formatBytes)(e.bytesTotal)}`:"network transfer observed"}):null,(0,_jsxRuntime.jsx)(Row,{label:"Load cycles",value:String(e.loadCount)}),(0,_jsxRuntime.jsx)(Row,{label:"Still mounted",value:e.mounted?"yes":"no"})]}),(0,_jsxRuntime.jsxs)(Section,{title:"DIMENSIONS",children:[e.intrinsic?(0,_jsxRuntime.jsx)(Row,{label:"Decoded",value:`${e.intrinsic.width}\xD7${e.intrinsic.height} px`}):(0,_jsxRuntime.jsx)(Row,{label:"Decoded",value:"unknown"}),e.layout?(0,_jsxRuntime.jsx)(Row,{label:"Displayed",value:`${Math.round(e.layout.width)}\xD7${Math.round(e.layout.height)} dp (needs ${t?`${t.width}\xD7${t.height}`:"?"} px @${Math.round((0,_imageEventStore.effectivePixelRatio)()*100)/100}x)`}):(0,_jsxRuntime.jsx)(Row,{label:"Displayed",value:"no layout yet"}),l.label?(0,_jsxRuntime.jsx)(Row,{label:"Verdict",value:l.label,color:l.color}):null,a>0?(0,_jsxRuntime.jsx)(Row,{label:"Est. decoded memory",value:(0,_format.formatBytes)(a)}):null,s>0?(0,_jsxRuntime.jsx)(Row,{label:"Est. wasted",value:`${(0,_format.formatBytes)(s)} \u2014 resize the source to ${t?`${t.width}\xD7${t.height}`:"the displayed size"}`,color:_sharedUi.macOSColors.semantic.warning}):null,(e.layoutShifts??0)>0?(0,_jsxRuntime.jsx)(Row,{label:"Layout shifts",value:`${e.layoutShifts} \u2014 box resized after load; reserve explicit width/height`,color:_sharedUi.macOSColors.semantic.warning}):null]}),e.sourceKind==="network"||e.sourceKind==="asset"?(0,_jsxRuntime.jsx)(SavingsSection,{record:e},`savings-${e.id}`):null,e.status==="error"?(0,_jsxRuntime.jsxs)(Section,{title:"ERROR",children:[(0,_jsxRuntime.jsx)(Row,{label:"Message",value:e.error??"unknown",color:_sharedUi.macOSColors.semantic.error}),e.errorCode!=null?(0,_jsxRuntime.jsx)(Row,{label:"HTTP status",value:String(e.errorCode)}):null,e.errorHeaders?Object.entries(e.errorHeaders).map(([o,n])=>(0,_jsxRuntime.jsx)(Row,{label:o,value:String(n)},o)):null]}):null,e.sourceKind==="network"&&e.mounted?(0,_jsxRuntime.jsx)(SwapUrlSection,{record:e},e.id):null,e.lib==="expo"?(0,_jsxRuntime.jsx)(Section,{title:"CACHE ACTIONS (expo-image, global)",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.actionsRow,children:[(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:styles.actionButton,onPress:()=>clearExpoCache("memory"),children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.actionText,children:"Clear memory cache"})}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:styles.actionButton,onPress:()=>clearExpoCache("disk"),children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.actionText,children:"Clear disk cache"})})]})}):null]})}const styles=_reactNative.StyleSheet.create({container:{flex:1},content:{padding:12,gap:12},previewBox:{height:140,borderRadius:8,backgroundColor:_sharedUi.night.color.bg,overflow:"hidden"},preview:{width:"100%",height:"100%"},section:{gap:6},sectionTitle:{color:_sharedUi.night.color.textTertiary,fontSize:10,fontWeight:"700",letterSpacing:.8},sectionBody:{backgroundColor:_sharedUi.night.color.surface,borderRadius:8,borderWidth:_reactNative.StyleSheet.hairlineWidth,borderColor:_sharedUi.night.color.border,paddingHorizontal:10,paddingVertical:4},kvRow:{flexDirection:"row",paddingVertical:5,gap:12},kvLabel:{color:_sharedUi.night.color.textSecondary,fontSize:11,width:110},kvValue:{color:_sharedUi.night.color.text,fontSize:11,flex:1},actionsRow:{flexDirection:"row",gap:8,paddingVertical:8},actionButton:{backgroundColor:_sharedUi.night.color.surfaceElevated,borderRadius:6,paddingHorizontal:10,paddingVertical:6,borderWidth:_reactNative.StyleSheet.hairlineWidth,borderColor:_sharedUi.night.color.border},actionText:{color:_sharedUi.night.color.text,fontSize:11,fontWeight:"600"},actionDisabled:{opacity:.4},urlInput:{color:_sharedUi.night.color.text,fontSize:11,fontFamily:_sharedUi.monoFont,backgroundColor:_sharedUi.night.color.surfaceElevated,borderRadius:6,borderWidth:_reactNative.StyleSheet.hairlineWidth,borderColor:_sharedUi.night.color.border,paddingHorizontal:8,paddingVertical:6,marginTop:8},overrideBanner:{flexDirection:"row",alignItems:"center",gap:10,padding:10,borderRadius:8,backgroundColor:_sharedUi.night.color.warningSoft},overrideText:{flex:1,color:_sharedUi.night.color.warning,fontSize:11,lineHeight:15},overrideRestore:{color:_sharedUi.night.color.warning,fontSize:11,fontWeight:"700",letterSpacing:.5}});
@@ -1,158 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ImageDetailFooter = ImageDetailFooter;
7
- var _react = require("react");
8
- var _reactNative = require("react-native");
9
- var _sharedUi = require("@buoy-gg/shared-ui");
10
- var _actions = require("../capture/actions");
11
- var _overrides = require("../capture/overrides");
12
- var _jsxRuntime = require("react/jsx-runtime");
13
- /**
14
- * ImageDetailFooter — bottom navbar for the detail view: previous/next
15
- * stepping through the captured list at the edges, per-image actions in the
16
- * middle (hard reload / retry), with inline action feedback. Styling matches
17
- * shared-ui's EventStepperFooter so it reads like the rest of Buoy.
18
- *
19
- * Mount with key={record.id} so action feedback resets when stepping.
20
- */
21
-
22
- function ImageDetailFooter({
23
- record,
24
- hasPrevious,
25
- hasNext,
26
- onPrevious,
27
- onNext
28
- }) {
29
- const [message, setMessage] = (0, _react.useState)(null);
30
- const runAction = action => {
31
- setMessage("…");
32
- action().then(result => setMessage(result.message)).catch(error => setMessage(String(error?.message ?? error)));
33
- };
34
- const actionsDisabled = !record.mounted;
35
- const overrideActive = record.overrideLabel != null;
36
- const simulate = (source, label) => {
37
- (0, _overrides.setOverride)(record.id, {
38
- source,
39
- label
40
- });
41
- setMessage(`${label} — Restore to undo`);
42
- };
43
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_sharedUi.ToolFooter, {
44
- children: [message ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.FooterMessage, {
45
- children: message
46
- }) : actionsDisabled ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.FooterMessage, {
47
- tone: "muted",
48
- children: "Instance unmounted \u2014 reload actions need the image on screen."
49
- }) : null, /*#__PURE__*/(0, _jsxRuntime.jsxs)(_sharedUi.FooterRow, {
50
- style: {
51
- gap: 8
52
- },
53
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
54
- onPress: onPrevious,
55
- disabled: !hasPrevious,
56
- style: [styles.navButton, !hasPrevious && styles.disabled],
57
- activeOpacity: 0.7,
58
- accessibilityLabel: "Previous image",
59
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.ChevronLeft, {
60
- size: 20,
61
- color: hasPrevious ? _sharedUi.night.color.accent : _sharedUi.night.color.textTertiary
62
- })
63
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.FooterButton, {
64
- label: "Hard reload",
65
- size: "md",
66
- disabled: actionsDisabled,
67
- icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.RefreshCw, {
68
- size: 13,
69
- color: actionsDisabled ? _sharedUi.night.color.textTertiary : _sharedUi.night.color.info
70
- }),
71
- onPress: () => runAction(() => (0, _actions.hardReloadRecord)(record))
72
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.FooterButton, {
73
- label: record.status === "error" ? "Retry" : "Reload",
74
- size: "md",
75
- disabled: actionsDisabled,
76
- onPress: () => runAction(() => (0, _actions.retryRecord)(record))
77
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
78
- onPress: onNext,
79
- disabled: !hasNext,
80
- style: [styles.navButton, !hasNext && styles.disabled],
81
- activeOpacity: 0.7,
82
- accessibilityLabel: "Next image",
83
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.ChevronRight, {
84
- size: 20,
85
- color: hasNext ? _sharedUi.night.color.accent : _sharedUi.night.color.textTertiary
86
- })
87
- })]
88
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_sharedUi.FooterRow, {
89
- style: {
90
- gap: 8
91
- },
92
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(SimButton, {
93
- label: "Error",
94
- disabled: actionsDisabled,
95
- onPress: () => simulate({
96
- type: "error"
97
- }, "Forced error")
98
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(SimButton, {
99
- label: "Loading",
100
- disabled: actionsDisabled,
101
- onPress: () => simulate({
102
- type: "hang"
103
- }, "Forced loading")
104
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(SimButton, {
105
- label: "Blank",
106
- disabled: actionsDisabled,
107
- onPress: () => simulate({
108
- type: "blank"
109
- }, "Blanked")
110
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(SimButton, {
111
- label: "Find",
112
- disabled: actionsDisabled,
113
- onPress: () => {
114
- (0, _overrides.flashRecord)(record.id);
115
- setMessage("Flashing a red border on the image (2.5s)");
116
- }
117
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(SimButton, {
118
- label: "Restore",
119
- accent: true,
120
- disabled: !overrideActive,
121
- onPress: () => {
122
- (0, _overrides.clearOverride)(record.id);
123
- setMessage("Override removed — original source restored");
124
- }
125
- })]
126
- })]
127
- });
128
- }
129
- function SimButton({
130
- label,
131
- onPress,
132
- disabled,
133
- accent
134
- }) {
135
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.FooterButton, {
136
- label: label,
137
- onPress: onPress,
138
- disabled: disabled,
139
- accent: accent,
140
- style: {
141
- paddingVertical: 7
142
- }
143
- });
144
- }
145
- const styles = _reactNative.StyleSheet.create({
146
- navButton: {
147
- paddingHorizontal: 10,
148
- paddingVertical: 8,
149
- borderRadius: 6,
150
- backgroundColor: _sharedUi.night.color.button,
151
- alignItems: "center",
152
- justifyContent: "center"
153
- },
154
- disabled: {
155
- opacity: 0.4
156
- }
157
- });
158
- //# sourceMappingURL=ImageDetailFooter.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ImageDetailFooter=ImageDetailFooter;var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _actions=require("../capture/actions");var _overrides=require("../capture/overrides");var _jsxRuntime=require("react/jsx-runtime");function ImageDetailFooter({record:e,hasPrevious:s,hasNext:a,onPrevious:i,onNext:u}){const[d,o]=(0,_react.useState)(null);const c=l=>{o("\u2026");l().then(r=>o(r.message)).catch(r=>o(String(r?.message??r)))};const t=!e.mounted;const b=e.overrideLabel!=null;const n=(l,r)=>{(0,_overrides.setOverride)(e.id,{source:l,label:r});o(`${r} \u2014 Restore to undo`)};return(0,_jsxRuntime.jsxs)(_sharedUi.ToolFooter,{children:[d?(0,_jsxRuntime.jsx)(_sharedUi.FooterMessage,{children:d}):t?(0,_jsxRuntime.jsx)(_sharedUi.FooterMessage,{tone:"muted",children:"Instance unmounted \u2014 reload actions need the image on screen."}):null,(0,_jsxRuntime.jsxs)(_sharedUi.FooterRow,{style:{gap:8},children:[(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:i,disabled:!s,style:[styles.navButton,!s&&styles.disabled],activeOpacity:.7,accessibilityLabel:"Previous image",children:(0,_jsxRuntime.jsx)(_sharedUi.ChevronLeft,{size:20,color:s?_sharedUi.night.color.accent:_sharedUi.night.color.textTertiary})}),(0,_jsxRuntime.jsx)(_sharedUi.FooterButton,{label:"Hard reload",size:"md",disabled:t,icon:(0,_jsxRuntime.jsx)(_sharedUi.RefreshCw,{size:13,color:t?_sharedUi.night.color.textTertiary:_sharedUi.night.color.info}),onPress:()=>c(()=>(0,_actions.hardReloadRecord)(e))}),(0,_jsxRuntime.jsx)(_sharedUi.FooterButton,{label:e.status==="error"?"Retry":"Reload",size:"md",disabled:t,onPress:()=>c(()=>(0,_actions.retryRecord)(e))}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:u,disabled:!a,style:[styles.navButton,!a&&styles.disabled],activeOpacity:.7,accessibilityLabel:"Next image",children:(0,_jsxRuntime.jsx)(_sharedUi.ChevronRight,{size:20,color:a?_sharedUi.night.color.accent:_sharedUi.night.color.textTertiary})})]}),(0,_jsxRuntime.jsxs)(_sharedUi.FooterRow,{style:{gap:8},children:[(0,_jsxRuntime.jsx)(SimButton,{label:"Error",disabled:t,onPress:()=>n({type:"error"},"Forced error")}),(0,_jsxRuntime.jsx)(SimButton,{label:"Loading",disabled:t,onPress:()=>n({type:"hang"},"Forced loading")}),(0,_jsxRuntime.jsx)(SimButton,{label:"Blank",disabled:t,onPress:()=>n({type:"blank"},"Blanked")}),(0,_jsxRuntime.jsx)(SimButton,{label:"Find",disabled:t,onPress:()=>{(0,_overrides.flashRecord)(e.id);o("Flashing a red border on the image (2.5s)")}}),(0,_jsxRuntime.jsx)(SimButton,{label:"Restore",accent:true,disabled:!b,onPress:()=>{(0,_overrides.clearOverride)(e.id);o("Override removed \u2014 original source restored")}})]})]})}function SimButton({label:e,onPress:s,disabled:a,accent:i}){return(0,_jsxRuntime.jsx)(_sharedUi.FooterButton,{label:e,onPress:s,disabled:a,accent:i,style:{paddingVertical:7}})}const styles=_reactNative.StyleSheet.create({navButton:{paddingHorizontal:10,paddingVertical:8,borderRadius:6,backgroundColor:_sharedUi.night.color.button,alignItems:"center",justifyContent:"center"},disabled:{opacity:.4}});