@elite-dangerous-plugin-framework/core 0.0.1-pre1
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 +3 -0
- package/dist/_virtual/rolldown_runtime.js +18 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/v1alpha/context.d.ts +125 -0
- package/dist/v1alpha/element.d.ts +21 -0
- package/dist/v1alpha/element.js +15 -0
- package/dist/v1alpha/element.js.map +1 -0
- package/dist/v1alpha/index.d.ts +12 -0
- package/dist/v1alpha/index.js +12 -0
- package/dist/v1alpha/index.js.map +1 -0
- package/dist/v1alpha/journalEvent.d.ts +19 -0
- package/dist/v1alpha/manifest.d.ts +15 -0
- package/dist/v1alpha/settingsContext.d.ts +51 -0
- package/package.json +29 -0
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) {
|
|
6
|
+
__defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
if (symbols) {
|
|
12
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
13
|
+
}
|
|
14
|
+
return target;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { __exportAll };
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { JournalEventItemV1Alpha } from "./journalEvent.js";
|
|
2
|
+
import { PluginManifestV1AlphaWithId } from "./manifest.js";
|
|
3
|
+
|
|
4
|
+
//#region src/v1alpha/context.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* When subscribing to Listeners, you get back a function that you must invoke to stop listening.
|
|
7
|
+
* It is the caller's responsibility to do so.
|
|
8
|
+
*/
|
|
9
|
+
type Destructor = () => void;
|
|
10
|
+
/**
|
|
11
|
+
* This is the main object your Plugin interacts with EDPF
|
|
12
|
+
*
|
|
13
|
+
* You can subscribe to events, requests specific Procedures (e.g requesting entire current journal file) (based on what your permissions allow)
|
|
14
|
+
*/
|
|
15
|
+
interface PluginContextV1Alpha {
|
|
16
|
+
/**
|
|
17
|
+
* ## Used to receive Journal Events
|
|
18
|
+
*
|
|
19
|
+
* Pass a callback into this method. The Callback will be invoked each time a Journal Event is received.
|
|
20
|
+
*
|
|
21
|
+
* Note that EDPF does Event batching, meaining you receive a List of Events if they happen in very quick succession.
|
|
22
|
+
*
|
|
23
|
+
* This can be called multiple times. On call, you get back a destructor that should be invoked to unregister.
|
|
24
|
+
*/
|
|
25
|
+
registerEventListener(callback: (events: JournalEventItemV1Alpha[]) => void): Destructor;
|
|
26
|
+
/**
|
|
27
|
+
* ## Used to block shutdown for cleanup tasks
|
|
28
|
+
*
|
|
29
|
+
* If your Plugin requires some form of cleanup / finalizing, register a shutdown listener here.
|
|
30
|
+
* When stopping a Plugin, the Context will **wait up to a second** for you to finish cleanup.
|
|
31
|
+
*
|
|
32
|
+
* Cleanup is considered finished **when the Promise returns**. The callback is invoked once only
|
|
33
|
+
*
|
|
34
|
+
* This can be called multiple times. On call, you get back a destructor that should be invoked to unregister.
|
|
35
|
+
*/
|
|
36
|
+
registerShutdownListener(callback: () => Promise<void>): Destructor;
|
|
37
|
+
/**
|
|
38
|
+
* ## Used to open a URL in the User's browser
|
|
39
|
+
*
|
|
40
|
+
* Note that using a `<a href="…"/>` is not possible as that would cause In-Webview navigation. Instead, you have to instruct the OS to open the resource outside the webview.
|
|
41
|
+
* This Command does just that. Do note that only the `http` and `https` protocols are supported.
|
|
42
|
+
*
|
|
43
|
+
* This action is considered a Safe action and is accessible to all plugins without additional permissions
|
|
44
|
+
*/
|
|
45
|
+
openUrl(url: string): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* ## Request a reread of the current Journal
|
|
48
|
+
*
|
|
49
|
+
* This will replay all open Journals (one per CMDR), which should get the plugin up to speed on the current state.
|
|
50
|
+
*
|
|
51
|
+
* @returns a mapping containing CMDR Names as the Key and the entire file's events until this point in time within the Batch.
|
|
52
|
+
*/
|
|
53
|
+
rereadCurrentJournals(): Promise<Record<string, JournalEventItemV1Alpha[]>>;
|
|
54
|
+
/**
|
|
55
|
+
* This is useful for writing plugins in a more abstract manner. (e.g. not hardcoding settings keys).
|
|
56
|
+
* The property exposes the Plugin Manifest
|
|
57
|
+
*/
|
|
58
|
+
get pluginMeta(): PluginManifestV1AlphaWithId;
|
|
59
|
+
/**
|
|
60
|
+
* Your Plugin is exposed via an asset server that is running on localhost. The Port is not stable. Use this readonly property to get the base URL.
|
|
61
|
+
*
|
|
62
|
+
* You can then append the path to the file, relative to the `frontend` folder. Do note that relative escapes out of the `frontend` folder are not supported.
|
|
63
|
+
*
|
|
64
|
+
* `assetsBase` has always a `/` as a suffix.
|
|
65
|
+
*/
|
|
66
|
+
get assetsBase(): string;
|
|
67
|
+
/**
|
|
68
|
+
* Accessing Settings, as well as any non-default Methods, is done via the capabilities object
|
|
69
|
+
*/
|
|
70
|
+
get Capabilities(): PluginContextV1AlphaCapabilities;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Interacting with EDPF beyond the usual receiving of journal events is done with the help of **Capabilities**.
|
|
74
|
+
*
|
|
75
|
+
* There is a set of default capabilities that are deemed safe to use and sensible defaults. There are however also more complex cases that require more access to the user's system.
|
|
76
|
+
* A plugin has to advertise its need to for these capabilities. It can do so via it's manifest file.
|
|
77
|
+
*
|
|
78
|
+
* When using non-standard capabilities, a User is prompted / warned the first time they try to run the plugin.
|
|
79
|
+
*/
|
|
80
|
+
interface PluginContextV1AlphaCapabilities {
|
|
81
|
+
/**
|
|
82
|
+
* **Enabled by default**
|
|
83
|
+
*
|
|
84
|
+
* always present, used to read and write settings.
|
|
85
|
+
*/
|
|
86
|
+
get Settings(): PluginContextV1AlphaCapabilitiesSettings;
|
|
87
|
+
}
|
|
88
|
+
interface PluginContextV1AlphaCapabilitiesSettings {
|
|
89
|
+
/**
|
|
90
|
+
* ## Write a setting for this plugin
|
|
91
|
+
*
|
|
92
|
+
* You can also push settings outside the Settings UI. Use this function to write a key / value pair.
|
|
93
|
+
*
|
|
94
|
+
* This is what you should look out for:
|
|
95
|
+
* - The key contains segments, separated by a dot (.)
|
|
96
|
+
* - You need at least 2 Segments
|
|
97
|
+
* - the first segment **MUST** be your plugin ID
|
|
98
|
+
* - the last segment determines if this is a "public" setting. If it starts uppercase, it is readable by every plugin
|
|
99
|
+
* - `myPlugin.some.key` is private. Only your own plugin can read and edit it and get notified about it
|
|
100
|
+
* - `myPlugin.some.Key` is public. You can read and edit it, other plugins can read it
|
|
101
|
+
*/
|
|
102
|
+
writeSetting<T>(key: string, value: undefined | T): Promise<undefined | T>;
|
|
103
|
+
/**
|
|
104
|
+
* ## Fetches a setting by Key.
|
|
105
|
+
* See Docs for {@link writeSetting()} for key structure
|
|
106
|
+
*
|
|
107
|
+
* Return the setting if present, undefined if it doesnt exist.
|
|
108
|
+
* Throws an error if you are not allowed to access this setting
|
|
109
|
+
*/
|
|
110
|
+
getSetting<T>(key: string): Promise<T | undefined>;
|
|
111
|
+
/**
|
|
112
|
+
* ## Used to listen for Settings
|
|
113
|
+
*
|
|
114
|
+
* Any plugin may listen for its own and other plugins changing their settings
|
|
115
|
+
*
|
|
116
|
+
* Do note that only keys where the last segment starts with an **Uppercase** char will be propagated here, except if the setting key is from your own plugin. This only gives you the key. If you wish the get the value, you should invoke {@link getSetting}
|
|
117
|
+
*
|
|
118
|
+
* This function can be called multiple times. **Each call gives you back an unlistener. Invoke it for clean up**. Callbacks are cleaned up automatically on Plugin shutdown.
|
|
119
|
+
*
|
|
120
|
+
*/
|
|
121
|
+
registerSettingsChangedListener(callback: (key: string, value: unknown) => void): Destructor;
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
export { Destructor, PluginContextV1Alpha, PluginContextV1AlphaCapabilitiesSettings };
|
|
125
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PluginContextV1Alpha } from "./context.js";
|
|
2
|
+
import { PluginSettingsContextV1Alpha } from "./settingsContext.js";
|
|
3
|
+
|
|
4
|
+
//#region src/v1alpha/element.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Inherit from this class for your Plugin definition if your manifest defines `v1alpha` as the type!
|
|
7
|
+
*/
|
|
8
|
+
declare abstract class EDPFPluginElementV1Alpha extends HTMLElement {
|
|
9
|
+
abstract initPlugin(ctx: PluginContextV1Alpha): void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Inherit from this class for your Plugin **Settings** definition if your manifest defines `v1alpha` as the type!
|
|
13
|
+
*
|
|
14
|
+
* Note that the settings element is stripped down and only contains the relevant methods to get and update secrets.
|
|
15
|
+
*/
|
|
16
|
+
declare abstract class EDPFPluginSettingsElementV1Alpha extends HTMLElement {
|
|
17
|
+
abstract initSettings(ctx: PluginSettingsContextV1Alpha): void;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { EDPFPluginElementV1Alpha, EDPFPluginSettingsElementV1Alpha };
|
|
21
|
+
//# sourceMappingURL=element.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/v1alpha/element.ts
|
|
2
|
+
/**
|
|
3
|
+
* Inherit from this class for your Plugin definition if your manifest defines `v1alpha` as the type!
|
|
4
|
+
*/
|
|
5
|
+
var EDPFPluginElementV1Alpha = class extends HTMLElement {};
|
|
6
|
+
/**
|
|
7
|
+
* Inherit from this class for your Plugin **Settings** definition if your manifest defines `v1alpha` as the type!
|
|
8
|
+
*
|
|
9
|
+
* Note that the settings element is stripped down and only contains the relevant methods to get and update secrets.
|
|
10
|
+
*/
|
|
11
|
+
var EDPFPluginSettingsElementV1Alpha = class extends HTMLElement {};
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { EDPFPluginElementV1Alpha, EDPFPluginSettingsElementV1Alpha };
|
|
15
|
+
//# sourceMappingURL=element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element.js","names":[],"sources":["../../src/v1alpha/element.ts"],"sourcesContent":["import { PluginContextV1Alpha } from \"./context.js\";\nimport { PluginSettingsContextV1Alpha } from \"./settingsContext.js\";\n\n/**\n * Inherit from this class for your Plugin definition if your manifest defines `v1alpha` as the type!\n */\nexport abstract class EDPFPluginElementV1Alpha extends HTMLElement {\n public abstract initPlugin(ctx: PluginContextV1Alpha): void;\n}\n\n/**\n * Inherit from this class for your Plugin **Settings** definition if your manifest defines `v1alpha` as the type!\n *\n * Note that the settings element is stripped down and only contains the relevant methods to get and update secrets.\n */\nexport abstract class EDPFPluginSettingsElementV1Alpha extends HTMLElement {\n public abstract initSettings(ctx: PluginSettingsContextV1Alpha): void;\n}\n"],"mappings":";;;;AAMA,IAAsB,2BAAtB,cAAuD,YAAY;;;;;;AASnE,IAAsB,mCAAtB,cAA+D,YAAY"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { JournalEventItemV1Alpha } from "./journalEvent.js";
|
|
2
|
+
import { PluginContextV1Alpha } from "./context.js";
|
|
3
|
+
import { PluginSettingsContextV1Alpha } from "./settingsContext.js";
|
|
4
|
+
import { EDPFPluginElementV1Alpha, EDPFPluginSettingsElementV1Alpha } from "./element.js";
|
|
5
|
+
|
|
6
|
+
//#region src/v1alpha/index.d.ts
|
|
7
|
+
declare namespace index_d_exports {
|
|
8
|
+
export { EDPFPluginElementV1Alpha, EDPFPluginSettingsElementV1Alpha, JournalEventItemV1Alpha, PluginContextV1Alpha, PluginSettingsContextV1Alpha };
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { EDPFPluginElementV1Alpha, EDPFPluginSettingsElementV1Alpha, type JournalEventItemV1Alpha, type PluginContextV1Alpha, type PluginSettingsContextV1Alpha, index_d_exports };
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { __exportAll } from "../_virtual/rolldown_runtime.js";
|
|
2
|
+
import { EDPFPluginElementV1Alpha, EDPFPluginSettingsElementV1Alpha } from "./element.js";
|
|
3
|
+
|
|
4
|
+
//#region src/v1alpha/index.ts
|
|
5
|
+
var v1alpha_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
+
EDPFPluginElementV1Alpha: () => EDPFPluginElementV1Alpha,
|
|
7
|
+
EDPFPluginSettingsElementV1Alpha: () => EDPFPluginSettingsElementV1Alpha
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { EDPFPluginElementV1Alpha, EDPFPluginSettingsElementV1Alpha, v1alpha_exports };
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/v1alpha/index.ts"],"sourcesContent":["export type { PluginContextV1Alpha } from \"./context.js\";\nexport type { PluginSettingsContextV1Alpha } from \"./settingsContext.js\";\nexport type { JournalEventItemV1Alpha } from \"./journalEvent.js\";\nexport {\n EDPFPluginElementV1Alpha,\n EDPFPluginSettingsElementV1Alpha,\n} from \"./element.js\";\n"],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/v1alpha/journalEvent.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* EDPF sends Journal Items as stringified JSON.
|
|
4
|
+
* EDPF does a bit of buffering to reduce the amount of internal events being sent.
|
|
5
|
+
*
|
|
6
|
+
* As of 2025-11, this buffering is based on two timers:
|
|
7
|
+
* - a soft-resettable 0.1s (if a new event drops in, the timer resets)
|
|
8
|
+
* - a hard cap at 0.5s
|
|
9
|
+
*
|
|
10
|
+
* Events are guaranteed to be sorted as they are found in the journal.
|
|
11
|
+
*/
|
|
12
|
+
interface JournalEventItemV1Alpha {
|
|
13
|
+
cmdr: string;
|
|
14
|
+
file: string;
|
|
15
|
+
event: string;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { JournalEventItemV1Alpha };
|
|
19
|
+
//# sourceMappingURL=journalEvent.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/v1alpha/manifest.d.ts
|
|
2
|
+
interface PluginManifestV1Alpha {
|
|
3
|
+
type: "v1alpha";
|
|
4
|
+
name: string;
|
|
5
|
+
description?: string | null | undefined;
|
|
6
|
+
repository_url?: string | null | undefined;
|
|
7
|
+
support_url?: string | null | undefined;
|
|
8
|
+
version?: string | null | undefined;
|
|
9
|
+
}
|
|
10
|
+
type PluginManifestV1AlphaWithId = PluginManifestV1Alpha & {
|
|
11
|
+
id: string;
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { PluginManifestV1AlphaWithId };
|
|
15
|
+
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { PluginManifestV1AlphaWithId } from "./manifest.js";
|
|
2
|
+
import { Destructor, PluginContextV1AlphaCapabilitiesSettings } from "./context.js";
|
|
3
|
+
|
|
4
|
+
//#region src/v1alpha/settingsContext.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* The settings context. This is trimmed down and does not get any Journal updates. You only get access to read and write Settings here, plus get the assetsBase so you can load images / stylesheets.
|
|
7
|
+
*/
|
|
8
|
+
interface PluginSettingsContextV1Alpha {
|
|
9
|
+
/**
|
|
10
|
+
* **Enabled by default**
|
|
11
|
+
*
|
|
12
|
+
* always present, used to read and write settings.
|
|
13
|
+
*/
|
|
14
|
+
get Settings(): PluginContextV1AlphaCapabilitiesSettings;
|
|
15
|
+
/**
|
|
16
|
+
* Your Plugin is exposed via an asset server that is running on localhost. The Port is not stable. Use this readonly property to get the base URL.
|
|
17
|
+
*
|
|
18
|
+
* You can then append the path to the file, relative to the `frontend` folder. Do note that relative escapes out of the `frontend` folder are not supported.
|
|
19
|
+
*
|
|
20
|
+
* `assetsBase` has always a `/` as a suffix.
|
|
21
|
+
*/
|
|
22
|
+
get assetsBase(): string;
|
|
23
|
+
/**
|
|
24
|
+
* This is useful for writing plugins in a more abstract manner. (e.g. not hardcoding settings keys).
|
|
25
|
+
* The property exposes the Plugin Manifest
|
|
26
|
+
*/
|
|
27
|
+
get pluginMeta(): PluginManifestV1AlphaWithId;
|
|
28
|
+
/**
|
|
29
|
+
* ## Used to block shutdown for cleanup tasks
|
|
30
|
+
*
|
|
31
|
+
* If your Plugin requires some form of cleanup / finalizing, register a shutdown listener here.
|
|
32
|
+
* When stopping a Plugin, the Context will **wait up to a second** for you to finish cleanup.
|
|
33
|
+
*
|
|
34
|
+
* Cleanup is considered finished **when the Promise returns**. The callback is invoked once only
|
|
35
|
+
*
|
|
36
|
+
* This can be called multiple times. On call, you get back a destructor that should be invoked to unregister.
|
|
37
|
+
*/
|
|
38
|
+
registerShutdownListener(callback: () => Promise<void>): Destructor;
|
|
39
|
+
/**
|
|
40
|
+
* ## Used to open a URL in the User's browser
|
|
41
|
+
*
|
|
42
|
+
* Note that using a `<a href="…"/>` is not possible as that would cause In-Webview navigation. Instead, you have to instruct the OS to open the resource outside the webview.
|
|
43
|
+
* This Command does just that. Do note that only the `http` and `https` protocols are supported.
|
|
44
|
+
*
|
|
45
|
+
* This action is considered a Safe action and is accessible to all plugins without additional permissions
|
|
46
|
+
*/
|
|
47
|
+
openUrl(url: string): Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { PluginSettingsContextV1Alpha };
|
|
51
|
+
//# sourceMappingURL=settingsContext.d.ts.map
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"private": false,
|
|
3
|
+
"name": "@elite-dangerous-plugin-framework/core",
|
|
4
|
+
"description": "Core Plugin Library for Elite: Dangerous Plugin Framework. This provides mostly types and helpers to interact with EDPF, as well as an abstraction layer around the HTMLElement used by plugins.",
|
|
5
|
+
"workspaces": [
|
|
6
|
+
"packages/*"
|
|
7
|
+
],
|
|
8
|
+
"type": "module",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsdown",
|
|
15
|
+
"pretty": "prettier src -w"
|
|
16
|
+
},
|
|
17
|
+
"types": "dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": "./dist/index.js",
|
|
20
|
+
"./v1alpha": "./dist/v1alpha/index.js",
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"provenance": false,
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"version": "0.0.1-pre1",
|
|
28
|
+
"gitHead": "c7919bb37e1b55eadd413bd0e8ceda64adabdf23"
|
|
29
|
+
}
|