@kingingwang/pi-windows-arm64 0.85.1 → 0.86.1
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/bin/CHANGELOG.md +110 -0
- package/bin/README.md +3 -1
- package/bin/docs/compaction.md +39 -13
- package/bin/docs/custom-provider.md +22 -13
- package/bin/docs/development.md +4 -4
- package/bin/docs/docs.json +4 -0
- package/bin/docs/environment-variables.md +1 -0
- package/bin/docs/extensions.md +57 -43
- package/bin/docs/json.md +4 -4
- package/bin/docs/models.md +33 -2
- package/bin/docs/providers.md +10 -2
- package/bin/docs/sdk.md +4 -2
- package/bin/docs/security.md +1 -1
- package/bin/docs/session-format.md +82 -40
- package/bin/docs/sessions.md +27 -0
- package/bin/docs/settings.md +56 -1
- package/bin/docs/termux.md +0 -1
- package/bin/docs/tui.md +2 -2
- package/bin/docs/usage.md +1 -0
- package/bin/examples/extensions/README.md +0 -1
- package/bin/examples/extensions/custom-provider-anthropic/index.ts +18 -12
- package/bin/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/bin/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/bin/examples/extensions/custom-provider-gitlab-duo/index.ts +2 -2
- package/bin/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/bin/examples/extensions/gondolin/package-lock.json +2 -2
- package/bin/examples/extensions/gondolin/package.json +1 -1
- package/bin/examples/extensions/prompt-customizer.ts +19 -67
- package/bin/examples/extensions/sandbox/package-lock.json +2 -2
- package/bin/examples/extensions/sandbox/package.json +1 -1
- package/bin/examples/extensions/with-deps/package-lock.json +2 -2
- package/bin/examples/extensions/with-deps/package.json +1 -1
- package/bin/native/win32/prebuilds/win32-arm64/win32-platform.node +0 -0
- package/bin/package.json +17 -23
- package/bin/pi.exe +2 -2
- package/package.json +1 -1
- package/bin/examples/extensions/kimi-deferred-tools.ts +0 -61
- package/bin/native/win32/prebuilds/win32-arm64/win32-console-mode.node +0 -0
- package/bin/node_modules/@mariozechner/clipboard/.yarnrc.yml +0 -1
- package/bin/node_modules/@mariozechner/clipboard/Cargo.toml +0 -45
- package/bin/node_modules/@mariozechner/clipboard/README.md +0 -60
- package/bin/node_modules/@mariozechner/clipboard/build.rs +0 -5
- package/bin/node_modules/@mariozechner/clipboard/clipboard.win32-arm64-msvc.node +0 -0
- package/bin/node_modules/@mariozechner/clipboard/exp.ts +0 -12
- package/bin/node_modules/@mariozechner/clipboard/index.d.ts +0 -37
- package/bin/node_modules/@mariozechner/clipboard/index.js +0 -606
- package/bin/node_modules/@mariozechner/clipboard/package.json +0 -56
- package/bin/node_modules/@mariozechner/clipboard/src/clipboard_rs/common.rs +0 -307
- package/bin/node_modules/@mariozechner/clipboard/src/clipboard_rs/mod.rs +0 -93
- package/bin/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/ios.rs +0 -313
- package/bin/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/macos.rs +0 -471
- package/bin/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/mod.rs +0 -252
- package/bin/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/wayland.rs +0 -431
- package/bin/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/win.rs +0 -712
- package/bin/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/x11.rs +0 -916
- package/bin/node_modules/@mariozechner/clipboard/src/lib.rs +0 -194
|
@@ -1,313 +0,0 @@
|
|
|
1
|
-
use crate::clipboard_rs::{
|
|
2
|
-
common::Result, Clipboard, ClipboardContent, ClipboardHandler, ClipboardWatcher, ContentFormat,
|
|
3
|
-
};
|
|
4
|
-
#[cfg(feature = "image")]
|
|
5
|
-
use crate::clipboard_rs::{common::RustImage, RustImageData};
|
|
6
|
-
use objc2::{rc::Retained, runtime::ProtocolObject};
|
|
7
|
-
use objc2_foundation::{ns_string, NSArray, NSData, NSDictionary, NSString};
|
|
8
|
-
use objc2_ui_kit::UIPasteboard;
|
|
9
|
-
#[cfg(feature = "image")]
|
|
10
|
-
use objc2_ui_kit::{UIImage, UIImagePNGRepresentation};
|
|
11
|
-
use std::{
|
|
12
|
-
sync::mpsc::{self, Receiver, Sender},
|
|
13
|
-
time::Duration,
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
pub struct ClipboardContext {
|
|
17
|
-
clipboard: Retained<UIPasteboard>,
|
|
18
|
-
}
|
|
19
|
-
pub struct ClipboardWatcherContext<T: ClipboardHandler> {
|
|
20
|
-
clipboard: Retained<UIPasteboard>,
|
|
21
|
-
handlers: Vec<T>,
|
|
22
|
-
running: bool,
|
|
23
|
-
stop_signal: Sender<()>,
|
|
24
|
-
stop_receiver: Receiver<()>,
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
impl<T: ClipboardHandler> ClipboardWatcherContext<T> {
|
|
28
|
-
pub fn new() -> Result<Self> {
|
|
29
|
-
let clipboard = unsafe { UIPasteboard::generalPasteboard() };
|
|
30
|
-
let (tx, rx) = mpsc::channel();
|
|
31
|
-
Ok(Self {
|
|
32
|
-
clipboard,
|
|
33
|
-
handlers: Vec::new(),
|
|
34
|
-
running: false,
|
|
35
|
-
stop_signal: tx,
|
|
36
|
-
stop_receiver: rx,
|
|
37
|
-
})
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
unsafe impl<T: ClipboardHandler> Send for ClipboardWatcherContext<T> {}
|
|
42
|
-
|
|
43
|
-
impl<T: ClipboardHandler> ClipboardWatcher<T> for ClipboardWatcherContext<T> {
|
|
44
|
-
fn add_handler(&mut self, handler: T) -> &mut Self {
|
|
45
|
-
self.handlers.push(handler);
|
|
46
|
-
self
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
fn start_watch(&mut self) {
|
|
50
|
-
if self.running {
|
|
51
|
-
println!("already start watch!");
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
if self.handlers.is_empty() {
|
|
55
|
-
println!("no handler, no need to start watch!");
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
self.running = true;
|
|
59
|
-
let mut last_change_count = unsafe { self.clipboard.changeCount() };
|
|
60
|
-
loop {
|
|
61
|
-
// if receive stop signal, break loop
|
|
62
|
-
if self
|
|
63
|
-
.stop_receiver
|
|
64
|
-
.recv_timeout(Duration::from_millis(500))
|
|
65
|
-
.is_ok()
|
|
66
|
-
{
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
let change_count = unsafe { self.clipboard.changeCount() };
|
|
70
|
-
if last_change_count == 0 {
|
|
71
|
-
last_change_count = change_count;
|
|
72
|
-
} else if change_count != last_change_count {
|
|
73
|
-
self
|
|
74
|
-
.handlers
|
|
75
|
-
.iter_mut()
|
|
76
|
-
.for_each(|handler| handler.on_clipboard_change());
|
|
77
|
-
last_change_count = change_count;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
self.running = false;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
fn get_shutdown_channel(&self) -> WatcherShutdown {
|
|
84
|
-
WatcherShutdown {
|
|
85
|
-
stop_signal: self.stop_signal.clone(),
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
pub struct WatcherShutdown {
|
|
91
|
-
stop_signal: Sender<()>,
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
impl Drop for WatcherShutdown {
|
|
95
|
-
fn drop(&mut self) {
|
|
96
|
-
let _ = self.stop_signal.send(());
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
impl ClipboardContext {
|
|
101
|
-
pub fn new() -> Result<Self> {
|
|
102
|
-
let clipboard = unsafe { UIPasteboard::generalPasteboard() };
|
|
103
|
-
Ok(Self { clipboard })
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
fn write_to_clipboard(&self, data: &[ClipboardContent]) -> Result<()> {
|
|
107
|
-
let items = data
|
|
108
|
-
.iter()
|
|
109
|
-
.map(|content| match content {
|
|
110
|
-
ClipboardContent::Text(text) => {
|
|
111
|
-
let ns_text = NSString::from_str(text);
|
|
112
|
-
let pair = unsafe {
|
|
113
|
-
NSDictionary::dictionaryWithObject_forKey(
|
|
114
|
-
ns_text.as_ref(),
|
|
115
|
-
ProtocolObject::from_ref(ns_string!("public.utf8-plain-text")),
|
|
116
|
-
)
|
|
117
|
-
};
|
|
118
|
-
Some(pair)
|
|
119
|
-
}
|
|
120
|
-
ClipboardContent::Rtf(rtf) => {
|
|
121
|
-
let ns_rtf = NSString::from_str(rtf);
|
|
122
|
-
let pair = unsafe {
|
|
123
|
-
NSDictionary::dictionaryWithObject_forKey(
|
|
124
|
-
ns_rtf.as_ref(),
|
|
125
|
-
ProtocolObject::from_ref(ns_string!("public.rtf")),
|
|
126
|
-
)
|
|
127
|
-
};
|
|
128
|
-
Some(pair)
|
|
129
|
-
}
|
|
130
|
-
ClipboardContent::Html(html) => {
|
|
131
|
-
let ns_html = NSString::from_str(html);
|
|
132
|
-
let pair = unsafe {
|
|
133
|
-
NSDictionary::dictionaryWithObject_forKey(
|
|
134
|
-
ns_html.as_ref(),
|
|
135
|
-
ProtocolObject::from_ref(ns_string!("public.html")),
|
|
136
|
-
)
|
|
137
|
-
};
|
|
138
|
-
Some(pair)
|
|
139
|
-
}
|
|
140
|
-
#[cfg(feature = "image")]
|
|
141
|
-
ClipboardContent::Image(image) => {
|
|
142
|
-
let png = image.to_png().unwrap();
|
|
143
|
-
let ns_data = NSData::with_bytes(png.get_bytes());
|
|
144
|
-
let image = unsafe { UIImage::imageWithData(&ns_data) };
|
|
145
|
-
if let Some(image) = image {
|
|
146
|
-
let pair = unsafe {
|
|
147
|
-
NSDictionary::dictionaryWithObject_forKey(
|
|
148
|
-
image.as_ref(),
|
|
149
|
-
ProtocolObject::from_ref(ns_string!("public.png")),
|
|
150
|
-
)
|
|
151
|
-
};
|
|
152
|
-
Some(pair)
|
|
153
|
-
} else {
|
|
154
|
-
None
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
_ => None,
|
|
158
|
-
})
|
|
159
|
-
.filter_map(|item| item)
|
|
160
|
-
.collect::<Vec<_>>();
|
|
161
|
-
unsafe {
|
|
162
|
-
self
|
|
163
|
-
.clipboard
|
|
164
|
-
.setItems(&NSArray::from_retained_slice(&items))
|
|
165
|
-
};
|
|
166
|
-
Ok(())
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
impl Clipboard for ClipboardContext {
|
|
171
|
-
fn available_formats(&self) -> Result<Vec<String>> {
|
|
172
|
-
let formats = unsafe { self.clipboard.pasteboardTypes() };
|
|
173
|
-
Ok(formats.iter().map(|f| f.to_string()).collect())
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
fn has(&self, format: ContentFormat) -> bool {
|
|
177
|
-
match format {
|
|
178
|
-
ContentFormat::Text => unsafe { self.clipboard.hasStrings() },
|
|
179
|
-
#[cfg(feature = "image")]
|
|
180
|
-
ContentFormat::Image => unsafe { self.clipboard.hasImages() },
|
|
181
|
-
ContentFormat::Rtf => unsafe {
|
|
182
|
-
self
|
|
183
|
-
.clipboard
|
|
184
|
-
.containsPasteboardTypes(&NSArray::from_slice(&[ns_string!("public.rtf")]))
|
|
185
|
-
},
|
|
186
|
-
ContentFormat::Html => unsafe {
|
|
187
|
-
self
|
|
188
|
-
.clipboard
|
|
189
|
-
.containsPasteboardTypes(&NSArray::from_slice(&[ns_string!("public.html")]))
|
|
190
|
-
},
|
|
191
|
-
ContentFormat::Files => false,
|
|
192
|
-
ContentFormat::Other(format) => unsafe {
|
|
193
|
-
self
|
|
194
|
-
.clipboard
|
|
195
|
-
.containsPasteboardTypes(&NSArray::from_retained_slice(&[NSString::from_str(
|
|
196
|
-
&format,
|
|
197
|
-
)]))
|
|
198
|
-
},
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
fn clear(&self) -> Result<()> {
|
|
203
|
-
unsafe { self.clipboard.setItems(&NSArray::from_slice(&[])) };
|
|
204
|
-
Ok(())
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
fn get_buffer(&self, format: &str) -> Result<Vec<u8>> {
|
|
208
|
-
let ns_format = NSString::from_str(format);
|
|
209
|
-
let data = unsafe { self.clipboard.dataForPasteboardType(&ns_format) };
|
|
210
|
-
if let Some(data) = data {
|
|
211
|
-
Ok(data.to_vec())
|
|
212
|
-
} else {
|
|
213
|
-
Err("No data found".into())
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
fn get_text(&self) -> Result<String> {
|
|
218
|
-
let text = unsafe { self.clipboard.string() };
|
|
219
|
-
if let Some(text) = text {
|
|
220
|
-
Ok(text.to_string())
|
|
221
|
-
} else {
|
|
222
|
-
Err("No text found".into())
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
fn get_rich_text(&self) -> Result<String> {
|
|
227
|
-
let buffer = self.get_buffer("public.rtf")?;
|
|
228
|
-
Ok(String::from_utf8_lossy(&buffer).to_string())
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
fn get_html(&self) -> Result<String> {
|
|
232
|
-
let buffer = self.get_buffer("public.html")?;
|
|
233
|
-
Ok(String::from_utf8_lossy(&buffer).to_string())
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
#[cfg(feature = "image")]
|
|
237
|
-
fn get_image(&self) -> Result<RustImageData> {
|
|
238
|
-
let image = unsafe { self.clipboard.image() };
|
|
239
|
-
if let Some(image) = image {
|
|
240
|
-
let data = unsafe { UIImagePNGRepresentation(&image) };
|
|
241
|
-
if let Some(data) = data {
|
|
242
|
-
let bytes = unsafe { data.as_bytes_unchecked() };
|
|
243
|
-
Ok(RustImageData::from_bytes(bytes)?)
|
|
244
|
-
} else {
|
|
245
|
-
Err("No image data found".into())
|
|
246
|
-
}
|
|
247
|
-
} else {
|
|
248
|
-
Err("No image found".into())
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
fn get_files(&self) -> Result<Vec<String>> {
|
|
253
|
-
Err("Not supported".into())
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
fn get(&self, _formats: &[ContentFormat]) -> Result<Vec<ClipboardContent>> {
|
|
257
|
-
Err("Not supported".into())
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
fn set_buffer(&self, format: &str, buffer: Vec<u8>) -> Result<()> {
|
|
261
|
-
let ns_format = NSString::from_str(format);
|
|
262
|
-
let ns_data = NSData::with_bytes(&buffer);
|
|
263
|
-
unsafe {
|
|
264
|
-
self
|
|
265
|
-
.clipboard
|
|
266
|
-
.setData_forPasteboardType(&ns_data, &ns_format)
|
|
267
|
-
}
|
|
268
|
-
Ok(())
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
fn set_text(&self, text: String) -> Result<()> {
|
|
272
|
-
unsafe {
|
|
273
|
-
self
|
|
274
|
-
.clipboard
|
|
275
|
-
.setString(Some(&NSString::from_str(text.as_str())))
|
|
276
|
-
};
|
|
277
|
-
Ok(())
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
fn set_rich_text(&self, _text: String) -> Result<()> {
|
|
281
|
-
Err("Not supported".into())
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
fn set_html(&self, _html: String) -> Result<()> {
|
|
285
|
-
Err("Not supported".into())
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
#[cfg(feature = "image")]
|
|
289
|
-
fn set_image(&self, image: RustImageData) -> Result<()> {
|
|
290
|
-
if image.is_empty() {
|
|
291
|
-
Err("Image is empty".into())
|
|
292
|
-
} else {
|
|
293
|
-
let png = image.to_png()?;
|
|
294
|
-
let ns_data = NSData::with_bytes(png.get_bytes());
|
|
295
|
-
let image = unsafe { UIImage::imageWithData(&ns_data) };
|
|
296
|
-
if let Some(image) = image {
|
|
297
|
-
unsafe { self.clipboard.setImage(Some(&image)) };
|
|
298
|
-
Ok(())
|
|
299
|
-
} else {
|
|
300
|
-
Err("Failed to create image".into())
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
fn set_files(&self, _files: Vec<String>) -> Result<()> {
|
|
306
|
-
Err("Not supported".into())
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
fn set(&self, contents: Vec<ClipboardContent>) -> Result<()> {
|
|
310
|
-
self.write_to_clipboard(&contents)?;
|
|
311
|
-
Ok(())
|
|
312
|
-
}
|
|
313
|
-
}
|