@croffledev/croffle-types 1.8.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 +39 -22
- package/api/calendar.d.ts +3 -3
- package/api/extensions.d.ts +1 -1
- package/api/http.d.ts +1 -1
- package/api/os.d.ts +5 -1
- package/api/settings.d.ts +1 -1
- package/api/ui.d.ts +1 -1
- package/croffle-api.d.ts +11 -11
- package/index.d.ts +17 -17
- package/models/schedule.d.ts +1 -1
- package/models/search.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -34,43 +34,60 @@ pnpm add -D @croffledev/croffle-types
|
|
|
34
34
|
|
|
35
35
|
## 🛠️ Usage
|
|
36
36
|
|
|
37
|
-
###
|
|
37
|
+
### Extension entry
|
|
38
38
|
|
|
39
|
-
|
|
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 {
|
|
42
|
+
import type { ExtensionContext } from '@croffledev/croffle-types';
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
name: 'MyAwesomePlugin',
|
|
46
|
-
version: '1.0.0',
|
|
44
|
+
let detachMenu: (() => void) | null = null;
|
|
47
45
|
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
53
|
-
|
|
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
|
|
58
|
+
export function deactivated() {
|
|
59
|
+
detachMenu?.();
|
|
60
|
+
}
|
|
58
61
|
```
|
|
59
62
|
|
|
60
|
-
###
|
|
63
|
+
### Manifest context menus
|
|
61
64
|
|
|
62
|
-
|
|
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
|
|
69
|
-
|
|
|
70
|
-
| `
|
|
71
|
-
| `
|
|
72
|
-
| `
|
|
73
|
-
| `
|
|
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[]>;
|
package/api/extensions.d.ts
CHANGED
package/api/http.d.ts
CHANGED
package/api/os.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import type {
|
|
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
package/api/ui.d.ts
CHANGED
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';
|
package/models/schedule.d.ts
CHANGED
package/models/search.d.ts
CHANGED