@croffledev/croffle-types 1.7.0 β†’ 1.8.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.
package/README.md CHANGED
@@ -34,43 +34,60 @@ pnpm add -D @croffledev/croffle-types
34
34
 
35
35
  ## πŸ› οΈ Usage
36
36
 
37
- ### Basic Plugin Definition
37
+ ### Extension entry
38
38
 
39
- Import the types to define your plugin structure. This ensures your plugin correctly implements the required lifecycle hooks and metadata.
39
+ An extension's entry module exports `activated(context)` and optionally `deactivated()`. `ExtensionContext` is the host API (`croffle.*`) plus storage, session and configuration already bound to your extension, and `ui` for adding views, settings tabs and context menu items.
40
40
 
41
41
  ```typescript
42
- import type { ICrofflePlugin, PluginContext } from '@croffledev/croffle-types';
42
+ import type { ExtensionContext } from '@croffledev/croffle-types';
43
43
 
44
- const myPlugin: ICrofflePlugin = {
45
- name: 'MyAwesomePlugin',
46
- version: '1.0.0',
44
+ let detachMenu: (() => void) | null = null;
47
45
 
48
- onLoad(context: PluginContext) {
49
- console.log('Croffle Plugin Loaded!', context.appVersion);
50
- },
46
+ export function activated(context: ExtensionContext) {
47
+ context.ui.registerView('my-view', (container) => {
48
+ container.textContent = 'Hello from my extension';
49
+ });
51
50
 
52
- onUnload() {
53
- console.log('Cleaning up...');
54
- },
55
- };
51
+ // Declared in croffle-manifest.json β†’ contributes.contextMenus: [{ "id": "hello", ... }]
52
+ detachMenu = context.ui.onContextMenu('hello', (target) => {
53
+ // target: the right-clicked day cell or schedule element, or null
54
+ console.log('clicked', target);
55
+ });
56
+ }
56
57
 
57
- export default myPlugin;
58
+ export function deactivated() {
59
+ detachMenu?.();
60
+ }
58
61
  ```
59
62
 
60
- ### Type Augmentation (Optional)
63
+ ### Manifest context menus
61
64
 
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.
65
+ ```json
66
+ {
67
+ "contributes": {
68
+ "contextMenus": [{ "id": "hello", "label": "Say hello", "targetView": ["calendar"] }]
69
+ }
70
+ }
71
+ ```
72
+
73
+ - `id`: unique within the extension; pass it to `onContextMenu`.
74
+ - `label`: shown as written.
75
+ - `targetView`: where the item appears (`calendar` or one of your view ids); omit for every screen.
76
+ - `disabled`: show the item greyed out.
77
+
78
+ Items appear only after `onContextMenu` attaches an action. `onContextMenu(id, handler, { condition })` hides the item for a right-click when `condition(target)` returns `false`. Requires Croffle 1.2.5 or later.
63
79
 
64
80
  ---
65
81
 
66
82
  ## πŸ“– Key Definitions
67
83
 
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. |
84
+ | Type / Interface | Description |
85
+ | :-------------------- | :---------------------------------------------------------------------------------- |
86
+ | `ExtensionContext` | What `activated` receives: host API plus extension-bound storage, session, config. |
87
+ | `UiApi` | `registerView`, `registerConfigurationTab`, `onContextMenu`, `registerContextMenu`. |
88
+ | `CroffleManifest` | Shape of `croffle-manifest.json`, including `contributes`. |
89
+ | `ContextMenuManifest` | One `contributes.contextMenus` entry. |
90
+ | `CroffleAPI` | The host API exposed as `window.croffle`. |
74
91
 
75
92
  ---
76
93
 
package/api/calendar.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import type { Schedule } from '../models/schedule';
2
- import type { SearchQuery } from '../models/search';
3
- import type { Tag } from '../models/tag';
1
+ import type { Schedule } from '../models/schedule.js';
2
+ import type { SearchQuery } from '../models/search.js';
3
+ import type { Tag } from '../models/tag.js';
4
4
 
5
5
  export interface SchedulesApi {
6
6
  getAll(period: { start: string; end: string }): Promise<Schedule[]>;
@@ -1,4 +1,4 @@
1
- import type { ExtensionInfo } from '../models/extension';
1
+ import type { ExtensionInfo } from '../models/extension.js';
2
2
 
3
3
  export interface ExtensionInfoApi {
4
4
  getInstalled(): Promise<ExtensionInfo[]>;
package/api/http.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { HttpResponse } from '../models/http';
1
+ import type { HttpResponse } from '../models/http.js';
2
2
 
3
3
  export interface HttpApi {
4
4
  get(
package/api/os.d.ts CHANGED
@@ -1,4 +1,8 @@
1
- import type { ClipboardImageData, ClipboardResult, ClipboardTextData } from '../models/clipboard';
1
+ import type {
2
+ ClipboardImageData,
3
+ ClipboardResult,
4
+ ClipboardTextData,
5
+ } from '../models/clipboard.js';
2
6
 
3
7
  export interface OsApi {
4
8
  showNotification(title: string, body: string): Promise<void>;
package/api/settings.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { AppSettings } from '../models/app-settings';
1
+ import type { AppSettings } from '../models/app-settings.js';
2
2
 
3
3
  export interface SettingsApi {
4
4
  getAll(): Promise<AppSettings>;
package/api/ui.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ConfigurationSectionContribution } from '../models/extension';
1
+ import type { ConfigurationSectionContribution } from '../models/extension.js';
2
2
 
3
3
  export type RegisterConfigurationTabOptions = {
4
4
  label: string;
@@ -8,14 +8,36 @@ export type RegisterConfigurationTabOptions = {
8
8
  sections?: ConfigurationSectionContribution[];
9
9
  };
10
10
 
11
+ export type ContextMenuHandlerOptions = {
12
+ condition?: (target: HTMLElement | null) => boolean;
13
+ };
14
+
11
15
  export interface UiApi {
12
16
  registerView(viewId: string, renderFn: (container: HTMLElement) => void): void;
17
+ /**
18
+ * μ½”λ“œλ§ŒμœΌλ‘œ μ»¨ν…μŠ€νŠΈ 메뉴 ν•­λͺ©μ„ μΆ”κ°€ν•©λ‹ˆλ‹€. manifest에 μ„ μ–Έν•œ ν•­λͺ©μ€ `onContextMenu`λ₯Ό μ“°μ„Έμš”.
19
+ * @param target 메뉴가 λœ¨λŠ” ν™”λ©΄ (`calendar` λ˜λŠ” ν™•μž₯ viewId)
20
+ * @param callback μš°ν΄λ¦­ν•œ μš”μ†Œ(λ‚ μ§œ μΉΈ, 일정 λ“±)λ₯Ό λ°›μŠ΅λ‹ˆλ‹€. μ—†μœΌλ©΄ `null`.
21
+ */
13
22
  registerContextMenu(
14
23
  target: string,
15
24
  command: string,
16
25
  label: string,
17
- callback: (target: string) => void,
26
+ callback: (target: HTMLElement | null) => void,
18
27
  ): void;
28
+ /**
29
+ * manifest `contributes.contextMenus`에 μ„ μ–Έν•œ ν•­λͺ©μ— λ™μž‘μ„ λΆ™μž…λ‹ˆλ‹€.
30
+ * λ™μž‘μ΄ λΆ™κΈ° μ „κΉŒμ§€ ν•­λͺ©μ€ 메뉴에 λ‚˜νƒ€λ‚˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.
31
+ * @param id manifest ν•­λͺ©μ˜ `id`
32
+ * @param handler μš°ν΄λ¦­ν•œ μš”μ†Œλ₯Ό λ°›μŠ΅λ‹ˆλ‹€. μ—†μœΌλ©΄ `null`.
33
+ * @param options.condition `false`λ₯Ό 돌렀주면 κ·Έ μš°ν΄λ¦­μ—μ„œλŠ” ν•­λͺ©μ„ μˆ¨κΉλ‹ˆλ‹€.
34
+ * @returns λ™μž‘μ„ λ–Όμ–΄ λ‚΄λŠ” ν•¨μˆ˜ (`deactivated`μ—μ„œ 호좜)
35
+ */
36
+ onContextMenu(
37
+ id: string,
38
+ handler: (target: HTMLElement | null) => void,
39
+ options?: ContextMenuHandlerOptions,
40
+ ): () => void;
19
41
  /**
20
42
  * μ•± μ„€μ • λͺ¨λ‹¬μ— extension configuration 탭을 μΆ”κ°€ν•©λ‹ˆλ‹€.
21
43
  * @param tabId 고유 νƒ­ ID (`${extensionId}:${tabId}` ν˜•νƒœλ‘œ μ €μž₯됨)
package/croffle-api.d.ts CHANGED
@@ -1,25 +1,25 @@
1
- import type { CalendarApi } from './api/calendar';
2
- import type { EventApi } from './api/event';
1
+ import type { CalendarApi } from './api/calendar.js';
2
+ import type { EventApi } from './api/event.js';
3
3
  import type {
4
4
  ExtensionScopedConfigurationApi,
5
5
  ExtensionScopedSessionApi,
6
6
  ExtensionScopedStorageApi,
7
7
  ExtensionsApi,
8
- } from './api/extensions';
9
- import type { HttpApi } from './api/http';
10
- import type { OsApi } from './api/os';
11
- import type { SettingsApi } from './api/settings';
12
- import type { UiApi } from './api/ui';
13
- import type { WindowApi } from './api/window';
14
- import type { AppEventType } from './enums';
8
+ } from './api/extensions.js';
9
+ import type { HttpApi } from './api/http.js';
10
+ import type { OsApi } from './api/os.js';
11
+ import type { SettingsApi } from './api/settings.js';
12
+ import type { UiApi } from './api/ui.js';
13
+ import type { WindowApi } from './api/window.js';
14
+ import type { AppEventType } from './enums.js';
15
15
  import type {
16
16
  AppSettingLanguage,
17
17
  AppSettingTheme,
18
18
  CalendarTimeFormat,
19
19
  CalendarView,
20
20
  CalendarWeekStartDay,
21
- } from './models/app-settings';
22
- import type { ClipboardDataType } from './models/clipboard';
21
+ } from './models/app-settings.js';
22
+ import type { ClipboardDataType } from './models/clipboard.js';
23
23
 
24
24
  export interface EnumsApi {
25
25
  AppSettingLanguage: typeof AppSettingLanguage;
package/index.d.ts CHANGED
@@ -1,17 +1,17 @@
1
- export * from './models/tag';
2
- export * from './models/schedule';
3
- export * from './models/search';
4
- export * from './models/extension';
5
- export * from './models/app-settings';
6
- export * from './models/clipboard';
7
- export * from './models/http';
8
- export * from './enums';
9
- export * from './api/window';
10
- export * from './api/calendar';
11
- export * from './api/extensions';
12
- export * from './api/settings';
13
- export * from './api/os';
14
- export * from './api/http';
15
- export * from './api/event';
16
- export * from './api/ui';
17
- export * from './croffle-api';
1
+ export * from './models/tag.js';
2
+ export * from './models/schedule.js';
3
+ export * from './models/search.js';
4
+ export * from './models/extension.js';
5
+ export * from './models/app-settings.js';
6
+ export * from './models/clipboard.js';
7
+ export * from './models/http.js';
8
+ export * from './enums.js';
9
+ export * from './api/window.js';
10
+ export * from './api/calendar.js';
11
+ export * from './api/extensions.js';
12
+ export * from './api/settings.js';
13
+ export * from './api/os.js';
14
+ export * from './api/http.js';
15
+ export * from './api/event.js';
16
+ export * from './api/ui.js';
17
+ export * from './croffle-api.js';
@@ -37,11 +37,17 @@ export type ViewManifest = {
37
37
  url: string;
38
38
  };
39
39
 
40
- /** Manifest `contributes.contextMenus` ν•­λͺ© (action은 μ½”λ“œμ—μ„œλ§Œ) */
40
+ /**
41
+ * Manifest `contributes.contextMenus` ν•­λͺ©. λ™μž‘μ€ μ½”λ“œμ—μ„œ `context.ui.onContextMenu(id, …)`둜 λΆ™μž…λ‹ˆλ‹€.
42
+ */
41
43
  export type ContextMenuManifest = {
44
+ /** ν™•μž₯ μ•ˆμ—μ„œ 고유. `onContextMenu`의 id */
42
45
  id: string;
46
+ /** 메뉴에 κ·ΈλŒ€λ‘œ ν‘œμ‹œλ˜λŠ” 문ꡬ */
43
47
  label: string;
48
+ /** 메뉴가 λœ¨λŠ” ν™”λ©΄ (`calendar` λ˜λŠ” ν™•μž₯ viewId). μƒλž΅ν•˜λ©΄ λͺ¨λ“  ν™”λ©΄ */
44
49
  targetView?: string[];
50
+ /** `true`λ©΄ ν•­λͺ©μ„ λΉ„ν™œμ„±μœΌλ‘œ ν‘œμ‹œ */
45
51
  disabled?: boolean;
46
52
  };
47
53
 
@@ -1,4 +1,4 @@
1
- import type { Tag } from './tag';
1
+ import type { Tag } from './tag.js';
2
2
 
3
3
  /**
4
4
  * Override of one occurrence of a recurring schedule, keyed by the occurrence's
@@ -1,4 +1,4 @@
1
- import type { Tag } from './tag';
1
+ import type { Tag } from './tag.js';
2
2
 
3
3
  export type SearchQuery = {
4
4
  text?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@croffledev/croffle-types",
3
- "version": "1.7.0",
3
+ "version": "1.8.1",
4
4
  "description": "Croffle project type definitions.",
5
5
  "license": "MIT",
6
6
  "type": "module",