@shisho/plugin-types 0.0.10 → 0.0.11
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/global.d.ts +1 -1
- package/host-api.d.ts +79 -2
- package/package.json +1 -1
package/global.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ShishoPlugin } from "./hooks";
|
|
|
2
2
|
import { ShishoHostAPI } from "./host-api";
|
|
3
3
|
|
|
4
4
|
declare global {
|
|
5
|
-
/** Host API object providing logging, config, HTTP, filesystem, archive, XML, and
|
|
5
|
+
/** Host API object providing logging, config, HTTP, URL utilities, filesystem, archive, XML, FFmpeg, and shell access. */
|
|
6
6
|
var shisho: ShishoHostAPI;
|
|
7
7
|
/** Plugin object that defines hook implementations. */
|
|
8
8
|
var plugin: ShishoPlugin;
|
package/host-api.d.ts
CHANGED
|
@@ -42,12 +42,88 @@ export interface FetchResponse {
|
|
|
42
42
|
json(): unknown;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* HTTP client with domain whitelisting.
|
|
47
|
+
*
|
|
48
|
+
* Domain patterns in manifest httpAccess.domains:
|
|
49
|
+
* - Exact match: "example.com" only allows "example.com"
|
|
50
|
+
* - Wildcard: "*.example.com" allows "example.com", "api.example.com", "a.b.example.com"
|
|
51
|
+
*/
|
|
46
52
|
export interface ShishoHTTP {
|
|
47
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Fetch a URL. Domain must be declared in manifest httpAccess.domains.
|
|
55
|
+
* Supports wildcard patterns like "*.example.com" for subdomains.
|
|
56
|
+
*/
|
|
48
57
|
fetch(url: string, options?: FetchOptions): FetchResponse;
|
|
49
58
|
}
|
|
50
59
|
|
|
60
|
+
/** Parsed URL components from shisho.url.parse(). */
|
|
61
|
+
export interface ParsedURL {
|
|
62
|
+
/** The original URL string. */
|
|
63
|
+
href: string;
|
|
64
|
+
/** URL scheme without ":" (e.g., "https"). */
|
|
65
|
+
protocol: string;
|
|
66
|
+
/** Host including port if present (e.g., "example.com:8080"). */
|
|
67
|
+
host: string;
|
|
68
|
+
/** Hostname without port (e.g., "example.com"). */
|
|
69
|
+
hostname: string;
|
|
70
|
+
/** Port number as string, or empty if not specified. */
|
|
71
|
+
port: string;
|
|
72
|
+
/** Path component (e.g., "/path/to/resource"). */
|
|
73
|
+
pathname: string;
|
|
74
|
+
/** Query string with leading "?" or empty string. */
|
|
75
|
+
search: string;
|
|
76
|
+
/** Fragment with leading "#" or empty string. */
|
|
77
|
+
hash: string;
|
|
78
|
+
/** Username from URL, or empty string. */
|
|
79
|
+
username: string;
|
|
80
|
+
/** Password from URL, or empty string. */
|
|
81
|
+
password: string;
|
|
82
|
+
/** Parsed query parameters. Single values are strings, repeated keys are arrays. */
|
|
83
|
+
query: Record<string, string | string[]>;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* URL utilities that aren't available in Goja's ES5.1 runtime.
|
|
88
|
+
* Provides functionality similar to browser URLSearchParams and URL APIs.
|
|
89
|
+
*/
|
|
90
|
+
export interface ShishoURL {
|
|
91
|
+
/**
|
|
92
|
+
* Encode a string for use in URL query parameters.
|
|
93
|
+
* Similar to JavaScript's encodeURIComponent().
|
|
94
|
+
*/
|
|
95
|
+
encodeURIComponent(str: string): string;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Decode a URL-encoded string.
|
|
99
|
+
* Similar to JavaScript's decodeURIComponent().
|
|
100
|
+
*/
|
|
101
|
+
decodeURIComponent(str: string): string;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Convert an object to a URL query string.
|
|
105
|
+
* Keys are sorted alphabetically for deterministic output.
|
|
106
|
+
* Array values create multiple key=value pairs.
|
|
107
|
+
* Null/undefined values are skipped.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* shisho.url.searchParams({ q: "test", page: 1 }) // "page=1&q=test"
|
|
111
|
+
* shisho.url.searchParams({ tags: ["a", "b"] }) // "tags=a&tags=b"
|
|
112
|
+
*/
|
|
113
|
+
searchParams(params: Record<string, unknown>): string;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Parse a URL string into its components.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* const url = shisho.url.parse("https://api.example.com/search?q=test");
|
|
120
|
+
* url.hostname // "api.example.com"
|
|
121
|
+
* url.pathname // "/search"
|
|
122
|
+
* url.query.q // "test"
|
|
123
|
+
*/
|
|
124
|
+
parse(url: string): ParsedURL;
|
|
125
|
+
}
|
|
126
|
+
|
|
51
127
|
/** Filesystem operations (sandboxed). */
|
|
52
128
|
export interface ShishoFS {
|
|
53
129
|
/** Read file contents as ArrayBuffer. */
|
|
@@ -270,6 +346,7 @@ export interface ShishoHostAPI {
|
|
|
270
346
|
log: ShishoLog;
|
|
271
347
|
config: ShishoConfig;
|
|
272
348
|
http: ShishoHTTP;
|
|
349
|
+
url: ShishoURL;
|
|
273
350
|
fs: ShishoFS;
|
|
274
351
|
archive: ShishoArchive;
|
|
275
352
|
xml: ShishoXML;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shisho/plugin-types",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "TypeScript type definitions for Shisho plugin development",
|
|
5
5
|
"homepage": "https://github.com/shishobooks/shisho/blob/master/packages/plugin-types/README.md",
|
|
6
6
|
"types": "index.d.ts",
|