@croffledev/croffle-types 1.0.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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +92 -0
  3. package/index.d.ts +365 -0
  4. package/package.json +24 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Croffle Dev.
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.
package/README.md ADDED
@@ -0,0 +1,92 @@
1
+ # @croffledev/croffle-types
2
+
3
+ <div align="center">
4
+ <img src="./.github/content/Logo2Only.png" width="120" />
5
+
6
+ # Croffle Types
7
+
8
+ > Official TypeScript definitions for CROFFLE plugin development
9
+
10
+ </div>
11
+
12
+ **@croffledev/croffle-types** provides the essential type definitions and interfaces required to build, extend, and integrate plugins for the [CROFFLE](https://www.google.com/search?q=https://github.com/croffledev/croffle) ecosystem.
13
+
14
+ By using this package, developers can ensure type safety and leverage IntelliSense when interacting with the Croffle Core API, IPC events, and the plugin lifecycle.
15
+
16
+ ---
17
+
18
+ ## 📦 Installation
19
+
20
+ This package should be installed as a **development dependency** in your plugin project.
21
+
22
+ ```bash
23
+ # Using npm
24
+ npm install -D @croffledev/croffle-types
25
+
26
+ # Using yarn
27
+ yarn add -D @croffledev/croffle-types
28
+
29
+ # Using pnpm
30
+ pnpm add -D @croffledev/croffle-types
31
+ ```
32
+
33
+ ---
34
+
35
+ ## 🛠️ Usage
36
+
37
+ ### Basic Plugin Definition
38
+
39
+ Import the types to define your plugin structure. This ensures your plugin correctly implements the required lifecycle hooks and metadata.
40
+
41
+ ```typescript
42
+ import type { ICrofflePlugin, PluginContext } from "@croffledev/croffle-types";
43
+
44
+ const myPlugin: ICrofflePlugin = {
45
+ name: "MyAwesomePlugin",
46
+ version: "1.0.0",
47
+
48
+ onLoad(context: PluginContext) {
49
+ console.log("Croffle Plugin Loaded!", context.appVersion);
50
+ },
51
+
52
+ onUnload() {
53
+ console.log("Cleaning up...");
54
+ },
55
+ };
56
+
57
+ export default myPlugin;
58
+ ```
59
+
60
+ ### Type Augmentation (Optional)
61
+
62
+ If your plugin extends the global `window` object or adds custom IPC channels, you can use these types to maintain a robust development environment.
63
+
64
+ ---
65
+
66
+ ## 📖 Key Definitions
67
+
68
+ | Type / Interface | Description |
69
+ | :--------------- | :----------------------------------------------------------------------------- |
70
+ | `ICrofflePlugin` | The base interface for every Croffle plugin. |
71
+ | `PluginContext` | Provides access to Croffle's internal APIs (Database, Storage, Notifications). |
72
+ | `BridgeAPI` | Types for IPC communication between the Renderer and Main process. |
73
+ | `ThemeConfig` | Interfaces for accessing Croffle's CSS variables and theme state. |
74
+
75
+ ---
76
+
77
+ ## 👩‍💻 For Contributors
78
+
79
+ If you want to contribute to the type definitions or add support for new Core APIs:
80
+
81
+ 1. Fork the [Croffle Main Repository](https://www.google.com/search?q=https://github.com/croffledev/croffle).
82
+ 2. Navigate to the types workspace (or this standalone repo).
83
+ 3. Update `index.d.ts`.
84
+ 4. Submit a Pull Request with a clear description of the changes.
85
+
86
+ ---
87
+
88
+ ## 📄 License
89
+
90
+ This package is distributed under the **MIT License**.
91
+
92
+ Copyright (c) 2026 **Croffle Dev.** & Croffle Contributors
package/index.d.ts ADDED
@@ -0,0 +1,365 @@
1
+ declare module 'croffle' {
2
+ export interface Schedule {
3
+ id: string;
4
+ title: string;
5
+ description: string;
6
+ location: string;
7
+ startDate: string; // ISO 8601 format
8
+ endDate: string; // ISO 8601 format
9
+ isAllDay: boolean;
10
+ recurrenceRule?: string;
11
+ colorLabel: string;
12
+ tags: Tag[];
13
+ createdAt: string; // ISO 8601 format
14
+ updatedAt: string; // ISO 8601 format
15
+ }
16
+
17
+ export interface Tag {
18
+ id: string;
19
+ name: string;
20
+ color: string;
21
+ }
22
+
23
+ export interface SearchQuery {
24
+ text?: string;
25
+ dateRange?: {
26
+ start: string; // ISO 8601 format
27
+ end: string; // ISO 8601 format
28
+ };
29
+ tags?: Tag[];
30
+ }
31
+
32
+ export interface FeatureView {
33
+ id: string; // 각 메뉴를 식별할 고유 ID (플러그인별 고유값)
34
+ title: string; // 사용자에게 보여줄 한글 제목
35
+ subtitle: string; // 디자인을 위한 영문 부제목
36
+ icon: Component; // 표시할 아이콘 컴포넌트
37
+ url: string; // 클릭 시 이동할 경로
38
+ active?: boolean; // 현재 활성화 상태 여부 (선택적)
39
+ pluginName?: string; // 해당 메뉴를 제공하는 플러그인 이름 (관리용)
40
+ }
41
+
42
+ export interface FeatureContextMenu {
43
+ id: string; // 메뉴의 고유 식별자 ex) add-schedule, delete-schedule
44
+ label: string; // 메뉴에 표시될 텍스트
45
+ action: (targetElement: HTMLElement | null) => void; // 메뉴 클릭 시 실행될 함수
46
+ condition?: (targetElement: HTMLElement | null) => boolean;
47
+ disabled?: boolean; // 메뉴 활성화 여부 (선택 사항)
48
+ targetView?: string[]; // 메뉴가 표시될 대상 (viewId)
49
+ }
50
+
51
+ export interface PluginInfo {
52
+ enabled: boolean;
53
+ id: string;
54
+ name: string;
55
+ version: string;
56
+ author: string;
57
+ main?: string;
58
+ description?: string;
59
+ features: {
60
+ views?: FeatureView[];
61
+ contextMenus?: FeatureContextMenu[];
62
+ };
63
+ }
64
+
65
+ export enum AppSettingLanguage {
66
+ KO = 'ko',
67
+ EN = 'en',
68
+ }
69
+
70
+ export enum AppSettingTheme {
71
+ LIGHT = 'light',
72
+ DARK = 'dark',
73
+ SYSTEM = 'system',
74
+ }
75
+
76
+ export enum AppSettingStartupBehavior {
77
+ OPEN_LAST_SESSION = 'openLastSession',
78
+ OPEN_NEW_WINDOW = 'openNewWindow',
79
+ DO_NOTHING = 'doNothing',
80
+ }
81
+
82
+ export enum CalendarView {
83
+ DAY = 'day',
84
+ WEEK = 'week',
85
+ MONTH = 'month',
86
+ YEAR = 'year',
87
+ }
88
+
89
+ export enum CalendarWeekStartDay {
90
+ SUNDAY = 'sunday',
91
+ MONDAY = 'monday',
92
+ }
93
+
94
+ export enum CalendarTimeFormat {
95
+ H12 = '12h',
96
+ H24 = '24h',
97
+ }
98
+
99
+ export interface AppSettings {
100
+ general: {
101
+ language: AppSettingLanguage;
102
+ theme: AppSettingTheme;
103
+ autoUpdate: boolean;
104
+ startupBehavior: AppSettingStartupBehavior;
105
+ startOnSystemBoot: boolean;
106
+ startMinimized: boolean;
107
+ };
108
+ calendar: {
109
+ defaultView: CalendarView;
110
+ weekStartDay: CalendarWeekStartDay;
111
+ showWeekNumbers: boolean;
112
+ timeFormat: CalendarTimeFormat;
113
+ };
114
+ notifications: {
115
+ enabled: boolean;
116
+ defaultReminderMinutes: number;
117
+ };
118
+ }
119
+
120
+ export enum ClipboardDataType {
121
+ TEXT = 'text',
122
+ IMAGE = 'image',
123
+ EMPTY = 'empty',
124
+ ERROR = 'error',
125
+ }
126
+
127
+ export interface ClipboardResult {
128
+ type: ClipboardDataType;
129
+ value: string | Buffer | null;
130
+ }
131
+
132
+ export interface ClipboardTextData {
133
+ type: ClipboardDataType.TEXT;
134
+ value: string;
135
+ }
136
+
137
+ export interface ClipboardImageData {
138
+ type: ClipboardDataType.IMAGE;
139
+ value: Buffer;
140
+ }
141
+
142
+ export interface HttpResponse<T = unknown> {
143
+ ok: boolean;
144
+ status: number;
145
+ data: T | null;
146
+ }
147
+
148
+ // IPC Event Types in main process
149
+ export enum AppEventType {
150
+ // Schedule
151
+ SCHEDULE_GET = 'schedule:get',
152
+ SCHEDULE_CREATE = 'schedule:create',
153
+ SCHEDULE_UPDATE = 'schedule:update',
154
+ SCHEDULE_DELETE = 'schedule:delete',
155
+ SCHEDULE_EXPORT_TO_FILE = 'schedule:exportToFile',
156
+ SCHEDULE_IMPORT_FROM_FILE = 'schedule:importFromFile',
157
+
158
+ // Tag
159
+ TAG_GET = 'tag:getAll',
160
+ TAG_GET_BY_NAME = 'tag:getByName',
161
+ TAG_CREATE = 'tag:create',
162
+ TAG_UPDATE = 'tag:update',
163
+ TAG_DELETE = 'tag:delete',
164
+
165
+ // Plugin Info
166
+ PLUGIN_INFO_GET_INSTALLED = 'pluginInfo:getInstalled',
167
+ PLUGIN_INFO_GET_ENABLED = 'pluginInfo:getEnabled',
168
+ PLUGIN_INFO_GET_BY_NAME = 'pluginInfo:getByName',
169
+ PLUGIN_INFO_CREATE = 'pluginInfo:create',
170
+ PLUGIN_INFO_UPDATE = 'pluginInfo:update',
171
+ PLUGIN_INFO_DELETE = 'pluginInfo:delete',
172
+
173
+ // Plugin Storage
174
+ PLUGIN_STORAGE_GET = 'pluginStorage:get',
175
+ PLUGIN_STORAGE_SET = 'pluginStorage:set',
176
+ PLUGIN_STORAGE_DELETE = 'pluginStorage:delete',
177
+
178
+ // Settings
179
+ SETTINGS_GET = 'settings:get',
180
+ SETTINGS_GET_OF = 'settings:getOf',
181
+ SETTINGS_UPDATE = 'settings:update',
182
+
183
+ // Window
184
+ WINDOW_MINIMIZE = 'window:minimize',
185
+ WINDOW_RESTORE = 'window:restore',
186
+ WINDOW_MAXIMIZE = 'window:maximize',
187
+ WINDOW_CLOSE = 'window:close',
188
+ WINDOW_EXIT = 'window:exit',
189
+ WINDOW_CHECK_FOR_UPDATES = 'window:checkForUpdates',
190
+ WINDOW_SHOW = 'window:show',
191
+ WINDOW_HIDE = 'window:hide',
192
+
193
+ // OS Service
194
+ NATIVE_OS_NOTIFICATION = 'nativeOs:notification',
195
+ NATIVE_OS_CLIPBOARD_GET = 'nativeOs:clipboard:get',
196
+ NATIVE_OS_CLIPBOARD_SET = 'nativeOs:clipboard:set',
197
+
198
+ // HTTP Service
199
+ HTTP_SERVICE_GET = 'httpService:get',
200
+ HTTP_SERVICE_POST = 'httpService:post',
201
+
202
+ // Plugin
203
+ PLUGIN_INSTALL = 'plugin:install',
204
+ PLUGIN_TOGGLE = 'plugin:toggle',
205
+ PLUGIN_UNINSTALL = 'plugin:uninstall',
206
+
207
+ // Plugin Session Storage
208
+ PLUGIN_SESSION_STORAGE_GET = 'sessionStorage:get',
209
+ PLUGIN_SESSION_STORAGE_SET = 'sessionStorage:set',
210
+ PLUGIN_SESSION_STORAGE_CLEAR = 'sessionStorage:clear',
211
+ PLUGIN_SESSION_STORAGE_DELETE = 'sessionStorage:delete',
212
+ PLUGIN_SESSION_STORAGE_CLEAR_ALL = 'sessionStorage:clearAll',
213
+
214
+ // Background works
215
+ SCHEDULER_REGISTER = 'scheduler:register',
216
+ SCHEDULER_UNREGISTER = 'scheduler:unregister',
217
+
218
+ // UI Extensions
219
+ UI_ADD_MENU_ITEM = 'ui:addMenuItem',
220
+ UI_CONTEXT_MENU_ADD_ITEM = 'ui:contextMenu:addItem',
221
+ }
222
+
223
+ export interface PluginContext {
224
+ base: typeof base;
225
+ app: typeof app;
226
+ enums: typeof enums;
227
+ ui: typeof ui;
228
+ }
229
+
230
+ export namespace windows {
231
+ export function minimize(): Promise<void>;
232
+ export function maximize(): Promise<void>;
233
+ export function close(): Promise<void>;
234
+ export function exitApp(): Promise<void>;
235
+ export function checkForUpdates(): Promise<void>;
236
+ export function setCloseToTrayMode(enabled: boolean): Promise<void>;
237
+ }
238
+
239
+ export namespace tags {
240
+ export function getAll(): Promise<Tag[]>;
241
+ export function getByName(name: string): Promise<Tag | null>;
242
+ export function create(name: string, color: string): Promise<Tag>;
243
+ export function modify(id: string, name: string, color: string): Promise<Tag>;
244
+ export function remove(id: string): Promise<boolean>;
245
+ }
246
+
247
+ export namespace schedules {
248
+ export function getAll(period: { start: string; end: string }): Promise<Schedule[]>;
249
+ export function create(data: Partial<Schedule>): Promise<Schedule>;
250
+ export function update(id: string, data: Partial<Schedule>): Promise<Schedule>;
251
+ export function remove(id: string): Promise<boolean>;
252
+ export function exportSchedulesToFile(period?: {
253
+ start: string;
254
+ end: string;
255
+ }): Promise<{ filePath: string; count: number } | null>;
256
+ export function importScheduleFromFile(
257
+ mode?: 'merge' | 'duplicate'
258
+ ): Promise<{ created: number; updated: number } | null>;
259
+ }
260
+
261
+ export namespace pluginInfo {
262
+ export function getInstalled(): Promise<PluginInfo[]>;
263
+ export function getEnabled(): Promise<PluginInfo[]>;
264
+ export function getByName(name: string): Promise<PluginInfo | null>;
265
+ export function install(data: Partial<PluginInfo>): Promise<PluginInfo>;
266
+ export function toggle(name: string, enable: boolean): Promise<PluginInfo | null>;
267
+ export function uninstall(name: string): Promise<boolean>;
268
+ }
269
+
270
+ export namespace search {
271
+ export function search(query: SearchQuery): Promise<Schedule[]>;
272
+ }
273
+
274
+ export namespace settings {
275
+ export function getAll(): Promise<AppSettings>;
276
+ export function getOf(key: string): Promise<AppSettings[keyof AppSettings]>;
277
+ export function update(newSettings: Partial<AppSettings>): Promise<AppSettings>;
278
+ }
279
+
280
+ export namespace pluginStorage {
281
+ export function get(pluginId: string, key: string): Promise<string | null>;
282
+ export function set(pluginId: string, key: string, value: string): Promise<void>;
283
+ }
284
+
285
+ export namespace os {
286
+ export function showNotification(title: string, body: string): Promise<void>;
287
+ export function getClipboard(): Promise<ClipboardResult>;
288
+ export function setClipboard(data: ClipboardTextData | ClipboardImageData): Promise<void>;
289
+ }
290
+
291
+ export namespace http {
292
+ export function get(
293
+ url: string,
294
+ params?: Record<string, string>,
295
+ headers?: Record<string, string>
296
+ ): Promise<HttpResponse>;
297
+ export function post(
298
+ url: string,
299
+ body?: unknown,
300
+ headers?: Record<string, string>
301
+ ): Promise<HttpResponse>;
302
+ }
303
+
304
+ export namespace event {
305
+ /**
306
+ * Send event to all windows
307
+ * @param type event type
308
+ * @param payload event payload
309
+ */
310
+ export function emit(type: string, payload: unknown): void;
311
+ /**
312
+ * Listen to event from all windows
313
+ * @param type event type
314
+ * @param callback callback function
315
+ * @returns unsubscribe function
316
+ */
317
+ export function on(type: string, callback: (payload: unknown) => void): () => void;
318
+ }
319
+
320
+ export const base: {
321
+ windows: typeof windows;
322
+ tags: typeof tags;
323
+ schedules: typeof schedules;
324
+ pluginInfo: typeof pluginInfo;
325
+ search: typeof search;
326
+ settings: typeof settings;
327
+ };
328
+
329
+ export const app: {
330
+ os: typeof os;
331
+ http: typeof http;
332
+ storage: typeof pluginStorage;
333
+ event: typeof event;
334
+ session: PluginSessionAPI;
335
+ };
336
+
337
+ export interface PluginSessionAPI {
338
+ get: <T = unknown>(pluginId: string, key: string) => Promise<T | null>;
339
+ set: <T = unknown>(pluginId: string, key: string, value: T) => Promise<void>;
340
+ delete: (pluginId: string, key: string) => Promise<boolean>;
341
+ clear: (pluginId: string) => Promise<void>;
342
+ clearAll: () => Promise<void>;
343
+ }
344
+
345
+ export const enums: {
346
+ AppSettingLanguage: typeof AppSettingLanguage;
347
+ AppSettingTheme: typeof AppSettingTheme;
348
+ AppSettingStartupBehavior: typeof AppSettingStartupBehavior;
349
+ CalendarView: typeof CalendarView;
350
+ CalendarWeekStartDay: typeof CalendarWeekStartDay;
351
+ CalendarTimeFormat: typeof CalendarTimeFormat;
352
+ ClipboardDataType: typeof ClipboardDataType;
353
+ AppEventType: typeof AppEventType;
354
+ };
355
+
356
+ export const ui: {
357
+ registerView: (viewId: string, renderFn: (container: HTMLElement) => void) => void;
358
+ registerContextMenu: (
359
+ target: string,
360
+ command: string,
361
+ label: string,
362
+ callback: (target: string) => void
363
+ ) => void;
364
+ };
365
+ }
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@croffledev/croffle-types",
3
+ "version": "1.0.0",
4
+ "description": "Croffle project type definitions.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "",
8
+ "types": "index.d.ts",
9
+ "files": [
10
+ "index.d.ts"
11
+ ],
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/team-croffle/croffle-types.git"
18
+ },
19
+ "author": {
20
+ "name": "Croffle Team",
21
+ "email": "support@croffledev.kr",
22
+ "url": "https://github.com/team-croffle"
23
+ }
24
+ }