@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 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;
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';
@@ -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.8.0",
3
+ "version": "1.8.1",
4
4
  "description": "Croffle project type definitions.",
5
5
  "license": "MIT",
6
6
  "type": "module",