@t3mode/plugin-sdk 0.0.0-stage → 1.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/LICENSE +21 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.js +4 -0
- package/package.json +26 -3
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Hezaerd
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export type LogLevel = "debug" | "info" | "warn" | "error";
|
|
2
|
+
export interface BooleanOption {
|
|
3
|
+
readonly type: "boolean";
|
|
4
|
+
readonly label: string;
|
|
5
|
+
readonly description?: string;
|
|
6
|
+
readonly default: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface SelectOption<V extends string = string> {
|
|
9
|
+
readonly type: "select";
|
|
10
|
+
readonly label: string;
|
|
11
|
+
readonly description?: string;
|
|
12
|
+
readonly choices: ReadonlyArray<{
|
|
13
|
+
readonly value: V;
|
|
14
|
+
readonly label: string;
|
|
15
|
+
}>;
|
|
16
|
+
readonly default: V;
|
|
17
|
+
}
|
|
18
|
+
export type OptionSpec = BooleanOption | SelectOption;
|
|
19
|
+
export type OptionsSpec = Readonly<Record<string, OptionSpec>>;
|
|
20
|
+
export type OptionValues<O extends OptionsSpec> = { readonly [K in keyof O]: O[K] extends SelectOption<infer V> ? V : boolean; };
|
|
21
|
+
/** Shown on the settings page next to each running plugin. */
|
|
22
|
+
export interface PluginReport {
|
|
23
|
+
readonly state: "active" | "waiting";
|
|
24
|
+
readonly detail: string;
|
|
25
|
+
}
|
|
26
|
+
export interface PluginApi<O extends OptionsSpec = OptionsSpec> {
|
|
27
|
+
/** The id from the plugin's manifest.json. */
|
|
28
|
+
readonly id: string;
|
|
29
|
+
readonly options: OptionValues<O>;
|
|
30
|
+
/** Adds a stylesheet, removed when the plugin stops. */
|
|
31
|
+
readonly css: (text: string) => void;
|
|
32
|
+
/** Runs `callback` now and after DOM changes and route changes, at most once per frame. */
|
|
33
|
+
readonly observe: (callback: () => void) => void;
|
|
34
|
+
readonly listen: <E extends Event = Event>(target: EventTarget, type: string, handler: (event: E) => void, options?: AddEventListenerOptions) => void;
|
|
35
|
+
readonly interval: (callback: () => void, ms: number) => void;
|
|
36
|
+
/** Creates an element owned by the plugin. It is removed when the plugin stops. */
|
|
37
|
+
readonly element: <K extends keyof HTMLElementTagNameMap>(tag: K) => HTMLElementTagNameMap[K];
|
|
38
|
+
readonly onCleanup: (cleanup: () => void) => void;
|
|
39
|
+
/** JSON in localStorage, namespaced to the plugin. Lives as long as T3 Code's own UI state. */
|
|
40
|
+
readonly storage: {
|
|
41
|
+
readonly get: <T>(key: string, fallback: T) => T;
|
|
42
|
+
readonly set: (key: string, value: unknown) => void;
|
|
43
|
+
};
|
|
44
|
+
readonly log: (level: LogLevel, message: string) => void;
|
|
45
|
+
readonly report: (report: PluginReport) => void;
|
|
46
|
+
/** The first element matching any of the selectors, tried in order: newest markup first. */
|
|
47
|
+
readonly queryFirst: <E extends Element = HTMLElement>(candidates: ReadonlyArray<string>) => E | null;
|
|
48
|
+
/** The thread on screen as T3 Code keys it, `<environmentId>:<threadId>`, or null off a thread. */
|
|
49
|
+
readonly currentThreadKey: (hash?: string) => string | null;
|
|
50
|
+
/**
|
|
51
|
+
* T3 Code's React state, read from the fiber React attaches to DOM nodes. Component names are
|
|
52
|
+
* minified, so lookups match on the shape of the data, and return undefined when it changed.
|
|
53
|
+
*/
|
|
54
|
+
readonly react: {
|
|
55
|
+
/** Props of the closest ancestor component (inclusive) whose props pass `test`. */
|
|
56
|
+
readonly findPropsUp: (node: Element, test: (props: Record<string, unknown>) => boolean, maxDepth?: number) => Record<string, unknown> | undefined;
|
|
57
|
+
/** The first hook state in the tree under the root of `node` that passes `test`. */
|
|
58
|
+
readonly findHookState: <T>(node: Element, test: (value: unknown) => value is T, budget?: number) => T | undefined;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export interface PluginDefinition<O extends OptionsSpec = OptionsSpec> {
|
|
62
|
+
readonly options: O;
|
|
63
|
+
/** Called on start and again after any option change (the plugin is restarted). */
|
|
64
|
+
start(api: PluginApi<O>): void;
|
|
65
|
+
}
|
|
66
|
+
/** Returns the definition unchanged, typing `api.options` from `options`. */
|
|
67
|
+
export declare const definePlugin: <const O extends OptionsSpec>(definition: PluginDefinition<O>) => PluginDefinition<O>;
|
package/dist/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t3mode/plugin-sdk",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "definePlugin and the plugin API types for t3mode, the plugin loader for T3 Code",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/Hezaerd/t3mode.git",
|
|
9
|
+
"directory": "packages/plugin-sdk"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"type": "module",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"vite-plus": "1.4.0"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "vp pack",
|
|
26
|
+
"typecheck": "effect-tsgo tsc --noEmit -p ."
|
|
27
|
+
},
|
|
28
|
+
"types": "./dist/index.d.ts"
|
|
6
29
|
}
|
package/README.md
DELETED