@vicinae/api 0.16.1 → 0.16.3
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/dist/api/bus.d.ts +5 -0
- package/dist/api/cache.js +5 -4
- package/dist/api/color.d.ts +2 -1
- package/dist/api/color.js +48 -3
- package/dist/api/components/action-pannel.d.ts +3 -3
- package/dist/api/components/action-pannel.js +4 -2
- package/dist/api/components/actions.d.ts +10 -1
- package/dist/api/components/actions.js +13 -1
- package/dist/api/components/dropdown.d.ts +1 -1
- package/dist/api/components/dropdown.js +3 -1
- package/dist/api/components/empty-view.js +4 -2
- package/dist/api/components/form.d.ts +16 -2
- package/dist/api/components/form.js +28 -4
- package/dist/api/components/grid.d.ts +8 -19
- package/dist/api/components/grid.js +32 -2
- package/dist/api/components/list.d.ts +22 -3
- package/dist/api/components/list.js +49 -2
- package/dist/api/components/metadata.d.ts +1 -1
- package/dist/api/components/metadata.js +5 -1
- package/dist/api/components/tag.d.ts +2 -2
- package/dist/api/components/tag.js +4 -3
- package/dist/api/context/navigation-provider.js +1 -4
- package/dist/api/environment.d.ts +4 -0
- package/dist/api/image.d.ts +7 -5
- package/dist/api/image.js +4 -0
- package/dist/api/oauth.d.ts +3 -8
- package/dist/api/oauth.js +51 -21
- package/dist/api/proto/application.d.ts +10 -0
- package/dist/api/proto/application.js +150 -3
- package/dist/api/proto/daemon.d.ts +4 -1
- package/dist/api/proto/daemon.js +71 -16
- package/dist/api/proto/manager.d.ts +2 -0
- package/dist/api/proto/manager.js +32 -0
- package/dist/api/proto/oauth.d.ts +42 -0
- package/dist/api/proto/oauth.js +620 -5
- package/dist/api/proto/ui.d.ts +12 -1
- package/dist/api/proto/ui.js +164 -9
- package/dist/api/proto/wm.d.ts +20 -0
- package/dist/api/proto/wm.js +291 -7
- package/dist/api/utils.d.ts +43 -0
- package/dist/api/utils.js +24 -1
- package/dist/api/window-management.d.ts +29 -0
- package/dist/api/window-management.js +17 -0
- package/dist/commands/build/index.js +5 -2
- package/dist/commands/develop/index.js +7 -2
- package/dist/schemas/manifest.d.ts +255 -5
- package/dist/schemas/manifest.js +202 -4
- package/dist/utils/extension-types.d.ts +14 -0
- package/dist/utils/extension-types.js +162 -0
- package/package.json +1 -1
- package/types/jsx.d.ts +54 -33
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateExtensionTypes = updateExtensionTypes;
|
|
4
|
+
exports.createExtensionTypes = createExtensionTypes;
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
/**
|
|
8
|
+
* Generates and updates the extension types file in the specified directory
|
|
9
|
+
*/
|
|
10
|
+
function updateExtensionTypes(manifest, outDir) {
|
|
11
|
+
const content = createExtensionTypes(manifest);
|
|
12
|
+
const envPath = (0, node_path_1.join)(outDir, "vicinae-env.d.ts");
|
|
13
|
+
(0, node_fs_1.writeFileSync)(envPath, content);
|
|
14
|
+
return { envPath };
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Generates TypeScript type definitions from a manifest (package.json)
|
|
18
|
+
*/
|
|
19
|
+
function createExtensionTypes(manifest) {
|
|
20
|
+
const extPrefs = generateExtensionPreferences(manifest);
|
|
21
|
+
const cmdPrefs = generateCommandPreferences(manifest);
|
|
22
|
+
const argTypes = generateCommandArguments(manifest);
|
|
23
|
+
return `
|
|
24
|
+
/// <reference types="@vicinae/api">
|
|
25
|
+
|
|
26
|
+
/*
|
|
27
|
+
* This file is auto-generated from the extension's manifest.
|
|
28
|
+
* Do not modify manually. Instead, update the \`package.json\` file.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
type ExtensionPreferences = {
|
|
32
|
+
${extPrefs}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
declare type Preferences = ExtensionPreferences
|
|
36
|
+
|
|
37
|
+
declare namespace Preferences {
|
|
38
|
+
${cmdPrefs}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
declare namespace Arguments {
|
|
42
|
+
${argTypes}
|
|
43
|
+
}
|
|
44
|
+
`.trim();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Generates TypeScript type definitions for extension preferences
|
|
48
|
+
*/
|
|
49
|
+
function generateExtensionPreferences(manifest) {
|
|
50
|
+
if (!manifest.preferences) {
|
|
51
|
+
return "";
|
|
52
|
+
}
|
|
53
|
+
const extPrefs = [];
|
|
54
|
+
for (const pref of manifest.preferences) {
|
|
55
|
+
let prefText = generateDocComment(pref.title, pref.description);
|
|
56
|
+
if (prefText) {
|
|
57
|
+
prefText += "\n\t";
|
|
58
|
+
}
|
|
59
|
+
prefText += `"${pref.name}"${pref.required ? "?" : ""}: ${getPreferenceType(pref)};`;
|
|
60
|
+
extPrefs.push(prefText);
|
|
61
|
+
}
|
|
62
|
+
return extPrefs.join("\n").trim();
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Generates a JSDoc comment string for a preference or argument
|
|
66
|
+
*/
|
|
67
|
+
function generateDocComment(title, description) {
|
|
68
|
+
if (!title && !description) {
|
|
69
|
+
return "";
|
|
70
|
+
}
|
|
71
|
+
const content = [title, description].filter(Boolean).join(" - ");
|
|
72
|
+
return `\n\t/** ${content.trim()} */`;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Generates a TypeScript type string for a preference value
|
|
76
|
+
*/
|
|
77
|
+
function getPreferenceType(pref) {
|
|
78
|
+
if (pref.type === "checkbox") {
|
|
79
|
+
return "boolean";
|
|
80
|
+
}
|
|
81
|
+
if (pref.type === "dropdown" &&
|
|
82
|
+
Array.isArray(pref.data) &&
|
|
83
|
+
pref.data.length > 0) {
|
|
84
|
+
// Build a union type from the 'value' fields for dropdowns
|
|
85
|
+
const unionValues = pref.data
|
|
86
|
+
.map((option) => typeof option.value === "string" ? `"${option.value}"` : undefined)
|
|
87
|
+
.filter((v) => !!v)
|
|
88
|
+
.join(" | ");
|
|
89
|
+
return unionValues || "string";
|
|
90
|
+
}
|
|
91
|
+
return "string";
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Generates TypeScript type definitions for command preferences
|
|
95
|
+
*/
|
|
96
|
+
function generateCommandPreferences(manifest) {
|
|
97
|
+
const cmdPrefs = [];
|
|
98
|
+
for (const cmd of manifest.commands) {
|
|
99
|
+
const prefix = generateDocComment(`Command: ${cmd.title}`) +
|
|
100
|
+
`\n\texport type ${toPascalCase(cmd.name)} = ExtensionPreferences & {`;
|
|
101
|
+
const prefs = [];
|
|
102
|
+
for (const pref of cmd.preferences ?? []) {
|
|
103
|
+
let prefText = "";
|
|
104
|
+
const docComment = generateDocComment(pref.title, pref.description);
|
|
105
|
+
if (docComment) {
|
|
106
|
+
prefText = `\n\t\t${docComment.trim()}\n\t\t`;
|
|
107
|
+
}
|
|
108
|
+
prefText += `"${pref.name}"${pref.required ? "?" : ""}: ${getPreferenceType(pref)};`;
|
|
109
|
+
prefs.push(prefText);
|
|
110
|
+
}
|
|
111
|
+
cmdPrefs.push(`${prefix}\n\t\t${prefs.join("\n").trim()}\n\t}`);
|
|
112
|
+
}
|
|
113
|
+
return cmdPrefs.join("\n").trim();
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Generates TypeScript type definitions for command arguments
|
|
117
|
+
*/
|
|
118
|
+
function generateCommandArguments(manifest) {
|
|
119
|
+
const cmdArgs = [];
|
|
120
|
+
for (const cmd of manifest.commands) {
|
|
121
|
+
const prefix = generateDocComment(`Command: ${cmd.title}`) +
|
|
122
|
+
`\n\texport type ${toPascalCase(cmd.name)} = {`;
|
|
123
|
+
const args = [];
|
|
124
|
+
for (const arg of cmd.arguments ?? []) {
|
|
125
|
+
const docComment = generateDocComment(arg.placeholder);
|
|
126
|
+
let argText = `\n\t\t${docComment.trim()}\n\t\t`;
|
|
127
|
+
argText += `"${arg.name}"${arg.required ? "?" : ""}: ${getArgumentType(arg)}`;
|
|
128
|
+
args.push(argText);
|
|
129
|
+
}
|
|
130
|
+
cmdArgs.push(`${prefix}\n\t\t${args.join("\n").trim()}\n\t}`);
|
|
131
|
+
}
|
|
132
|
+
return cmdArgs.join("\n").trim();
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Generates a TypeScript type string for an argument value
|
|
136
|
+
*/
|
|
137
|
+
function getArgumentType(arg) {
|
|
138
|
+
if (arg.type === "dropdown" &&
|
|
139
|
+
Array.isArray(arg.data) &&
|
|
140
|
+
arg.data.length > 0) {
|
|
141
|
+
// Build a union type from the 'value' fields
|
|
142
|
+
const unionValues = arg.data
|
|
143
|
+
.map((option) => typeof option.value === "string" ? `"${option.value}"` : undefined)
|
|
144
|
+
.filter((v) => !!v)
|
|
145
|
+
.join(" | ");
|
|
146
|
+
if (unionValues) {
|
|
147
|
+
return unionValues;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return "string";
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Converts a string to PascalCase
|
|
154
|
+
*/
|
|
155
|
+
function toPascalCase(str) {
|
|
156
|
+
return str
|
|
157
|
+
.replace(/([a-z])([A-Z])/g, "$1 $2") // Splits camelCase words into separate words
|
|
158
|
+
.replace(/[-_]+|[^\p{L}\p{N}]/gu, " ") // Replaces dashes, underscores, and special characters with spaces
|
|
159
|
+
.toLowerCase() // Converts the entire string to lowercase
|
|
160
|
+
.replace(/(?:^|\s)(\p{L})/gu, (_, letter) => letter.toUpperCase()) // Capitalizes the first letter of each word
|
|
161
|
+
.replace(/\s+/g, ""); // Removes all spaces
|
|
162
|
+
}
|
package/package.json
CHANGED
package/types/jsx.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import type {
|
|
3
|
+
DatePickerType,
|
|
4
|
+
Grid,
|
|
5
|
+
Keyboard,
|
|
6
|
+
List,
|
|
7
|
+
Quicklink,
|
|
8
|
+
SerializedColorLike,
|
|
9
|
+
SerializedImageLike,
|
|
10
|
+
} from "../src";
|
|
11
11
|
|
|
12
12
|
type BaseFormField = {
|
|
13
13
|
onBlur?: Function;
|
|
@@ -18,6 +18,9 @@ type BaseFormField = {
|
|
|
18
18
|
declare module "react" {
|
|
19
19
|
namespace JSX {
|
|
20
20
|
interface IntrinsicElements {
|
|
21
|
+
view: {
|
|
22
|
+
children: React.ReactNode;
|
|
23
|
+
};
|
|
21
24
|
detail: {
|
|
22
25
|
navigationTitle?: string;
|
|
23
26
|
markdown: string;
|
|
@@ -41,18 +44,24 @@ declare module "react" {
|
|
|
41
44
|
title: string;
|
|
42
45
|
id?: string;
|
|
43
46
|
subtitle?: string;
|
|
44
|
-
icon?:
|
|
47
|
+
icon?:
|
|
48
|
+
| SerializedImageLike
|
|
49
|
+
| {
|
|
50
|
+
value?: SerializedImageLike | null;
|
|
51
|
+
tooltip: string;
|
|
52
|
+
};
|
|
45
53
|
keywords?: string[];
|
|
46
|
-
|
|
54
|
+
accessories?: List.Item.SerializedAccessory[];
|
|
55
|
+
children?: React.ReactNode;
|
|
47
56
|
};
|
|
48
|
-
"list-item-detail":
|
|
57
|
+
"list-item-detail": List.Item.Detail.Props;
|
|
49
58
|
"list-item-detail-metadata": any;
|
|
50
59
|
|
|
51
60
|
grid: {
|
|
52
61
|
inset?: Grid.Inset;
|
|
53
62
|
columns?: number;
|
|
54
63
|
fit: Grid.Fit;
|
|
55
|
-
aspectRatio:
|
|
64
|
+
aspectRatio: number;
|
|
56
65
|
|
|
57
66
|
children?: React.ReactNode;
|
|
58
67
|
filtering?: boolean;
|
|
@@ -67,7 +76,7 @@ declare module "react" {
|
|
|
67
76
|
inset?: Grid.Inset;
|
|
68
77
|
columns?: number;
|
|
69
78
|
fit?: Grid.Fit;
|
|
70
|
-
aspectRatio?:
|
|
79
|
+
aspectRatio?: number;
|
|
71
80
|
|
|
72
81
|
title?: string;
|
|
73
82
|
subtitle?: string;
|
|
@@ -77,18 +86,21 @@ declare module "react" {
|
|
|
77
86
|
title?: string;
|
|
78
87
|
id?: string;
|
|
79
88
|
subtitle?: string;
|
|
80
|
-
content?:
|
|
81
|
-
|
|
82
|
-
| { color: ColorLike }
|
|
83
|
-
| { value: ImageLike; tooltip?: string };
|
|
89
|
+
content?: SerializedImageLike | { color: SerializedColorLike };
|
|
90
|
+
tooltip?: string;
|
|
84
91
|
keywords?: string[];
|
|
85
|
-
|
|
92
|
+
accessory?: {
|
|
93
|
+
icon?: SerializedImageLike;
|
|
94
|
+
tooltip?: string | null;
|
|
95
|
+
};
|
|
96
|
+
children?: React.ReactNode;
|
|
86
97
|
};
|
|
87
98
|
|
|
88
99
|
"empty-view": {
|
|
89
100
|
description?: string;
|
|
90
101
|
title?: string;
|
|
91
|
-
icon?:
|
|
102
|
+
icon?: SerializedImageLike;
|
|
103
|
+
children?: React.ReactNode;
|
|
92
104
|
};
|
|
93
105
|
metadata: {
|
|
94
106
|
children?: React.ReactNode;
|
|
@@ -96,7 +108,7 @@ declare module "react" {
|
|
|
96
108
|
"metadata-label": {
|
|
97
109
|
title: string;
|
|
98
110
|
text: string;
|
|
99
|
-
icon?:
|
|
111
|
+
icon?: SerializedImageLike;
|
|
100
112
|
};
|
|
101
113
|
"metadata-separator": {};
|
|
102
114
|
"metadata-link": {
|
|
@@ -110,7 +122,7 @@ declare module "react" {
|
|
|
110
122
|
};
|
|
111
123
|
"action-panel-submenu": {
|
|
112
124
|
title: string;
|
|
113
|
-
icon?:
|
|
125
|
+
icon?: SerializedImageLike;
|
|
114
126
|
onOpen?: () => void;
|
|
115
127
|
onSearchTextChange?: (text: string) => void;
|
|
116
128
|
children?: React.ReactNode;
|
|
@@ -123,8 +135,8 @@ declare module "react" {
|
|
|
123
135
|
title: string;
|
|
124
136
|
onAction: () => void;
|
|
125
137
|
onSubmit?: Function;
|
|
126
|
-
shortcut?: Keyboard.Shortcut;
|
|
127
|
-
icon?:
|
|
138
|
+
shortcut?: Keyboard.Shortcut | Keyboard.Shortcut.Common;
|
|
139
|
+
icon?: SerializedImageLike;
|
|
128
140
|
autoFocus?: boolean;
|
|
129
141
|
type?: string;
|
|
130
142
|
quicklink?: Quicklink;
|
|
@@ -135,7 +147,7 @@ declare module "react" {
|
|
|
135
147
|
};
|
|
136
148
|
"tag-item": {
|
|
137
149
|
color?: SerializedColorLike;
|
|
138
|
-
icon?:
|
|
150
|
+
icon?: SerializedImageLike;
|
|
139
151
|
text?: string;
|
|
140
152
|
onAction?: () => void;
|
|
141
153
|
};
|
|
@@ -154,14 +166,23 @@ declare module "react" {
|
|
|
154
166
|
"tag-picker-item": {
|
|
155
167
|
title: string;
|
|
156
168
|
value: string;
|
|
157
|
-
icon?:
|
|
169
|
+
icon?: SerializedImageLike;
|
|
158
170
|
};
|
|
159
171
|
"text-area-field": BaseFormField & {};
|
|
160
|
-
"file-picker-field": BaseFormField & {
|
|
172
|
+
"file-picker-field": BaseFormField & {
|
|
173
|
+
allowMultipleSelection?: boolean;
|
|
174
|
+
canChooseDirectories?: boolean;
|
|
175
|
+
canChooseFiles?: boolean;
|
|
176
|
+
showHiddenFiles?: boolean;
|
|
177
|
+
};
|
|
161
178
|
"dropdown-field": BaseFormField & {
|
|
162
|
-
children?: ReactNode;
|
|
179
|
+
children?: React.ReactNode;
|
|
180
|
+
};
|
|
181
|
+
"date-picker-field": BaseFormField & {
|
|
182
|
+
min?: Date;
|
|
183
|
+
max?: Date;
|
|
184
|
+
type?: DatePickerType;
|
|
163
185
|
};
|
|
164
|
-
"date-picker-field": {};
|
|
165
186
|
"checkbox-field": BaseFormField & {};
|
|
166
187
|
"password-field": {};
|
|
167
188
|
"textarea-field": {};
|
|
@@ -169,16 +190,16 @@ declare module "react" {
|
|
|
169
190
|
dropdown: {
|
|
170
191
|
onChange?: Function;
|
|
171
192
|
onSearchTextChange?: (text: string) => void;
|
|
172
|
-
children?: ReactNode;
|
|
193
|
+
children?: React.ReactNode;
|
|
173
194
|
};
|
|
174
195
|
"dropdown-section": {
|
|
175
196
|
title?: string;
|
|
176
|
-
children: ReactNode;
|
|
197
|
+
children: React.ReactNode;
|
|
177
198
|
};
|
|
178
199
|
"dropdown-item": {
|
|
179
200
|
title: string;
|
|
180
201
|
value: string;
|
|
181
|
-
icon?:
|
|
202
|
+
icon?: SerializedImageLike;
|
|
182
203
|
keywords?: string[];
|
|
183
204
|
};
|
|
184
205
|
|