@croffledev/croffle-types 1.8.0 β†’ 2.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.
package/README.md CHANGED
@@ -34,43 +34,93 @@ 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 public host API (`CroffleAPI`, also reachable as `window.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.
79
+
80
+ ### What an extension can use
81
+
82
+ `CroffleAPI` is the whole host surface an extension gets; anything else in the app (window controls, writing settings, installing extensions, file dialogs) is host-only and not exposed.
83
+
84
+ | Member | What it does |
85
+ | :------------------------------------ | :----------------------------------------------------------------------------------------------- |
86
+ | `calendar.schedules` | `getAll`, `create`, `update`, `remove`, `moveOccurrence` |
87
+ | `calendar.tags` | `getAll`, `getByName`, `create`, `modify`, `remove` |
88
+ | `calendar.search` | `q(query)` |
89
+ | `settings` | `getAll`, `getOf` (read-only) |
90
+ | `extensions.info` | `getInstalled`, `getEnabled`, `getByName` (read-only) |
91
+ | `event` | `emit`, `on` β€” see below |
92
+ | `http`, `os`, `enums` | HTTP helpers, OS info and the enum objects (`AppEventType`, `CalendarView`, …) |
93
+ | `storage`, `session`, `configuration` | Context only; already bound to your extension id |
94
+ | `ui` | Context only; `registerView`, `registerConfigurationTab`, `onContextMenu`, `registerContextMenu` |
95
+
96
+ **Events.** `context.event.emit('ping')` is delivered as `<extensionId>:ping`; a name that already starts with your id is sent as is. Core events (`AppEventType`) and other extensions' prefixes cannot be emitted β€” they are dropped with a console warning. `on(name)` subscribes to anything, core events included.
97
+
98
+ ### Migrating from 1.x to 2.0
99
+
100
+ | Removed in 2.0 | Use instead |
101
+ | :----------------------------------------------------------------------------------- | :-------------------------------------------------------------- |
102
+ | `window.*` (`minimize`, `close`, `exitApp`, `checkForUpdates`, `setCloseToTrayMode`) | Host-only; no replacement |
103
+ | `settings.update` | Host-only; settings change through the app UI |
104
+ | `extensions.info.install` / `installFromLocal` / `toggle` / `uninstall` | Host-only |
105
+ | `extensions.storage` / `session` / `configuration` (`extensionId` argument) | `context.storage` / `context.session` / `context.configuration` |
106
+ | `calendar.schedules.exportSchedulesToFile` / `importScheduleFromFile` | Host-only |
107
+ | `Schedule.reminderMinutes` | `Schedule.reminders` (`number[] \| null`) |
108
+ | Helpers that leaked through `croffle.enums` | Only enum objects remain (`AppCloseBehavior` added) |
109
+ | `window.electron` | Removed; extensions never needed it |
110
+
111
+ Event names also changed: an `emit('x')` from an extension now reaches subscribers as `<extensionId>:x`.
63
112
 
64
113
  ---
65
114
 
66
115
  ## πŸ“– Key Definitions
67
116
 
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. |
117
+ | Type / Interface | Description |
118
+ | :-------------------- | :---------------------------------------------------------------------------------- |
119
+ | `ExtensionContext` | What `activated` receives: host API plus extension-bound storage, session, config. |
120
+ | `UiApi` | `registerView`, `registerConfigurationTab`, `onContextMenu`, `registerContextMenu`. |
121
+ | `CroffleManifest` | Shape of `croffle-manifest.json`, including `contributes`. |
122
+ | `ContextMenuManifest` | One `contributes.contextMenus` entry. |
123
+ | `CroffleAPI` | The public host API exposed as `window.croffle` (see "What an extension can use"). |
74
124
 
75
125
  ---
76
126
 
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[]>;
@@ -17,13 +17,6 @@ export interface SchedulesApi {
17
17
  occurrenceStart: Date | string,
18
18
  newStart: Date | string,
19
19
  ): Promise<Schedule>;
20
- exportSchedulesToFile(period?: {
21
- start: string;
22
- end: string;
23
- }): Promise<{ filePath: string; count: number } | null>;
24
- importScheduleFromFile(
25
- mode?: 'merge' | 'duplicate',
26
- ): Promise<{ created: number; updated: number } | null>;
27
20
  }
28
21
 
29
22
  export interface TagsApi {
package/api/event.d.ts CHANGED
@@ -1,3 +1,11 @@
1
+ /**
2
+ * App-wide event bus.
3
+ *
4
+ * From an extension, `emit(name)` is namespaced with the extension id: `emit('ping')`
5
+ * is delivered as `<extensionId>:ping` (a name already carrying that prefix is kept).
6
+ * Core events (`AppEventType`) and other extensions' prefixes cannot be emitted; they
7
+ * are dropped with a console warning. `on` subscribes to any name, core events included.
8
+ */
1
9
  export interface EventApi {
2
10
  emit(eventName: string, ...args: unknown[]): void;
3
11
  on(eventName: string, callback: (...args: unknown[]) => void): () => void;
@@ -1,33 +1,10 @@
1
- import type { ExtensionInfo } from '../models/extension';
1
+ import type { ExtensionInfo } from '../models/extension.js';
2
2
 
3
+ /** Read-only view of installed extensions. Install / toggle / uninstall are host-only. */
3
4
  export interface ExtensionInfoApi {
4
5
  getInstalled(): Promise<ExtensionInfo[]>;
5
6
  getEnabled(): Promise<ExtensionInfo[]>;
6
7
  getByName(name: string): Promise<ExtensionInfo | null>;
7
- install(data: Partial<ExtensionInfo>): Promise<ExtensionInfo>;
8
- installFromLocal(): Promise<ExtensionInfo | null>;
9
- toggle(name: string, enable: boolean): Promise<ExtensionInfo | null>;
10
- uninstall(name: string): Promise<boolean>;
11
- }
12
-
13
- /** Extension-scoped configuration (persisted via storage) */
14
- export interface ExtensionConfigurationApi {
15
- get<T = Record<string, unknown>>(extensionId: string, storageKey?: string): Promise<T>;
16
- set(extensionId: string, values: Record<string, unknown>, storageKey?: string): Promise<void>;
17
- }
18
-
19
- export interface ExtensionStorageApi {
20
- get<T = unknown>(extensionId: string, key: string): Promise<T | null>;
21
- set(extensionId: string, key: string, value: unknown): Promise<void>;
22
- delete(extensionId: string, key: string): Promise<boolean>;
23
- clear(extensionId: string): Promise<void>;
24
- }
25
-
26
- export interface ExtensionSessionApi {
27
- get<T = unknown>(extensionId: string, key: string): Promise<T | null>;
28
- set<T = unknown>(extensionId: string, key: string, value: T): Promise<void>;
29
- delete(extensionId: string, key: string): Promise<boolean>;
30
- clear(extensionId: string): Promise<void>;
31
8
  }
32
9
 
33
10
  /** Bound to a single extension id (passed via ExtensionContext) */
@@ -45,6 +22,7 @@ export interface ExtensionScopedSessionApi {
45
22
  clear(): Promise<void>;
46
23
  }
47
24
 
25
+ /** Extension-scoped configuration (persisted via storage) */
48
26
  export interface ExtensionScopedConfigurationApi {
49
27
  get<T = Record<string, unknown>>(storageKey?: string): Promise<T>;
50
28
  set(values: Record<string, unknown>, storageKey?: string): Promise<void>;
@@ -52,7 +30,4 @@ export interface ExtensionScopedConfigurationApi {
52
30
 
53
31
  export interface ExtensionsApi {
54
32
  info: ExtensionInfoApi;
55
- configuration: ExtensionConfigurationApi;
56
- storage: ExtensionStorageApi;
57
- session: ExtensionSessionApi;
58
33
  }
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,7 +1,7 @@
1
- import type { AppSettings } from '../models/app-settings';
1
+ import type { AppSettings } from '../models/app-settings.js';
2
2
 
3
+ /** Read-only view of the app settings. Writing them is host-only. */
3
4
  export interface SettingsApi {
4
5
  getAll(): Promise<AppSettings>;
5
6
  getOf(key: string): Promise<AppSettings[keyof AppSettings]>;
6
- update(newSettings: Partial<AppSettings>): Promise<AppSettings>;
7
7
  }
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;
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 { AppEventType } from './enums.js';
15
14
  import type {
15
+ AppCloseBehavior,
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;
@@ -27,13 +27,17 @@ export interface EnumsApi {
27
27
  CalendarView: typeof CalendarView;
28
28
  CalendarWeekStartDay: typeof CalendarWeekStartDay;
29
29
  CalendarTimeFormat: typeof CalendarTimeFormat;
30
+ AppCloseBehavior: typeof AppCloseBehavior;
30
31
  ClipboardDataType: typeof ClipboardDataType;
31
32
  AppEventType: typeof AppEventType;
32
33
  }
33
34
 
34
- /** Preload에 λ…ΈμΆœλ˜λŠ” 호슀트 API (ui μ œμ™Έ) */
35
+ /**
36
+ * Host API reachable from an extension (`window.croffle` and `ExtensionContext`).
37
+ * Window control, settings writes, extension management and file dialogs are
38
+ * host-only and not part of this surface.
39
+ */
35
40
  export interface CroffleAPI {
36
- window: WindowApi;
37
41
  os: OsApi;
38
42
  http: HttpApi;
39
43
  event: EventApi;
package/index.d.ts CHANGED
@@ -1,17 +1,16 @@
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/calendar.js';
10
+ export * from './api/extensions.js';
11
+ export * from './api/settings.js';
12
+ export * from './api/os.js';
13
+ export * from './api/http.js';
14
+ export * from './api/event.js';
15
+ export * from './api/ui.js';
16
+ export * from './croffle-api.js';
@@ -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
@@ -31,13 +31,9 @@ export type Schedule = {
31
31
  * Reminder offsets in minutes before the schedule starts, ascending.
32
32
  * `null` = follow the app-wide notifications.defaultReminderMinutes.
33
33
  * `[]` = no reminder at all.
34
+ * (The 1.2.0 single-value `reminderMinutes` mirror was removed in types 2.0.)
34
35
  */
35
36
  reminders: number[] | null;
36
- /**
37
- * @deprecated Mirror of the first entry in `reminders`, kept for extensions
38
- * written against 1.2.0. Removed in 1.3 β€” read `reminders` instead.
39
- */
40
- reminderMinutes?: number | null;
41
37
  /**
42
38
  * Per-occurrence overrides of a recurring schedule (empty or missing for one-off schedules).
43
39
  * Extensions that expand `recurrenceRule` themselves must apply these: skip each
@@ -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.8.0",
3
+ "version": "2.0.0",
4
4
  "description": "Croffle project type definitions.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/api/window.d.ts DELETED
@@ -1,13 +0,0 @@
1
- export interface WindowApi {
2
- minimize(): Promise<void>;
3
- maximize(): Promise<void>;
4
- close(): Promise<void>;
5
- exitApp(): Promise<void>;
6
- checkForUpdates(): Promise<void>;
7
- /**
8
- * @deprecated Since 1.2.2 the close behavior is a user setting. This call now writes
9
- * `general.closeBehavior` (`true` β†’ `tray`, `false` β†’ `quit`). Use `settings.update` instead.
10
- * Will be removed in 1.3.
11
- */
12
- setCloseToTrayMode(enabled: boolean): Promise<void>;
13
- }