@crosscopy/clipboard 0.1.10 → 0.2.5
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/.yarnrc.yml +1 -0
- package/Cargo.toml +24 -0
- package/README.md +46 -94
- package/build.rs +5 -0
- package/exp.ts +12 -0
- package/index.d.ts +23 -0
- package/index.js +317 -0
- package/package.json +44 -37
- package/src/lib.rs +192 -0
- package/dist/demo.d.ts +0 -1
- package/dist/demo.js +0 -244
- package/dist/demo.js.map +0 -1
- package/dist/demo.mjs +0 -234
- package/dist/demo.mjs.map +0 -1
- package/dist/index.d.ts +0 -34
- package/dist/index.js +0 -184
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -171
- package/dist/index.mjs.map +0 -1
- package/go-clipboard/binaries/go-clipboard-darwin-arm64 +0 -0
- package/go-clipboard/binaries/go-clipboard-darwin-x64 +0 -0
- package/go-clipboard/binaries/go-clipboard-linux-arm +0 -0
- package/go-clipboard/binaries/go-clipboard-linux-x64 +0 -0
- package/go-clipboard/binaries/go-clipboard-win32-x64.exe +0 -0
- package/go-clipboard/scripts/win/read_image.ps1 +0 -23
- package/go-clipboard/scripts/win/read_text.ps1 +0 -1
- package/go-clipboard/scripts/win/write_image.ps1 +0 -15
- package/go-clipboard/scripts/win/write_text.ps1 +0 -7
package/.yarnrc.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
nodeLinker: node-modules
|
package/Cargo.toml
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
edition = "2021"
|
|
3
|
+
name = "crosscopy_clipboard"
|
|
4
|
+
version = "0.0.0"
|
|
5
|
+
|
|
6
|
+
[lib]
|
|
7
|
+
crate-type = ["cdylib"]
|
|
8
|
+
|
|
9
|
+
[dependencies]
|
|
10
|
+
base64 = "0.22.0"
|
|
11
|
+
clipboard-rs = "0.1.4"
|
|
12
|
+
futures = "0.3.30"
|
|
13
|
+
# Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix
|
|
14
|
+
napi = { version = "2.12.2", default-features = false, features = ["napi4", "tokio_rt"] }
|
|
15
|
+
napi-derive = "2.12.2"
|
|
16
|
+
tokio = "1.36.0"
|
|
17
|
+
|
|
18
|
+
[build-dependencies]
|
|
19
|
+
napi-build = "2.0.1"
|
|
20
|
+
|
|
21
|
+
[profile.release]
|
|
22
|
+
lto = true
|
|
23
|
+
strip = "symbols"
|
|
24
|
+
|
package/README.md
CHANGED
|
@@ -1,94 +1,46 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
clipboard.on("image", (data) => {
|
|
48
|
-
fs.writeFileSync("test.png", data);
|
|
49
|
-
});
|
|
50
|
-
clipboard.listen();
|
|
51
|
-
setTimeout(() => {
|
|
52
|
-
clipboard.close();
|
|
53
|
-
}, 10000);
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
## Explanation
|
|
57
|
-
|
|
58
|
-
It's achieved using child process + `stdout`.
|
|
59
|
-
|
|
60
|
-
I took a golang version of the listener from [golang-design/clipboard](https://github.com/golang-design/clipboard).
|
|
61
|
-
|
|
62
|
-
When a change is detected, `IMAGE_CHANGED` or `TEXT_CHANGED` is printed to `stdout`.
|
|
63
|
-
|
|
64
|
-
This library runs compiled go-version clipboard listener using child process and listen to the `stdout`.
|
|
65
|
-
|
|
66
|
-
If it sees the keywords in child process's `stdout`, an event will be emitted.
|
|
67
|
-
|
|
68
|
-
Run `npm run demo` to see a demo for 10 sec. Once started, copy some text and screenshot and check the terminal.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
## Supported Platforms
|
|
72
|
-
|
|
73
|
-
Format: `process.platform/process.arch`
|
|
74
|
-
|
|
75
|
-
The process here is from nodejs.
|
|
76
|
-
|
|
77
|
-
Supported platforms can be found in `go-clipboard/binaries`.
|
|
78
|
-
|
|
79
|
-
If your nodejs gives different platform or arch, it may not work.
|
|
80
|
-
|
|
81
|
-
## Release
|
|
82
|
-
|
|
83
|
-
Cross Compile doesn't work due to some CGO problem. Have to build on different platforms manually.
|
|
84
|
-
|
|
85
|
-
Within `go-clipboard` folder.
|
|
86
|
-
|
|
87
|
-
```bash
|
|
88
|
-
go build -o binaries/go-clipboard-darwin-arm64
|
|
89
|
-
go build -o binaries/go-clipboard-darwin-x64
|
|
90
|
-
go build -o binaries/go-clipboard-win32-x64.exe
|
|
91
|
-
go build -o binaries/go-clipboard-linux-x64
|
|
92
|
-
go build -o binaries/go-clipboard-linux-arm
|
|
93
|
-
go build -o binaries/go-clipboard-linux-arm64
|
|
94
|
-
```
|
|
1
|
+
# Clipboard
|
|
2
|
+
|
|
3
|
+
npm package: https://www.npmjs.com/package/@crosscopy/clipboard
|
|
4
|
+
GitHub: https://github.com/crosscopy/clipboard
|
|
5
|
+
|
|
6
|
+
> This is a clipboard API npm package that allows you to copy and paste data to and from the clipboard.
|
|
7
|
+
> There doesn't seem to be a good clipboard package for node.js (that supports data format beyond text), so I decided to make one.
|
|
8
|
+
> Data Format Supported
|
|
9
|
+
>
|
|
10
|
+
> - Text
|
|
11
|
+
> - Image
|
|
12
|
+
> - Rich Text Format
|
|
13
|
+
> - Files
|
|
14
|
+
> - HTML
|
|
15
|
+
|
|
16
|
+
## Acknowledgements
|
|
17
|
+
|
|
18
|
+
- [ChurchTao/clipboard-rs](https://github.com/ChurchTao/clipboard-rs) is written in rust, which is used to provide the native clipboard support for this package across Linux, Windows and MacOS. This package is basically a wrapper around this rust package.
|
|
19
|
+
- https://crates.io/crates/clipboard-rs
|
|
20
|
+
- [napi.rs](https://napi.rs/) was used to create the node.js addon for this package, so that API calls written in rust can be called from node.js.
|
|
21
|
+
|
|
22
|
+
## API
|
|
23
|
+
|
|
24
|
+
Detailed API function declarations can be found in the [index.d.ts](./index.d.ts).
|
|
25
|
+
|
|
26
|
+
Or you can refer to the source code in [src/lib.rs](./src/lib.rs).
|
|
27
|
+
|
|
28
|
+
## Sample
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
import Clipboard from "@crosscopy/clipboard";
|
|
32
|
+
|
|
33
|
+
console.log(await Clipboard.getText());
|
|
34
|
+
|
|
35
|
+
console.log(await Clipboard.getHtml());
|
|
36
|
+
|
|
37
|
+
if (await Clipboard.hasImage()) {
|
|
38
|
+
console.log(await Clipboard.getImageBase64());
|
|
39
|
+
} else {
|
|
40
|
+
console.log("No Image");
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Plan
|
|
45
|
+
|
|
46
|
+
A clipboard listener will be added soon for monitoring clipboard changes and get notified when the clipboard content changes.
|
package/build.rs
ADDED
package/exp.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Clipboard from "./index.js";
|
|
2
|
+
|
|
3
|
+
console.log(await Clipboard.getText());
|
|
4
|
+
|
|
5
|
+
console.log(await Clipboard.getHtml());
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
if (await Clipboard.hasImage()) {
|
|
9
|
+
console.log(await Clipboard.getImageBase64());
|
|
10
|
+
} else {
|
|
11
|
+
console.log("No Image");
|
|
12
|
+
}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/* auto-generated by NAPI-RS */
|
|
5
|
+
|
|
6
|
+
export function availableFormats(): Array<string>
|
|
7
|
+
export function getText(): Promise<string>
|
|
8
|
+
export function setText(text: string): Promise<void>
|
|
9
|
+
export function hasText(): boolean
|
|
10
|
+
export function getImageBinary(): Promise<Array<number>>
|
|
11
|
+
export function getImageBase64(): Promise<string>
|
|
12
|
+
export function setImageBinary(imageBytes: Array<number>): Promise<void>
|
|
13
|
+
export function setImageBase64(base64Str: string): Promise<void>
|
|
14
|
+
export function hasImage(): boolean
|
|
15
|
+
export function getHtml(): Promise<string>
|
|
16
|
+
export function setHtml(html: string): Promise<void>
|
|
17
|
+
export function hasHtml(): boolean
|
|
18
|
+
export function getRtf(): Promise<string>
|
|
19
|
+
export function setRtf(rtf: string): Promise<void>
|
|
20
|
+
export function hasRtf(): boolean
|
|
21
|
+
export function clear(): Promise<void>
|
|
22
|
+
export function watch(): void
|
|
23
|
+
export function callThreadsafeFunction(callback: (...args: any[]) => any): void
|
package/index.js
ADDED
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/* prettier-ignore */
|
|
4
|
+
|
|
5
|
+
/* auto-generated by NAPI-RS */
|
|
6
|
+
|
|
7
|
+
const { existsSync, readFileSync } = require('fs')
|
|
8
|
+
const { join } = require('path')
|
|
9
|
+
|
|
10
|
+
const { platform, arch } = process
|
|
11
|
+
|
|
12
|
+
let nativeBinding = null
|
|
13
|
+
let localFileExisted = false
|
|
14
|
+
let loadError = null
|
|
15
|
+
|
|
16
|
+
function isMusl() {
|
|
17
|
+
// For Node 10
|
|
18
|
+
if (!process.report || typeof process.report.getReport !== 'function') {
|
|
19
|
+
try {
|
|
20
|
+
const lddPath = require('child_process').execSync('which ldd').toString().trim()
|
|
21
|
+
return readFileSync(lddPath, 'utf8').includes('musl')
|
|
22
|
+
} catch (e) {
|
|
23
|
+
return true
|
|
24
|
+
}
|
|
25
|
+
} else {
|
|
26
|
+
const { glibcVersionRuntime } = process.report.getReport().header
|
|
27
|
+
return !glibcVersionRuntime
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
switch (platform) {
|
|
32
|
+
case 'android':
|
|
33
|
+
switch (arch) {
|
|
34
|
+
case 'arm64':
|
|
35
|
+
localFileExisted = existsSync(join(__dirname, 'clipboard.android-arm64.node'))
|
|
36
|
+
try {
|
|
37
|
+
if (localFileExisted) {
|
|
38
|
+
nativeBinding = require('./clipboard.android-arm64.node')
|
|
39
|
+
} else {
|
|
40
|
+
nativeBinding = require('@crosscopy/clipboard-android-arm64')
|
|
41
|
+
}
|
|
42
|
+
} catch (e) {
|
|
43
|
+
loadError = e
|
|
44
|
+
}
|
|
45
|
+
break
|
|
46
|
+
case 'arm':
|
|
47
|
+
localFileExisted = existsSync(join(__dirname, 'clipboard.android-arm-eabi.node'))
|
|
48
|
+
try {
|
|
49
|
+
if (localFileExisted) {
|
|
50
|
+
nativeBinding = require('./clipboard.android-arm-eabi.node')
|
|
51
|
+
} else {
|
|
52
|
+
nativeBinding = require('@crosscopy/clipboard-android-arm-eabi')
|
|
53
|
+
}
|
|
54
|
+
} catch (e) {
|
|
55
|
+
loadError = e
|
|
56
|
+
}
|
|
57
|
+
break
|
|
58
|
+
default:
|
|
59
|
+
throw new Error(`Unsupported architecture on Android ${arch}`)
|
|
60
|
+
}
|
|
61
|
+
break
|
|
62
|
+
case 'win32':
|
|
63
|
+
switch (arch) {
|
|
64
|
+
case 'x64':
|
|
65
|
+
localFileExisted = existsSync(
|
|
66
|
+
join(__dirname, 'clipboard.win32-x64-msvc.node')
|
|
67
|
+
)
|
|
68
|
+
try {
|
|
69
|
+
if (localFileExisted) {
|
|
70
|
+
nativeBinding = require('./clipboard.win32-x64-msvc.node')
|
|
71
|
+
} else {
|
|
72
|
+
nativeBinding = require('@crosscopy/clipboard-win32-x64-msvc')
|
|
73
|
+
}
|
|
74
|
+
} catch (e) {
|
|
75
|
+
loadError = e
|
|
76
|
+
}
|
|
77
|
+
break
|
|
78
|
+
case 'ia32':
|
|
79
|
+
localFileExisted = existsSync(
|
|
80
|
+
join(__dirname, 'clipboard.win32-ia32-msvc.node')
|
|
81
|
+
)
|
|
82
|
+
try {
|
|
83
|
+
if (localFileExisted) {
|
|
84
|
+
nativeBinding = require('./clipboard.win32-ia32-msvc.node')
|
|
85
|
+
} else {
|
|
86
|
+
nativeBinding = require('@crosscopy/clipboard-win32-ia32-msvc')
|
|
87
|
+
}
|
|
88
|
+
} catch (e) {
|
|
89
|
+
loadError = e
|
|
90
|
+
}
|
|
91
|
+
break
|
|
92
|
+
case 'arm64':
|
|
93
|
+
localFileExisted = existsSync(
|
|
94
|
+
join(__dirname, 'clipboard.win32-arm64-msvc.node')
|
|
95
|
+
)
|
|
96
|
+
try {
|
|
97
|
+
if (localFileExisted) {
|
|
98
|
+
nativeBinding = require('./clipboard.win32-arm64-msvc.node')
|
|
99
|
+
} else {
|
|
100
|
+
nativeBinding = require('@crosscopy/clipboard-win32-arm64-msvc')
|
|
101
|
+
}
|
|
102
|
+
} catch (e) {
|
|
103
|
+
loadError = e
|
|
104
|
+
}
|
|
105
|
+
break
|
|
106
|
+
default:
|
|
107
|
+
throw new Error(`Unsupported architecture on Windows: ${arch}`)
|
|
108
|
+
}
|
|
109
|
+
break
|
|
110
|
+
case 'darwin':
|
|
111
|
+
localFileExisted = existsSync(join(__dirname, 'clipboard.darwin-universal.node'))
|
|
112
|
+
try {
|
|
113
|
+
if (localFileExisted) {
|
|
114
|
+
nativeBinding = require('./clipboard.darwin-universal.node')
|
|
115
|
+
} else {
|
|
116
|
+
nativeBinding = require('@crosscopy/clipboard-darwin-universal')
|
|
117
|
+
}
|
|
118
|
+
break
|
|
119
|
+
} catch {}
|
|
120
|
+
switch (arch) {
|
|
121
|
+
case 'x64':
|
|
122
|
+
localFileExisted = existsSync(join(__dirname, 'clipboard.darwin-x64.node'))
|
|
123
|
+
try {
|
|
124
|
+
if (localFileExisted) {
|
|
125
|
+
nativeBinding = require('./clipboard.darwin-x64.node')
|
|
126
|
+
} else {
|
|
127
|
+
nativeBinding = require('@crosscopy/clipboard-darwin-x64')
|
|
128
|
+
}
|
|
129
|
+
} catch (e) {
|
|
130
|
+
loadError = e
|
|
131
|
+
}
|
|
132
|
+
break
|
|
133
|
+
case 'arm64':
|
|
134
|
+
localFileExisted = existsSync(
|
|
135
|
+
join(__dirname, 'clipboard.darwin-arm64.node')
|
|
136
|
+
)
|
|
137
|
+
try {
|
|
138
|
+
if (localFileExisted) {
|
|
139
|
+
nativeBinding = require('./clipboard.darwin-arm64.node')
|
|
140
|
+
} else {
|
|
141
|
+
nativeBinding = require('@crosscopy/clipboard-darwin-arm64')
|
|
142
|
+
}
|
|
143
|
+
} catch (e) {
|
|
144
|
+
loadError = e
|
|
145
|
+
}
|
|
146
|
+
break
|
|
147
|
+
default:
|
|
148
|
+
throw new Error(`Unsupported architecture on macOS: ${arch}`)
|
|
149
|
+
}
|
|
150
|
+
break
|
|
151
|
+
case 'freebsd':
|
|
152
|
+
if (arch !== 'x64') {
|
|
153
|
+
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
|
|
154
|
+
}
|
|
155
|
+
localFileExisted = existsSync(join(__dirname, 'clipboard.freebsd-x64.node'))
|
|
156
|
+
try {
|
|
157
|
+
if (localFileExisted) {
|
|
158
|
+
nativeBinding = require('./clipboard.freebsd-x64.node')
|
|
159
|
+
} else {
|
|
160
|
+
nativeBinding = require('@crosscopy/clipboard-freebsd-x64')
|
|
161
|
+
}
|
|
162
|
+
} catch (e) {
|
|
163
|
+
loadError = e
|
|
164
|
+
}
|
|
165
|
+
break
|
|
166
|
+
case 'linux':
|
|
167
|
+
switch (arch) {
|
|
168
|
+
case 'x64':
|
|
169
|
+
if (isMusl()) {
|
|
170
|
+
localFileExisted = existsSync(
|
|
171
|
+
join(__dirname, 'clipboard.linux-x64-musl.node')
|
|
172
|
+
)
|
|
173
|
+
try {
|
|
174
|
+
if (localFileExisted) {
|
|
175
|
+
nativeBinding = require('./clipboard.linux-x64-musl.node')
|
|
176
|
+
} else {
|
|
177
|
+
nativeBinding = require('@crosscopy/clipboard-linux-x64-musl')
|
|
178
|
+
}
|
|
179
|
+
} catch (e) {
|
|
180
|
+
loadError = e
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
localFileExisted = existsSync(
|
|
184
|
+
join(__dirname, 'clipboard.linux-x64-gnu.node')
|
|
185
|
+
)
|
|
186
|
+
try {
|
|
187
|
+
if (localFileExisted) {
|
|
188
|
+
nativeBinding = require('./clipboard.linux-x64-gnu.node')
|
|
189
|
+
} else {
|
|
190
|
+
nativeBinding = require('@crosscopy/clipboard-linux-x64-gnu')
|
|
191
|
+
}
|
|
192
|
+
} catch (e) {
|
|
193
|
+
loadError = e
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
break
|
|
197
|
+
case 'arm64':
|
|
198
|
+
if (isMusl()) {
|
|
199
|
+
localFileExisted = existsSync(
|
|
200
|
+
join(__dirname, 'clipboard.linux-arm64-musl.node')
|
|
201
|
+
)
|
|
202
|
+
try {
|
|
203
|
+
if (localFileExisted) {
|
|
204
|
+
nativeBinding = require('./clipboard.linux-arm64-musl.node')
|
|
205
|
+
} else {
|
|
206
|
+
nativeBinding = require('@crosscopy/clipboard-linux-arm64-musl')
|
|
207
|
+
}
|
|
208
|
+
} catch (e) {
|
|
209
|
+
loadError = e
|
|
210
|
+
}
|
|
211
|
+
} else {
|
|
212
|
+
localFileExisted = existsSync(
|
|
213
|
+
join(__dirname, 'clipboard.linux-arm64-gnu.node')
|
|
214
|
+
)
|
|
215
|
+
try {
|
|
216
|
+
if (localFileExisted) {
|
|
217
|
+
nativeBinding = require('./clipboard.linux-arm64-gnu.node')
|
|
218
|
+
} else {
|
|
219
|
+
nativeBinding = require('@crosscopy/clipboard-linux-arm64-gnu')
|
|
220
|
+
}
|
|
221
|
+
} catch (e) {
|
|
222
|
+
loadError = e
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
break
|
|
226
|
+
case 'arm':
|
|
227
|
+
localFileExisted = existsSync(
|
|
228
|
+
join(__dirname, 'clipboard.linux-arm-gnueabihf.node')
|
|
229
|
+
)
|
|
230
|
+
try {
|
|
231
|
+
if (localFileExisted) {
|
|
232
|
+
nativeBinding = require('./clipboard.linux-arm-gnueabihf.node')
|
|
233
|
+
} else {
|
|
234
|
+
nativeBinding = require('@crosscopy/clipboard-linux-arm-gnueabihf')
|
|
235
|
+
}
|
|
236
|
+
} catch (e) {
|
|
237
|
+
loadError = e
|
|
238
|
+
}
|
|
239
|
+
break
|
|
240
|
+
case 'riscv64':
|
|
241
|
+
if (isMusl()) {
|
|
242
|
+
localFileExisted = existsSync(
|
|
243
|
+
join(__dirname, 'clipboard.linux-riscv64-musl.node')
|
|
244
|
+
)
|
|
245
|
+
try {
|
|
246
|
+
if (localFileExisted) {
|
|
247
|
+
nativeBinding = require('./clipboard.linux-riscv64-musl.node')
|
|
248
|
+
} else {
|
|
249
|
+
nativeBinding = require('@crosscopy/clipboard-linux-riscv64-musl')
|
|
250
|
+
}
|
|
251
|
+
} catch (e) {
|
|
252
|
+
loadError = e
|
|
253
|
+
}
|
|
254
|
+
} else {
|
|
255
|
+
localFileExisted = existsSync(
|
|
256
|
+
join(__dirname, 'clipboard.linux-riscv64-gnu.node')
|
|
257
|
+
)
|
|
258
|
+
try {
|
|
259
|
+
if (localFileExisted) {
|
|
260
|
+
nativeBinding = require('./clipboard.linux-riscv64-gnu.node')
|
|
261
|
+
} else {
|
|
262
|
+
nativeBinding = require('@crosscopy/clipboard-linux-riscv64-gnu')
|
|
263
|
+
}
|
|
264
|
+
} catch (e) {
|
|
265
|
+
loadError = e
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
break
|
|
269
|
+
case 's390x':
|
|
270
|
+
localFileExisted = existsSync(
|
|
271
|
+
join(__dirname, 'clipboard.linux-s390x-gnu.node')
|
|
272
|
+
)
|
|
273
|
+
try {
|
|
274
|
+
if (localFileExisted) {
|
|
275
|
+
nativeBinding = require('./clipboard.linux-s390x-gnu.node')
|
|
276
|
+
} else {
|
|
277
|
+
nativeBinding = require('@crosscopy/clipboard-linux-s390x-gnu')
|
|
278
|
+
}
|
|
279
|
+
} catch (e) {
|
|
280
|
+
loadError = e
|
|
281
|
+
}
|
|
282
|
+
break
|
|
283
|
+
default:
|
|
284
|
+
throw new Error(`Unsupported architecture on Linux: ${arch}`)
|
|
285
|
+
}
|
|
286
|
+
break
|
|
287
|
+
default:
|
|
288
|
+
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
if (!nativeBinding) {
|
|
292
|
+
if (loadError) {
|
|
293
|
+
throw loadError
|
|
294
|
+
}
|
|
295
|
+
throw new Error(`Failed to load native binding`)
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const { availableFormats, getText, setText, hasText, getImageBinary, getImageBase64, setImageBinary, setImageBase64, hasImage, getHtml, setHtml, hasHtml, getRtf, setRtf, hasRtf, clear, watch, callThreadsafeFunction } = nativeBinding
|
|
299
|
+
|
|
300
|
+
module.exports.availableFormats = availableFormats
|
|
301
|
+
module.exports.getText = getText
|
|
302
|
+
module.exports.setText = setText
|
|
303
|
+
module.exports.hasText = hasText
|
|
304
|
+
module.exports.getImageBinary = getImageBinary
|
|
305
|
+
module.exports.getImageBase64 = getImageBase64
|
|
306
|
+
module.exports.setImageBinary = setImageBinary
|
|
307
|
+
module.exports.setImageBase64 = setImageBase64
|
|
308
|
+
module.exports.hasImage = hasImage
|
|
309
|
+
module.exports.getHtml = getHtml
|
|
310
|
+
module.exports.setHtml = setHtml
|
|
311
|
+
module.exports.hasHtml = hasHtml
|
|
312
|
+
module.exports.getRtf = getRtf
|
|
313
|
+
module.exports.setRtf = setRtf
|
|
314
|
+
module.exports.hasRtf = hasRtf
|
|
315
|
+
module.exports.clear = clear
|
|
316
|
+
module.exports.watch = watch
|
|
317
|
+
module.exports.callThreadsafeFunction = callThreadsafeFunction
|
package/package.json
CHANGED
|
@@ -1,45 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crosscopy/clipboard",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
"version": "0.2.5",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"types": "index.d.ts",
|
|
6
|
+
"napi": {
|
|
7
|
+
"name": "clipboard",
|
|
8
|
+
"triples": {
|
|
9
|
+
"additional": [
|
|
10
|
+
"aarch64-apple-darwin",
|
|
11
|
+
"aarch64-unknown-linux-gnu",
|
|
12
|
+
"aarch64-pc-windows-msvc",
|
|
13
|
+
"universal-apple-darwin",
|
|
14
|
+
"riscv64gc-unknown-linux-gnu"
|
|
15
|
+
]
|
|
16
|
+
}
|
|
14
17
|
},
|
|
18
|
+
"license": "MIT",
|
|
15
19
|
"repository": {
|
|
16
20
|
"type": "git",
|
|
17
|
-
"url": "
|
|
18
|
-
},
|
|
19
|
-
"keywords": [
|
|
20
|
-
"clipboard"
|
|
21
|
-
],
|
|
22
|
-
"author": "Huakun Shen",
|
|
23
|
-
"license": "ISC",
|
|
24
|
-
"bugs": {
|
|
25
|
-
"url": "https://github.com/CrossCopy/clipboard/issues"
|
|
21
|
+
"url": "https://github.com/CrossCopy/clipboard.git"
|
|
26
22
|
},
|
|
27
|
-
"homepage": "https://github.com/CrossCopy/clipboard#readme",
|
|
28
|
-
"dependencies": {},
|
|
29
23
|
"devDependencies": {
|
|
30
|
-
"@
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"
|
|
24
|
+
"@napi-rs/cli": "^2.18.0",
|
|
25
|
+
"ava": "^6.0.1"
|
|
26
|
+
},
|
|
27
|
+
"ava": {
|
|
28
|
+
"timeout": "3m"
|
|
29
|
+
},
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">= 10"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"artifacts": "napi artifacts",
|
|
35
|
+
"build": "napi build --platform --release",
|
|
36
|
+
"build:debug": "napi build --platform",
|
|
37
|
+
"prepublishOnly": "napi prepublish -t npm",
|
|
38
|
+
"test": "ava",
|
|
39
|
+
"universal": "napi universal",
|
|
40
|
+
"version": "napi version"
|
|
38
41
|
},
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
"optionalDependencies": {
|
|
43
|
+
"@crosscopy/clipboard-win32-x64-msvc": "0.2.5",
|
|
44
|
+
"@crosscopy/clipboard-darwin-x64": "0.2.5",
|
|
45
|
+
"@crosscopy/clipboard-linux-x64-gnu": "0.2.5",
|
|
46
|
+
"@crosscopy/clipboard-darwin-arm64": "0.2.5",
|
|
47
|
+
"@crosscopy/clipboard-linux-arm64-gnu": "0.2.5",
|
|
48
|
+
"@crosscopy/clipboard-win32-arm64-msvc": "0.2.5",
|
|
49
|
+
"@crosscopy/clipboard-darwin-universal": "0.2.5",
|
|
50
|
+
"@crosscopy/clipboard-linux-riscv64-gnu": "0.2.5"
|
|
51
|
+
}
|
|
52
|
+
}
|