@agimon-ai/po-native-components 0.0.0-alpha.7 → 0.0.0-alpha.71
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/LICENSE +149 -22
- package/dist/components/AgentAvatar.d.mts +14 -0
- package/dist/components/AgentAvatar.d.mts.map +1 -0
- package/dist/components/AgentAvatar.mjs +87 -0
- package/dist/components/AgentAvatar.mjs.map +1 -0
- package/dist/components/AnnotationSurface.d.mts +69 -0
- package/dist/components/AnnotationSurface.d.mts.map +1 -0
- package/dist/components/AnnotationSurface.mjs +426 -0
- package/dist/components/AnnotationSurface.mjs.map +1 -0
- package/dist/components/Badge.d.mts +1 -1
- package/dist/components/Badge.mjs +1 -1
- package/dist/components/Button.mjs +2 -2
- package/dist/components/CodeBlock.d.mts +3 -1
- package/dist/components/CodeBlock.d.mts.map +1 -1
- package/dist/components/CodeBlock.mjs +35 -47
- package/dist/components/CodeBlock.mjs.map +1 -1
- package/dist/components/CopyButton.d.mts +13 -0
- package/dist/components/CopyButton.d.mts.map +1 -0
- package/dist/components/CopyButton.mjs +43 -0
- package/dist/components/CopyButton.mjs.map +1 -0
- package/dist/components/Dialog.mjs +3 -3
- package/dist/components/Dot.d.mts +1 -1
- package/dist/components/Dot.mjs +2 -2
- package/dist/components/DropdownMenu.d.mts.map +1 -1
- package/dist/components/DropdownMenu.mjs +12 -6
- package/dist/components/DropdownMenu.mjs.map +1 -1
- package/dist/components/HashlineLines.d.mts +13 -0
- package/dist/components/HashlineLines.d.mts.map +1 -0
- package/dist/components/HashlineLines.mjs +148 -0
- package/dist/components/HashlineLines.mjs.map +1 -0
- package/dist/components/HostFilter.d.mts +17 -0
- package/dist/components/HostFilter.d.mts.map +1 -0
- package/dist/components/HostFilter.mjs +66 -0
- package/dist/components/HostFilter.mjs.map +1 -0
- package/dist/components/HostTag.d.mts +7 -0
- package/dist/components/HostTag.d.mts.map +1 -0
- package/dist/components/HostTag.mjs +47 -0
- package/dist/components/HostTag.mjs.map +1 -0
- package/dist/components/InfoStrip.d.mts +9 -0
- package/dist/components/InfoStrip.d.mts.map +1 -0
- package/dist/components/InfoStrip.mjs +53 -0
- package/dist/components/InfoStrip.mjs.map +1 -0
- package/dist/components/Input.mjs +3 -2
- package/dist/components/Input.mjs.map +1 -1
- package/dist/components/Label.mjs +1 -1
- package/dist/components/List.d.mts.map +1 -1
- package/dist/components/List.mjs +38 -6
- package/dist/components/List.mjs.map +1 -1
- package/dist/components/LiveDuration.d.mts +30 -0
- package/dist/components/LiveDuration.d.mts.map +1 -0
- package/dist/components/LiveDuration.mjs +67 -0
- package/dist/components/LiveDuration.mjs.map +1 -0
- package/dist/components/Markdown.d.mts +10 -1
- package/dist/components/Markdown.d.mts.map +1 -1
- package/dist/components/Markdown.mjs +330 -27
- package/dist/components/Markdown.mjs.map +1 -1
- package/dist/components/MessageItem.d.mts +8 -8
- package/dist/components/MessageItem.d.mts.map +1 -1
- package/dist/components/MessageItem.mjs +71 -55
- package/dist/components/MessageItem.mjs.map +1 -1
- package/dist/components/SectionLabel.mjs +1 -1
- package/dist/components/Sheet.d.mts +7 -1
- package/dist/components/Sheet.d.mts.map +1 -1
- package/dist/components/Sheet.mjs +19 -4
- package/dist/components/Sheet.mjs.map +1 -1
- package/dist/components/SheetFrame.d.mts +13 -0
- package/dist/components/SheetFrame.d.mts.map +1 -0
- package/dist/components/SheetFrame.mjs +113 -16
- package/dist/components/SheetFrame.mjs.map +1 -1
- package/dist/components/SheetList.d.mts +14 -0
- package/dist/components/SheetList.d.mts.map +1 -0
- package/dist/components/SheetList.mjs +34 -0
- package/dist/components/SheetList.mjs.map +1 -0
- package/dist/components/ShowMore.d.mts +10 -0
- package/dist/components/ShowMore.d.mts.map +1 -0
- package/dist/components/ShowMore.mjs +44 -0
- package/dist/components/ShowMore.mjs.map +1 -0
- package/dist/components/Spinner.d.mts +1 -1
- package/dist/components/StatusBadge.d.mts +1 -1
- package/dist/components/SyntaxLine.d.mts +19 -0
- package/dist/components/SyntaxLine.d.mts.map +1 -0
- package/dist/components/SyntaxLine.mjs +134 -0
- package/dist/components/SyntaxLine.mjs.map +1 -0
- package/dist/components/Tabs.mjs +2 -2
- package/dist/components/ToolPathLink.d.mts +10 -0
- package/dist/components/ToolPathLink.d.mts.map +1 -0
- package/dist/components/ToolPathLink.mjs +40 -0
- package/dist/components/ToolPathLink.mjs.map +1 -0
- package/dist/icons/iconGlyphs.d.mts +56 -0
- package/dist/icons/iconGlyphs.d.mts.map +1 -1
- package/dist/icons/iconGlyphs.mjs +56 -0
- package/dist/icons/iconGlyphs.mjs.map +1 -1
- package/dist/icons/icons.d.mts +57 -1
- package/dist/icons/icons.d.mts.map +1 -1
- package/dist/icons/icons.mjs +15 -1
- package/dist/icons/icons.mjs.map +1 -1
- package/dist/index.d.mts +17 -4
- package/dist/index.mjs +18 -5
- package/dist/lib/fonts.d.mts +3 -1
- package/dist/lib/fonts.d.mts.map +1 -1
- package/dist/lib/fonts.mjs +4 -2
- package/dist/lib/fonts.mjs.map +1 -1
- package/dist/lib/markdown.mjs +172 -23
- package/dist/lib/markdown.mjs.map +1 -1
- package/dist/lib/reading.mjs +60 -0
- package/dist/lib/reading.mjs.map +1 -0
- package/dist/lib/useReadingPage.mjs +33 -0
- package/dist/lib/useReadingPage.mjs.map +1 -0
- package/package.json +18 -14
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
import { fontOf } from "../lib/fonts.mjs";
|
|
2
|
+
import { selectionTick } from "../lib/haptics.mjs";
|
|
3
|
+
import { View } from "react-native-unistyles/components/native/View";
|
|
4
|
+
import { Text } from "react-native-unistyles/components/native/Text";
|
|
5
|
+
import { StyleSheet } from "react-native-unistyles";
|
|
6
|
+
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { Pressable } from "react-native-unistyles/components/native/Pressable";
|
|
9
|
+
|
|
10
|
+
//#region src/components/AnnotationSurface.tsx
|
|
11
|
+
const clamp = (value) => Number.isFinite(value) ? Math.min(1, Math.max(0, value)) : 0;
|
|
12
|
+
const MAX_POINTS = 128;
|
|
13
|
+
function Stroke({ points, width, height, highlight = false }) {
|
|
14
|
+
const thickness = highlight ? 16 : 3;
|
|
15
|
+
const bounded = points.slice(0, MAX_POINTS);
|
|
16
|
+
return bounded.map((point, index) => {
|
|
17
|
+
const previous = bounded[index - 1];
|
|
18
|
+
if (!previous || ![
|
|
19
|
+
point.x,
|
|
20
|
+
point.y,
|
|
21
|
+
previous.x,
|
|
22
|
+
previous.y
|
|
23
|
+
].every(Number.isFinite)) return null;
|
|
24
|
+
const x = clamp(previous.x) * width;
|
|
25
|
+
const y = clamp(previous.y) * height;
|
|
26
|
+
const dx = clamp(point.x) * width - x;
|
|
27
|
+
const dy = clamp(point.y) * height - y;
|
|
28
|
+
const length = Math.hypot(dx, dy);
|
|
29
|
+
return /* @__PURE__ */ jsx(View, { style: [
|
|
30
|
+
styles.segment,
|
|
31
|
+
highlight && styles.highlight,
|
|
32
|
+
{
|
|
33
|
+
left: x + dx / 2 - length / 2,
|
|
34
|
+
top: y + dy / 2 - thickness / 2,
|
|
35
|
+
width: length,
|
|
36
|
+
transform: [{ rotate: `${Math.atan2(dy, dx)}rad` }]
|
|
37
|
+
}
|
|
38
|
+
] }, index);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Tap to pin a note on whatever it wraps. Each pin is its own 44pt button, so a
|
|
43
|
+
* screen reader can reach every note; the surface's own element sits behind the
|
|
44
|
+
* content, so text and controls inside stay readable, and activating it places a
|
|
45
|
+
* note at its centre.
|
|
46
|
+
*/
|
|
47
|
+
function AnnotationSurface({ children, marks, selectedId, onPlace, onDraw, onSelectMark, accessibilityLabel, zoomable = false, onViewportChange, navigation = false, viewport: controlledViewport, drawingHighlight = false, style }) {
|
|
48
|
+
const [size, setSize] = useState({
|
|
49
|
+
width: 0,
|
|
50
|
+
height: 0
|
|
51
|
+
});
|
|
52
|
+
const [viewport, setViewport] = useState({
|
|
53
|
+
scale: 1,
|
|
54
|
+
x: 0,
|
|
55
|
+
y: 0
|
|
56
|
+
});
|
|
57
|
+
const transform = useRef(viewport);
|
|
58
|
+
const pinch = useRef(null);
|
|
59
|
+
const suppressTap = useRef(false);
|
|
60
|
+
const pressedPoint = useRef(void 0);
|
|
61
|
+
const navigating = useRef(false);
|
|
62
|
+
const reportViewport = (next, dimensions = size) => {
|
|
63
|
+
onViewportChange?.({
|
|
64
|
+
...dimensions,
|
|
65
|
+
zoom: next.scale,
|
|
66
|
+
originX: dimensions.width * (1 - next.scale) / 2 + next.x,
|
|
67
|
+
originY: dimensions.height * (1 - next.scale) / 2 + next.y
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
const boundViewport = (request, dimensions = size) => {
|
|
71
|
+
const scale = zoomable && Number.isFinite(request.zoom) ? Math.max(1, Math.min(4, request.zoom)) : 1;
|
|
72
|
+
const maxX = dimensions.width * (scale - 1) / 2;
|
|
73
|
+
const maxY = dimensions.height * (scale - 1) / 2;
|
|
74
|
+
return {
|
|
75
|
+
scale,
|
|
76
|
+
x: Math.max(-maxX, Math.min(maxX, (Number.isFinite(request.originX) ? request.originX : 0) + maxX)),
|
|
77
|
+
y: Math.max(-maxY, Math.min(maxY, (Number.isFinite(request.originY) ? request.originY : 0) + maxY))
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
const resetViewport = (dimensions = size) => {
|
|
81
|
+
pinch.current = null;
|
|
82
|
+
transform.current = boundViewport(controlledViewport ?? {
|
|
83
|
+
zoom: 1,
|
|
84
|
+
originX: 0,
|
|
85
|
+
originY: 0
|
|
86
|
+
}, dimensions);
|
|
87
|
+
setViewport(transform.current);
|
|
88
|
+
reportViewport(transform.current, dimensions);
|
|
89
|
+
};
|
|
90
|
+
useLayoutEffect(() => {
|
|
91
|
+
const next = boundViewport(controlledViewport ?? {
|
|
92
|
+
zoom: 1,
|
|
93
|
+
originX: 0,
|
|
94
|
+
originY: 0
|
|
95
|
+
});
|
|
96
|
+
if (next.scale !== transform.current.scale || Math.abs(next.x - transform.current.x) > 1e-6 || Math.abs(next.y - transform.current.y) > 1e-6) resetViewport();
|
|
97
|
+
}, [
|
|
98
|
+
zoomable,
|
|
99
|
+
controlledViewport?.zoom,
|
|
100
|
+
controlledViewport?.originX,
|
|
101
|
+
controlledViewport?.originY
|
|
102
|
+
]);
|
|
103
|
+
useLayoutEffect(() => {
|
|
104
|
+
reportViewport(transform.current);
|
|
105
|
+
}, [size, onViewportChange]);
|
|
106
|
+
const sourcePoint = (x, y) => {
|
|
107
|
+
const current = transform.current;
|
|
108
|
+
return {
|
|
109
|
+
x: clamp((x - size.width / 2 - current.x) / current.scale / size.width + .5),
|
|
110
|
+
y: clamp((y - size.height / 2 - current.y) / current.scale / size.height + .5)
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
const moveViewport = (event) => {
|
|
114
|
+
const { touches } = event.nativeEvent;
|
|
115
|
+
const [first, second] = touches;
|
|
116
|
+
const count = touches.length;
|
|
117
|
+
if (!zoomable || !first || count !== 2 && !(navigation && count === 1) || size.width <= 0 || size.height <= 0) {
|
|
118
|
+
pinch.current = null;
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
cancel();
|
|
122
|
+
suppressTap.current = true;
|
|
123
|
+
const x = second ? (first.pageX + second.pageX) / 2 : first.pageX;
|
|
124
|
+
const y = second ? (first.pageY + second.pageY) / 2 : first.pageY;
|
|
125
|
+
const distance = second ? Math.hypot(first.pageX - second.pageX, first.pageY - second.pageY) : 1;
|
|
126
|
+
if (![
|
|
127
|
+
x,
|
|
128
|
+
y,
|
|
129
|
+
distance
|
|
130
|
+
].every(Number.isFinite) || distance <= 0) {
|
|
131
|
+
pinch.current = null;
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (!pinch.current || pinch.current.count !== count) {
|
|
135
|
+
const focalX = Number.isFinite(first.locationX) ? first.locationX + x - first.pageX : x;
|
|
136
|
+
const focalY = Number.isFinite(first.locationY) ? first.locationY + y - first.pageY : y;
|
|
137
|
+
pinch.current = {
|
|
138
|
+
count,
|
|
139
|
+
focalX,
|
|
140
|
+
focalY,
|
|
141
|
+
x,
|
|
142
|
+
y,
|
|
143
|
+
distance,
|
|
144
|
+
scale: transform.current.scale,
|
|
145
|
+
offsetX: transform.current.x,
|
|
146
|
+
offsetY: transform.current.y
|
|
147
|
+
};
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const start = pinch.current;
|
|
151
|
+
const scale = Math.max(1, Math.min(4, start.scale * distance / start.distance));
|
|
152
|
+
const ratio = scale / start.scale;
|
|
153
|
+
const maxX = size.width * (scale - 1) / 2;
|
|
154
|
+
const maxY = size.height * (scale - 1) / 2;
|
|
155
|
+
transform.current = {
|
|
156
|
+
scale,
|
|
157
|
+
x: Math.max(-maxX, Math.min(maxX, start.offsetX * ratio + (start.focalX - size.width / 2) * (1 - ratio) + x - start.x)),
|
|
158
|
+
y: Math.max(-maxY, Math.min(maxY, start.offsetY * ratio + (start.focalY - size.height / 2) * (1 - ratio) + y - start.y))
|
|
159
|
+
};
|
|
160
|
+
reportViewport(transform.current);
|
|
161
|
+
setViewport(transform.current);
|
|
162
|
+
};
|
|
163
|
+
const [live, setLive] = useState([]);
|
|
164
|
+
const stroke = useRef(null);
|
|
165
|
+
const draw = useRef(onDraw);
|
|
166
|
+
draw.current = onDraw;
|
|
167
|
+
const drawing = onDraw !== void 0;
|
|
168
|
+
const cancel = () => {
|
|
169
|
+
stroke.current = null;
|
|
170
|
+
pressedPoint.current = void 0;
|
|
171
|
+
setLive([]);
|
|
172
|
+
};
|
|
173
|
+
useEffect(() => {
|
|
174
|
+
stroke.current = null;
|
|
175
|
+
setLive([]);
|
|
176
|
+
return () => {
|
|
177
|
+
stroke.current = null;
|
|
178
|
+
};
|
|
179
|
+
}, [
|
|
180
|
+
drawing,
|
|
181
|
+
navigation,
|
|
182
|
+
drawingHighlight,
|
|
183
|
+
controlledViewport?.zoom,
|
|
184
|
+
controlledViewport?.originX,
|
|
185
|
+
controlledViewport?.originY
|
|
186
|
+
]);
|
|
187
|
+
const append = (event) => {
|
|
188
|
+
if (!stroke.current || !draw.current) return cancel();
|
|
189
|
+
const { locationX, locationY, touches } = event.nativeEvent;
|
|
190
|
+
if (touches.length > 1 || ![
|
|
191
|
+
locationX,
|
|
192
|
+
locationY,
|
|
193
|
+
size.width,
|
|
194
|
+
size.height
|
|
195
|
+
].every(Number.isFinite) || size.width <= 0 || size.height <= 0) return cancel();
|
|
196
|
+
const point = sourcePoint(locationX, locationY);
|
|
197
|
+
const last = stroke.current[stroke.current.length - 1];
|
|
198
|
+
if (last?.x === point.x && last.y === point.y) return;
|
|
199
|
+
if (stroke.current.length < MAX_POINTS) stroke.current.push(point);
|
|
200
|
+
else stroke.current[127] = point;
|
|
201
|
+
setLive([...stroke.current]);
|
|
202
|
+
};
|
|
203
|
+
const place = (event) => {
|
|
204
|
+
if (!onPlace || onDraw || navigation || suppressTap.current) return;
|
|
205
|
+
const { locationX, locationY } = event.nativeEvent;
|
|
206
|
+
const point = size.width > 0 && size.height > 0 && Number.isFinite(locationX) && Number.isFinite(locationY) ? sourcePoint(locationX, locationY) : pressedPoint.current ?? {
|
|
207
|
+
x: .5,
|
|
208
|
+
y: .5
|
|
209
|
+
};
|
|
210
|
+
pressedPoint.current = void 0;
|
|
211
|
+
selectionTick();
|
|
212
|
+
onPlace(point);
|
|
213
|
+
};
|
|
214
|
+
return /* @__PURE__ */ jsxs(View, {
|
|
215
|
+
style: [
|
|
216
|
+
styles.frame,
|
|
217
|
+
zoomable && { overflow: "hidden" },
|
|
218
|
+
style
|
|
219
|
+
],
|
|
220
|
+
onStartShouldSetResponderCapture: (event) => zoomable && (navigation || event.nativeEvent.touches.length > 1),
|
|
221
|
+
onMoveShouldSetResponderCapture: (event) => zoomable && (navigation || event.nativeEvent.touches.length > 1),
|
|
222
|
+
onResponderGrant: zoomable ? (event) => {
|
|
223
|
+
cancel();
|
|
224
|
+
navigating.current = true;
|
|
225
|
+
suppressTap.current = true;
|
|
226
|
+
moveViewport(event);
|
|
227
|
+
} : void 0,
|
|
228
|
+
onResponderStart: zoomable ? (event) => {
|
|
229
|
+
cancel();
|
|
230
|
+
moveViewport(event);
|
|
231
|
+
} : void 0,
|
|
232
|
+
onResponderEnd: zoomable ? (event) => {
|
|
233
|
+
cancel();
|
|
234
|
+
moveViewport(event);
|
|
235
|
+
} : void 0,
|
|
236
|
+
onResponderMove: zoomable ? moveViewport : void 0,
|
|
237
|
+
onResponderRelease: zoomable ? () => {
|
|
238
|
+
navigating.current = false;
|
|
239
|
+
pinch.current = null;
|
|
240
|
+
} : void 0,
|
|
241
|
+
onResponderTerminationRequest: () => true,
|
|
242
|
+
onResponderTerminate: zoomable ? () => {
|
|
243
|
+
navigating.current = false;
|
|
244
|
+
pinch.current = null;
|
|
245
|
+
cancel();
|
|
246
|
+
} : void 0,
|
|
247
|
+
onLayout: (event) => {
|
|
248
|
+
cancel();
|
|
249
|
+
const { width, height } = event.nativeEvent.layout;
|
|
250
|
+
const dimensions = {
|
|
251
|
+
width: Number.isFinite(width) ? Math.max(0, width) : 0,
|
|
252
|
+
height: Number.isFinite(height) ? Math.max(0, height) : 0
|
|
253
|
+
};
|
|
254
|
+
resetViewport(dimensions);
|
|
255
|
+
setSize(dimensions);
|
|
256
|
+
},
|
|
257
|
+
children: [
|
|
258
|
+
/* @__PURE__ */ jsx(View, {
|
|
259
|
+
pointerEvents: "none",
|
|
260
|
+
style: styles.overlay,
|
|
261
|
+
accessible: true,
|
|
262
|
+
accessibilityRole: onPlace && !onDraw ? "button" : "image",
|
|
263
|
+
accessibilityLabel,
|
|
264
|
+
accessibilityHint: onPlace && !onDraw ? "Double tap to add a note here. Use the Note on whole image action to mark the whole image." : void 0,
|
|
265
|
+
accessibilityActions: onPlace ? [...onDraw ? [] : [{ name: "activate" }], {
|
|
266
|
+
name: "noteWholeImage",
|
|
267
|
+
label: "Note on whole image"
|
|
268
|
+
}] : void 0,
|
|
269
|
+
onAccessibilityAction: (event) => {
|
|
270
|
+
const { actionName } = event.nativeEvent;
|
|
271
|
+
if (actionName === "noteWholeImage" || actionName === "activate" && !onDraw) onPlace?.({
|
|
272
|
+
x: .5,
|
|
273
|
+
y: .5
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
}),
|
|
277
|
+
/* @__PURE__ */ jsx(Pressable, {
|
|
278
|
+
accessible: false,
|
|
279
|
+
disabled: !onPlace || !!onDraw || navigation,
|
|
280
|
+
onPressIn: (event) => {
|
|
281
|
+
pressedPoint.current = void 0;
|
|
282
|
+
if (navigating.current) return;
|
|
283
|
+
suppressTap.current = false;
|
|
284
|
+
const { locationX, locationY } = event.nativeEvent;
|
|
285
|
+
if (size.width > 0 && size.height > 0 && Number.isFinite(locationX) && Number.isFinite(locationY)) pressedPoint.current = sourcePoint(locationX, locationY);
|
|
286
|
+
},
|
|
287
|
+
onPress: place,
|
|
288
|
+
children: /* @__PURE__ */ jsxs(View, {
|
|
289
|
+
pointerEvents: zoomable && viewport.scale > 1 ? "none" : "auto",
|
|
290
|
+
style: zoomable ? { transform: [
|
|
291
|
+
{ translateX: viewport.x },
|
|
292
|
+
{ translateY: viewport.y },
|
|
293
|
+
{ scale: viewport.scale }
|
|
294
|
+
] } : void 0,
|
|
295
|
+
children: [children, /* @__PURE__ */ jsxs(View, {
|
|
296
|
+
pointerEvents: "none",
|
|
297
|
+
accessible: false,
|
|
298
|
+
style: styles.overlay,
|
|
299
|
+
children: [marks.map((mark) => mark.points && /* @__PURE__ */ jsx(Stroke, {
|
|
300
|
+
points: mark.points,
|
|
301
|
+
width: size.width,
|
|
302
|
+
height: size.height,
|
|
303
|
+
highlight: mark.highlight
|
|
304
|
+
}, mark.id)), onDraw && /* @__PURE__ */ jsx(Stroke, {
|
|
305
|
+
points: live,
|
|
306
|
+
width: size.width,
|
|
307
|
+
height: size.height,
|
|
308
|
+
highlight: drawingHighlight
|
|
309
|
+
})]
|
|
310
|
+
})]
|
|
311
|
+
})
|
|
312
|
+
}),
|
|
313
|
+
onDraw && !navigation && /* @__PURE__ */ jsx(View, {
|
|
314
|
+
accessible: false,
|
|
315
|
+
collapsable: false,
|
|
316
|
+
style: styles.overlay,
|
|
317
|
+
onStartShouldSetResponder: () => true,
|
|
318
|
+
onResponderGrant: (event) => {
|
|
319
|
+
stroke.current = [];
|
|
320
|
+
append(event);
|
|
321
|
+
},
|
|
322
|
+
onResponderStart: (event) => {
|
|
323
|
+
if (event.nativeEvent.touches.length > 1) cancel();
|
|
324
|
+
},
|
|
325
|
+
onResponderMove: append,
|
|
326
|
+
onResponderRelease: (event) => {
|
|
327
|
+
append(event);
|
|
328
|
+
const points = stroke.current;
|
|
329
|
+
cancel();
|
|
330
|
+
if (points && points.length >= 2 && points.some((point) => point.x !== points[0].x || point.y !== points[0].y)) draw.current?.(points);
|
|
331
|
+
},
|
|
332
|
+
onResponderTerminationRequest: () => true,
|
|
333
|
+
onResponderTerminate: cancel
|
|
334
|
+
}),
|
|
335
|
+
marks.map((mark) => {
|
|
336
|
+
const selected = mark.id === selectedId;
|
|
337
|
+
return /* @__PURE__ */ jsx(Pressable, {
|
|
338
|
+
accessibilityRole: "button",
|
|
339
|
+
accessibilityLabel: `Note ${mark.label}${mark.description ? `: ${mark.description}` : ""}`,
|
|
340
|
+
accessibilityState: { selected },
|
|
341
|
+
onPress: () => onSelectMark?.(mark.id),
|
|
342
|
+
style: [styles.hit, zoomable ? {
|
|
343
|
+
left: size.width / 2 + (clamp(mark.x) - .5) * size.width * viewport.scale + viewport.x,
|
|
344
|
+
top: size.height / 2 + (clamp(mark.y) - .5) * size.height * viewport.scale + viewport.y
|
|
345
|
+
} : {
|
|
346
|
+
left: `${clamp(mark.x) * 100}%`,
|
|
347
|
+
top: `${clamp(mark.y) * 100}%`
|
|
348
|
+
}],
|
|
349
|
+
children: /* @__PURE__ */ jsx(View, {
|
|
350
|
+
style: [styles.pin, selected && styles.pinSelected],
|
|
351
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
352
|
+
style: [styles.label, selected && styles.labelSelected],
|
|
353
|
+
children: mark.label
|
|
354
|
+
})
|
|
355
|
+
})
|
|
356
|
+
}, mark.id);
|
|
357
|
+
})
|
|
358
|
+
]
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
const HIT = 44;
|
|
362
|
+
const PIN = 28;
|
|
363
|
+
const styles = StyleSheet.create((theme) => ({
|
|
364
|
+
frame: {
|
|
365
|
+
position: "relative",
|
|
366
|
+
alignSelf: "stretch"
|
|
367
|
+
},
|
|
368
|
+
overlay: {
|
|
369
|
+
position: "absolute",
|
|
370
|
+
top: 0,
|
|
371
|
+
right: 0,
|
|
372
|
+
bottom: 0,
|
|
373
|
+
left: 0
|
|
374
|
+
},
|
|
375
|
+
segment: {
|
|
376
|
+
position: "absolute",
|
|
377
|
+
height: 3,
|
|
378
|
+
borderRadius: 1.5,
|
|
379
|
+
backgroundColor: theme.colors.magenta,
|
|
380
|
+
uni__dependencies: [0]
|
|
381
|
+
},
|
|
382
|
+
highlight: {
|
|
383
|
+
height: 16,
|
|
384
|
+
borderRadius: 8,
|
|
385
|
+
opacity: .3
|
|
386
|
+
},
|
|
387
|
+
hit: {
|
|
388
|
+
position: "absolute",
|
|
389
|
+
width: HIT,
|
|
390
|
+
height: HIT,
|
|
391
|
+
marginLeft: -22,
|
|
392
|
+
marginTop: -22,
|
|
393
|
+
alignItems: "center",
|
|
394
|
+
justifyContent: "center"
|
|
395
|
+
},
|
|
396
|
+
pin: {
|
|
397
|
+
width: PIN,
|
|
398
|
+
height: PIN,
|
|
399
|
+
borderRadius: PIN / 2,
|
|
400
|
+
alignItems: "center",
|
|
401
|
+
justifyContent: "center",
|
|
402
|
+
borderWidth: 2,
|
|
403
|
+
borderColor: theme.colors.magenta,
|
|
404
|
+
backgroundColor: theme.colors.bg,
|
|
405
|
+
uni__dependencies: [0]
|
|
406
|
+
},
|
|
407
|
+
pinSelected: {
|
|
408
|
+
backgroundColor: theme.colors.magenta,
|
|
409
|
+
uni__dependencies: [0]
|
|
410
|
+
},
|
|
411
|
+
label: {
|
|
412
|
+
color: theme.colors.magenta,
|
|
413
|
+
fontFamily: fontOf(theme.fontFamily.sans),
|
|
414
|
+
fontSize: theme.fontSize.sm,
|
|
415
|
+
fontWeight: theme.fontWeight.semibold,
|
|
416
|
+
uni__dependencies: [0]
|
|
417
|
+
},
|
|
418
|
+
labelSelected: {
|
|
419
|
+
color: theme.colors.bg,
|
|
420
|
+
uni__dependencies: [0]
|
|
421
|
+
}
|
|
422
|
+
}));
|
|
423
|
+
|
|
424
|
+
//#endregion
|
|
425
|
+
export { AnnotationSurface };
|
|
426
|
+
//# sourceMappingURL=AnnotationSurface.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnnotationSurface.mjs","names":["ReactNode","useEffect","useLayoutEffect","useRef","useState","GestureResponderEvent","StyleProp","ViewStyle","StyleSheet","fontOf","selectionTick","AnnotationMark","id","x","y","label","description","points","highlight","AnnotationSurfaceProps","children","marks","selectedId","onPlace","point","onDraw","onSelectMark","accessibilityLabel","zoomable","navigation","viewport","zoom","originX","originY","drawingHighlight","onViewportChange","width","height","style","clamp","value","Number","isFinite","Math","min","max","MAX_POINTS","Point","Stroke","thickness","bounded","slice","map","index","previous","every","dx","dy","length","hypot","styles","segment","left","top","transform","rotate","atan2","AnnotationSurface","controlledViewport","size","setSize","setViewport","scale","pinch","count","focalX","focalY","distance","offsetX","offsetY","suppressTap","pressedPoint","undefined","navigating","reportViewport","next","dimensions","boundViewport","request","NonNullable","maxX","maxY","resetViewport","current","abs","sourcePoint","moveViewport","event","touches","nativeEvent","first","second","cancel","pageX","pageY","locationX","locationY","start","ratio","live","setLive","stroke","draw","drawing","append","last","push","place","known","frame","overflow","layout","overlay","name","actionName","translateX","translateY","mark","some","selected","hit","pin","pinSelected","labelSelected","HIT","PIN","create","theme","position","alignSelf","right","bottom","borderRadius","backgroundColor","colors","magenta","uni__dependencies","opacity","marginLeft","marginTop","alignItems","justifyContent","borderWidth","borderColor","bg","color","fontFamily","sans","fontSize","sm","fontWeight","semibold"],"sources":["../../src/components/AnnotationSurface.tsx"],"sourcesContent":["import { type ReactNode, useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { type GestureResponderEvent, Pressable, type StyleProp, Text, View, type ViewStyle } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\nimport { selectionTick } from '../lib/haptics';\n\n/** One note pinned to the content, with an optional stroke, in fractions (0 to 1) of the surface's width and height. */\nexport interface AnnotationMark {\n id: string;\n x: number;\n y: number;\n /** The short text drawn on the pin, such as \"1\". */\n label: string;\n /** What a screen reader announces for the pin, such as the note text. */\n description?: string;\n /** Optional normalized freehand stroke. At most 128 finite points are rendered. */\n points?: readonly { x: number; y: number }[];\n /** A translucent, thick rose stroke over the content. */\n highlight?: boolean;\n}\n\nexport interface AnnotationSurfaceProps {\n /** The content being marked up: an image, a page, a block of text. */\n children: ReactNode;\n marks: readonly AnnotationMark[];\n selectedId?: string;\n /** A tap places a note there. Without onPlace or onDraw the surface is read-only. */\n onPlace?: (point: { x: number; y: number }) => void;\n /** Enables drawing instead of tap placement. Receives 2 to 128 finite [0,1] points only on a completed stroke. */\n onDraw?: (points: { x: number; y: number }[]) => void;\n onSelectMark?: (id: string) => void;\n /** What the content is, such as \"hero.png\". */\n accessibilityLabel: string;\n /** Image surfaces can pinch and move with two fingers on both native platforms. */\n zoomable?: boolean;\n /** Explicit one-finger pan instead of placing or drawing marks. */\n navigation?: boolean;\n /** Controlled transform. Origins are unscaled RN layout positions, not raster pixels. */\n viewport?: { zoom: number; originX: number; originY: number };\n /** Render the in-progress stroke as a highlight. */\n drawingHighlight?: boolean;\n /** Viewport dimensions and source-layout-to-viewport transform, all in RN layout units, not raster pixels. */\n onViewportChange?: (viewport: {\n width: number;\n height: number;\n zoom: number;\n originX: number;\n originY: number;\n }) => void;\n style?: StyleProp<ViewStyle>;\n}\n\nconst clamp = (value: number) => (Number.isFinite(value) ? Math.min(1, Math.max(0, value)) : 0);\nconst MAX_POINTS = 128;\ntype Point = { x: number; y: number };\n\nfunction Stroke({\n points,\n width,\n height,\n highlight = false,\n}: {\n points: readonly Point[];\n width: number;\n height: number;\n highlight?: boolean;\n}) {\n const thickness = highlight ? 16 : 3;\n // Slice before processing so even externally supplied strokes have bounded work.\n const bounded = points.slice(0, MAX_POINTS);\n return bounded.map((point, index) => {\n const previous = bounded[index - 1];\n if (!previous || ![point.x, point.y, previous.x, previous.y].every(Number.isFinite)) return null;\n const x = clamp(previous.x) * width;\n const y = clamp(previous.y) * height;\n const dx = clamp(point.x) * width - x;\n const dy = clamp(point.y) * height - y;\n const length = Math.hypot(dx, dy);\n return (\n <View\n key={index}\n style={[\n styles.segment,\n highlight && styles.highlight,\n {\n left: x + dx / 2 - length / 2,\n top: y + dy / 2 - thickness / 2,\n width: length,\n transform: [{ rotate: `${Math.atan2(dy, dx)}rad` }],\n },\n ]}\n />\n );\n });\n}\n\n/**\n * Tap to pin a note on whatever it wraps. Each pin is its own 44pt button, so a\n * screen reader can reach every note; the surface's own element sits behind the\n * content, so text and controls inside stay readable, and activating it places a\n * note at its centre.\n */\nexport function AnnotationSurface({\n children,\n marks,\n selectedId,\n onPlace,\n onDraw,\n onSelectMark,\n accessibilityLabel,\n zoomable = false,\n onViewportChange,\n navigation = false,\n viewport: controlledViewport,\n drawingHighlight = false,\n style,\n}: AnnotationSurfaceProps) {\n const [size, setSize] = useState({ width: 0, height: 0 });\n const [viewport, setViewport] = useState({ scale: 1, x: 0, y: 0 });\n const transform = useRef(viewport);\n const pinch = useRef<{\n count: number;\n focalX: number;\n focalY: number;\n distance: number;\n x: number;\n y: number;\n scale: number;\n offsetX: number;\n offsetY: number;\n } | null>(null);\n const suppressTap = useRef(false);\n const pressedPoint = useRef<Point | undefined>(undefined);\n const navigating = useRef(false);\n const reportViewport = (next: typeof viewport, dimensions = size) => {\n onViewportChange?.({\n ...dimensions,\n zoom: next.scale,\n originX: (dimensions.width * (1 - next.scale)) / 2 + next.x,\n originY: (dimensions.height * (1 - next.scale)) / 2 + next.y,\n });\n };\n const boundViewport = (request: NonNullable<AnnotationSurfaceProps['viewport']>, dimensions = size) => {\n const scale = zoomable && Number.isFinite(request.zoom) ? Math.max(1, Math.min(4, request.zoom)) : 1;\n const maxX = (dimensions.width * (scale - 1)) / 2;\n const maxY = (dimensions.height * (scale - 1)) / 2;\n return {\n scale,\n x: Math.max(-maxX, Math.min(maxX, (Number.isFinite(request.originX) ? request.originX : 0) + maxX)),\n y: Math.max(-maxY, Math.min(maxY, (Number.isFinite(request.originY) ? request.originY : 0) + maxY)),\n };\n };\n const resetViewport = (dimensions = size) => {\n pinch.current = null;\n transform.current = boundViewport(controlledViewport ?? { zoom: 1, originX: 0, originY: 0 }, dimensions);\n setViewport(transform.current);\n reportViewport(transform.current, dimensions);\n };\n // Layout effects publish programmatic zoom/Fit/focus before a parent's capture effect.\n useLayoutEffect(() => {\n const next = boundViewport(controlledViewport ?? { zoom: 1, originX: 0, originY: 0 });\n // A controlled parent's gesture echo is not a new navigation command.\n if (\n next.scale !== transform.current.scale ||\n Math.abs(next.x - transform.current.x) > 1e-6 ||\n Math.abs(next.y - transform.current.y) > 1e-6\n )\n resetViewport();\n }, [zoomable, controlledViewport?.zoom, controlledViewport?.originX, controlledViewport?.originY]);\n useLayoutEffect(() => {\n reportViewport(transform.current);\n }, [size, onViewportChange]);\n const sourcePoint = (x: number, y: number) => {\n const current = transform.current;\n return {\n x: clamp((x - size.width / 2 - current.x) / current.scale / size.width + 0.5),\n y: clamp((y - size.height / 2 - current.y) / current.scale / size.height + 0.5),\n };\n };\n const moveViewport = (event: GestureResponderEvent) => {\n const { touches } = event.nativeEvent;\n const [first, second] = touches;\n const count = touches.length;\n if (!zoomable || !first || (count !== 2 && !(navigation && count === 1)) || size.width <= 0 || size.height <= 0) {\n pinch.current = null;\n return;\n }\n cancel();\n suppressTap.current = true;\n const x = second ? (first.pageX + second.pageX) / 2 : first.pageX;\n const y = second ? (first.pageY + second.pageY) / 2 : first.pageY;\n const distance = second ? Math.hypot(first.pageX - second.pageX, first.pageY - second.pageY) : 1;\n if (![x, y, distance].every(Number.isFinite) || distance <= 0) {\n pinch.current = null;\n return;\n }\n if (!pinch.current || pinch.current.count !== count) {\n // Touch locations are frame-local; page positions are used only for movement deltas.\n const focalX = Number.isFinite(first.locationX) ? first.locationX + x - first.pageX : x;\n const focalY = Number.isFinite(first.locationY) ? first.locationY + y - first.pageY : y;\n pinch.current = {\n count,\n focalX,\n focalY,\n x,\n y,\n distance,\n scale: transform.current.scale,\n offsetX: transform.current.x,\n offsetY: transform.current.y,\n };\n return;\n }\n const start = pinch.current;\n const scale = Math.max(1, Math.min(4, (start.scale * distance) / start.distance));\n const ratio = scale / start.scale;\n const maxX = (size.width * (scale - 1)) / 2;\n const maxY = (size.height * (scale - 1)) / 2;\n transform.current = {\n scale,\n x: Math.max(\n -maxX,\n Math.min(maxX, start.offsetX * ratio + (start.focalX - size.width / 2) * (1 - ratio) + x - start.x),\n ),\n y: Math.max(\n -maxY,\n Math.min(maxY, start.offsetY * ratio + (start.focalY - size.height / 2) * (1 - ratio) + y - start.y),\n ),\n };\n // Publish synchronously so capture can reject a gesture even before React renders it.\n reportViewport(transform.current);\n setViewport(transform.current);\n };\n const [live, setLive] = useState<readonly Point[]>([]);\n const stroke = useRef<Point[] | null>(null);\n // Callers pass inline callbacks, so a new identity is not a new tool: only switching drawing off or on cancels.\n const draw = useRef(onDraw);\n draw.current = onDraw;\n const drawing = onDraw !== undefined;\n const cancel = () => {\n stroke.current = null;\n pressedPoint.current = undefined;\n setLive([]);\n };\n useEffect(() => {\n stroke.current = null;\n setLive([]);\n return () => {\n stroke.current = null;\n };\n }, [\n drawing,\n navigation,\n drawingHighlight,\n controlledViewport?.zoom,\n controlledViewport?.originX,\n controlledViewport?.originY,\n ]);\n const append = (event: GestureResponderEvent) => {\n if (!stroke.current || !draw.current) return cancel();\n const { locationX, locationY, touches } = event.nativeEvent;\n if (\n touches.length > 1 ||\n ![locationX, locationY, size.width, size.height].every(Number.isFinite) ||\n size.width <= 0 ||\n size.height <= 0\n )\n return cancel();\n const point = sourcePoint(locationX, locationY);\n const last = stroke.current[stroke.current.length - 1];\n if (last?.x === point.x && last.y === point.y) return;\n // Keep the start and a bounded prefix; update the last point once full.\n if (stroke.current.length < MAX_POINTS) stroke.current.push(point);\n else stroke.current[MAX_POINTS - 1] = point;\n setLive([...stroke.current]);\n };\n const place = (event: GestureResponderEvent) => {\n if (!onPlace || onDraw || navigation || suppressTap.current) return;\n const { locationX, locationY } = event.nativeEvent;\n const known = size.width > 0 && size.height > 0 && Number.isFinite(locationX) && Number.isFinite(locationY);\n const point = known ? sourcePoint(locationX, locationY) : (pressedPoint.current ?? { x: 0.5, y: 0.5 });\n pressedPoint.current = undefined;\n selectionTick();\n onPlace(point);\n };\n return (\n <View\n style={[styles.frame, zoomable && { overflow: 'hidden' }, style]}\n onStartShouldSetResponderCapture={(event) => zoomable && (navigation || event.nativeEvent.touches.length > 1)}\n onMoveShouldSetResponderCapture={(event) => zoomable && (navigation || event.nativeEvent.touches.length > 1)}\n onResponderGrant={\n zoomable\n ? (event) => {\n cancel();\n navigating.current = true;\n suppressTap.current = true;\n moveViewport(event);\n }\n : undefined\n }\n onResponderStart={\n zoomable\n ? (event) => {\n cancel();\n moveViewport(event);\n }\n : undefined\n }\n onResponderEnd={\n zoomable\n ? (event) => {\n cancel();\n moveViewport(event);\n }\n : undefined\n }\n onResponderMove={zoomable ? moveViewport : undefined}\n onResponderRelease={\n zoomable\n ? () => {\n navigating.current = false;\n pinch.current = null;\n }\n : undefined\n }\n onResponderTerminationRequest={() => true}\n onResponderTerminate={\n zoomable\n ? () => {\n navigating.current = false;\n pinch.current = null;\n cancel();\n }\n : undefined\n }\n onLayout={(event) => {\n cancel();\n const { width, height } = event.nativeEvent.layout;\n const dimensions = {\n width: Number.isFinite(width) ? Math.max(0, width) : 0,\n height: Number.isFinite(height) ? Math.max(0, height) : 0,\n };\n resetViewport(dimensions);\n setSize(dimensions);\n }}\n >\n <View\n pointerEvents=\"none\"\n style={styles.overlay}\n accessible\n accessibilityRole={onPlace && !onDraw ? 'button' : 'image'}\n accessibilityLabel={accessibilityLabel}\n accessibilityHint={\n onPlace && !onDraw\n ? 'Double tap to add a note here. Use the Note on whole image action to mark the whole image.'\n : undefined\n }\n accessibilityActions={\n onPlace\n ? [...(onDraw ? [] : [{ name: 'activate' }]), { name: 'noteWholeImage', label: 'Note on whole image' }]\n : undefined\n }\n onAccessibilityAction={(event) => {\n const { actionName } = event.nativeEvent;\n if (actionName === 'noteWholeImage' || (actionName === 'activate' && !onDraw)) onPlace?.({ x: 0.5, y: 0.5 });\n }}\n />\n <Pressable\n accessible={false}\n disabled={!onPlace || !!onDraw || navigation}\n onPressIn={(event) => {\n pressedPoint.current = undefined;\n if (navigating.current) return;\n suppressTap.current = false;\n // react-native-web onPress is a MouseEvent; its responder start retains the native location.\n const { locationX, locationY } = event.nativeEvent;\n if (size.width > 0 && size.height > 0 && Number.isFinite(locationX) && Number.isFinite(locationY))\n pressedPoint.current = sourcePoint(locationX, locationY);\n }}\n onPress={place}\n >\n {/* Zoomed content is only a picture, so every touch maps through the frame. At 1x it keeps its own controls, such as PDF page buttons. */}\n <View\n pointerEvents={zoomable && viewport.scale > 1 ? 'none' : 'auto'}\n style={\n zoomable\n ? { transform: [{ translateX: viewport.x }, { translateY: viewport.y }, { scale: viewport.scale }] }\n : undefined\n }\n >\n {children}\n <View pointerEvents=\"none\" accessible={false} style={styles.overlay}>\n {marks.map(\n (mark) =>\n mark.points && (\n <Stroke\n key={mark.id}\n points={mark.points}\n width={size.width}\n height={size.height}\n highlight={mark.highlight}\n />\n ),\n )}\n {onDraw && <Stroke points={live} width={size.width} height={size.height} highlight={drawingHighlight} />}\n </View>\n </View>\n </Pressable>\n {onDraw && !navigation && (\n <View\n accessible={false}\n // Only JS responder props, which Fabric may flatten out of the native tree; keep it hit-testable.\n collapsable={false}\n style={styles.overlay}\n onStartShouldSetResponder={() => true}\n onResponderGrant={(event) => {\n stroke.current = [];\n append(event);\n }}\n onResponderStart={(event) => {\n if (event.nativeEvent.touches.length > 1) cancel();\n }}\n onResponderMove={append}\n onResponderRelease={(event) => {\n append(event);\n const points = stroke.current;\n cancel();\n if (\n points &&\n points.length >= 2 &&\n points.some((point) => point.x !== points[0].x || point.y !== points[0].y)\n ) {\n draw.current?.(points);\n }\n }}\n onResponderTerminationRequest={() => true}\n onResponderTerminate={cancel}\n />\n )}\n {marks.map((mark) => {\n const selected = mark.id === selectedId;\n return (\n <Pressable\n key={mark.id}\n accessibilityRole=\"button\"\n accessibilityLabel={`Note ${mark.label}${mark.description ? `: ${mark.description}` : ''}`}\n accessibilityState={{ selected }}\n onPress={() => onSelectMark?.(mark.id)}\n style={[\n styles.hit,\n zoomable\n ? {\n left: size.width / 2 + (clamp(mark.x) - 0.5) * size.width * viewport.scale + viewport.x,\n top: size.height / 2 + (clamp(mark.y) - 0.5) * size.height * viewport.scale + viewport.y,\n }\n : { left: `${clamp(mark.x) * 100}%`, top: `${clamp(mark.y) * 100}%` },\n ]}\n >\n <View style={[styles.pin, selected && styles.pinSelected]}>\n <Text style={[styles.label, selected && styles.labelSelected]}>{mark.label}</Text>\n </View>\n </Pressable>\n );\n })}\n </View>\n );\n}\n\nconst HIT = 44;\nconst PIN = 28;\n\nconst styles = StyleSheet.create((theme) => ({\n frame: { position: 'relative', alignSelf: 'stretch' },\n overlay: { position: 'absolute', top: 0, right: 0, bottom: 0, left: 0 },\n segment: { position: 'absolute', height: 3, borderRadius: 1.5, backgroundColor: theme.colors.magenta },\n highlight: { height: 16, borderRadius: 8, opacity: 0.3 },\n hit: {\n position: 'absolute',\n width: HIT,\n height: HIT,\n marginLeft: -HIT / 2,\n marginTop: -HIT / 2,\n alignItems: 'center',\n justifyContent: 'center',\n },\n pin: {\n width: PIN,\n height: PIN,\n borderRadius: PIN / 2,\n alignItems: 'center',\n justifyContent: 'center',\n borderWidth: 2,\n borderColor: theme.colors.magenta,\n backgroundColor: theme.colors.bg,\n },\n pinSelected: { backgroundColor: theme.colors.magenta },\n label: {\n color: theme.colors.magenta,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n fontWeight: theme.fontWeight.semibold,\n },\n labelSelected: { color: theme.colors.bg },\n}));\n"],"mappings":";;;;;;;;;;AAqDA,MAAMuC,SAASC,UAAmBC,OAAOC,SAASF,KAAK,IAAIG,KAAKC,IAAI,GAAGD,KAAKE,IAAI,GAAGL,KAAK,CAAC,IAAI;AAC7F,MAAMM,aAAa;AAGnB,SAASE,OAAO,EACd/B,QACAmB,OACAC,QACAnB,YAAY,SAMX;CACD,MAAM+B,YAAY/B,YAAY,KAAK;CAEnC,MAAMgC,UAAUjC,OAAOkC,MAAM,GAAGL,UAAU;CAC1C,OAAOI,QAAQE,KAAK5B,OAAO6B,UAAU;EACnC,MAAMC,WAAWJ,QAAQG,QAAQ;EACjC,IAAI,CAACC,YAAY,CAAC;GAAC9B,MAAMX;GAAGW,MAAMV;GAAGwC,SAASzC;GAAGyC,SAASxC;EAAC,CAAC,CAACyC,MAAMd,OAAOC,QAAQ,GAAG,OAAO;EAC5F,MAAM7B,IAAI0B,MAAMe,SAASzC,CAAC,IAAIuB;EAC9B,MAAMtB,IAAIyB,MAAMe,SAASxC,CAAC,IAAIuB;EAC9B,MAAMmB,KAAKjB,MAAMf,MAAMX,CAAC,IAAIuB,QAAQvB;EACpC,MAAM4C,KAAKlB,MAAMf,MAAMV,CAAC,IAAIuB,SAASvB;EACrC,MAAM4C,SAASf,KAAKgB,MAAMH,IAAIC,EAAE;EAChC,OACE,oBAAC,MAAD,EAEE,OAAO;GACLG,OAAOC;GACP3C,aAAa0C,OAAO1C;GACpB;IACE4C,MAAMjD,IAAI2C,KAAK,IAAIE,SAAS;IAC5BK,K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 +1,5 @@
|
|
|
1
|
-
import { ChipTone } from "@agimon-ai/po-web-components/nativeTheme";
|
|
2
1
|
import { StyleProp, ViewProps, ViewStyle } from "react-native";
|
|
2
|
+
import { ChipTone } from "@agimon-ai/po-web-components/nativeTheme";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
//#region src/components/Badge.d.ts
|
|
5
5
|
export type BadgeTone = ChipTone;
|
|
@@ -2,8 +2,8 @@ import { fontOf } from "../lib/fonts.mjs";
|
|
|
2
2
|
import { CHIP_INK } from "../lib/tone.mjs";
|
|
3
3
|
import { wrapText } from "../lib/wrapText.mjs";
|
|
4
4
|
import { View } from "react-native-unistyles/components/native/View";
|
|
5
|
-
import { withAlpha } from "@agimon-ai/po-web-components/nativeTheme";
|
|
6
5
|
import { StyleSheet, useUnistyles } from "react-native-unistyles";
|
|
6
|
+
import { withAlpha } from "@agimon-ai/po-web-components/nativeTheme";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
8
|
|
|
9
9
|
//#region src/components/Badge.tsx
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { fontOf } from "../lib/fonts.mjs";
|
|
2
|
+
import { impactLight } from "../lib/haptics.mjs";
|
|
2
3
|
import { wrapText } from "../lib/wrapText.mjs";
|
|
3
4
|
import { IconColorContext } from "../icons/IconColorContext.mjs";
|
|
4
|
-
import { impactLight } from "../lib/haptics.mjs";
|
|
5
5
|
import { Spinner } from "./Spinner.mjs";
|
|
6
|
-
import { withAlpha } from "@agimon-ai/po-web-components/nativeTheme";
|
|
7
6
|
import { StyleSheet, useUnistyles } from "react-native-unistyles";
|
|
7
|
+
import { withAlpha } from "@agimon-ai/po-web-components/nativeTheme";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { Pressable } from "react-native-unistyles/components/native/Pressable";
|
|
10
10
|
|
|
@@ -4,7 +4,9 @@ export interface CodeBlockProps {
|
|
|
4
4
|
text: string;
|
|
5
5
|
/** The fence's language word, such as `ts`; the web reads it from a `language-*` class. */
|
|
6
6
|
language?: string;
|
|
7
|
+
/** Initial reveal pages, useful for a reader restored to a known position. */
|
|
8
|
+
initialPage?: number;
|
|
7
9
|
}
|
|
8
|
-
export declare function CodeBlock({ text, language }: CodeBlockProps): import("react").JSX.Element;
|
|
10
|
+
export declare function CodeBlock({ text, language, initialPage }: CodeBlockProps): import("react").JSX.Element;
|
|
9
11
|
//#endregion
|
|
10
12
|
//# sourceMappingURL=CodeBlock.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlock.d.mts","names":[],"sources":["../../src/components/CodeBlock.tsx"],"mappings":";
|
|
1
|
+
{"version":3,"file":"CodeBlock.d.mts","names":[],"sources":["../../src/components/CodeBlock.tsx"],"mappings":";iBAiBiB;;EAEf;;EAEA;;EAEA;;wBAGc,YAAY,MAAM,UAAU,eAAmB,iCAAc,IAAA"}
|
|
@@ -1,61 +1,49 @@
|
|
|
1
1
|
import { fontOf } from "../lib/fonts.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { codePrefix } from "../lib/reading.mjs";
|
|
3
|
+
import { useReadingPage } from "../lib/useReadingPage.mjs";
|
|
4
|
+
import { CopyButton } from "./CopyButton.mjs";
|
|
5
|
+
import { ShowMore } from "./ShowMore.mjs";
|
|
4
6
|
import { View } from "react-native-unistyles/components/native/View";
|
|
5
|
-
import { StyleSheet } from "react-native-unistyles";
|
|
6
7
|
import { Text } from "react-native-unistyles/components/native/Text";
|
|
7
|
-
import {
|
|
8
|
+
import { StyleSheet } from "react-native-unistyles";
|
|
8
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
10
|
import { ScrollView } from "react-native-unistyles/components/native/ScrollView";
|
|
10
|
-
import { setStringAsync } from "expo-clipboard";
|
|
11
11
|
|
|
12
12
|
//#region src/components/CodeBlock.tsx
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
idle: "copy",
|
|
17
|
-
copied: "copied",
|
|
18
|
-
failed: "copying failed"
|
|
19
|
-
};
|
|
20
|
-
function CodeBlock({ text, language }) {
|
|
21
|
-
const [state, setState] = useState("idle");
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
if (state === "idle") return void 0;
|
|
24
|
-
const timer = setTimeout(() => setState("idle"), FEEDBACK_MS);
|
|
25
|
-
return () => clearTimeout(timer);
|
|
26
|
-
}, [state]);
|
|
27
|
-
const label = LABELS[state];
|
|
13
|
+
function CodeBlock({ text, language, initialPage = 1 }) {
|
|
14
|
+
const { page, reveal } = useReadingPage(text, initialPage);
|
|
15
|
+
const visible = codePrefix(text, page);
|
|
28
16
|
return /* @__PURE__ */ jsxs(View, {
|
|
29
|
-
style: styles.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}) : /* @__PURE__ */ jsx(CopyIcon, {
|
|
52
|
-
size: 12,
|
|
53
|
-
color: "faint"
|
|
54
|
-
})
|
|
55
|
-
})]
|
|
17
|
+
style: styles.root,
|
|
18
|
+
children: [/* @__PURE__ */ jsxs(View, {
|
|
19
|
+
style: styles.block,
|
|
20
|
+
accessibilityLabel: language === void 0 ? void 0 : `${language} code`,
|
|
21
|
+
children: [/* @__PURE__ */ jsx(ScrollView, {
|
|
22
|
+
horizontal: true,
|
|
23
|
+
showsHorizontalScrollIndicator: false,
|
|
24
|
+
contentContainerStyle: styles.scroll,
|
|
25
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
26
|
+
selectable: true,
|
|
27
|
+
style: styles.code,
|
|
28
|
+
children: visible
|
|
29
|
+
})
|
|
30
|
+
}), /* @__PURE__ */ jsx(CopyButton, {
|
|
31
|
+
text,
|
|
32
|
+
style: styles.copy
|
|
33
|
+
})]
|
|
34
|
+
}), visible.length < text.length ? /* @__PURE__ */ jsx(ShowMore, {
|
|
35
|
+
label: "Show more code",
|
|
36
|
+
summary: `${visible.length} of ${text.length} characters · ${visible.split("\n").length} of ${text.split("\n").length} lines`,
|
|
37
|
+
onPress: reveal
|
|
38
|
+
}) : null]
|
|
56
39
|
});
|
|
57
40
|
}
|
|
58
41
|
const styles = StyleSheet.create((theme) => ({
|
|
42
|
+
root: {
|
|
43
|
+
gap: theme.spacing(2),
|
|
44
|
+
minWidth: 0,
|
|
45
|
+
uni__dependencies: [0]
|
|
46
|
+
},
|
|
59
47
|
block: {
|
|
60
48
|
borderRadius: theme.borderRadius.DEFAULT,
|
|
61
49
|
borderWidth: 1,
|