@sliprail/sdk 0.1.0

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/lib/index.d.ts ADDED
@@ -0,0 +1,221 @@
1
+ export type SelectFilesOptions = {
2
+ type?: 'single-file' | 'multiple-files' | 'directory';
3
+ extensions?: string[];
4
+ };
5
+ export type WindowInfo = {
6
+ title: string;
7
+ pid: number;
8
+ handle: number;
9
+ appName: string;
10
+ filePath: string;
11
+ icon?: string;
12
+ };
13
+ export type WindowChannel = {
14
+ on: (event: string, callback: (...data: any[]) => void) => void;
15
+ off: (event: string, callback: (...data: any[]) => void) => void;
16
+ once: (event: string, callback: (...data: any[]) => void) => void;
17
+ emit: (event: string, ...data: unknown[]) => void;
18
+ removeAllListeners: () => void;
19
+ destroy: () => void;
20
+ _window: unknown;
21
+ _emitter: unknown;
22
+ };
23
+ export type ShowWindowOptions = {
24
+ htmlFile: string;
25
+ title?: string;
26
+ width?: number;
27
+ height?: number;
28
+ maximize?: boolean;
29
+ parameters?: Record<string, unknown>;
30
+ channel?: WindowChannel;
31
+ resizable?: boolean;
32
+ onClose?: () => void;
33
+ };
34
+ export type WindowControl = {
35
+ close: () => void;
36
+ show: () => void;
37
+ _runtime?: unknown;
38
+ };
39
+ export type KVStorage = {
40
+ set: (key: string, value: unknown) => Promise<void>;
41
+ get: (key: string) => Promise<unknown | undefined>;
42
+ has: (key: string) => Promise<boolean>;
43
+ remove: (key: string) => Promise<void>;
44
+ };
45
+ export type LoadChildShortcutsContext = {
46
+ signal: AbortSignal;
47
+ };
48
+ export type LivePreviewContent = {
49
+ content: string;
50
+ type?: 'info' | 'warn' | 'error' | 'hint';
51
+ };
52
+ export type ShortcutContext = {
53
+ parameter: any;
54
+ getSettings: () => Promise<Record<string, unknown>>;
55
+ showWindow: (showWindow: ShowWindowOptions) => WindowControl;
56
+ createStorage: () => KVStorage;
57
+ channel: WindowChannel | undefined;
58
+ events: {
59
+ on: (event: 'settingsChange', callback: () => unknown) => void;
60
+ };
61
+ };
62
+ export type Shortcut = {
63
+ id: string;
64
+ displayName: string;
65
+ hidden?: boolean;
66
+ description?: string;
67
+ icon?: string | {
68
+ src: string;
69
+ template?: boolean;
70
+ fallbackIcon?: string;
71
+ };
72
+ prependKeywords?: string[];
73
+ appendKeywords?: string[];
74
+ handle?: (context: ShortcutContext) => Promise<unknown> | unknown;
75
+ childShortcuts?: Shortcut[] | ((context: LoadChildShortcutsContext) => Promise<Shortcut[]> | Shortcut[]);
76
+ livePreview?: (parameters: string) => Promise<LivePreviewContent | undefined> | LivePreviewContent | undefined;
77
+ };
78
+ export type ExtensionSettingValue = undefined | boolean | string | string[] | ExtensionSettings[];
79
+ export type ExtensionSettings = Record<string, ExtensionSettingValue>;
80
+ export type ExtensionInfo = {
81
+ id: string;
82
+ displayName?: string;
83
+ settingValues: Record<string, any>;
84
+ settingDefinitions?: SettingDefinition[];
85
+ hasSettings: boolean;
86
+ hasStatus: boolean;
87
+ };
88
+ type CommonSettingOptions = {
89
+ id: string;
90
+ displayName: string;
91
+ prependDescription?: string | string[];
92
+ description?: string;
93
+ defaultValue?: unknown;
94
+ refreshOnOtherChange?: boolean | string | string[];
95
+ showRefreshOnError?: boolean;
96
+ };
97
+ export type BooleanSetting = CommonSettingOptions & {
98
+ type: 'boolean';
99
+ enableConfirmMessage?: string;
100
+ disableConfirmMessage?: string;
101
+ };
102
+ export type NumberSetting = CommonSettingOptions & {
103
+ type: 'number';
104
+ control?: 'input' | {
105
+ type: 'select';
106
+ options: OptionItem[];
107
+ };
108
+ };
109
+ export type StringSetting = CommonSettingOptions & {
110
+ type: 'string';
111
+ placeholder?: string;
112
+ control?: 'input' | 'textarea' | {
113
+ type: 'textarea';
114
+ autoHeight?: boolean;
115
+ rows?: number;
116
+ maxRows?: number;
117
+ };
118
+ };
119
+ export type ArrayObjectSetting = CommonSettingOptions & {
120
+ type: 'array-object';
121
+ subSettings: SettingDefinition[];
122
+ };
123
+ export type OptionItem = {
124
+ label?: string;
125
+ value: string;
126
+ group?: string;
127
+ description?: string;
128
+ };
129
+ export type ArrayStringSetting = CommonSettingOptions & {
130
+ type: 'array-string';
131
+ control: {
132
+ type: 'checkbox-group';
133
+ options: OptionItem[];
134
+ };
135
+ };
136
+ type StatusOk = {
137
+ status: 'ok';
138
+ message?: string;
139
+ };
140
+ type StatusLoading = {
141
+ status: 'loading';
142
+ message?: string;
143
+ };
144
+ type StatusError = {
145
+ status: 'error';
146
+ message: string;
147
+ onRetry?: () => unknown;
148
+ };
149
+ type StatusWarning = {
150
+ status: 'warning';
151
+ message: string;
152
+ };
153
+ export type ExtensionStatus = StatusOk | StatusLoading | StatusError | StatusWarning;
154
+ export type SettingDefinition = BooleanSetting | NumberSetting | StringSetting | ArrayStringSetting | ArrayObjectSetting;
155
+ export type Extension = {
156
+ id?: string;
157
+ name?: string;
158
+ role?: string;
159
+ icon?: string | {
160
+ src: string;
161
+ template?: boolean;
162
+ };
163
+ shortcuts: Shortcut[] | ((context: ShortcutContext) => Shortcut[] | Promise<Shortcut[]>);
164
+ settings?: SettingDefinition[] | ((context: ShortcutContext) => SettingDefinition[] | Promise<SettingDefinition[]>);
165
+ onReady?: (context: ShortcutContext) => unknown;
166
+ onDisabled?: (context: ShortcutContext) => unknown;
167
+ defaultCloudSync?: boolean;
168
+ beforeSaveSettings?: (context: ShortcutContext, settings: ExtensionSettings) => ExtensionSettings | Promise<ExtensionSettings>;
169
+ getStatus?: (context: ShortcutContext) => ExtensionStatus | Promise<ExtensionStatus>;
170
+ };
171
+ export type SliprailMain = {
172
+ openUrl: (url: string) => void;
173
+ openPath: (path: string) => void;
174
+ openFileLocation: (path: string) => void;
175
+ copyFilesToClipboard: (paths: string[]) => void;
176
+ saveTextFile: (options: {
177
+ filename: string;
178
+ content: string;
179
+ }) => Promise<void>;
180
+ cutFilesToClipboard: (paths: string[]) => void;
181
+ selectFiles: (options?: SelectFilesOptions) => Promise<string[]>;
182
+ showNotification: (options: {
183
+ title: string;
184
+ message: string;
185
+ }) => any;
186
+ showAlert: (message: string) => void;
187
+ copyToClipboard: (content: string) => void;
188
+ pasteFromClipboard: () => string;
189
+ getSystemWindows: () => Promise<WindowInfo[]>;
190
+ captureAllDisplays: () => Promise<string[]>;
191
+ createWindowChannel: () => WindowChannel;
192
+ debugLog: (...logs: unknown[]) => void;
193
+ };
194
+ export type SliprailRenderer = {
195
+ executeShortcut: (parameters: {
196
+ extensionId: string;
197
+ shortcutId: string;
198
+ parameter?: string;
199
+ }) => Promise<unknown>;
200
+ getParameters: () => Promise<Record<string, unknown>>;
201
+ openExtensionSettings: () => void;
202
+ createWindowChannel: () => WindowChannel;
203
+ openUrl: (url: string) => void;
204
+ openPath: (path: string) => void;
205
+ openFileLocation: (path: string) => void;
206
+ copyFilesToClipboard: (paths: string[]) => void;
207
+ cutFilesToClipboard: (paths: string[]) => void;
208
+ selectDirectory: () => Promise<string | undefined>;
209
+ openSettings: () => Promise<void>;
210
+ saveTextFile: (options: {
211
+ filename: string;
212
+ content: string;
213
+ }) => Promise<void>;
214
+ saveFile: (file: File) => Promise<void>;
215
+ saveBase64File: (filename: string, base64Content: string) => Promise<void>;
216
+ };
217
+ declare global {
218
+ var sliprailMain: SliprailMain;
219
+ var sliprailRenderer: SliprailRenderer;
220
+ }
221
+ export {};
package/lib/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ /* eslint-disable */export {};
2
+ //# sourceMappingURL=index.mjs.map
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "@sliprail/sdk",
3
+ "version": "0.1.0",
4
+ "license": "MIT",
5
+ "type": "module",
6
+ "main": "lib/index.mjs",
7
+ "files": [
8
+ "lib/index.mjs",
9
+ "lib/index.d.ts"
10
+ ],
11
+ "devDependencies": {
12
+ "@types/node": "^20.19.9",
13
+ "typescript": "5.6.3"
14
+ },
15
+ "engines": {
16
+ "node": ">=20"
17
+ }
18
+ }