@agimon-ai/po-native-components 0.0.0-alpha.194 → 0.0.0-alpha.196
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 +21 -149
- package/dist/components/AnnotationSurface.d.mts.map +1 -1
- package/dist/components/AnnotationSurface.mjs +8 -3
- package/dist/components/AnnotationSurface.mjs.map +1 -1
- package/dist/components/CodeBlock.d.mts.map +1 -1
- package/dist/components/CodeBlock.mjs +10 -3
- package/dist/components/CodeBlock.mjs.map +1 -1
- package/dist/components/ComputerRow.d.mts.map +1 -1
- package/dist/components/ComputerRow.mjs +12 -8
- package/dist/components/ComputerRow.mjs.map +1 -1
- package/dist/components/CopyButton.d.mts.map +1 -1
- package/dist/components/CopyButton.mjs +12 -6
- package/dist/components/CopyButton.mjs.map +1 -1
- package/dist/components/Dialog.d.mts +2 -2
- package/dist/components/Dialog.d.mts.map +1 -1
- package/dist/components/Dialog.mjs +7 -2
- package/dist/components/Dialog.mjs.map +1 -1
- package/dist/components/EmptyState.mjs +2 -2
- package/dist/components/EmptyState.mjs.map +1 -1
- package/dist/components/FileList.d.mts.map +1 -1
- package/dist/components/FileList.mjs +63 -62
- package/dist/components/FileList.mjs.map +1 -1
- package/dist/components/FilePreview.d.mts.map +1 -1
- package/dist/components/FilePreview.mjs +6 -4
- package/dist/components/FilePreview.mjs.map +1 -1
- package/dist/components/FileViewer.d.mts.map +1 -1
- package/dist/components/FileViewer.mjs +15 -10
- package/dist/components/FileViewer.mjs.map +1 -1
- package/dist/components/HashlineLines.d.mts.map +1 -1
- package/dist/components/HashlineLines.mjs +7 -2
- package/dist/components/HashlineLines.mjs.map +1 -1
- package/dist/components/HostFilter.d.mts +1 -1
- package/dist/components/HostFilter.d.mts.map +1 -1
- package/dist/components/HostFilter.mjs +4 -2
- package/dist/components/HostFilter.mjs.map +1 -1
- package/dist/components/HostTag.d.mts.map +1 -1
- package/dist/components/HostTag.mjs +2 -1
- package/dist/components/HostTag.mjs.map +1 -1
- package/dist/components/List.d.mts.map +1 -1
- package/dist/components/List.mjs +3 -1
- package/dist/components/List.mjs.map +1 -1
- package/dist/components/LoadingState.d.mts +17 -0
- package/dist/components/LoadingState.d.mts.map +1 -0
- package/dist/components/LoadingState.mjs +90 -0
- package/dist/components/LoadingState.mjs.map +1 -0
- package/dist/components/Markdown.d.mts.map +1 -1
- package/dist/components/Markdown.mjs +26 -26
- package/dist/components/Markdown.mjs.map +1 -1
- package/dist/components/MessageItem.d.mts.map +1 -1
- package/dist/components/MessageItem.mjs +22 -5
- package/dist/components/MessageItem.mjs.map +1 -1
- package/dist/components/Select.d.mts +1 -1
- package/dist/components/Select.d.mts.map +1 -1
- package/dist/components/Select.mjs +7 -4
- package/dist/components/Select.mjs.map +1 -1
- package/dist/components/Sheet.d.mts +1 -1
- package/dist/components/Sheet.d.mts.map +1 -1
- package/dist/components/Sheet.mjs +4 -1
- package/dist/components/Sheet.mjs.map +1 -1
- package/dist/components/ToolPathLink.d.mts.map +1 -1
- package/dist/components/ToolPathLink.mjs +3 -1
- package/dist/components/ToolPathLink.mjs.map +1 -1
- package/dist/components/ToolResultImage.d.mts +1 -1
- package/dist/components/ToolResultImage.d.mts.map +1 -1
- package/dist/components/ToolResultImage.mjs +7 -4
- package/dist/components/ToolResultImage.mjs.map +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +2 -1
- package/dist/lib/fileKindLabel.mjs +17 -0
- package/dist/lib/fileKindLabel.mjs.map +1 -0
- package/dist/po-runtime-identity.json +1 -1
- package/package.json +7 -6
package/LICENSE
CHANGED
|
@@ -1,149 +1,21 @@
|
|
|
1
|
-
License
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
other Organization. Use by an individual in the course of employment
|
|
23
|
-
or engagement by an Organization is use by that Organization.
|
|
24
|
-
|
|
25
|
-
(b) Small Organization Use. Use by or on behalf of an Organization whose
|
|
26
|
-
Annual Revenue is less than USD 1,000,000.
|
|
27
|
-
|
|
28
|
-
(c) Non-profit, Education and Research Use. Use, regardless of Annual
|
|
29
|
-
Revenue, by (i) an Organization registered or recognized as a
|
|
30
|
-
non-profit or charitable organization under the laws of its
|
|
31
|
-
jurisdiction, for its non-profit purposes; (ii) an accredited school,
|
|
32
|
-
college, or university, for teaching, learning, or academic research;
|
|
33
|
-
or (iii) a publicly funded research institution, for its research.
|
|
34
|
-
|
|
35
|
-
(d) Service Provider Use. Use by a consultant, contractor, agency, or other
|
|
36
|
-
service provider, regardless of its own Annual Revenue, solely to
|
|
37
|
-
build, deploy, host, operate, or support the Licensed Work for a client
|
|
38
|
-
whose own use would be Eligible Use under (a), (b), or (c). A service
|
|
39
|
-
provider's use for its own purposes is Eligible Use only if the service
|
|
40
|
-
provider itself qualifies under (b) or (c).
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
Hosted services. Offering the Licensed Work to third parties as a hosted
|
|
44
|
-
or managed service whose primary value is the Licensed Work is Eligible
|
|
45
|
-
Use only if each such third party's own use would be Eligible Use.
|
|
46
|
-
|
|
47
|
-
Definitions. "Organization" means any company, partnership, sole
|
|
48
|
-
proprietorship, trust, association, government body, or other entity, and
|
|
49
|
-
includes an individual acting in a business or professional capacity.
|
|
50
|
-
"Affiliate" means any entity that directly or indirectly controls, is
|
|
51
|
-
controlled by, or is under common control with an Organization, where
|
|
52
|
-
"control" means ownership of more than 50% of the voting interests of an
|
|
53
|
-
entity or the power to direct its management and policies by contract or
|
|
54
|
-
otherwise. "Annual Revenue" means the total gross revenue of an
|
|
55
|
-
Organization and all of its Affiliates combined, from all sources and
|
|
56
|
-
whether or not related to the Licensed Work, for its most recently
|
|
57
|
-
completed fiscal year, or, if it has not completed a fiscal year, for the
|
|
58
|
-
twelve months before the use (or since its formation, if shorter),
|
|
59
|
-
converted into US dollars at the average exchange rate for that period.
|
|
60
|
-
Proceeds of equity or debt financing are not revenue.
|
|
61
|
-
|
|
62
|
-
Threshold. If an Organization stops qualifying under (b), its existing
|
|
63
|
-
production use remains Eligible Use for 90 days after it stops
|
|
64
|
-
qualifying, after which it must obtain a commercial license or stop
|
|
65
|
-
production use. Use that was Eligible Use when it occurred never requires
|
|
66
|
-
a commercial license after the fact.
|
|
67
|
-
Change Date: Four years from the date a version of the Licensed Work
|
|
68
|
-
is first publicly released by the Licensor.
|
|
69
|
-
Change License: Apache License, Version 2.0
|
|
70
|
-
|
|
71
|
-
For information about alternative licensing arrangements for the Licensed
|
|
72
|
-
Work, please visit: https://agimon.ai/licensing
|
|
73
|
-
|
|
74
|
-
Notice
|
|
75
|
-
|
|
76
|
-
The Business Source License (this document, or the "License") is not an Open
|
|
77
|
-
Source license. However, the Licensed Work will eventually be made available
|
|
78
|
-
under an Open Source License, as stated in this License.
|
|
79
|
-
|
|
80
|
-
-----------------------------------------------------------------------------
|
|
81
|
-
|
|
82
|
-
Business Source License 1.1
|
|
83
|
-
|
|
84
|
-
Terms
|
|
85
|
-
|
|
86
|
-
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
87
|
-
works, redistribute, and make non-production use of the Licensed Work. The
|
|
88
|
-
Licensor may make an Additional Use Grant, above, permitting limited
|
|
89
|
-
production use.
|
|
90
|
-
|
|
91
|
-
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
92
|
-
available distribution of a specific version of the Licensed Work under this
|
|
93
|
-
License, whichever comes first, the Licensor hereby grants you rights under
|
|
94
|
-
the terms of the Change License, and the rights granted in the paragraph
|
|
95
|
-
above terminate.
|
|
96
|
-
|
|
97
|
-
If your use of the Licensed Work does not comply with the requirements
|
|
98
|
-
currently in effect as described in this License, you must purchase a
|
|
99
|
-
commercial license from the Licensor, its affiliated entities, or authorized
|
|
100
|
-
resellers, or you must refrain from using the Licensed Work.
|
|
101
|
-
|
|
102
|
-
All copies of the original and modified Licensed Work, and derivative works
|
|
103
|
-
of the Licensed Work, are subject to this License. This License applies
|
|
104
|
-
separately for each version of the Licensed Work and the Change Date may vary
|
|
105
|
-
for each version of the Licensed Work released by Licensor.
|
|
106
|
-
|
|
107
|
-
You must conspicuously display this License on each original or modified copy
|
|
108
|
-
of the Licensed Work. If you receive the Licensed Work in original or
|
|
109
|
-
modified form from a third party, the terms and conditions set forth in this
|
|
110
|
-
License apply to your use of that work.
|
|
111
|
-
|
|
112
|
-
Any use of the Licensed Work in violation of this License will automatically
|
|
113
|
-
terminate your rights under this License for the current and all other
|
|
114
|
-
versions of the Licensed Work.
|
|
115
|
-
|
|
116
|
-
This License does not grant you any right in any trademark or logo of
|
|
117
|
-
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
118
|
-
Licensor as expressly required by this License).
|
|
119
|
-
|
|
120
|
-
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
121
|
-
AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
122
|
-
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
123
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
124
|
-
TITLE.
|
|
125
|
-
|
|
126
|
-
MariaDB hereby grants you permission to use this License’s text to license
|
|
127
|
-
your works, and to refer to it using the trademark “Business Source License”,
|
|
128
|
-
as long as you comply with the Covenants of Licensor below.
|
|
129
|
-
|
|
130
|
-
Covenants of Licensor
|
|
131
|
-
|
|
132
|
-
In consideration of the right to use this License’s text and the “Business
|
|
133
|
-
Source License” name and trademark, Licensor covenants to MariaDB, and to all
|
|
134
|
-
other recipients of the licensed work to be provided by Licensor:
|
|
135
|
-
|
|
136
|
-
1. To specify as the Change License the GPL Version 2.0 or any later version,
|
|
137
|
-
or a license that is compatible with GPL Version 2.0 or a later version,
|
|
138
|
-
where “compatible” means that software provided under the Change License can
|
|
139
|
-
be included in a program with software provided under GPL Version 2.0 or a
|
|
140
|
-
later version. Licensor may specify additional Change Licenses without
|
|
141
|
-
limitation.
|
|
142
|
-
|
|
143
|
-
2. To either: (a) specify an additional grant of rights to use that does not
|
|
144
|
-
impose any additional restriction on the right granted in this License, as
|
|
145
|
-
the Additional Use Grant; or (b) insert the text “None”.
|
|
146
|
-
|
|
147
|
-
3. To specify a Change Date.
|
|
148
|
-
|
|
149
|
-
4. Not to modify this License in any other way.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Agimon Pty Ltd
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnnotationSurface.d.mts","names":[],"sources":["../../src/components/AnnotationSurface.tsx"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"AnnotationSurface.d.mts","names":[],"sources":["../../src/components/AnnotationSurface.tsx"],"mappings":";;;;iBASiB;EACf;EACA;EACA;;EAEA;;EAEA;;EAEA;IAAoB;IAAW;;;EAE/B;;iBAGe;;EAEf,UAAU;EACV,gBAAgB;EAChB;;EAEA,WAAW;IAAS;IAAW;;;EAE/B,UAAU;IAAU;IAAW;;EAC/B,gBAAgB;;EAEhB;;EAEA;;EAEA;;EAEA;IAAa;IAAc;IAAiB;;;EAE5C;;EAEA,oBAAoB;IAClB;IACA;IACA;IACA;IACA;;EAEF,QAAQ,UAAU;;;;;;;;wBAqDJ,oBACd,UACA,OACA,YACA,SACA,QACA,cACA,oBACA,UACA,kBACA,YACA,UAAU,oBACV,kBACA,SACC,yCAAsB,IAAA"}
|
|
@@ -6,6 +6,7 @@ import { StyleSheet } from "react-native-unistyles";
|
|
|
6
6
|
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { Pressable } from "react-native-unistyles/components/native/Pressable";
|
|
9
|
+
import { useT } from "@agimon-ai/po-core/native";
|
|
9
10
|
|
|
10
11
|
//#region src/components/AnnotationSurface.tsx
|
|
11
12
|
const clamp = (value) => Number.isFinite(value) ? Math.min(1, Math.max(0, value)) : 0;
|
|
@@ -45,6 +46,7 @@ function Stroke({ points, width, height, highlight = false }) {
|
|
|
45
46
|
* note at its centre.
|
|
46
47
|
*/
|
|
47
48
|
function AnnotationSurface({ children, marks, selectedId, onPlace, onDraw, onSelectMark, accessibilityLabel, zoomable = false, onViewportChange, navigation = false, viewport: controlledViewport, drawingHighlight = false, style }) {
|
|
49
|
+
const t = useT();
|
|
48
50
|
const [size, setSize] = useState({
|
|
49
51
|
width: 0,
|
|
50
52
|
height: 0
|
|
@@ -261,10 +263,10 @@ function AnnotationSurface({ children, marks, selectedId, onPlace, onDraw, onSel
|
|
|
261
263
|
accessible: true,
|
|
262
264
|
accessibilityRole: onPlace && !onDraw ? "button" : "image",
|
|
263
265
|
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,
|
|
266
|
+
accessibilityHint: onPlace && !onDraw ? t("nativeComponents.annotation.placeHint", "Double tap to add a note here. Use the Note on whole image action to mark the whole image.") : void 0,
|
|
265
267
|
accessibilityActions: onPlace ? [...onDraw ? [] : [{ name: "activate" }], {
|
|
266
268
|
name: "noteWholeImage",
|
|
267
|
-
label: "Note on whole image"
|
|
269
|
+
label: t("nativeComponents.annotation.noteWholeImage", "Note on whole image")
|
|
268
270
|
}] : void 0,
|
|
269
271
|
onAccessibilityAction: (event) => {
|
|
270
272
|
const { actionName } = event.nativeEvent;
|
|
@@ -336,7 +338,10 @@ function AnnotationSurface({ children, marks, selectedId, onPlace, onDraw, onSel
|
|
|
336
338
|
const selected = mark.id === selectedId;
|
|
337
339
|
return /* @__PURE__ */ jsx(Pressable, {
|
|
338
340
|
accessibilityRole: "button",
|
|
339
|
-
accessibilityLabel:
|
|
341
|
+
accessibilityLabel: mark.description ? t("nativeComponents.annotation.markDescribed", "Note {label}: {description}", {
|
|
342
|
+
label: mark.label,
|
|
343
|
+
description: mark.description
|
|
344
|
+
}) : t("nativeComponents.annotation.mark", "Note {label}", { label: mark.label }),
|
|
340
345
|
accessibilityState: { selected },
|
|
341
346
|
onPress: () => onSelectMark?.(mark.id),
|
|
342
347
|
style: [styles.hit, zoomable ? {
|
|
@@ -1 +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;EACn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AAY;EACZC,gBAAgB;CAClB;CACApB,KAAK;EACH/F,OAAOmG;EACPlG,QAAQkG;EACRO,cAAcP,MAAM;EACpBe,YAAY;EACZC,gBAAgB;EAChBC,aAAa;EACbC,aAAahB,MAAMO,OAAOC;EAC1BF,iBAAiBN,MAAMO,OAAOU;EAAER,mBAAA,CAAA,CAAA;CAClC;CACAd,aAAa;EAAEW,iBAAiBN,MAAMO,OAAOC;EAAOC,mBAAA,CAAA,CAAA;CAAC;CACrDnI,OAAO;EACL4I,OAAOlB,MAAMO,OAAOC;EACpBW,YAAYnJ,OAAOgI,MAAMmB,WAAWC,IAAI;EACxCC,UAAUrB,MAAMqB,SAASC;EACzBC,YAAYvB,MAAMuB,WAAWC;EAAQf,mBAAA,CAAA,CAAA;CACvC;CACAb,eAAe;EAAEsB,OAAOlB,MAAMO,OAAOU;EAAER,mBAAA,CAAA,CAAA;CAAC;AAC1C,EAAE"}
|
|
1
|
+
{"version":3,"file":"AnnotationSurface.mjs","names":["useT","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","t","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 { useT } from '@agimon-ai/po-core/native';\nimport { 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 t = useT();\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 ? t(\n 'nativeComponents.annotation.placeHint',\n 'Double tap to add a note here. Use the Note on whole image action to mark the whole image.',\n )\n : undefined\n }\n accessibilityActions={\n onPlace\n ? [\n ...(onDraw ? [] : [{ name: 'activate' }]),\n {\n name: 'noteWholeImage',\n label: t('nativeComponents.annotation.noteWholeImage', 'Note on whole image'),\n },\n ]\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={\n mark.description\n ? t('nativeComponents.annotation.markDescribed', 'Note {label}: {description}', {\n label: mark.label,\n description: mark.description,\n })\n : t('nativeComponents.annotation.mark', 'Note {label}', { label: mark.label })\n }\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":";;;;;;;;;;;AAsDA,MAAMwC,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,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1BF,iBAAiBN,MAAMO,OAAOU;EAAER,mBAAA,CAAA,CAAA;CAClC;CACAd,aAAa;EAAEW,iBAAiBN,MAAMO,OAAOC;EAAOC,mBAAA,CAAA,CAAA;CAAC;CACrDpI,OAAO;EACL6I,OAAOlB,MAAMO,OAAOC;EACpBW,YAAYpJ,OAAOiI,MAAMmB,WAAWC,IAAI;EACxCC,UAAUrB,MAAMqB,SAASC;EACzBC,YAAYvB,MAAMuB,WAAWC;EAAQf,mBAAA,CAAA,CAAA;CACvC;CACAb,eAAe;EAAEsB,OAAOlB,MAAMO,OAAOU;EAAER,mBAAA,CAAA,CAAA;CAAC;AAC1C,EAAE"}
|
|
@@ -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":";iBAkBiB;;EAEf;;EAEA;;EAEA;;wBAGc,YAAY,MAAM,UAAU,eAAmB,iCAAc,IAAA"}
|
|
@@ -7,17 +7,19 @@ import { View } from "react-native-unistyles/components/native/View";
|
|
|
7
7
|
import { Text } from "react-native-unistyles/components/native/Text";
|
|
8
8
|
import { StyleSheet } from "react-native-unistyles";
|
|
9
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { useT } from "@agimon-ai/po-core/native";
|
|
10
11
|
import { ScrollView } from "react-native-unistyles/components/native/ScrollView";
|
|
11
12
|
|
|
12
13
|
//#region src/components/CodeBlock.tsx
|
|
13
14
|
function CodeBlock({ text, language, initialPage = 1 }) {
|
|
15
|
+
const t = useT();
|
|
14
16
|
const { page, reveal } = useReadingPage(text, initialPage);
|
|
15
17
|
const visible = codePrefix(text, Math.max(initialPage, page));
|
|
16
18
|
return /* @__PURE__ */ jsxs(View, {
|
|
17
19
|
style: styles.root,
|
|
18
20
|
children: [/* @__PURE__ */ jsxs(View, {
|
|
19
21
|
style: styles.block,
|
|
20
|
-
accessibilityLabel: language === void 0 ? void 0 :
|
|
22
|
+
accessibilityLabel: language === void 0 ? void 0 : t("nativeComponents.codeBlock.label", "{language} code", { language }),
|
|
21
23
|
children: [/* @__PURE__ */ jsx(ScrollView, {
|
|
22
24
|
horizontal: true,
|
|
23
25
|
showsHorizontalScrollIndicator: false,
|
|
@@ -32,8 +34,13 @@ function CodeBlock({ text, language, initialPage = 1 }) {
|
|
|
32
34
|
style: styles.copy
|
|
33
35
|
})]
|
|
34
36
|
}), visible.length < text.length ? /* @__PURE__ */ jsx(ShowMore, {
|
|
35
|
-
label: "Show more code",
|
|
36
|
-
summary:
|
|
37
|
+
label: t("nativeComponents.codeBlock.showMore", "Show more code"),
|
|
38
|
+
summary: t("nativeComponents.codeBlock.summary", "{shownChars} of {totalChars} characters · {shownLines} of {totalLines} lines", {
|
|
39
|
+
shownChars: visible.length,
|
|
40
|
+
totalChars: text.length,
|
|
41
|
+
shownLines: visible.split("\n").length,
|
|
42
|
+
totalLines: text.split("\n").length
|
|
43
|
+
}),
|
|
37
44
|
onPress: reveal
|
|
38
45
|
}) : null]
|
|
39
46
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlock.mjs","names":["StyleSheet","fontOf","codePrefix","useReadingPage","CopyButton","ShowMore","CodeBlockProps","text","language","initialPage","CodeBlock","page","reveal","visible","Math","max","styles","root","block","undefined","scroll","code","copy","length","split","create","theme","gap","spacing","minWidth","uni__dependencies","borderRadius","DEFAULT","borderWidth","borderColor","colors","border","backgroundColor","deep","padding","paddingRight","color","fontFamily","mono","fontSize","sm","lineHeight","lineHeightRelaxed","position","top","right"],"sources":["../../src/components/CodeBlock.tsx"],"sourcesContent":["import { ScrollView, Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\nimport { codePrefix } from '../lib/reading';\nimport { useReadingPage } from '../lib/useReadingPage';\nimport { CopyButton } from './CopyButton';\nimport { ShowMore } from './ShowMore';\n\n/*\n * A fenced code block: the source in selectable mono type that scrolls\n * sideways rather than wrapping, and a copy button that says when it worked.\n *\n * ponytail: no syntax colouring and no mermaid diagrams yet; a mermaid fence\n * shows its source, which is still the whole content.\n */\n\nexport interface CodeBlockProps {\n /** The block's source, without the fence lines. */\n text: string;\n /** The fence's language word, such as `ts`; the web reads it from a `language-*` class. */\n language?: string;\n /** Initial reveal pages, useful for a reader restored to a known position. */\n initialPage?: number;\n}\n\nexport function CodeBlock({ text, language, initialPage = 1 }: CodeBlockProps) {\n const { page, reveal } = useReadingPage(text, initialPage);\n const visible = codePrefix(text, Math.max(initialPage, page));\n return (\n <View style={styles.root}>\n <View
|
|
1
|
+
{"version":3,"file":"CodeBlock.mjs","names":["useT","StyleSheet","fontOf","codePrefix","useReadingPage","CopyButton","ShowMore","CodeBlockProps","text","language","initialPage","CodeBlock","t","page","reveal","visible","Math","max","styles","root","block","undefined","scroll","code","copy","length","shownChars","totalChars","shownLines","split","totalLines","create","theme","gap","spacing","minWidth","uni__dependencies","borderRadius","DEFAULT","borderWidth","borderColor","colors","border","backgroundColor","deep","padding","paddingRight","color","fontFamily","mono","fontSize","sm","lineHeight","lineHeightRelaxed","position","top","right"],"sources":["../../src/components/CodeBlock.tsx"],"sourcesContent":["import { useT } from '@agimon-ai/po-core/native';\nimport { ScrollView, Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\nimport { codePrefix } from '../lib/reading';\nimport { useReadingPage } from '../lib/useReadingPage';\nimport { CopyButton } from './CopyButton';\nimport { ShowMore } from './ShowMore';\n\n/*\n * A fenced code block: the source in selectable mono type that scrolls\n * sideways rather than wrapping, and a copy button that says when it worked.\n *\n * ponytail: no syntax colouring and no mermaid diagrams yet; a mermaid fence\n * shows its source, which is still the whole content.\n */\n\nexport interface CodeBlockProps {\n /** The block's source, without the fence lines. */\n text: string;\n /** The fence's language word, such as `ts`; the web reads it from a `language-*` class. */\n language?: string;\n /** Initial reveal pages, useful for a reader restored to a known position. */\n initialPage?: number;\n}\n\nexport function CodeBlock({ text, language, initialPage = 1 }: CodeBlockProps) {\n const t = useT();\n const { page, reveal } = useReadingPage(text, initialPage);\n const visible = codePrefix(text, Math.max(initialPage, page));\n return (\n <View style={styles.root}>\n <View\n style={styles.block}\n accessibilityLabel={\n language === undefined ? undefined : t('nativeComponents.codeBlock.label', '{language} code', { language })\n }\n >\n <ScrollView horizontal showsHorizontalScrollIndicator={false} contentContainerStyle={styles.scroll}>\n <Text selectable style={styles.code}>\n {visible}\n </Text>\n </ScrollView>\n\n <CopyButton text={text} style={styles.copy} />\n </View>\n {visible.length < text.length ? (\n <ShowMore\n label={t('nativeComponents.codeBlock.showMore', 'Show more code')}\n summary={t(\n 'nativeComponents.codeBlock.summary',\n '{shownChars} of {totalChars} characters · {shownLines} of {totalLines} lines',\n {\n shownChars: visible.length,\n totalChars: text.length,\n shownLines: visible.split('\\n').length,\n totalLines: text.split('\\n').length,\n },\n )}\n onPress={reveal}\n />\n ) : null}\n </View>\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n root: { gap: theme.spacing(2), minWidth: 0 },\n block: {\n borderRadius: theme.borderRadius.DEFAULT,\n borderWidth: 1,\n borderColor: theme.colors.border,\n backgroundColor: theme.colors.deep,\n },\n // The right padding keeps the first line clear of the copy button.\n scroll: { padding: theme.spacing(2.5), paddingRight: theme.spacing(9) },\n code: {\n color: theme.colors.text,\n fontFamily: fontOf(theme.fontFamily.mono),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeightRelaxed.sm,\n },\n copy: { position: 'absolute', top: theme.spacing(1.5), right: theme.spacing(1.5) },\n}));\n"],"mappings":";;;;;;;;;;;;;AA2BA,SAAgBW,UAAU,EAAEH,MAAMC,UAAUC,cAAc,KAAqB;CAC7E,MAAME,IAAIZ,KAAK;CACf,MAAM,EAAEa,MAAMC,WAAWV,eAAeI,MAAME,WAAW;CACzD,MAAMK,U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SAASC;EACzBC,YAAYpB,MAAMqB,kBAAkBF;EAAEf,mBAAA,CAAA,CAAA;CACxC;CACAZ,MAAM;EAAE8B,UAAU;EAAYC,KAAKvB,MAAME,QAAQ,GAAG;EAAGsB,OAAOxB,MAAME,QAAQ,GAAG;EAACE,mBAAA,CAAA,CAAA;CAAC;AACnF,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComputerRow.d.mts","names":[],"sources":["../../src/components/ComputerRow.tsx"],"mappings":";
|
|
1
|
+
{"version":3,"file":"ComputerRow.d.mts","names":[],"sources":["../../src/components/ComputerRow.tsx"],"mappings":";YASY;iBAgBK;EACf;;EAEA;EACA,QAAQ;;EAER;EACA;;;wBAIc,cAAc,MAAM,MAAM,QAAQ,UAAU,WAAW,mCAAgB,IAAA"}
|
|
@@ -6,19 +6,23 @@ import { View } from "react-native-unistyles/components/native/View";
|
|
|
6
6
|
import { Text } from "react-native-unistyles/components/native/Text";
|
|
7
7
|
import { StyleSheet } from "react-native-unistyles";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { useT } from "@agimon-ai/po-core/native";
|
|
9
10
|
|
|
10
11
|
//#region src/components/ComputerRow.tsx
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
function statusLabel(status, t) {
|
|
13
|
+
switch (status) {
|
|
14
|
+
case "connected": return t("nativeComponents.computerRow.status.connected", "Connected");
|
|
15
|
+
case "connecting": return t("nativeComponents.computerRow.status.connecting", "Connecting");
|
|
16
|
+
case "disconnected": return t("nativeComponents.computerRow.status.disconnected", "Offline");
|
|
17
|
+
case "update_required": return t("nativeComponents.computerRow.status.updateRequired", "Needs update");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
17
20
|
const HOME_FOLDER = /^(\/Users|\/home)\/[^/]+(?=\/|$)/;
|
|
18
21
|
/** One computer to pick in a sheet: its name, an optional folder, and whether it is reachable. */
|
|
19
22
|
function ComputerRow({ name, path, status, disabled, onPress }) {
|
|
20
23
|
const connected = status === "connected";
|
|
21
24
|
const shortPath = path?.replace(HOME_FOLDER, "~");
|
|
25
|
+
const label = statusLabel(status, useT());
|
|
22
26
|
return /* @__PURE__ */ jsx(ListRow, {
|
|
23
27
|
title: name,
|
|
24
28
|
description: shortPath ? /* @__PURE__ */ jsx(Text, {
|
|
@@ -41,12 +45,12 @@ function ComputerRow({ name, path, status, disabled, onPress }) {
|
|
|
41
45
|
pulse: status === "connecting"
|
|
42
46
|
}), /* @__PURE__ */ jsx(Text, {
|
|
43
47
|
style: [styles.statusLabel, connected && styles.statusConnected],
|
|
44
|
-
children:
|
|
48
|
+
children: label
|
|
45
49
|
})]
|
|
46
50
|
}),
|
|
47
51
|
disabled: disabled ?? !connected,
|
|
48
52
|
onPress,
|
|
49
|
-
accessibilityLabel: `${name}${shortPath ? `, ${shortPath}` : ""}, ${
|
|
53
|
+
accessibilityLabel: `${name}${shortPath ? `, ${shortPath}` : ""}, ${label}`,
|
|
50
54
|
style: styles.card
|
|
51
55
|
});
|
|
52
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComputerRow.mjs","names":["StyleSheet","MonitorIcon","fontOf","Dot","ListRow","ComputerStatus","
|
|
1
|
+
{"version":3,"file":"ComputerRow.mjs","names":["useT","StyleSheet","MonitorIcon","fontOf","Dot","ListRow","ComputerStatus","statusLabel","status","t","ReturnType","HOME_FOLDER","ComputerRowProps","name","path","disabled","onPress","ComputerRow","connected","shortPath","replace","label","styles","undefined","icon","iconConnected","statusConnected","card","create","theme","borderWidth","hairlineWidth","borderColor","colors","border","borderRadius","lg","marginBottom","spacing","minHeight","uni__dependencies","width","height","full","alignItems","justifyContent","backgroundColor","panel","color","faint","fontFamily","mono","fontSize","sm","lineHeight","flexDirection","gap","sans","green"],"sources":["../../src/components/ComputerRow.tsx"],"sourcesContent":["import { useT } from '@agimon-ai/po-core/native';\nimport { Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { MonitorIcon } from '../icons/icons';\nimport { fontOf } from '../lib/fonts';\nimport { Dot } from './Dot';\nimport { ListRow } from './List';\n\nexport type ComputerStatus = 'connected' | 'connecting' | 'disconnected' | 'update_required';\n\nfunction statusLabel(status: ComputerStatus, t: ReturnType<typeof useT>): string {\n switch (status) {\n case 'connected':\n return t('nativeComponents.computerRow.status.connected', 'Connected');\n case 'connecting':\n return t('nativeComponents.computerRow.status.connecting', 'Connecting');\n case 'disconnected':\n return t('nativeComponents.computerRow.status.disconnected', 'Offline');\n case 'update_required':\n return t('nativeComponents.computerRow.status.updateRequired', 'Needs update');\n }\n}\nconst HOME_FOLDER = /^(\\/Users|\\/home)\\/[^/]+(?=\\/|$)/;\n\nexport interface ComputerRowProps {\n name: string;\n /** A folder on that computer, in mono with the home folder shown as `~`. */\n path?: string;\n status: ComputerStatus;\n /** Whether the row can be picked. Defaults to off unless the computer is connected. */\n disabled?: boolean;\n onPress: () => void;\n}\n\n/** One computer to pick in a sheet: its name, an optional folder, and whether it is reachable. */\nexport function ComputerRow({ name, path, status, disabled, onPress }: ComputerRowProps) {\n const connected = status === 'connected';\n const shortPath = path?.replace(HOME_FOLDER, '~');\n const t = useT();\n const label = statusLabel(status, t);\n return (\n <ListRow\n title={name}\n description={\n shortPath ? (\n <Text numberOfLines={1} ellipsizeMode=\"middle\" style={styles.path}>\n {shortPath}\n </Text>\n ) : undefined\n }\n leading={\n <View style={[styles.icon, connected && styles.iconConnected]}>\n <MonitorIcon size={18} color={connected ? 'green' : 'faint'} />\n </View>\n }\n trailing={\n <View style={styles.status}>\n <Dot tone={connected ? 'green' : 'muted'} pulse={status === 'connecting'} />\n <Text style={[styles.statusLabel, connected && styles.statusConnected]}>{label}</Text>\n </View>\n }\n disabled={disabled ?? !connected}\n onPress={onPress}\n accessibilityLabel={`${name}${shortPath ? `, ${shortPath}` : ''}, ${label}`}\n style={styles.card}\n />\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n card: {\n borderWidth: StyleSheet.hairlineWidth,\n borderColor: theme.colors.border,\n borderRadius: theme.borderRadius.lg,\n marginBottom: theme.spacing(2),\n minHeight: 64,\n },\n icon: {\n width: 36,\n height: 36,\n borderRadius: theme.borderRadius.full,\n alignItems: 'center',\n justifyContent: 'center',\n backgroundColor: theme.colors.panel,\n },\n iconConnected: { backgroundColor: theme.colors['tint-green'] },\n path: {\n color: theme.colors.faint,\n fontFamily: fontOf(theme.fontFamily.mono),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n status: { flexDirection: 'row', alignItems: 'center', gap: theme.spacing(1.5) },\n statusLabel: {\n color: theme.colors.faint,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n statusConnected: { color: theme.colors.green },\n}));\n"],"mappings":";;;;;;;;;;;AAWA,SAASO,YAAYC,QAAwBC,GAAoC;CAC/E,QAAQD,QAAR;EACE,KAAK,aACH,OAAOC,EAAE,iDAAiD,WAAW;EACvE,KAAK,cACH,OAAOA,EAAE,kDAAkD,YAAY;EACzE,KAAK,gBACH,OAAOA,EAAE,oDAAoD,SAAS;EACxE,KAAK,mBACH,OAAOA,EAAE,sDAAsD,cAAc;CACjF;AACF;AACA,MAAME,cAAc;;AAapB,SAAgBM,YAAY,EAAEJ,MAAMC,MAAMN,QAAQO,UAAUC,WAA6B;CACvF,MAAME,YAAYV,WAAW;CAC7B,MAAMW,YAAYL,MAAMM,QAAQT,aAAa,GAAG;CAEhD,MAAMU,QAAQd,YAAYC,QADhBR,KACwBS,CAAC;CACnC,OACE,oBAAC,SAAD;EACE,OAAOI;EACP,aACEM,YACE,oBAAC,MAAD;GAAM,eAAe;GAAG,eAAc;GAAS,OAAOG,OAAOR;aAC1DK;EACG,KACJI;EAEN,SACE,oBAAC,MAAD;GAAM,OAAO,CAACD,OAAOE,MAAMN,aAAaI,OAAOG,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B,MAAMqB,WAAWO,IAAI;EACxCL,UAAUvB,MAAMuB,SAASC;EACzBC,YAAYzB,MAAMyB,WAAWD;EAAEb,mBAAA,CAAA,CAAA;CACjC;CACAd,iBAAiB;EAAEsB,OAAOnB,MAAMI,OAAOyB;EAAKlB,mBAAA,CAAA,CAAA;CAAC;AAC/C,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopyButton.d.mts","names":[],"sources":["../../src/components/CopyButton.tsx"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"CopyButton.d.mts","names":[],"sources":["../../src/components/CopyButton.tsx"],"mappings":";;iBAmBiB;;EAEf;;EAEA;EACA,QAAQ,UAAU;;;wBAIJ,aAAa,MAAM,OAAO,SAAS,kCAAe,IAAA"}
|
|
@@ -2,19 +2,22 @@ import { Button } from "./Button.mjs";
|
|
|
2
2
|
import { CheckIcon, CopyIcon } from "../icons/icons.mjs";
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { useT } from "@agimon-ai/po-core/native";
|
|
5
6
|
import { setStringAsync } from "expo-clipboard";
|
|
6
7
|
|
|
7
8
|
//#region src/components/CopyButton.tsx
|
|
8
9
|
/** How long the control stays acknowledged before returning to its icon. */
|
|
9
10
|
const FEEDBACK_MS = 1500;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
11
|
+
function stateLabel(state, t) {
|
|
12
|
+
if (state === "copied") return t("nativeComponents.copyButton.copied", "copied");
|
|
13
|
+
if (state === "failed") return t("nativeComponents.copyButton.failed", "copying failed");
|
|
14
|
+
return t("nativeComponents.copyButton.copy", "copy");
|
|
15
|
+
}
|
|
15
16
|
/** A quiet icon button that copies text and says, briefly, whether it worked. */
|
|
16
17
|
function CopyButton({ text, label, style }) {
|
|
17
18
|
const [state, setState] = useState("idle");
|
|
19
|
+
const t = useT();
|
|
20
|
+
const action = stateLabel(state, t);
|
|
18
21
|
useEffect(() => {
|
|
19
22
|
if (state === "idle") return void 0;
|
|
20
23
|
const timer = setTimeout(() => setState("idle"), FEEDBACK_MS);
|
|
@@ -23,7 +26,10 @@ function CopyButton({ text, label, style }) {
|
|
|
23
26
|
return /* @__PURE__ */ jsx(Button, {
|
|
24
27
|
variant: "ghost",
|
|
25
28
|
size: "icon",
|
|
26
|
-
accessibilityLabel: label === void 0 ?
|
|
29
|
+
accessibilityLabel: label === void 0 ? action : t("nativeComponents.copyButton.withLabel", "{action} {label}", {
|
|
30
|
+
action,
|
|
31
|
+
label
|
|
32
|
+
}),
|
|
27
33
|
onPress: () => {
|
|
28
34
|
setStringAsync(text).then((saved) => setState(saved ? "copied" : "failed"), () => setState("failed"));
|
|
29
35
|
},
|