This repository was archived by the owner on Nov 19, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclipcc-extension.d.ts
More file actions
193 lines (163 loc) · 5.77 KB
/
clipcc-extension.d.ts
File metadata and controls
193 lines (163 loc) · 5.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/**
* @Copyright (c) 2020 Clipteam
* @Version 0.2.0
* @License MIT
*/
// TypeScript Support for ClipCC Extension API v1
declare module 'clipcc-extension' {
export namespace type {
export enum BlockType {
COMMAND = 1,
REPORTER = 2,
BOOLEAN = 3,
// BRANCH = 4, /* deleted */
HAT = 5
}
export enum ParameterType {
NUMBER = 1,
STRING = 2,
BOOLEAN = 3,
COLOR = 5,
MATRIX = 6,
NOTE = 7,
ANGLE = 8,
IMAGE = 99
}
export interface ExtensionInfo {
id: string;
version: string;
author: string | string[];
icon: string;
inset_icon: string;
api: number;
optional?: boolean;
dependency: { [key: string]: string };
}
export interface SettingsItemBoolean {
id: string;
type: "boolean";
default: boolean;
}
export interface SettingsItemNumber {
id: string;
type: "number";
default: number;
max?: number;
min?: number;
precision?: number;
}
export interface SettingsItemSelector {
id: string;
type: "selector";
default: string;
items: string[];
}
export type SettingsItem = SettingsItemBoolean | SettingsItemNumber | SettingsItemSelector;
export interface BlockPrototype {
opcode: string;
type: BlockType;
option?: BlockOption;
branchCount?: number;
param?: { [key: string]: ParameterPrototype };
messageId: string;
categoryId: string;
function: Function;
}
export interface BlockOption {
terminal?: boolean;
monitor?: boolean;
}
export interface ParameterPrototype {
type: ParameterType;
default?: any;
menu?: MenuItemPrototype[];
menuId?: string;
field?: boolean;
shadow?: ShadowPrototype;
}
export interface MenuItemPrototype {
messageId: string;
value: any;
}
export interface ShadowPrototype {
type: string;
fieldName: string;
}
export interface CategoryPrototype {
categoryId: string;
messageId: string;
color: string;
}
export type VmInstance = Object;
export type BlockInstance = Object;
export type GuiInstance = Object;
export type Project = Object;
}
export namespace api {
export function registExtensionAPI(api: Object): void;
export function addCategory(category: type.CategoryPrototype): void;
export function removeCategory(categoryId: string): void;
export function addBlock(block: type.BlockPrototype): void;
export function addBlocks(blocks: type.BlockPrototype[]): void;
export function removeBlock(opcode: string): void;
export function removeBlocks(opcodes: string[]): void;
export function getVmInstance(): type.VmInstance;
export function getGuiDocument(): Document;
export function getGuiInstance(): type.GuiInstance;
export function getBlockInstance(): type.BlockInstance;
export function getStageCanvas(): HTMLCanvasElement;
export function getSettings(id: string): any;
export function registerGlobalFunction(name: string, func: Function): void;
export function unregisterGlobalFunction(name: string): void;
export function callGlobalFunction(name: string, ...args: any[]): any;
export function migrateChangeBlock(targets: Object, srcBlockId: string, dstBlockId: string): void;
}
export namespace error {
const ERROR_UNAVAILABLE_EXTENSION = 0x90;
const ERROR_CIRCULAR_REQUIREMENT = 0x91;
}
export class MigrationHelper {
constructor();
addVersionMigration(srcVer: string, dstVer: string, migrationScript: Function): void;
migrationFromVersion(srcVer: string, dstVer: string, projectData: type.Project): void;
}
enum LoadMode {
UNLOAD = 0,
INITIATIVE_LOAD = 1,
PASSIVE_LOAD = 2
}
interface ExtensionLoadInfo {
id: string;
mode: LoadMode;
}
export class ExtensionManager {
constructor();
addInstance(id: string, info: type.ExtensionInfo, instance: Extension): void;
removeInstance(id: string): void;
getInstance(id: string): Extension;
getInfo(id: string): type.ExtensionInfo;
exist(id: string): boolean;
setLoadStatus(id: string, loadStatus: boolean): void;
getLoadStatus(id: string): boolean;
getLoadedExtensions(): string[];
loadExtensionsWithMode(extensions: ExtensionLoadInfo[], vmCallback: Function): void;
unloadExtensions(extensions: string[]);
getExtensionLoadOrder(extensions: string[]): ExtensionLoadInfo[];
getExtensionUnloadOrder(extensions: string[]): string[];
emitEventToExtension(id: string, event: string, ...args: any[]): void;
emitEventToAll(event: string, ...args): void;
emitEvent(event: string, ...args: any[]): void;
}
export const extensionManager: ExtensionManager;
export class Extension {
constructor();
onInit?(): void;
onUninit?(): void;
beforeProjectLoad?(data: any, extensions: any): void;
beforeProjectSave?(data: any): void;
}
export class CompatibleExtension extends Extension {
constructor();
onInit?(): void;
}
}