@buoy-gg/images 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.
- package/README.md +11 -70
- package/lib/commonjs/autoCapture.js +1 -4
- package/lib/commonjs/autoCapture.web.js +1 -6
- package/lib/commonjs/capture/actions.js +1 -243
- package/lib/commonjs/capture/install.js +1 -45
- package/lib/commonjs/capture/install.web.js +1 -250
- package/lib/commonjs/capture/installExpoImage.js +1 -99
- package/lib/commonjs/capture/installRnImage.js +1 -132
- package/lib/commonjs/capture/nativeImageModules.js +1 -30
- package/lib/commonjs/capture/nativeImageModules.web.js +1 -18
- package/lib/commonjs/capture/overrides.js +1 -346
- package/lib/commonjs/capture/rnDecoratorEarly.js +1 -55
- package/lib/commonjs/capture/savings.js +1 -209
- package/lib/commonjs/capture/savings.web.js +1 -71
- package/lib/commonjs/capture/shared.js +1 -378
- package/lib/commonjs/components/ImageDetail.js +1 -455
- package/lib/commonjs/components/ImageDetailFooter.js +1 -158
- package/lib/commonjs/components/ImageRow.js +1 -156
- package/lib/commonjs/components/ImagesHeader.js +1 -63
- package/lib/commonjs/components/ImagesIcon.js +1 -19
- package/lib/commonjs/components/ImagesListFooter.js +1 -126
- package/lib/commonjs/components/ImagesModal.js +1 -240
- package/lib/commonjs/components/ImagesRoot.js +1 -24
- package/lib/commonjs/components/ImagesRoot.web.js +1 -13
- package/lib/commonjs/components/InsightsBar.js +1 -59
- package/lib/commonjs/export.js +1 -81
- package/lib/commonjs/format.js +1 -117
- package/lib/commonjs/hooks/useImageRecords.js +1 -20
- package/lib/commonjs/index.js +1 -261
- package/lib/commonjs/preset.js +1 -39
- package/lib/commonjs/register.js +1 -19
- package/lib/commonjs/registerEarly.js +1 -14
- package/lib/commonjs/remote.js +1 -42
- package/lib/commonjs/state.js +1 -58
- package/lib/commonjs/store/imageEventStore.js +1 -238
- package/lib/commonjs/store/insights.js +1 -76
- package/lib/commonjs/sync/imagesSyncAdapter.js +1 -361
- package/lib/commonjs/types.js +0 -1
- package/lib/module/autoCapture.js +1 -4
- package/lib/module/autoCapture.web.js +1 -5
- package/lib/module/capture/actions.js +1 -230
- package/lib/module/capture/install.js +1 -40
- package/lib/module/capture/install.web.js +1 -243
- package/lib/module/capture/installExpoImage.js +1 -94
- package/lib/module/capture/installRnImage.js +1 -125
- package/lib/module/capture/nativeImageModules.js +1 -24
- package/lib/module/capture/nativeImageModules.web.js +1 -12
- package/lib/module/capture/overrides.js +1 -329
- package/lib/module/capture/rnDecoratorEarly.js +1 -50
- package/lib/module/capture/savings.js +1 -205
- package/lib/module/capture/savings.web.js +1 -67
- package/lib/module/capture/shared.js +1 -369
- package/lib/module/components/ImageDetail.js +1 -451
- package/lib/module/components/ImageDetailFooter.js +1 -154
- package/lib/module/components/ImageRow.js +1 -152
- package/lib/module/components/ImagesHeader.js +1 -59
- package/lib/module/components/ImagesIcon.js +1 -12
- package/lib/module/components/ImagesListFooter.js +1 -122
- package/lib/module/components/ImagesModal.js +1 -235
- package/lib/module/components/ImagesRoot.js +1 -20
- package/lib/module/components/ImagesRoot.web.js +1 -9
- package/lib/module/components/InsightsBar.js +1 -55
- package/lib/module/export.js +1 -76
- package/lib/module/format.js +1 -108
- package/lib/module/hooks/useImageRecords.js +1 -16
- package/lib/module/index.js +1 -79
- package/lib/module/preset.js +1 -35
- package/lib/module/register.js +1 -19
- package/lib/module/registerEarly.js +1 -14
- package/lib/module/remote.js +1 -36
- package/lib/module/state.js +1 -54
- package/lib/module/store/imageEventStore.js +1 -221
- package/lib/module/store/insights.js +1 -71
- package/lib/module/sync/imagesSyncAdapter.js +1 -356
- package/lib/module/types.js +0 -1
- package/lib/web/chunks/chunk-TTS5EH4R.mjs +1 -2
- package/lib/web/index.mjs +3 -4
- package/lib/web/register.mjs +1 -2
- package/package.json +3 -7
- package/register.js +1 -15
- package/lib/commonjs/autoCapture.js.map +0 -1
- package/lib/commonjs/autoCapture.web.js.map +0 -1
- package/lib/commonjs/capture/actions.js.map +0 -1
- package/lib/commonjs/capture/install.js.map +0 -1
- package/lib/commonjs/capture/install.web.js.map +0 -1
- package/lib/commonjs/capture/installExpoImage.js.map +0 -1
- package/lib/commonjs/capture/installRnImage.js.map +0 -1
- package/lib/commonjs/capture/nativeImageModules.js.map +0 -1
- package/lib/commonjs/capture/nativeImageModules.web.js.map +0 -1
- package/lib/commonjs/capture/overrides.js.map +0 -1
- package/lib/commonjs/capture/rnDecoratorEarly.js.map +0 -1
- package/lib/commonjs/capture/savings.js.map +0 -1
- package/lib/commonjs/capture/savings.web.js.map +0 -1
- package/lib/commonjs/capture/shared.js.map +0 -1
- package/lib/commonjs/components/ImageDetail.js.map +0 -1
- package/lib/commonjs/components/ImageDetailFooter.js.map +0 -1
- package/lib/commonjs/components/ImageRow.js.map +0 -1
- package/lib/commonjs/components/ImagesHeader.js.map +0 -1
- package/lib/commonjs/components/ImagesIcon.js.map +0 -1
- package/lib/commonjs/components/ImagesListFooter.js.map +0 -1
- package/lib/commonjs/components/ImagesModal.js.map +0 -1
- package/lib/commonjs/components/ImagesRoot.js.map +0 -1
- package/lib/commonjs/components/ImagesRoot.web.js.map +0 -1
- package/lib/commonjs/components/InsightsBar.js.map +0 -1
- package/lib/commonjs/export.js.map +0 -1
- package/lib/commonjs/format.js.map +0 -1
- package/lib/commonjs/hooks/useImageRecords.js.map +0 -1
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/preset.js.map +0 -1
- package/lib/commonjs/register.js.map +0 -1
- package/lib/commonjs/registerEarly.js.map +0 -1
- package/lib/commonjs/remote.js.map +0 -1
- package/lib/commonjs/state.js.map +0 -1
- package/lib/commonjs/store/imageEventStore.js.map +0 -1
- package/lib/commonjs/store/insights.js.map +0 -1
- package/lib/commonjs/sync/imagesSyncAdapter.js.map +0 -1
- package/lib/commonjs/types.js.map +0 -1
- package/lib/module/autoCapture.js.map +0 -1
- package/lib/module/autoCapture.web.js.map +0 -1
- package/lib/module/capture/actions.js.map +0 -1
- package/lib/module/capture/install.js.map +0 -1
- package/lib/module/capture/install.web.js.map +0 -1
- package/lib/module/capture/installExpoImage.js.map +0 -1
- package/lib/module/capture/installRnImage.js.map +0 -1
- package/lib/module/capture/nativeImageModules.js.map +0 -1
- package/lib/module/capture/nativeImageModules.web.js.map +0 -1
- package/lib/module/capture/overrides.js.map +0 -1
- package/lib/module/capture/rnDecoratorEarly.js.map +0 -1
- package/lib/module/capture/savings.js.map +0 -1
- package/lib/module/capture/savings.web.js.map +0 -1
- package/lib/module/capture/shared.js.map +0 -1
- package/lib/module/components/ImageDetail.js.map +0 -1
- package/lib/module/components/ImageDetailFooter.js.map +0 -1
- package/lib/module/components/ImageRow.js.map +0 -1
- package/lib/module/components/ImagesHeader.js.map +0 -1
- package/lib/module/components/ImagesIcon.js.map +0 -1
- package/lib/module/components/ImagesListFooter.js.map +0 -1
- package/lib/module/components/ImagesModal.js.map +0 -1
- package/lib/module/components/ImagesRoot.js.map +0 -1
- package/lib/module/components/ImagesRoot.web.js.map +0 -1
- package/lib/module/components/InsightsBar.js.map +0 -1
- package/lib/module/export.js.map +0 -1
- package/lib/module/format.js.map +0 -1
- package/lib/module/hooks/useImageRecords.js.map +0 -1
- package/lib/module/index.js.map +0 -1
- package/lib/module/preset.js.map +0 -1
- package/lib/module/register.js.map +0 -1
- package/lib/module/registerEarly.js.map +0 -1
- package/lib/module/remote.js.map +0 -1
- package/lib/module/state.js.map +0 -1
- package/lib/module/store/imageEventStore.js.map +0 -1
- package/lib/module/store/insights.js.map +0 -1
- package/lib/module/sync/imagesSyncAdapter.js.map +0 -1
- package/lib/module/types.js.map +0 -1
- package/lib/typescript/autoCapture.d.ts.map +0 -1
- package/lib/typescript/autoCapture.web.d.ts.map +0 -1
- package/lib/typescript/capture/actions.d.ts.map +0 -1
- package/lib/typescript/capture/install.d.ts.map +0 -1
- package/lib/typescript/capture/install.web.d.ts.map +0 -1
- package/lib/typescript/capture/installExpoImage.d.ts.map +0 -1
- package/lib/typescript/capture/installRnImage.d.ts.map +0 -1
- package/lib/typescript/capture/nativeImageModules.d.ts.map +0 -1
- package/lib/typescript/capture/nativeImageModules.web.d.ts.map +0 -1
- package/lib/typescript/capture/overrides.d.ts.map +0 -1
- package/lib/typescript/capture/rnDecoratorEarly.d.ts.map +0 -1
- package/lib/typescript/capture/savings.d.ts.map +0 -1
- package/lib/typescript/capture/savings.web.d.ts.map +0 -1
- package/lib/typescript/capture/shared.d.ts.map +0 -1
- package/lib/typescript/components/ImageDetail.d.ts.map +0 -1
- package/lib/typescript/components/ImageDetailFooter.d.ts.map +0 -1
- package/lib/typescript/components/ImageRow.d.ts.map +0 -1
- package/lib/typescript/components/ImagesHeader.d.ts.map +0 -1
- package/lib/typescript/components/ImagesIcon.d.ts.map +0 -1
- package/lib/typescript/components/ImagesListFooter.d.ts.map +0 -1
- package/lib/typescript/components/ImagesModal.d.ts.map +0 -1
- package/lib/typescript/components/ImagesRoot.d.ts.map +0 -1
- package/lib/typescript/components/ImagesRoot.web.d.ts.map +0 -1
- package/lib/typescript/components/InsightsBar.d.ts.map +0 -1
- package/lib/typescript/export.d.ts.map +0 -1
- package/lib/typescript/format.d.ts.map +0 -1
- package/lib/typescript/hooks/useImageRecords.d.ts.map +0 -1
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/preset.d.ts.map +0 -1
- package/lib/typescript/register.d.ts.map +0 -1
- package/lib/typescript/registerEarly.d.ts.map +0 -1
- package/lib/typescript/remote.d.ts.map +0 -1
- package/lib/typescript/state.d.ts.map +0 -1
- package/lib/typescript/store/imageEventStore.d.ts.map +0 -1
- package/lib/typescript/store/insights.d.ts.map +0 -1
- package/lib/typescript/sync/imagesSyncAdapter.d.ts.map +0 -1
- package/lib/typescript/types.d.ts.map +0 -1
- package/lib/web/chunks/chunk-7CWLRQ2L.mjs +0 -2
- package/lib/web/chunks/chunk-B5A6CYSS.mjs +0 -2
- package/lib/web/chunks/chunk-LKTR6X2V.mjs +0 -2
|
@@ -1,250 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getCaptureStatus = getCaptureStatus;
|
|
7
|
-
exports.installImageCapture = installImageCapture;
|
|
8
|
-
exports.startBrowserImageCapture = startBrowserImageCapture;
|
|
9
|
-
exports.stopBrowserImageCapture = stopBrowserImageCapture;
|
|
10
|
-
var _state = require("../state");
|
|
11
|
-
var _imageEventStore = require("../store/imageEventStore");
|
|
12
|
-
var _overrides = require("./overrides");
|
|
13
|
-
const tracked = new Map();
|
|
14
|
-
let detach;
|
|
15
|
-
let leases = 0;
|
|
16
|
-
const EMPTY_IMAGE = 'data:image/png;base64,';
|
|
17
|
-
function apply(item) {
|
|
18
|
-
const record = (0, _imageEventStore.getRecord)(item.id);
|
|
19
|
-
if (!record) return;
|
|
20
|
-
const state = (0, _state.imagesState)();
|
|
21
|
-
const override = (0, _overrides.getOverride)(item.id);
|
|
22
|
-
const modes = (0, _overrides.getGlobalModes)();
|
|
23
|
-
let source = item.source;
|
|
24
|
-
if (modes.network === 'offline' && record.sourceKind === 'network') source = EMPTY_IMAGE;
|
|
25
|
-
if (override?.source) {
|
|
26
|
-
const next = override.source;
|
|
27
|
-
if (next.type === 'url') source = next.uri;else if (next.type === 'error') source = EMPTY_IMAGE;else source = null;
|
|
28
|
-
if (next.type === 'hang') (0, _imageEventStore.updateRecord)(item.id, {
|
|
29
|
-
status: 'loading'
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
const request = state.reloadRequests.get(item.id);
|
|
33
|
-
const reload = request && request.nonce !== item.nonce;
|
|
34
|
-
if (reload) {
|
|
35
|
-
item.nonce = request.nonce;
|
|
36
|
-
if (request.bust && source && /^https?:/.test(new URL(source, document.baseURI).href)) {
|
|
37
|
-
const url = new URL(source, document.baseURI);
|
|
38
|
-
url.searchParams.set('__buoy_reload', String(Date.now()));
|
|
39
|
-
source = url.href;
|
|
40
|
-
}
|
|
41
|
-
item.image.removeAttribute('src');
|
|
42
|
-
(0, _imageEventStore.updateRecord)(item.id, {
|
|
43
|
-
status: 'loading',
|
|
44
|
-
startedAt: Date.now(),
|
|
45
|
-
loadCount: record.loadCount + 1
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
if (modes.network === 'cold' && source && /^https?:/.test(new URL(source, document.baseURI).href)) {
|
|
49
|
-
if (item.coldSource !== source || !item.coldURL || reload) {
|
|
50
|
-
item.coldSource = source;
|
|
51
|
-
const url = new URL(source, document.baseURI);
|
|
52
|
-
url.searchParams.set('__buoy_reload', `${Date.now()}-${item.nonce}`);
|
|
53
|
-
item.coldURL = url.href;
|
|
54
|
-
}
|
|
55
|
-
source = item.coldURL;
|
|
56
|
-
} else {
|
|
57
|
-
item.coldSource = undefined;
|
|
58
|
-
item.coldURL = undefined;
|
|
59
|
-
}
|
|
60
|
-
item.appliedSource = source;
|
|
61
|
-
item.appliedSrcset = source !== item.source ? null : item.srcset;
|
|
62
|
-
if (item.appliedSrcset === null) item.image.removeAttribute('srcset');else if (item.image.getAttribute('srcset') !== item.appliedSrcset) item.image.setAttribute('srcset', item.appliedSrcset);
|
|
63
|
-
if (source === null) item.image.removeAttribute('src');else if (item.image.getAttribute('src') !== source) item.image.setAttribute('src', source);
|
|
64
|
-
const style = document.createElement('span').style;
|
|
65
|
-
style.cssText = item.style ?? '';
|
|
66
|
-
const fit = override?.extraProps?.contentFit ?? override?.extraProps?.resizeMode;
|
|
67
|
-
if (typeof fit === 'string') style.objectFit = {
|
|
68
|
-
stretch: 'fill',
|
|
69
|
-
center: 'none'
|
|
70
|
-
}[fit] ?? fit;
|
|
71
|
-
if (modes.blank || override?.source?.type === 'blank') style.opacity = '0';
|
|
72
|
-
for (const [key, value] of Object.entries(override?.style ?? {})) {
|
|
73
|
-
const css = key.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`);
|
|
74
|
-
style.setProperty(css, typeof value === 'number' && !['opacity', 'zIndex', 'flex', 'flexGrow', 'flexShrink'].includes(key) ? `${value}px` : String(value));
|
|
75
|
-
}
|
|
76
|
-
if ((state.flashUntil.get(item.id) ?? 0) > Date.now()) style.outline = '3px solid #ff453a';
|
|
77
|
-
item.appliedStyle = style.cssText || null;
|
|
78
|
-
if (item.image.getAttribute('style') !== item.appliedStyle) {
|
|
79
|
-
if (item.appliedStyle === null) item.image.removeAttribute('style');else item.image.setAttribute('style', item.appliedStyle);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
function track(image) {
|
|
83
|
-
if (tracked.has(image) || image.closest('[data-buoy-root]')) return;
|
|
84
|
-
const uri = image.currentSrc || image.src;
|
|
85
|
-
if (!uri) return;
|
|
86
|
-
const record = (0, _imageEventStore.createRecord)({
|
|
87
|
-
lib: 'web',
|
|
88
|
-
uri,
|
|
89
|
-
sourceKind: uri.startsWith('data:') ? 'data' : uri.startsWith('blob:') ? 'file' : 'network',
|
|
90
|
-
hasAltText: image.hasAttribute('alt') || image.hasAttribute('aria-label')
|
|
91
|
-
});
|
|
92
|
-
const item = {
|
|
93
|
-
id: record.id,
|
|
94
|
-
image,
|
|
95
|
-
source: image.getAttribute('src'),
|
|
96
|
-
srcset: image.getAttribute('srcset'),
|
|
97
|
-
style: image.getAttribute('style'),
|
|
98
|
-
appliedSource: image.getAttribute('src'),
|
|
99
|
-
appliedSrcset: image.getAttribute('srcset'),
|
|
100
|
-
appliedStyle: image.getAttribute('style'),
|
|
101
|
-
nonce: 0,
|
|
102
|
-
dispose() {}
|
|
103
|
-
};
|
|
104
|
-
const layout = () => {
|
|
105
|
-
const rect = image.getBoundingClientRect();
|
|
106
|
-
const previous = record.layout;
|
|
107
|
-
const shifted = record.status === 'loaded' && previous && (previous.width !== rect.width || previous.height !== rect.height);
|
|
108
|
-
(0, _imageEventStore.updateRecord)(record.id, {
|
|
109
|
-
layout: {
|
|
110
|
-
width: rect.width,
|
|
111
|
-
height: rect.height
|
|
112
|
-
},
|
|
113
|
-
layoutShifts: (record.layoutShifts ?? 0) + (shifted ? 1 : 0)
|
|
114
|
-
});
|
|
115
|
-
};
|
|
116
|
-
const loaded = () => {
|
|
117
|
-
const timings = performance.getEntriesByName(image.currentSrc || image.src);
|
|
118
|
-
const timing = timings[timings.length - 1];
|
|
119
|
-
(0, _imageEventStore.updateRecord)(record.id, {
|
|
120
|
-
status: 'loaded',
|
|
121
|
-
loadedAt: Date.now(),
|
|
122
|
-
intrinsic: {
|
|
123
|
-
width: image.naturalWidth,
|
|
124
|
-
height: image.naturalHeight
|
|
125
|
-
},
|
|
126
|
-
...(!(0, _overrides.getOverride)(record.id)?.source && (0, _overrides.getGlobalModes)().network === 'normal' ? {
|
|
127
|
-
uri: image.currentSrc || image.src
|
|
128
|
-
} : {}),
|
|
129
|
-
durationMs: timing?.duration,
|
|
130
|
-
bytesTotal: timing && timing.encodedBodySize > 0 ? timing.encodedBodySize : undefined,
|
|
131
|
-
cacheVerdict: timing && timing.transferSize > 0 ? 'none' : undefined,
|
|
132
|
-
cacheVerdictSource: timing ? 'event' : undefined
|
|
133
|
-
});
|
|
134
|
-
layout();
|
|
135
|
-
};
|
|
136
|
-
const failed = () => (0, _imageEventStore.updateRecord)(record.id, {
|
|
137
|
-
status: 'error',
|
|
138
|
-
erroredAt: Date.now(),
|
|
139
|
-
error: 'The browser could not load this image.'
|
|
140
|
-
});
|
|
141
|
-
image.addEventListener('load', loaded);
|
|
142
|
-
image.addEventListener('error', failed);
|
|
143
|
-
const observer = typeof ResizeObserver === 'undefined' ? undefined : new ResizeObserver(layout);
|
|
144
|
-
observer?.observe(image);
|
|
145
|
-
item.dispose = () => {
|
|
146
|
-
observer?.disconnect();
|
|
147
|
-
image.removeEventListener('load', loaded);
|
|
148
|
-
image.removeEventListener('error', failed);
|
|
149
|
-
};
|
|
150
|
-
tracked.set(image, item);
|
|
151
|
-
layout();
|
|
152
|
-
(0, _imageEventStore.updateRecord)(record.id, {
|
|
153
|
-
status: 'loading',
|
|
154
|
-
startedAt: Date.now(),
|
|
155
|
-
loadCount: 1
|
|
156
|
-
});
|
|
157
|
-
if (image.complete) {
|
|
158
|
-
if (image.naturalWidth > 0) loaded();else failed();
|
|
159
|
-
}
|
|
160
|
-
apply(item);
|
|
161
|
-
}
|
|
162
|
-
function installImageCapture() {
|
|
163
|
-
const state = (0, _state.imagesState)();
|
|
164
|
-
if (typeof document === 'undefined' || state.captureDisabled || detach) return;
|
|
165
|
-
state.captureInstalled = true;
|
|
166
|
-
const scan = () => {
|
|
167
|
-
for (const [image, item] of tracked) if (!image.isConnected) {
|
|
168
|
-
item.dispose();
|
|
169
|
-
tracked.delete(image);
|
|
170
|
-
(0, _imageEventStore.updateRecord)(item.id, {
|
|
171
|
-
mounted: false
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
document.querySelectorAll('img').forEach(track);
|
|
175
|
-
};
|
|
176
|
-
const observer = new MutationObserver(changes => {
|
|
177
|
-
if ((0, _state.imagesState)().captureDisabled) {
|
|
178
|
-
stopBrowserImageCapture();
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
for (const change of changes) {
|
|
182
|
-
const image = change.target;
|
|
183
|
-
const item = tracked.get(image);
|
|
184
|
-
if (!item || change.type !== 'attributes') continue;
|
|
185
|
-
if (change.attributeName === 'src' && image.getAttribute('src') !== item.appliedSource || change.attributeName === 'srcset' && image.getAttribute('srcset') !== item.appliedSrcset) {
|
|
186
|
-
item.dispose();
|
|
187
|
-
tracked.delete(image);
|
|
188
|
-
(0, _imageEventStore.updateRecord)(item.id, {
|
|
189
|
-
mounted: false
|
|
190
|
-
});
|
|
191
|
-
} else if (change.attributeName === 'style' && image.getAttribute('style') !== item.appliedStyle) {
|
|
192
|
-
item.style = image.getAttribute('style');
|
|
193
|
-
apply(item);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
scan();
|
|
197
|
-
});
|
|
198
|
-
observer.observe(document.documentElement, {
|
|
199
|
-
childList: true,
|
|
200
|
-
subtree: true,
|
|
201
|
-
attributes: true,
|
|
202
|
-
attributeFilter: ['src', 'srcset', 'style', 'alt']
|
|
203
|
-
});
|
|
204
|
-
const actions = () => {
|
|
205
|
-
for (const item of tracked.values()) apply(item);
|
|
206
|
-
};
|
|
207
|
-
state.actionListeners.add(actions);
|
|
208
|
-
detach = () => {
|
|
209
|
-
observer.disconnect();
|
|
210
|
-
state.actionListeners.delete(actions);
|
|
211
|
-
for (const item of tracked.values()) {
|
|
212
|
-
item.dispose();
|
|
213
|
-
for (const [attribute, value, applied] of [['src', item.source, item.appliedSource], ['srcset', item.srcset, item.appliedSrcset], ['style', item.style, item.appliedStyle]]) {
|
|
214
|
-
if (item.image.getAttribute(attribute) !== applied) continue;
|
|
215
|
-
if (value === null) item.image.removeAttribute(attribute);else item.image.setAttribute(attribute, value);
|
|
216
|
-
}
|
|
217
|
-
(0, _imageEventStore.updateRecord)(item.id, {
|
|
218
|
-
mounted: false
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
tracked.clear();
|
|
222
|
-
state.captureInstalled = false;
|
|
223
|
-
};
|
|
224
|
-
scan();
|
|
225
|
-
}
|
|
226
|
-
function stopBrowserImageCapture() {
|
|
227
|
-
detach?.();
|
|
228
|
-
detach = undefined;
|
|
229
|
-
}
|
|
230
|
-
function startBrowserImageCapture() {
|
|
231
|
-
if (typeof document === 'undefined') return () => {};
|
|
232
|
-
if (leases++ === 0) installImageCapture();
|
|
233
|
-
let released = false;
|
|
234
|
-
return () => {
|
|
235
|
-
if (released) return;
|
|
236
|
-
released = true;
|
|
237
|
-
if (--leases === 0) stopBrowserImageCapture();
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
function getCaptureStatus() {
|
|
241
|
-
return (0, _state.imagesState)().mirrorCaptureStatus ?? {
|
|
242
|
-
installed: !!detach,
|
|
243
|
-
rnDecoratorActive: false,
|
|
244
|
-
rnDecoratorTooLate: false,
|
|
245
|
-
expoPatched: false,
|
|
246
|
-
expoAvailable: false,
|
|
247
|
-
browserObserverActive: !!detach
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
//# sourceMappingURL=install.web.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getCaptureStatus=getCaptureStatus;exports.installImageCapture=installImageCapture;exports.startBrowserImageCapture=startBrowserImageCapture;exports.stopBrowserImageCapture=stopBrowserImageCapture;var _state=require("../state");var _imageEventStore=require("../store/imageEventStore");var _overrides=require("./overrides");const tracked=new Map;let detach;let leases=0;const EMPTY_IMAGE="data:image/png;base64,";function apply(e){const l=(0,_imageEventStore.getRecord)(e.id);if(!l)return;const n=(0,_state.imagesState)();const d=(0,_overrides.getOverride)(e.id);const r=(0,_overrides.getGlobalModes)();let t=e.source;if(r.network==="offline"&&l.sourceKind==="network")t=EMPTY_IMAGE;if(d?.source){const c=d.source;if(c.type==="url")t=c.uri;else if(c.type==="error")t=EMPTY_IMAGE;else t=null;if(c.type==="hang")(0,_imageEventStore.updateRecord)(e.id,{status:"loading"})}const s=n.reloadRequests.get(e.id);const o=s&&s.nonce!==e.nonce;if(o){e.nonce=s.nonce;if(s.bust&&t&&/^https?:/.test(new URL(t,document.baseURI).href)){const c=new URL(t,document.baseURI);c.searchParams.set("__buoy_reload",String(Date.now()));t=c.href}e.image.removeAttribute("src");(0,_imageEventStore.updateRecord)(e.id,{status:"loading",startedAt:Date.now(),loadCount:l.loadCount+1})}if(r.network==="cold"&&t&&/^https?:/.test(new URL(t,document.baseURI).href)){if(e.coldSource!==t||!e.coldURL||o){e.coldSource=t;const c=new URL(t,document.baseURI);c.searchParams.set("__buoy_reload",`${Date.now()}-${e.nonce}`);e.coldURL=c.href}t=e.coldURL}else{e.coldSource=void 0;e.coldURL=void 0}e.appliedSource=t;e.appliedSrcset=t!==e.source?null:e.srcset;if(e.appliedSrcset===null)e.image.removeAttribute("srcset");else if(e.image.getAttribute("srcset")!==e.appliedSrcset)e.image.setAttribute("srcset",e.appliedSrcset);if(t===null)e.image.removeAttribute("src");else if(e.image.getAttribute("src")!==t)e.image.setAttribute("src",t);const i=document.createElement("span").style;i.cssText=e.style??"";const a=d?.extraProps?.contentFit??d?.extraProps?.resizeMode;if(typeof a==="string")i.objectFit={stretch:"fill",center:"none"}[a]??a;if(r.blank||d?.source?.type==="blank")i.opacity="0";for(const[c,u]of Object.entries(d?.style??{})){const p=c.replace(/[A-Z]/g,f=>`-${f.toLowerCase()}`);i.setProperty(p,typeof u==="number"&&!["opacity","zIndex","flex","flexGrow","flexShrink"].includes(c)?`${u}px`:String(u))}if((n.flashUntil.get(e.id)??0)>Date.now())i.outline="3px solid #ff453a";e.appliedStyle=i.cssText||null;if(e.image.getAttribute("style")!==e.appliedStyle){if(e.appliedStyle===null)e.image.removeAttribute("style");else e.image.setAttribute("style",e.appliedStyle)}}function track(e){if(tracked.has(e)||e.closest("[data-buoy-root]"))return;const l=e.currentSrc||e.src;if(!l)return;const n=(0,_imageEventStore.createRecord)({lib:"web",uri:l,sourceKind:l.startsWith("data:")?"data":l.startsWith("blob:")?"file":"network",hasAltText:e.hasAttribute("alt")||e.hasAttribute("aria-label")});const d={id:n.id,image:e,source:e.getAttribute("src"),srcset:e.getAttribute("srcset"),style:e.getAttribute("style"),appliedSource:e.getAttribute("src"),appliedSrcset:e.getAttribute("srcset"),appliedStyle:e.getAttribute("style"),nonce:0,dispose(){}};const r=()=>{const i=e.getBoundingClientRect();const a=n.layout;const c=n.status==="loaded"&&a&&(a.width!==i.width||a.height!==i.height);(0,_imageEventStore.updateRecord)(n.id,{layout:{width:i.width,height:i.height},layoutShifts:(n.layoutShifts??0)+(c?1:0)})};const t=()=>{const i=performance.getEntriesByName(e.currentSrc||e.src);const a=i[i.length-1];(0,_imageEventStore.updateRecord)(n.id,{status:"loaded",loadedAt:Date.now(),intrinsic:{width:e.naturalWidth,height:e.naturalHeight},...!(0,_overrides.getOverride)(n.id)?.source&&(0,_overrides.getGlobalModes)().network==="normal"?{uri:e.currentSrc||e.src}:{},durationMs:a?.duration,bytesTotal:a&&a.encodedBodySize>0?a.encodedBodySize:void 0,cacheVerdict:a&&a.transferSize>0?"none":void 0,cacheVerdictSource:a?"event":void 0});r()};const s=()=>(0,_imageEventStore.updateRecord)(n.id,{status:"error",erroredAt:Date.now(),error:"The browser could not load this image."});e.addEventListener("load",t);e.addEventListener("error",s);const o=typeof ResizeObserver==="undefined"?void 0:new ResizeObserver(r);o?.observe(e);d.dispose=()=>{o?.disconnect();e.removeEventListener("load",t);e.removeEventListener("error",s)};tracked.set(e,d);r();(0,_imageEventStore.updateRecord)(n.id,{status:"loading",startedAt:Date.now(),loadCount:1});if(e.complete){if(e.naturalWidth>0)t();else s()}apply(d)}function installImageCapture(){const e=(0,_state.imagesState)();if(typeof document==="undefined"||e.captureDisabled||detach)return;e.captureInstalled=true;const l=()=>{for(const[r,t]of tracked)if(!r.isConnected){t.dispose();tracked.delete(r);(0,_imageEventStore.updateRecord)(t.id,{mounted:false})}document.querySelectorAll("img").forEach(track)};const n=new MutationObserver(r=>{if((0,_state.imagesState)().captureDisabled){stopBrowserImageCapture();return}for(const t of r){const s=t.target;const o=tracked.get(s);if(!o||t.type!=="attributes")continue;if(t.attributeName==="src"&&s.getAttribute("src")!==o.appliedSource||t.attributeName==="srcset"&&s.getAttribute("srcset")!==o.appliedSrcset){o.dispose();tracked.delete(s);(0,_imageEventStore.updateRecord)(o.id,{mounted:false})}else if(t.attributeName==="style"&&s.getAttribute("style")!==o.appliedStyle){o.style=s.getAttribute("style");apply(o)}}l()});n.observe(document.documentElement,{childList:true,subtree:true,attributes:true,attributeFilter:["src","srcset","style","alt"]});const d=()=>{for(const r of tracked.values())apply(r)};e.actionListeners.add(d);detach=()=>{n.disconnect();e.actionListeners.delete(d);for(const r of tracked.values()){r.dispose();for(const[t,s,o]of[["src",r.source,r.appliedSource],["srcset",r.srcset,r.appliedSrcset],["style",r.style,r.appliedStyle]]){if(r.image.getAttribute(t)!==o)continue;if(s===null)r.image.removeAttribute(t);else r.image.setAttribute(t,s)}(0,_imageEventStore.updateRecord)(r.id,{mounted:false})}tracked.clear();e.captureInstalled=false};l()}function stopBrowserImageCapture(){detach?.();detach=void 0}function startBrowserImageCapture(){if(typeof document==="undefined")return()=>{};if(leases++===0)installImageCapture();let e=false;return()=>{if(e)return;e=true;if(--leases===0)stopBrowserImageCapture()}}function getCaptureStatus(){return(0,_state.imagesState)().mirrorCaptureStatus??{installed:!!detach,rnDecoratorActive:false,rnDecoratorTooLate:false,expoPatched:false,expoAvailable:false,browserObserverActive:!!detach}}
|
|
@@ -1,99 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.expoCaptureStatus = expoCaptureStatus;
|
|
7
|
-
exports.installExpoImageInterceptor = installExpoImageInterceptor;
|
|
8
|
-
var _state = require("../state");
|
|
9
|
-
var _actions = require("./actions");
|
|
10
|
-
var _overrides = require("./overrides");
|
|
11
|
-
var _shared = require("./shared");
|
|
12
|
-
/**
|
|
13
|
-
* expo-image interception via class-prototype patch.
|
|
14
|
-
*
|
|
15
|
-
* expo-image's <Image> is a class component (React.PureComponent) whose
|
|
16
|
-
* render() reads `this.props`, so wrapping the prototype's render and swapping
|
|
17
|
-
* `this.props` for an instrumented copy for the duration of the original
|
|
18
|
-
* render is timing-immune (prototype methods are looked up dynamically — no
|
|
19
|
-
* import-order race like the RN core decorator). Props are restored in
|
|
20
|
-
* `finally`, so PureComponent's shouldComponentUpdate still compares the
|
|
21
|
-
* app's real props.
|
|
22
|
-
*
|
|
23
|
-
* Double-patch safety: install flags live on the globalThis singleton AND a
|
|
24
|
-
* marker is stamped on the prototype itself, so even two module instances of
|
|
25
|
-
* this package can't wrap render() twice.
|
|
26
|
-
*
|
|
27
|
-
* expo-image is an optional peer: if it isn't installed, this is a no-op.
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
const PATCH_MARKER = "__buoyImagesPatched";
|
|
31
|
-
const trackers = new WeakMap();
|
|
32
|
-
function trackerFor(instance) {
|
|
33
|
-
let tracker = trackers.get(instance);
|
|
34
|
-
if (!tracker) {
|
|
35
|
-
tracker = new _shared.ImageInstanceTracker("expo");
|
|
36
|
-
trackers.set(instance, tracker);
|
|
37
|
-
}
|
|
38
|
-
return tracker;
|
|
39
|
-
}
|
|
40
|
-
function installExpoImageInterceptor() {
|
|
41
|
-
const s = (0, _state.imagesState)();
|
|
42
|
-
if (s.expoInstalled) return;
|
|
43
|
-
s.expoInstalled = true;
|
|
44
|
-
let ImageClass;
|
|
45
|
-
try {
|
|
46
|
-
ImageClass = require("expo-image").Image;
|
|
47
|
-
} catch {
|
|
48
|
-
s.expoAvailable = false;
|
|
49
|
-
return; // expo-image not installed in this app
|
|
50
|
-
}
|
|
51
|
-
if (!ImageClass?.prototype?.render) {
|
|
52
|
-
s.expoAvailable = false;
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
s.expoAvailable = true;
|
|
56
|
-
const proto = ImageClass.prototype;
|
|
57
|
-
if (proto[PATCH_MARKER]) {
|
|
58
|
-
s.expoPatched = true;
|
|
59
|
-
return; // already patched by another module instance of this package
|
|
60
|
-
}
|
|
61
|
-
proto[PATCH_MARKER] = true;
|
|
62
|
-
const originalRender = proto.render;
|
|
63
|
-
const originalUnmount = proto.componentWillUnmount;
|
|
64
|
-
proto.render = function buoyImagesRender() {
|
|
65
|
-
const originalProps = this.props;
|
|
66
|
-
if ((0, _shared.isInternalImage)(originalProps?.testID)) {
|
|
67
|
-
return originalRender.call(this);
|
|
68
|
-
}
|
|
69
|
-
const tracker = trackerFor(this);
|
|
70
|
-
tracker.syncSource(originalProps?.source);
|
|
71
|
-
tracker.noteA11y(Boolean(originalProps?.alt ?? originalProps?.accessibilityLabel));
|
|
72
|
-
// Keep the action layer pointed at the live instance (reloadAsync etc.).
|
|
73
|
-
(0, _actions.registerExpoInstance)(tracker.getRecordId(), this);
|
|
74
|
-
const wrapped = tracker.handlers(originalProps);
|
|
75
|
-
try {
|
|
76
|
-
// Simulation layer: global modes + per-record override + locate-flash.
|
|
77
|
-
this.props = (0, _overrides.applyOverrides)({
|
|
78
|
-
...originalProps,
|
|
79
|
-
...wrapped
|
|
80
|
-
}, tracker.getRecordId(), "expo");
|
|
81
|
-
return originalRender.call(this);
|
|
82
|
-
} finally {
|
|
83
|
-
this.props = originalProps;
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
proto.componentWillUnmount = function buoyImagesUnmount() {
|
|
87
|
-
trackers.get(this)?.unmount();
|
|
88
|
-
originalUnmount?.call(this);
|
|
89
|
-
};
|
|
90
|
-
s.expoPatched = true;
|
|
91
|
-
}
|
|
92
|
-
function expoCaptureStatus() {
|
|
93
|
-
const s = (0, _state.imagesState)();
|
|
94
|
-
return {
|
|
95
|
-
available: s.expoAvailable,
|
|
96
|
-
patched: s.expoPatched
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
//# sourceMappingURL=installExpoImage.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.expoCaptureStatus=expoCaptureStatus;exports.installExpoImageInterceptor=installExpoImageInterceptor;var _state=require("../state");var _actions=require("./actions");var _overrides=require("./overrides");var _shared=require("./shared");const PATCH_MARKER="__buoyImagesPatched";const trackers=new WeakMap;function trackerFor(e){let t=trackers.get(e);if(!t){t=new _shared.ImageInstanceTracker("expo");trackers.set(e,t)}return t}function installExpoImageInterceptor(){const e=(0,_state.imagesState)();if(e.expoInstalled)return;e.expoInstalled=true;let t;try{t=require("expo-image").Image}catch{e.expoAvailable=false;return}if(!t?.prototype?.render){e.expoAvailable=false;return}e.expoAvailable=true;const a=t.prototype;if(a[PATCH_MARKER]){e.expoPatched=true;return}a[PATCH_MARKER]=true;const n=a.render;const s=a.componentWillUnmount;a.render=function i(){const r=this.props;if((0,_shared.isInternalImage)(r?.testID)){return n.call(this)}const o=trackerFor(this);o.syncSource(r?.source);o.noteA11y(Boolean(r?.alt??r?.accessibilityLabel));(0,_actions.registerExpoInstance)(o.getRecordId(),this);const l=o.handlers(r);try{this.props=(0,_overrides.applyOverrides)({...r,...l},o.getRecordId(),"expo");return n.call(this)}finally{this.props=r}};a.componentWillUnmount=function i(){trackers.get(this)?.unmount();s?.call(this)};e.expoPatched=true}function expoCaptureStatus(){const e=(0,_state.imagesState)();return{available:e.expoAvailable,patched:e.expoPatched}}
|
|
@@ -1,132 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.installRnImageInterceptor = installRnImageInterceptor;
|
|
7
|
-
exports.rnCaptureStatus = rnCaptureStatus;
|
|
8
|
-
exports.useImageCapture = useImageCapture;
|
|
9
|
-
var React = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _state = require("../state");
|
|
11
|
-
var _actions = require("./actions");
|
|
12
|
-
var _overrides = require("./overrides");
|
|
13
|
-
var _shared = require("./shared");
|
|
14
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
16
|
-
/**
|
|
17
|
-
* RN core <Image> interception via the official injection hook.
|
|
18
|
-
*
|
|
19
|
-
* `unstable_setImageComponentDecorator` wraps EVERY RN <Image> app-wide — but
|
|
20
|
-
* the decorator is latched ONCE, at Image module evaluation
|
|
21
|
-
* (`Image.ios.js` / `Image.android.js` read it at module scope). So install
|
|
22
|
-
* order matters: this must run before anything touches `Image` from
|
|
23
|
-
* 'react-native' — hence the `@buoy-gg/images/register` first-import.
|
|
24
|
-
*
|
|
25
|
-
* Detection strategy: the decorator sets `decoratorInvoked` when RN's Image
|
|
26
|
-
* module applies it. `unstable_registerImageAttachedCallback` is a live Set
|
|
27
|
-
* (never latched), so image mounts are always visible — if mounts happen but
|
|
28
|
-
* the decorator never ran, we were too late and CaptureStatus reports it.
|
|
29
|
-
*
|
|
30
|
-
* All flags live on the globalThis singleton (../state.ts) so a second module
|
|
31
|
-
* instance of this package neither re-installs nor reports a stale status.
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
/** Wraps one RN Image render with capture instrumentation + reload actions. */
|
|
35
|
-
function useImageCapture(props) {
|
|
36
|
-
const trackerRef = React.useRef(null);
|
|
37
|
-
if (trackerRef.current == null) {
|
|
38
|
-
trackerRef.current = new _shared.ImageInstanceTracker("rn");
|
|
39
|
-
}
|
|
40
|
-
const tracker = trackerRef.current;
|
|
41
|
-
const internal = (0, _shared.isInternalImage)(props.testID);
|
|
42
|
-
if (!internal) {
|
|
43
|
-
tracker.syncSource(props.source);
|
|
44
|
-
tracker.noteA11y(Boolean(props.alt ?? props.accessibilityLabel ?? props["aria-label"]));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Action/override bus: version bumps re-render just this instance (snapshot
|
|
48
|
-
// is per-record with a global floor, so unrelated actions don't invalidate
|
|
49
|
-
// other images but global-mode toggles reach everyone).
|
|
50
|
-
React.useSyncExternalStore(_actions.subscribeActions, () => (0, _overrides.getRenderVersion)(internal ? null : tracker.getRecordId()));
|
|
51
|
-
React.useEffect(() => {
|
|
52
|
-
if (internal) return undefined;
|
|
53
|
-
return () => tracker.unmount();
|
|
54
|
-
}, [tracker, internal]);
|
|
55
|
-
if (internal) return {
|
|
56
|
-
props,
|
|
57
|
-
reloadKey: 0
|
|
58
|
-
};
|
|
59
|
-
const recordId = tracker.getRecordId();
|
|
60
|
-
const wrapped = tracker.handlers(props);
|
|
61
|
-
const out = {
|
|
62
|
-
...props,
|
|
63
|
-
...wrapped
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
// While a bust request is pending (cleared when the load settles), refetch
|
|
67
|
-
// bypassing caches — VERIFIED both platforms honor source.cache: 'reload'.
|
|
68
|
-
const request = (0, _actions.getReloadRequest)(recordId);
|
|
69
|
-
if (request?.bust) {
|
|
70
|
-
out.source = (0, _overrides.patchSourceCache)(out.source, "reload");
|
|
71
|
-
}
|
|
72
|
-
// Simulation layer: global modes + per-record override + locate-flash.
|
|
73
|
-
(0, _overrides.applyOverrides)(out, recordId, "rn");
|
|
74
|
-
return {
|
|
75
|
-
props: out,
|
|
76
|
-
reloadKey: (0, _actions.getReloadNonce)(recordId)
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
function installRnImageInterceptor() {
|
|
80
|
-
const s = (0, _state.imagesState)();
|
|
81
|
-
if (s.rnInstalled) return;
|
|
82
|
-
s.rnInstalled = true;
|
|
83
|
-
try {
|
|
84
|
-
// Deep import: evaluates ONLY the injection module, never Image itself.
|
|
85
|
-
const injection = require("react-native/Libraries/Image/ImageInjection");
|
|
86
|
-
const setDecorator = injection.unstable_setImageComponentDecorator;
|
|
87
|
-
const registerAttached = injection.unstable_registerImageAttachedCallback;
|
|
88
|
-
|
|
89
|
-
// `register-early` (a pre-InitializeCore entry) may have registered the
|
|
90
|
-
// decorator already; registering again would replace it with an identical one.
|
|
91
|
-
if (typeof setDecorator === "function" && !s.decoratorRegistered) {
|
|
92
|
-
setDecorator(BaseImage => {
|
|
93
|
-
(0, _state.imagesState)().decoratorInvoked = true;
|
|
94
|
-
const CapturedImage = /*#__PURE__*/React.forwardRef(function BuoyCapturedImage(props, ref) {
|
|
95
|
-
const {
|
|
96
|
-
props: instrumented,
|
|
97
|
-
reloadKey
|
|
98
|
-
} = useImageCapture(props);
|
|
99
|
-
// key bump forces a native remount → fresh load cycle (retry).
|
|
100
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(BaseImage, {
|
|
101
|
-
...instrumented,
|
|
102
|
-
ref: ref
|
|
103
|
-
}, `buoy-r${reloadKey}`);
|
|
104
|
-
});
|
|
105
|
-
return CapturedImage;
|
|
106
|
-
});
|
|
107
|
-
s.decoratorRegistered = true;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// Live mount signal — works regardless of decorator timing. Used purely
|
|
111
|
-
// to detect the "decorator registered too late" condition.
|
|
112
|
-
if (typeof registerAttached === "function") {
|
|
113
|
-
registerAttached(() => {
|
|
114
|
-
(0, _state.imagesState)().attachSeen++;
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
} catch {
|
|
118
|
-
// Internal RN path moved (version drift) or non-RN platform — expo-image
|
|
119
|
-
// capture still works; status will report the decorator as inactive.
|
|
120
|
-
s.decoratorRegistered = false;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
function rnCaptureStatus() {
|
|
124
|
-
const s = (0, _state.imagesState)();
|
|
125
|
-
return {
|
|
126
|
-
decoratorRegistered: s.decoratorRegistered,
|
|
127
|
-
decoratorActive: s.decoratorInvoked,
|
|
128
|
-
// Mounts observed but our wrapper never rendered → Image latched first.
|
|
129
|
-
tooLate: s.decoratorRegistered && !s.decoratorInvoked && s.attachSeen > 0
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
//# sourceMappingURL=installRnImage.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.installRnImageInterceptor=installRnImageInterceptor;exports.rnCaptureStatus=rnCaptureStatus;exports.useImageCapture=useImageCapture;var React=_interopRequireWildcard(require("react"));var _state=require("../state");var _actions=require("./actions");var _overrides=require("./overrides");var _shared=require("./shared");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,o){if("function"==typeof WeakMap)var r=new WeakMap,a=new WeakMap;return(_interopRequireWildcard=function(t,i){if(!i&&t&&t.__esModule)return t;var n,c,u={__proto__:null,default:t};if(null===t||"object"!=typeof t&&"function"!=typeof t)return u;if(n=i?a:r){if(n.has(t))return n.get(t);n.set(t,u)}for(const s in t)"default"!==s&&{}.hasOwnProperty.call(t,s)&&((c=(n=Object.defineProperty)&&Object.getOwnPropertyDescriptor(t,s))&&(c.get||c.set)?n(u,s,c):u[s]=t[s]);return u})(e,o)}function useImageCapture(e){const o=React.useRef(null);if(o.current==null){o.current=new _shared.ImageInstanceTracker("rn")}const r=o.current;const a=(0,_shared.isInternalImage)(e.testID);if(!a){r.syncSource(e.source);r.noteA11y(Boolean(e.alt??e.accessibilityLabel??e["aria-label"]))}React.useSyncExternalStore(_actions.subscribeActions,()=>(0,_overrides.getRenderVersion)(a?null:r.getRecordId()));React.useEffect(()=>{if(a)return void 0;return()=>r.unmount()},[r,a]);if(a)return{props:e,reloadKey:0};const t=r.getRecordId();const i=r.handlers(e);const n={...e,...i};const c=(0,_actions.getReloadRequest)(t);if(c?.bust){n.source=(0,_overrides.patchSourceCache)(n.source,"reload")}(0,_overrides.applyOverrides)(n,t,"rn");return{props:n,reloadKey:(0,_actions.getReloadNonce)(t)}}function installRnImageInterceptor(){const e=(0,_state.imagesState)();if(e.rnInstalled)return;e.rnInstalled=true;try{const o=require("react-native/Libraries/Image/ImageInjection");const r=o.unstable_setImageComponentDecorator;const a=o.unstable_registerImageAttachedCallback;if(typeof r==="function"&&!e.decoratorRegistered){r(t=>{(0,_state.imagesState)().decoratorInvoked=true;const i=React.forwardRef(function n(c,u){const{props:s,reloadKey:d}=useImageCapture(c);return(0,_jsxRuntime.jsx)(t,{...s,ref:u},`buoy-r${d}`)});return i});e.decoratorRegistered=true}if(typeof a==="function"){a(()=>{(0,_state.imagesState)().attachSeen++})}}catch{e.decoratorRegistered=false}}function rnCaptureStatus(){const e=(0,_state.imagesState)();return{decoratorRegistered:e.decoratorRegistered,decoratorActive:e.decoratorInvoked,tooLate:e.decoratorRegistered&&!e.decoratorInvoked&&e.attachSeen>0}}
|
|
@@ -1,30 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.loadExpoImage = loadExpoImage;
|
|
7
|
-
exports.loadFileSystemModule = loadFileSystemModule;
|
|
8
|
-
exports.loadLegacyFileSystem = loadLegacyFileSystem;
|
|
9
|
-
function loadExpoImage() {
|
|
10
|
-
try {
|
|
11
|
-
return require('expo-image');
|
|
12
|
-
} catch {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function loadLegacyFileSystem() {
|
|
17
|
-
try {
|
|
18
|
-
return require('expo-file-system/legacy');
|
|
19
|
-
} catch {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function loadFileSystemModule() {
|
|
24
|
-
try {
|
|
25
|
-
return require('expo-file-system');
|
|
26
|
-
} catch {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=nativeImageModules.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.loadExpoImage=loadExpoImage;exports.loadFileSystemModule=loadFileSystemModule;exports.loadLegacyFileSystem=loadLegacyFileSystem;function loadExpoImage(){try{return require("expo-image")}catch{return null}}function loadLegacyFileSystem(){try{return require("expo-file-system/legacy")}catch{return null}}function loadFileSystemModule(){try{return require("expo-file-system")}catch{return null}}
|
|
@@ -1,18 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.loadExpoImage = loadExpoImage;
|
|
7
|
-
exports.loadFileSystemModule = loadFileSystemModule;
|
|
8
|
-
exports.loadLegacyFileSystem = loadLegacyFileSystem;
|
|
9
|
-
function loadExpoImage() {
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
function loadLegacyFileSystem() {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
function loadFileSystemModule() {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=nativeImageModules.web.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.loadExpoImage=loadExpoImage;exports.loadFileSystemModule=loadFileSystemModule;exports.loadLegacyFileSystem=loadLegacyFileSystem;function loadExpoImage(){return null}function loadLegacyFileSystem(){return null}function loadFileSystemModule(){return null}
|