@croffledev/croffle-types 1.8.1 → 2.0.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 +35 -2
- package/api/calendar.d.ts +0 -7
- package/api/event.d.ts +8 -0
- package/api/extensions.d.ts +2 -27
- package/api/settings.d.ts +1 -1
- package/croffle-api.d.ts +7 -3
- package/index.d.ts +0 -1
- package/models/schedule.d.ts +1 -5
- package/package.json +2 -2
- package/api/window.d.ts +0 -13
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ pnpm add -D @croffledev/croffle-types
|
|
|
36
36
|
|
|
37
37
|
### Extension entry
|
|
38
38
|
|
|
39
|
-
An extension's entry module exports `activated(context)` and optionally `deactivated()`. `ExtensionContext` is the host API (`croffle
|
|
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
42
|
import type { ExtensionContext } from '@croffledev/croffle-types';
|
|
@@ -77,6 +77,39 @@ export function deactivated() {
|
|
|
77
77
|
|
|
78
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
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`.
|
|
112
|
+
|
|
80
113
|
---
|
|
81
114
|
|
|
82
115
|
## 📖 Key Definitions
|
|
@@ -87,7 +120,7 @@ Items appear only after `onContextMenu` attaches an action. `onContextMenu(id, h
|
|
|
87
120
|
| `UiApi` | `registerView`, `registerConfigurationTab`, `onContextMenu`, `registerContextMenu`. |
|
|
88
121
|
| `CroffleManifest` | Shape of `croffle-manifest.json`, including `contributes`. |
|
|
89
122
|
| `ContextMenuManifest` | One `contributes.contextMenus` entry. |
|
|
90
|
-
| `CroffleAPI` | The host API exposed as `window.croffle
|
|
123
|
+
| `CroffleAPI` | The public host API exposed as `window.croffle` (see "What an extension can use"). |
|
|
91
124
|
|
|
92
125
|
---
|
|
93
126
|
|
package/api/calendar.d.ts
CHANGED
|
@@ -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;
|
package/api/extensions.d.ts
CHANGED
|
@@ -1,33 +1,10 @@
|
|
|
1
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/settings.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
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/croffle-api.d.ts
CHANGED
|
@@ -10,9 +10,9 @@ import type { HttpApi } from './api/http.js';
|
|
|
10
10
|
import type { OsApi } from './api/os.js';
|
|
11
11
|
import type { SettingsApi } from './api/settings.js';
|
|
12
12
|
import type { UiApi } from './api/ui.js';
|
|
13
|
-
import type { WindowApi } from './api/window.js';
|
|
14
13
|
import type { AppEventType } from './enums.js';
|
|
15
14
|
import type {
|
|
15
|
+
AppCloseBehavior,
|
|
16
16
|
AppSettingLanguage,
|
|
17
17
|
AppSettingTheme,
|
|
18
18
|
CalendarTimeFormat,
|
|
@@ -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
|
-
/**
|
|
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
|
@@ -6,7 +6,6 @@ export * from './models/app-settings.js';
|
|
|
6
6
|
export * from './models/clipboard.js';
|
|
7
7
|
export * from './models/http.js';
|
|
8
8
|
export * from './enums.js';
|
|
9
|
-
export * from './api/window.js';
|
|
10
9
|
export * from './api/calendar.js';
|
|
11
10
|
export * from './api/extensions.js';
|
|
12
11
|
export * from './api/settings.js';
|
package/models/schedule.d.ts
CHANGED
|
@@ -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
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@croffledev/croffle-types",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Croffle project type definitions.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"url": "https://github.com/team-croffle"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@types/node": "^26.
|
|
34
|
+
"@types/node": "^26.6.6"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/node": "^26.1.2",
|
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
|
-
}
|