@croffledev/croffle-types 1.0.1 → 1.1.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.
Files changed (2) hide show
  1. package/index.d.ts +101 -44
  2. package/package.json +7 -2
package/index.d.ts CHANGED
@@ -29,24 +29,71 @@ export interface SearchQuery {
29
29
  }
30
30
 
31
31
  export interface FeatureView {
32
- id: string; // 각 메뉴를 식별할 고유 ID (플러그인별 고유값)
33
- title: string; // 사용자에게 보여줄 한글 제목
34
- subtitle: string; // 디자인을 위한 영문 부제목
35
- icon: unknown; // 표시할 아이콘 컴포넌트
36
- url: string; // 클릭 시 이동할 경로
37
- active?: boolean; // 현재 활성화 상태 여부 (선택적)
38
- pluginName?: string; // 해당 메뉴를 제공하는 플러그인 이름 (관리용)
32
+ id: string;
33
+ title: string;
34
+ subtitle: string;
35
+ icon: unknown;
36
+ url: string;
37
+ active?: boolean;
38
+ pluginName?: string;
39
39
  }
40
40
 
41
41
  export interface FeatureContextMenu {
42
- id: string; // 메뉴의 고유 식별자 ex) add-schedule, delete-schedule
43
- label: string; // 메뉴에 표시될 텍스트
44
- action: (targetElement: HTMLElement | null) => void; // 메뉴 클릭 시 실행될 함수
42
+ id: string;
43
+ label: string;
44
+ action: (targetElement: HTMLElement | null) => void;
45
45
  condition?: (targetElement: HTMLElement | null) => boolean;
46
- disabled?: boolean; // 메뉴 활성화 여부 (선택 사항)
47
- targetView?: string[]; // 메뉴가 표시될 대상 (viewId)
46
+ disabled?: boolean;
47
+ targetView?: string[];
48
+ }
49
+
50
+ /** 설정 항목 스키마 (extension SDK / manifest 공용) */
51
+ export type ConfigItemType =
52
+ | "string"
53
+ | "number"
54
+ | "boolean"
55
+ | "select"
56
+ | "path";
57
+
58
+ export interface ConfigItemSchema<T = unknown> {
59
+ type: ConfigItemType;
60
+ label: string;
61
+ description?: string;
62
+ defaultValue: T;
63
+ options?: Array<{
64
+ label: string;
65
+ value: T extends string | number ? T : never;
66
+ }>;
48
67
  }
49
68
 
69
+ /** extension이 기여하는 설정 섹션 (선언형) */
70
+ export interface SettingsSectionContribution {
71
+ id: string;
72
+ title?: string;
73
+ description?: string;
74
+ items: Record<string, ConfigItemSchema>;
75
+ }
76
+
77
+ /** extension이 기여하는 설정 탭 */
78
+ export interface SettingsTabContribution {
79
+ id: string;
80
+ label: string;
81
+ icon?: unknown;
82
+ pluginId: string;
83
+ pluginName?: string;
84
+ order?: number;
85
+ /** 커스텀 패널 렌더러 (Vue 외부 DOM 마운트) */
86
+ render?: (container: HTMLElement) => void;
87
+ /** 선언형 스키마 섹션 (render와 동시 사용 불가) */
88
+ sections?: SettingsSectionContribution[];
89
+ }
90
+
91
+ /** manifest(plugin.json)에 선언 가능한 설정 탭 메타 (render 제외) */
92
+ export type SettingsTabManifest = Omit<
93
+ SettingsTabContribution,
94
+ "pluginId" | "pluginName" | "render"
95
+ >;
96
+
50
97
  export interface PluginInfo {
51
98
  enabled: boolean;
52
99
  id: string;
@@ -58,6 +105,7 @@ export interface PluginInfo {
58
105
  features: {
59
106
  views?: FeatureView[];
60
107
  contextMenus?: FeatureContextMenu[];
108
+ settingsTabs?: SettingsTabManifest[];
61
109
  };
62
110
  }
63
111
 
@@ -144,9 +192,7 @@ export interface HttpResponse<T = unknown> {
144
192
  data: T | null;
145
193
  }
146
194
 
147
- // IPC Event Types in main process
148
195
  export enum AppEventType {
149
- // Schedule
150
196
  SCHEDULE_GET = "schedule:get",
151
197
  SCHEDULE_CREATE = "schedule:create",
152
198
  SCHEDULE_UPDATE = "schedule:update",
@@ -154,14 +200,12 @@ export enum AppEventType {
154
200
  SCHEDULE_EXPORT_TO_FILE = "schedule:exportToFile",
155
201
  SCHEDULE_IMPORT_FROM_FILE = "schedule:importFromFile",
156
202
 
157
- // Tag
158
203
  TAG_GET = "tag:getAll",
159
204
  TAG_GET_BY_NAME = "tag:getByName",
160
205
  TAG_CREATE = "tag:create",
161
206
  TAG_UPDATE = "tag:update",
162
207
  TAG_DELETE = "tag:delete",
163
208
 
164
- // Plugin Info
165
209
  PLUGIN_INFO_GET_INSTALLED = "pluginInfo:getInstalled",
166
210
  PLUGIN_INFO_GET_ENABLED = "pluginInfo:getEnabled",
167
211
  PLUGIN_INFO_GET_BY_NAME = "pluginInfo:getByName",
@@ -169,17 +213,14 @@ export enum AppEventType {
169
213
  PLUGIN_INFO_UPDATE = "pluginInfo:update",
170
214
  PLUGIN_INFO_DELETE = "pluginInfo:delete",
171
215
 
172
- // Plugin Storage
173
216
  PLUGIN_STORAGE_GET = "pluginStorage:get",
174
217
  PLUGIN_STORAGE_SET = "pluginStorage:set",
175
218
  PLUGIN_STORAGE_DELETE = "pluginStorage:delete",
176
219
 
177
- // Settings
178
220
  SETTINGS_GET = "settings:get",
179
221
  SETTINGS_GET_OF = "settings:getOf",
180
222
  SETTINGS_UPDATE = "settings:update",
181
223
 
182
- // Window
183
224
  WINDOW_MINIMIZE = "window:minimize",
184
225
  WINDOW_RESTORE = "window:restore",
185
226
  WINDOW_MAXIMIZE = "window:maximize",
@@ -189,36 +230,39 @@ export enum AppEventType {
189
230
  WINDOW_SHOW = "window:show",
190
231
  WINDOW_HIDE = "window:hide",
191
232
 
192
- // OS Service
193
233
  NATIVE_OS_NOTIFICATION = "nativeOs:notification",
194
234
  NATIVE_OS_CLIPBOARD_GET = "nativeOs:clipboard:get",
195
235
  NATIVE_OS_CLIPBOARD_SET = "nativeOs:clipboard:set",
196
236
 
197
- // HTTP Service
198
237
  HTTP_SERVICE_GET = "httpService:get",
199
238
  HTTP_SERVICE_POST = "httpService:post",
200
239
 
201
- // Plugin
202
240
  PLUGIN_INSTALL = "plugin:install",
203
241
  PLUGIN_TOGGLE = "plugin:toggle",
204
242
  PLUGIN_UNINSTALL = "plugin:uninstall",
205
243
 
206
- // Plugin Session Storage
207
244
  PLUGIN_SESSION_STORAGE_GET = "sessionStorage:get",
208
245
  PLUGIN_SESSION_STORAGE_SET = "sessionStorage:set",
209
246
  PLUGIN_SESSION_STORAGE_CLEAR = "sessionStorage:clear",
210
247
  PLUGIN_SESSION_STORAGE_DELETE = "sessionStorage:delete",
211
248
  PLUGIN_SESSION_STORAGE_CLEAR_ALL = "sessionStorage:clearAll",
212
249
 
213
- // Background works
214
250
  SCHEDULER_REGISTER = "scheduler:register",
215
251
  SCHEDULER_UNREGISTER = "scheduler:unregister",
216
252
 
217
- // UI Extensions
218
253
  UI_ADD_MENU_ITEM = "ui:addMenuItem",
219
254
  UI_CONTEXT_MENU_ADD_ITEM = "ui:contextMenu:addItem",
220
255
  }
221
256
 
257
+ /** ui.registerSettingsTab 옵션 */
258
+ export interface RegisterSettingsTabOptions {
259
+ label: string;
260
+ icon?: unknown;
261
+ order?: number;
262
+ render?: (container: HTMLElement) => void;
263
+ sections?: SettingsSectionContribution[];
264
+ }
265
+
222
266
  export interface PluginContext {
223
267
  base: typeof base;
224
268
  app: typeof app;
@@ -268,6 +312,7 @@ export namespace pluginInfo {
268
312
  export function getEnabled(): Promise<PluginInfo[]>;
269
313
  export function getByName(name: string): Promise<PluginInfo | null>;
270
314
  export function install(data: Partial<PluginInfo>): Promise<PluginInfo>;
315
+ export function installFromLocal(zipPath: string): Promise<PluginInfo>;
271
316
  export function toggle(
272
317
  name: string,
273
318
  enable: boolean,
@@ -279,6 +324,7 @@ export namespace search {
279
324
  export function search(query: SearchQuery): Promise<Schedule[]>;
280
325
  }
281
326
 
327
+ /** 앱 전역 설정 (settings.json) */
282
328
  export namespace settings {
283
329
  export function getAll(): Promise<AppSettings>;
284
330
  export function getOf(key: string): Promise<AppSettings[keyof AppSettings]>;
@@ -287,6 +333,19 @@ export namespace settings {
287
333
  ): Promise<AppSettings>;
288
334
  }
289
335
 
336
+ /** 플러그인별 설정 저장소 (pluginStorage 기반) */
337
+ export namespace pluginSettings {
338
+ export function get<T = Record<string, unknown>>(
339
+ pluginId: string,
340
+ storageKey?: string,
341
+ ): Promise<T>;
342
+ export function set(
343
+ pluginId: string,
344
+ values: Record<string, unknown>,
345
+ storageKey?: string,
346
+ ): Promise<void>;
347
+ }
348
+
290
349
  export namespace pluginStorage {
291
350
  export function get(pluginId: string, key: string): Promise<string | null>;
292
351
  export function set(
@@ -318,18 +377,7 @@ export namespace http {
318
377
  }
319
378
 
320
379
  export namespace event {
321
- /**
322
- * Send event to all windows
323
- * @param type event type
324
- * @param payload event payload
325
- */
326
380
  export function emit(type: string, payload: unknown): void;
327
- /**
328
- * Listen to event from all windows
329
- * @param type event type
330
- * @param callback callback function
331
- * @returns unsubscribe function
332
- */
333
381
  export function on(
334
382
  type: string,
335
383
  callback: (payload: unknown) => void,
@@ -343,14 +391,7 @@ export const base: {
343
391
  pluginInfo: typeof pluginInfo;
344
392
  search: typeof search;
345
393
  settings: typeof settings;
346
- };
347
-
348
- export const app: {
349
- os: typeof os;
350
- http: typeof http;
351
- storage: typeof pluginStorage;
352
- event: typeof event;
353
- session: PluginSessionAPI;
394
+ pluginSettings: typeof pluginSettings;
354
395
  };
355
396
 
356
397
  export interface PluginSessionAPI {
@@ -361,6 +402,14 @@ export interface PluginSessionAPI {
361
402
  clearAll: () => Promise<void>;
362
403
  }
363
404
 
405
+ export const app: {
406
+ os: typeof os;
407
+ http: typeof http;
408
+ storage: typeof pluginStorage;
409
+ event: typeof event;
410
+ session: PluginSessionAPI;
411
+ };
412
+
364
413
  export const enums: {
365
414
  AppSettingLanguage: typeof AppSettingLanguage;
366
415
  AppSettingTheme: typeof AppSettingTheme;
@@ -383,4 +432,12 @@ export const ui: {
383
432
  label: string,
384
433
  callback: (target: string) => void,
385
434
  ) => void;
435
+ /**
436
+ * 설정 모달에 탭을 추가합니다.
437
+ * @param tabId 고유 탭 ID (플러그인 ID와 조합해 `${pluginId}:${tabId}` 형태로 저장됨)
438
+ */
439
+ registerSettingsTab: (
440
+ tabId: string,
441
+ options: RegisterSettingsTabOptions,
442
+ ) => void;
386
443
  };
package/package.json CHANGED
@@ -1,11 +1,16 @@
1
1
  {
2
2
  "name": "@croffledev/croffle-types",
3
- "version": "1.0.1",
3
+ "version": "1.1.1",
4
4
  "description": "Croffle project type definitions.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "main": "",
8
- "types": "index.d.ts",
8
+ "types": "./index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./index.d.ts"
12
+ }
13
+ },
9
14
  "files": [
10
15
  "index.d.ts"
11
16
  ],