Skip to content

Commit adf7180

Browse files
committed
add clipboard apis
1 parent 9be955a commit adf7180

File tree

6 files changed

+77
-5
lines changed

6 files changed

+77
-5
lines changed

.github/workflows/publish.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,25 @@ jobs:
3333
- name: Build packages
3434
run: yarn build
3535

36-
- name: Publish package
36+
- name: Check if beta version
37+
id: check_beta
38+
run: |
39+
if [[ "$VERSION" == *"beta"* ]]; then
40+
echo "IS_BETA=true" >> $GITHUB_ENV
41+
echo "Publishing as beta version"
42+
else
43+
echo "IS_BETA=false" >> $GITHUB_ENV
44+
echo "Publishing as stable version"
45+
fi
46+
47+
- name: Publish package (beta)
48+
if: env.IS_BETA == 'true'
49+
run: yarn publish --access public --non-interactive --tag beta
50+
env:
51+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
52+
53+
- name: Publish package (stable)
54+
if: env.IS_BETA == 'false'
3755
run: yarn publish --access public --non-interactive
3856
env:
3957
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@beekeeperstudio/plugin",
3-
"version": "1.2.2",
3+
"version": "1.3.0",
44
"description": "A simple TypeScript wrapper to send messages from your Beekeeper Studio plugin to the main app.",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/index.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,26 @@ export async function setEncryptedData<T>(keyOrValue: string | T, value?: T): Pr
115115
}
116116
}
117117

118+
/** Clipboard interface. */
119+
export const clipboard = {
120+
/** Write text to the Electron clipboard. */
121+
async writeText(text: string): Promise<void> {
122+
await request({
123+
name: "clipboard.writeText",
124+
args: { text },
125+
});
126+
},
127+
/** Read text from the Electron clipboard. */
128+
async readText(): Promise<string> {
129+
return await request({
130+
name: "clipboard.readText",
131+
args: void 0,
132+
});
133+
},
134+
// async write() {},
135+
// async read() {},
136+
};
137+
118138
export * from "./commonTypes";
119139
export * from "./requestTypes";
120140
export * from "./responseTypes";

src/notificationTypes.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ export interface WindowEventNotification {
1818
};
1919
}
2020

21+
export interface PluginErrorNotification {
22+
name: "pluginError";
23+
args: {
24+
name?: string;
25+
message?: string;
26+
stack?: string;
27+
};
28+
}
29+
2130
export type PluginNotificationData =
2231
| ThemeChangedNotification
23-
| WindowEventNotification;
32+
| WindowEventNotification
33+
| PluginErrorNotification;

src/requestTypes.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,18 @@ export interface SetEncryptedDataRequest<T extends unknown> extends BaseRequest
9999
};
100100
}
101101

102+
export interface ClipboardWriteTextRequest extends BaseRequest {
103+
name: "clipboard.writeText";
104+
args: {
105+
text: string;
106+
};
107+
}
108+
109+
export interface ClipboardReadTextRequest extends BaseRequest {
110+
name: "clipboard.readText";
111+
args: void;
112+
}
113+
102114
export type PluginRequestData =
103115
| GetTablesRequest
104116
| GetColumnsRequest
@@ -113,6 +125,8 @@ export type PluginRequestData =
113125
| GetDataRequest
114126
| SetDataRequest<unknown>
115127
| GetEncryptedDataRequest
116-
| SetEncryptedDataRequest<unknown>;
128+
| SetEncryptedDataRequest<unknown>
129+
| ClipboardWriteTextRequest
130+
| ClipboardReadTextRequest;
117131

118132
export type PluginRequestPayload = PluginRequestData;

src/responseTypes.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ export interface SetEncryptedDataResponse extends BaseResponse {
7979
result: void;
8080
}
8181

82+
export interface ClipboardWriteTextResponse extends BaseResponse {
83+
result: void;
84+
}
85+
86+
export interface ClipboardReadTextResponse extends BaseResponse {
87+
result: string;
88+
}
89+
8290
export type PluginResponseData =
8391
| GetTablesResponse
8492
| GetColumnsResponse
@@ -93,7 +101,9 @@ export type PluginResponseData =
93101
| GetDataResponse<unknown>
94102
| SetDataResponse
95103
| GetEncryptedDataResponse<unknown>
96-
| SetEncryptedDataResponse;
104+
| SetEncryptedDataResponse
105+
| ClipboardWriteTextResponse
106+
| ClipboardReadTextResponse;
97107

98108
export type PluginResponsePayload = PluginResponseData;
99109

0 commit comments

Comments
 (0)