@jay-framework/editor-protocol 0.9.0 → 0.11.0
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/index.d.ts +119 -5
- package/dist/index.js +15 -0
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -31,6 +31,9 @@ interface HasImageMessage extends BaseMessage<HasImageResponse> {
|
|
|
31
31
|
type: 'hasImage';
|
|
32
32
|
imageId: string;
|
|
33
33
|
}
|
|
34
|
+
interface GetProjectInfoMessage extends BaseMessage<GetProjectInfoResponse> {
|
|
35
|
+
type: 'getProjectInfo';
|
|
36
|
+
}
|
|
34
37
|
interface PublishResponse extends BaseResponse {
|
|
35
38
|
type: 'publish';
|
|
36
39
|
status: {
|
|
@@ -52,8 +55,115 @@ interface HasImageResponse extends BaseResponse {
|
|
|
52
55
|
exists: boolean;
|
|
53
56
|
imageUrl?: string;
|
|
54
57
|
}
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
interface ProjectPage {
|
|
59
|
+
name: string;
|
|
60
|
+
url: string;
|
|
61
|
+
filePath: string;
|
|
62
|
+
contractSchema?: ContractSchema;
|
|
63
|
+
usedComponents: {
|
|
64
|
+
appName: string;
|
|
65
|
+
componentName: string;
|
|
66
|
+
key: string;
|
|
67
|
+
}[];
|
|
68
|
+
}
|
|
69
|
+
interface ProjectComponent {
|
|
70
|
+
name: string;
|
|
71
|
+
filePath: string;
|
|
72
|
+
contractPath?: string;
|
|
73
|
+
}
|
|
74
|
+
interface StaticContractDef {
|
|
75
|
+
name: string;
|
|
76
|
+
contract: string;
|
|
77
|
+
component: string;
|
|
78
|
+
description?: string;
|
|
79
|
+
}
|
|
80
|
+
interface DynamicContractDef {
|
|
81
|
+
prefix: string;
|
|
82
|
+
component: string;
|
|
83
|
+
generator: string;
|
|
84
|
+
}
|
|
85
|
+
interface PluginManifest {
|
|
86
|
+
name: string;
|
|
87
|
+
module?: string;
|
|
88
|
+
contracts?: StaticContractDef[];
|
|
89
|
+
dynamic_contracts?: DynamicContractDef;
|
|
90
|
+
}
|
|
91
|
+
interface Plugin {
|
|
92
|
+
manifest: PluginManifest;
|
|
93
|
+
location: {
|
|
94
|
+
type: 'local' | 'npm';
|
|
95
|
+
path?: string;
|
|
96
|
+
module?: string;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
interface InstalledApp {
|
|
100
|
+
name: string;
|
|
101
|
+
module: string;
|
|
102
|
+
pages: {
|
|
103
|
+
name: string;
|
|
104
|
+
headless_components: {
|
|
105
|
+
name: string;
|
|
106
|
+
key: string;
|
|
107
|
+
contract: string;
|
|
108
|
+
slugs?: string[];
|
|
109
|
+
}[];
|
|
110
|
+
}[];
|
|
111
|
+
components: {
|
|
112
|
+
name: string;
|
|
113
|
+
headless_components: {
|
|
114
|
+
name: string;
|
|
115
|
+
key: string;
|
|
116
|
+
contract: string;
|
|
117
|
+
}[];
|
|
118
|
+
}[];
|
|
119
|
+
config_map?: {
|
|
120
|
+
display_name: string;
|
|
121
|
+
key: string;
|
|
122
|
+
}[];
|
|
123
|
+
}
|
|
124
|
+
interface ProjectInfo {
|
|
125
|
+
name: string;
|
|
126
|
+
localPath: string;
|
|
127
|
+
pages: ProjectPage[];
|
|
128
|
+
components: ProjectComponent[];
|
|
129
|
+
plugins: Plugin[];
|
|
130
|
+
installedApps: InstalledApp[];
|
|
131
|
+
installedAppContracts: {
|
|
132
|
+
[appName: string]: InstalledAppContracts;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
interface GetProjectInfoResponse extends BaseResponse {
|
|
136
|
+
type: 'getProjectInfo';
|
|
137
|
+
info: ProjectInfo;
|
|
138
|
+
}
|
|
139
|
+
interface ContractTag {
|
|
140
|
+
tag: string;
|
|
141
|
+
type: string | string[];
|
|
142
|
+
dataType?: string;
|
|
143
|
+
elementType?: string;
|
|
144
|
+
required?: boolean;
|
|
145
|
+
repeated?: boolean;
|
|
146
|
+
tags?: ContractTag[];
|
|
147
|
+
link?: string;
|
|
148
|
+
}
|
|
149
|
+
interface ContractSchema {
|
|
150
|
+
name: string;
|
|
151
|
+
tags: ContractTag[];
|
|
152
|
+
}
|
|
153
|
+
interface InstalledAppContracts {
|
|
154
|
+
appName: string;
|
|
155
|
+
module: string;
|
|
156
|
+
pages: Array<{
|
|
157
|
+
pageName: string;
|
|
158
|
+
contractSchema: ContractSchema;
|
|
159
|
+
}>;
|
|
160
|
+
components: Array<{
|
|
161
|
+
componentName: string;
|
|
162
|
+
contractSchema: ContractSchema;
|
|
163
|
+
}>;
|
|
164
|
+
}
|
|
165
|
+
type EditorProtocolMessageTypes = PublishMessage | SaveImageMessage | HasImageMessage | GetProjectInfoMessage;
|
|
166
|
+
type EditorProtocolResponseTypes = PublishResponse | SaveImageResponse | HasImageResponse | GetProjectInfoResponse;
|
|
57
167
|
interface ProtocolMessage {
|
|
58
168
|
id: string;
|
|
59
169
|
timestamp: number;
|
|
@@ -68,11 +178,13 @@ interface EditorProtocol {
|
|
|
68
178
|
publish(params: PublishMessage): Promise<PublishResponse>;
|
|
69
179
|
saveImage(params: SaveImageMessage): Promise<SaveImageResponse>;
|
|
70
180
|
hasImage(params: HasImageMessage): Promise<HasImageResponse>;
|
|
181
|
+
getProjectInfo(params: GetProjectInfoMessage): Promise<GetProjectInfoResponse>;
|
|
71
182
|
}
|
|
72
183
|
interface DevServerProtocol {
|
|
73
184
|
onPublish(callback: EditorProtocol['publish']): void;
|
|
74
185
|
onSaveImage(callback: EditorProtocol['saveImage']): void;
|
|
75
186
|
onHasImage(callback: EditorProtocol['hasImage']): void;
|
|
187
|
+
onGetProjectInfo(callback: EditorProtocol['getProjectInfo']): void;
|
|
76
188
|
}
|
|
77
189
|
|
|
78
190
|
interface EditorConfig {
|
|
@@ -93,10 +205,12 @@ interface PortDiscoveryResponse {
|
|
|
93
205
|
declare function createPublishMessage(pages?: PublishMessage['pages'], components?: PublishMessage['components']): PublishMessage;
|
|
94
206
|
declare function createSaveImageMessage(imageId: string, imageData: string): SaveImageMessage;
|
|
95
207
|
declare function createHasImageMessage(imageId: string): HasImageMessage;
|
|
208
|
+
declare function createGetProjectInfoMessage(): GetProjectInfoMessage;
|
|
96
209
|
declare function createPublishResponse(status: PublishResponse['status']): PublishResponse;
|
|
97
210
|
declare function createSaveImageResponse(success: boolean, imageUrl?: string, error?: string): SaveImageResponse;
|
|
98
211
|
declare function createHasImageResponse(exists: boolean, imageUrl?: string): HasImageResponse;
|
|
99
|
-
declare function
|
|
100
|
-
declare function
|
|
212
|
+
declare function createGetProjectInfoResponse(info: ProjectInfo, success?: boolean, error?: string): GetProjectInfoResponse;
|
|
213
|
+
declare function createProtocolMessage(payload: EditorProtocolMessageTypes): ProtocolMessage;
|
|
214
|
+
declare function createProtocolResponse(id: string, payload: EditorProtocolResponseTypes): ProtocolResponse;
|
|
101
215
|
|
|
102
|
-
export { type BaseMessage, type BaseResponse, type ConnectionState, type DevServerProtocol, type EditorConfig, type EditorProtocol, type EditorProtocolMessageTypes, type EditorProtocolResponseTypes, type HasImageMessage, type HasImageResponse, type PortDiscoveryResponse, type ProtocolMessage, type ProtocolResponse, type PublishComponent, type PublishMessage, type PublishPage, type PublishResponse, type PublishStatus, type SaveImageMessage, type SaveImageResponse, createHasImageMessage, createHasImageResponse, createProtocolMessage, createProtocolResponse, createPublishMessage, createPublishResponse, createSaveImageMessage, createSaveImageResponse };
|
|
216
|
+
export { type BaseMessage, type BaseResponse, type ConnectionState, type ContractSchema, type ContractTag, type DevServerProtocol, type DynamicContractDef, type EditorConfig, type EditorProtocol, type EditorProtocolMessageTypes, type EditorProtocolResponseTypes, type GetProjectInfoMessage, type GetProjectInfoResponse, type HasImageMessage, type HasImageResponse, type InstalledApp, type InstalledAppContracts, type Plugin, type PluginManifest, type PortDiscoveryResponse, type ProjectComponent, type ProjectInfo, type ProjectPage, type ProtocolMessage, type ProtocolResponse, type PublishComponent, type PublishMessage, type PublishPage, type PublishResponse, type PublishStatus, type SaveImageMessage, type SaveImageResponse, type StaticContractDef, createGetProjectInfoMessage, createGetProjectInfoResponse, createHasImageMessage, createHasImageResponse, createProtocolMessage, createProtocolResponse, createPublishMessage, createPublishResponse, createSaveImageMessage, createSaveImageResponse };
|
package/dist/index.js
CHANGED
|
@@ -18,6 +18,11 @@ function createHasImageMessage(imageId) {
|
|
|
18
18
|
imageId
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
+
function createGetProjectInfoMessage() {
|
|
22
|
+
return {
|
|
23
|
+
type: "getProjectInfo"
|
|
24
|
+
};
|
|
25
|
+
}
|
|
21
26
|
function createPublishResponse(status) {
|
|
22
27
|
return {
|
|
23
28
|
type: "publish",
|
|
@@ -41,6 +46,14 @@ function createHasImageResponse(exists, imageUrl) {
|
|
|
41
46
|
imageUrl
|
|
42
47
|
};
|
|
43
48
|
}
|
|
49
|
+
function createGetProjectInfoResponse(info, success = true, error) {
|
|
50
|
+
return {
|
|
51
|
+
type: "getProjectInfo",
|
|
52
|
+
success,
|
|
53
|
+
info,
|
|
54
|
+
error
|
|
55
|
+
};
|
|
56
|
+
}
|
|
44
57
|
let messageIdCounter = 0;
|
|
45
58
|
function generateMessageId() {
|
|
46
59
|
const timestamp = Date.now();
|
|
@@ -62,6 +75,8 @@ function createProtocolResponse(id, payload) {
|
|
|
62
75
|
};
|
|
63
76
|
}
|
|
64
77
|
export {
|
|
78
|
+
createGetProjectInfoMessage,
|
|
79
|
+
createGetProjectInfoResponse,
|
|
65
80
|
createHasImageMessage,
|
|
66
81
|
createHasImageResponse,
|
|
67
82
|
createProtocolMessage,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jay-framework/editor-protocol",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"test:watch": ":"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@jay-framework/dev-environment": "^0.
|
|
28
|
-
"@jay-framework/jay-cli": "^0.
|
|
27
|
+
"@jay-framework/dev-environment": "^0.11.0",
|
|
28
|
+
"@jay-framework/jay-cli": "^0.11.0",
|
|
29
29
|
"@types/node": "^22.15.21",
|
|
30
30
|
"rimraf": "^5.0.5",
|
|
31
31
|
"tsup": "^8.0.1",
|