@lovision/plugin-dev 1.0.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/README.md +49 -0
- package/dist/build.d.ts +16 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +108 -0
- package/dist/build.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +123 -0
- package/dist/cli.js.map +1 -0
- package/dist/create-plugin.d.ts +19 -0
- package/dist/create-plugin.d.ts.map +1 -0
- package/dist/create-plugin.js +186 -0
- package/dist/create-plugin.js.map +1 -0
- package/dist/dev.d.ts +13 -0
- package/dist/dev.d.ts.map +1 -0
- package/dist/dev.js +206 -0
- package/dist/dev.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/publish.d.ts +15 -0
- package/dist/publish.d.ts.map +1 -0
- package/dist/publish.js +55 -0
- package/dist/publish.js.map +1 -0
- package/dist/shared.d.ts +93 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +436 -0
- package/dist/shared.js.map +1 -0
- package/dist/templates/ai-layout-assistant/README.md.template +24 -0
- package/dist/templates/ai-layout-assistant/eslint.config.mjs +19 -0
- package/dist/templates/ai-layout-assistant/manifest.json.template +38 -0
- package/dist/templates/ai-layout-assistant/package.json.template +18 -0
- package/dist/templates/ai-layout-assistant/src/main.ts.template +345 -0
- package/dist/templates/ai-layout-assistant/tsconfig.json +14 -0
- package/dist/templates/ai-layout-assistant/ui.html.template +114 -0
- package/dist/templates/asset-browser/README.md.template +24 -0
- package/dist/templates/asset-browser/eslint.config.mjs +19 -0
- package/dist/templates/asset-browser/manifest.json.template +29 -0
- package/dist/templates/asset-browser/package.json.template +18 -0
- package/dist/templates/asset-browser/src/main.ts.template +177 -0
- package/dist/templates/asset-browser/tsconfig.json +14 -0
- package/dist/templates/asset-browser/ui.html.template +137 -0
- package/dist/templates/base/README.md.template +34 -0
- package/dist/templates/base/eslint.config.mjs +19 -0
- package/dist/templates/base/manifest.json.template +22 -0
- package/dist/templates/base/package.json.template +18 -0
- package/dist/templates/base/src/main.ts.template +20 -0
- package/dist/templates/base/tsconfig.json +14 -0
- package/dist/templates/batch-layout-organizer/README.md.template +24 -0
- package/dist/templates/batch-layout-organizer/eslint.config.mjs +19 -0
- package/dist/templates/batch-layout-organizer/manifest.json.template +31 -0
- package/dist/templates/batch-layout-organizer/package.json.template +18 -0
- package/dist/templates/batch-layout-organizer/src/main.ts.template +324 -0
- package/dist/templates/batch-layout-organizer/tsconfig.json +14 -0
- package/dist/templates/batch-layout-organizer/ui.html.template +116 -0
- package/dist/templates/data-filler-full/README.md.template +32 -0
- package/dist/templates/data-filler-full/eslint.config.mjs +19 -0
- package/dist/templates/data-filler-full/manifest.json.template +31 -0
- package/dist/templates/data-filler-full/package.json.template +18 -0
- package/dist/templates/data-filler-full/src/main.ts.template +412 -0
- package/dist/templates/data-filler-full/tsconfig.json +14 -0
- package/dist/templates/data-filler-full/ui.html.template +221 -0
- package/dist/templates/data-filler-lite/README.md.template +47 -0
- package/dist/templates/data-filler-lite/eslint.config.mjs +19 -0
- package/dist/templates/data-filler-lite/manifest.json.template +29 -0
- package/dist/templates/data-filler-lite/package.json.template +18 -0
- package/dist/templates/data-filler-lite/src/main.ts.template +222 -0
- package/dist/templates/data-filler-lite/tsconfig.json +14 -0
- package/dist/templates/data-filler-lite/ui.html.template +180 -0
- package/dist/templates/design-lint-panel/README.md.template +33 -0
- package/dist/templates/design-lint-panel/eslint.config.mjs +19 -0
- package/dist/templates/design-lint-panel/manifest.json.template +29 -0
- package/dist/templates/design-lint-panel/package.json.template +18 -0
- package/dist/templates/design-lint-panel/src/main.ts.template +221 -0
- package/dist/templates/design-lint-panel/tsconfig.json +14 -0
- package/dist/templates/design-lint-panel/ui.html.template +172 -0
- package/dist/templates/export-selection/README.md.template +26 -0
- package/dist/templates/export-selection/eslint.config.mjs +19 -0
- package/dist/templates/export-selection/manifest.json.template +31 -0
- package/dist/templates/export-selection/package.json.template +18 -0
- package/dist/templates/export-selection/src/main.ts.template +386 -0
- package/dist/templates/export-selection/tsconfig.json +14 -0
- package/dist/templates/export-selection/ui.html.template +163 -0
- package/dist/templates/review-submitter/README.md.template +24 -0
- package/dist/templates/review-submitter/eslint.config.mjs +19 -0
- package/dist/templates/review-submitter/manifest.json.template +35 -0
- package/dist/templates/review-submitter/package.json.template +18 -0
- package/dist/templates/review-submitter/src/main.ts.template +306 -0
- package/dist/templates/review-submitter/tsconfig.json +14 -0
- package/dist/templates/review-submitter/ui.html.template +114 -0
- package/dist/validate.d.ts +8 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +42 -0
- package/dist/validate.js.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { definePlugin } from "@lovision/plugin-sdk";
|
|
2
|
+
|
|
3
|
+
type Vec2 = {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
type Size = {
|
|
9
|
+
height: number;
|
|
10
|
+
width: number;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type SceneNodeSnapshot = {
|
|
14
|
+
children: SceneNodeSnapshot[];
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
parentId: string | null;
|
|
18
|
+
position: Vec2;
|
|
19
|
+
size: Size;
|
|
20
|
+
type: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
type SceneSnapshot = {
|
|
24
|
+
root: SceneNodeSnapshot;
|
|
25
|
+
version: number;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
type ContextSnapshot = {
|
|
29
|
+
project?: ContextEntity | null;
|
|
30
|
+
takenAt: number;
|
|
31
|
+
user?: ContextEntity | null;
|
|
32
|
+
workspace?: ContextEntity | null;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
type ContextEntity = {
|
|
36
|
+
displayName?: string;
|
|
37
|
+
id: string;
|
|
38
|
+
role?: string;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
type BinaryResourceRef = {
|
|
42
|
+
byteLength: number;
|
|
43
|
+
createdAt: number;
|
|
44
|
+
id: string;
|
|
45
|
+
kind: string;
|
|
46
|
+
mimeType: string;
|
|
47
|
+
name?: string;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
type WorkflowSubmissionResult = {
|
|
51
|
+
id: string;
|
|
52
|
+
kind: string;
|
|
53
|
+
receipt?: unknown;
|
|
54
|
+
status: "accepted" | "queued" | "submitted";
|
|
55
|
+
submittedAt: number;
|
|
56
|
+
target: string;
|
|
57
|
+
url?: string;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
type ReviewContext = {
|
|
61
|
+
context: {
|
|
62
|
+
current(params?: {
|
|
63
|
+
include?: Array<"project" | "user" | "workspace">;
|
|
64
|
+
}): Promise<ContextSnapshot>;
|
|
65
|
+
};
|
|
66
|
+
document: {
|
|
67
|
+
snapshot(): Promise<SceneSnapshot>;
|
|
68
|
+
};
|
|
69
|
+
export: {
|
|
70
|
+
screenshot(params?: {
|
|
71
|
+
background?: "current" | "transparent" | "white";
|
|
72
|
+
fileName?: string;
|
|
73
|
+
format?: "jpeg" | "png" | "webp";
|
|
74
|
+
nodeIds?: string[];
|
|
75
|
+
quality?: number;
|
|
76
|
+
scale?: number;
|
|
77
|
+
}): Promise<BinaryResourceRef>;
|
|
78
|
+
};
|
|
79
|
+
notify: {
|
|
80
|
+
send(
|
|
81
|
+
message: string,
|
|
82
|
+
options?: { kind?: "error" | "info" | "success" | "warning" },
|
|
83
|
+
): Promise<void>;
|
|
84
|
+
};
|
|
85
|
+
selection: {
|
|
86
|
+
get(): Promise<string[]>;
|
|
87
|
+
};
|
|
88
|
+
workflow: {
|
|
89
|
+
submit(params: {
|
|
90
|
+
artifacts?: Array<{ resource: BinaryResourceRef; role?: string }>;
|
|
91
|
+
idempotencyKey?: string;
|
|
92
|
+
kind: string;
|
|
93
|
+
payload: unknown;
|
|
94
|
+
target: string;
|
|
95
|
+
}): Promise<WorkflowSubmissionResult>;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
type ReviewDraft = {
|
|
100
|
+
context: ContextSnapshot;
|
|
101
|
+
nodeCount: number;
|
|
102
|
+
screenshot: BinaryResourceRef;
|
|
103
|
+
selectedIds: string[];
|
|
104
|
+
snapshotVersion: number;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
type ReviewMessage =
|
|
108
|
+
| {
|
|
109
|
+
type: "captured";
|
|
110
|
+
payload: ReviewDraftSummary;
|
|
111
|
+
}
|
|
112
|
+
| {
|
|
113
|
+
type: "error";
|
|
114
|
+
payload: {
|
|
115
|
+
message: string;
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
| {
|
|
119
|
+
type: "ready";
|
|
120
|
+
payload: {
|
|
121
|
+
message: string;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
| {
|
|
125
|
+
type: "submitted";
|
|
126
|
+
payload: {
|
|
127
|
+
draft: ReviewDraftSummary;
|
|
128
|
+
submission: WorkflowSubmissionResult;
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
type ReviewDraftSummary = {
|
|
133
|
+
context: ContextSnapshot;
|
|
134
|
+
nodeCount: number;
|
|
135
|
+
screenshot: {
|
|
136
|
+
byteLength: number;
|
|
137
|
+
id: string;
|
|
138
|
+
mimeType: string;
|
|
139
|
+
};
|
|
140
|
+
selectedCount: number;
|
|
141
|
+
snapshotVersion: number;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
definePlugin({
|
|
145
|
+
apiVersion: "1.0",
|
|
146
|
+
version: "0.1.0",
|
|
147
|
+
command: async (ctx) => {
|
|
148
|
+
const session = await ctx.ui.show({
|
|
149
|
+
mode: "modal",
|
|
150
|
+
entry: "./ui.html",
|
|
151
|
+
title: "Review Submitter",
|
|
152
|
+
width: 560,
|
|
153
|
+
height: 480,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
let closed = false;
|
|
157
|
+
let latestDraft: ReviewDraft | null = null;
|
|
158
|
+
const postToUi = async (message: ReviewMessage): Promise<void> => {
|
|
159
|
+
if (closed) return;
|
|
160
|
+
await session.postMessage(message);
|
|
161
|
+
};
|
|
162
|
+
const modalClosed = new Promise<void>((resolve) => {
|
|
163
|
+
session.on("close", () => {
|
|
164
|
+
closed = true;
|
|
165
|
+
void ctx.notify.send("Review Submitter closed.", { kind: "info" });
|
|
166
|
+
resolve();
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
session.on("capture-review", async () => {
|
|
171
|
+
await handleUiAction(postToUi, async () => {
|
|
172
|
+
latestDraft = await captureReviewDraft(ctx);
|
|
173
|
+
await postToUi({
|
|
174
|
+
type: "captured",
|
|
175
|
+
payload: summarizeDraft(latestDraft),
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
session.on("submit-review", async () => {
|
|
181
|
+
await handleUiAction(postToUi, async () => {
|
|
182
|
+
const draft = latestDraft ?? (await captureReviewDraft(ctx));
|
|
183
|
+
latestDraft = draft;
|
|
184
|
+
const submission = await submitReview(ctx, draft);
|
|
185
|
+
await postToUi({
|
|
186
|
+
type: "submitted",
|
|
187
|
+
payload: {
|
|
188
|
+
draft: summarizeDraft(draft),
|
|
189
|
+
submission,
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
await ctx.notify.send(
|
|
193
|
+
`Review Submitter submitted ${submission.id}.`,
|
|
194
|
+
{ kind: "success" },
|
|
195
|
+
);
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
await postToUi({
|
|
200
|
+
type: "ready",
|
|
201
|
+
payload: {
|
|
202
|
+
message:
|
|
203
|
+
"Ready. Capture the current context, then submit a review workflow.",
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
await modalClosed;
|
|
208
|
+
return { closed: true, ok: true };
|
|
209
|
+
},
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
async function handleUiAction(
|
|
213
|
+
postToUi: (message: ReviewMessage) => Promise<void>,
|
|
214
|
+
action: () => Promise<unknown>,
|
|
215
|
+
): Promise<void> {
|
|
216
|
+
try {
|
|
217
|
+
await action();
|
|
218
|
+
} catch (error) {
|
|
219
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
220
|
+
await postToUi({ type: "error", payload: { message } });
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
async function captureReviewDraft(ctx: ReviewContext): Promise<ReviewDraft> {
|
|
225
|
+
const [snapshot, selectedIds, context] = await Promise.all([
|
|
226
|
+
ctx.document.snapshot(),
|
|
227
|
+
ctx.selection.get(),
|
|
228
|
+
ctx.context.current({ include: ["user", "workspace"] }),
|
|
229
|
+
]);
|
|
230
|
+
const screenshotNodeIds =
|
|
231
|
+
selectedIds.length > 0 ? selectedIds : resolveFirstCanvasNodeId(snapshot);
|
|
232
|
+
const screenshot = await ctx.export.screenshot({
|
|
233
|
+
background: "current",
|
|
234
|
+
fileName: "review-snapshot.png",
|
|
235
|
+
format: "png",
|
|
236
|
+
nodeIds: screenshotNodeIds,
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
return {
|
|
240
|
+
context,
|
|
241
|
+
nodeCount: collectNodes(snapshot.root).filter(
|
|
242
|
+
(node) => node.id !== snapshot.root.id,
|
|
243
|
+
).length,
|
|
244
|
+
screenshot,
|
|
245
|
+
selectedIds,
|
|
246
|
+
snapshotVersion: snapshot.version,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function resolveFirstCanvasNodeId(snapshot: SceneSnapshot): string[] {
|
|
251
|
+
const first = collectNodes(snapshot.root).find(
|
|
252
|
+
(node) => node.id !== snapshot.root.id,
|
|
253
|
+
);
|
|
254
|
+
if (!first) {
|
|
255
|
+
throw new Error("Review Submitter needs at least one canvas node.");
|
|
256
|
+
}
|
|
257
|
+
return [first.id];
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
async function submitReview(
|
|
261
|
+
ctx: ReviewContext,
|
|
262
|
+
draft: ReviewDraft,
|
|
263
|
+
): Promise<WorkflowSubmissionResult> {
|
|
264
|
+
return await ctx.workflow.submit({
|
|
265
|
+
target: "review.submit",
|
|
266
|
+
kind: "design-review",
|
|
267
|
+
payload: {
|
|
268
|
+
context: {
|
|
269
|
+
userId: draft.context.user?.id ?? null,
|
|
270
|
+
userName: draft.context.user?.displayName ?? null,
|
|
271
|
+
workspaceId: draft.context.workspace?.id ?? null,
|
|
272
|
+
workspaceName: draft.context.workspace?.displayName ?? null,
|
|
273
|
+
},
|
|
274
|
+
nodeCount: draft.nodeCount,
|
|
275
|
+
selectedCount: draft.selectedIds.length,
|
|
276
|
+
snapshotVersion: draft.snapshotVersion,
|
|
277
|
+
},
|
|
278
|
+
artifacts: [{ role: "screenshot", resource: draft.screenshot }],
|
|
279
|
+
idempotencyKey: `review-${draft.snapshotVersion}-${draft.screenshot.id}`,
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function summarizeDraft(draft: ReviewDraft): ReviewDraftSummary {
|
|
284
|
+
return {
|
|
285
|
+
context: draft.context,
|
|
286
|
+
nodeCount: draft.nodeCount,
|
|
287
|
+
screenshot: {
|
|
288
|
+
byteLength: draft.screenshot.byteLength,
|
|
289
|
+
id: draft.screenshot.id,
|
|
290
|
+
mimeType: draft.screenshot.mimeType,
|
|
291
|
+
},
|
|
292
|
+
selectedCount: draft.selectedIds.length,
|
|
293
|
+
snapshotVersion: draft.snapshotVersion,
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function collectNodes(
|
|
298
|
+
node: SceneNodeSnapshot,
|
|
299
|
+
out: SceneNodeSnapshot[] = [],
|
|
300
|
+
): SceneNodeSnapshot[] {
|
|
301
|
+
out.push(node);
|
|
302
|
+
for (const child of node.children) {
|
|
303
|
+
collectNodes(child, out);
|
|
304
|
+
}
|
|
305
|
+
return out;
|
|
306
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"lib": ["ESNext", "WebWorker"],
|
|
4
|
+
"module": "Preserve",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"target": "ESNext",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"allowImportingTsExtensions": true,
|
|
10
|
+
"verbatimModuleSyntax": true,
|
|
11
|
+
"noEmit": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["src/**/*"]
|
|
14
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<title>Review Submitter</title>
|
|
7
|
+
<style>
|
|
8
|
+
:root {
|
|
9
|
+
color-scheme: light dark;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
body {
|
|
13
|
+
margin: 0;
|
|
14
|
+
color: CanvasText;
|
|
15
|
+
background: Canvas;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
main {
|
|
19
|
+
display: grid;
|
|
20
|
+
gap: 1rem;
|
|
21
|
+
padding: 1rem;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.actions {
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-wrap: wrap;
|
|
27
|
+
gap: 0.5rem;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.status {
|
|
31
|
+
min-height: 1.5rem;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
pre {
|
|
35
|
+
max-height: 16rem;
|
|
36
|
+
overflow: auto;
|
|
37
|
+
padding: 0.75rem;
|
|
38
|
+
color: CanvasText;
|
|
39
|
+
background: Canvas;
|
|
40
|
+
border: 1px solid ButtonBorder;
|
|
41
|
+
}
|
|
42
|
+
</style>
|
|
43
|
+
</head>
|
|
44
|
+
<body>
|
|
45
|
+
<main>
|
|
46
|
+
<header>
|
|
47
|
+
<h1>Review Submitter</h1>
|
|
48
|
+
<p>Capture context and submit a host workflow review.</p>
|
|
49
|
+
</header>
|
|
50
|
+
|
|
51
|
+
<div class="actions">
|
|
52
|
+
<button id="capture-button" type="button">Capture review snapshot</button>
|
|
53
|
+
<button id="submit-button" type="button">Submit review</button>
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<p id="status" class="status" role="status">Waiting for host...</p>
|
|
57
|
+
<pre id="details" aria-label="Review details"></pre>
|
|
58
|
+
</main>
|
|
59
|
+
|
|
60
|
+
<script>
|
|
61
|
+
const uiId = globalThis.__LOVISION_PLUGIN_UI_ID__;
|
|
62
|
+
const status = document.getElementById("status");
|
|
63
|
+
const details = document.getElementById("details");
|
|
64
|
+
|
|
65
|
+
function post(type, payload) {
|
|
66
|
+
parent.postMessage(
|
|
67
|
+
{
|
|
68
|
+
type: "plugin-ui-message",
|
|
69
|
+
direction: "ui-to-main",
|
|
70
|
+
uiId,
|
|
71
|
+
message: { type, payload },
|
|
72
|
+
},
|
|
73
|
+
"*",
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
document.getElementById("capture-button").addEventListener("click", () => {
|
|
78
|
+
status.textContent = "Capturing review snapshot...";
|
|
79
|
+
details.textContent = "";
|
|
80
|
+
post("capture-review", {});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
document.getElementById("submit-button").addEventListener("click", () => {
|
|
84
|
+
status.textContent = "Submitting review...";
|
|
85
|
+
post("submit-review", {});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
window.addEventListener("message", (event) => {
|
|
89
|
+
const envelope = event.data;
|
|
90
|
+
if (
|
|
91
|
+
!envelope ||
|
|
92
|
+
envelope.type !== "plugin-ui-message" ||
|
|
93
|
+
envelope.direction !== "main-to-ui" ||
|
|
94
|
+
envelope.uiId !== uiId
|
|
95
|
+
) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const message = envelope.message;
|
|
100
|
+
if (message.type === "ready") {
|
|
101
|
+
status.textContent = message.payload.message;
|
|
102
|
+
} else if (message.type === "captured") {
|
|
103
|
+
status.textContent = "Captured review snapshot.";
|
|
104
|
+
details.textContent = JSON.stringify(message.payload, null, 2);
|
|
105
|
+
} else if (message.type === "submitted") {
|
|
106
|
+
status.textContent = `Submitted review ${message.payload.submission.id} (${message.payload.submission.status}).`;
|
|
107
|
+
details.textContent = JSON.stringify(message.payload, null, 2);
|
|
108
|
+
} else if (message.type === "error") {
|
|
109
|
+
status.textContent = message.payload.message;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
</script>
|
|
113
|
+
</body>
|
|
114
|
+
</html>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ToolDiagnostic } from "./shared.js";
|
|
2
|
+
export type ValidationReport = {
|
|
3
|
+
diagnostics: readonly ToolDiagnostic[];
|
|
4
|
+
ok: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare function validatePluginProject(projectRoot?: string): Promise<ValidationReport>;
|
|
7
|
+
export declare function validateBundleFile(bundlePath: string): Promise<ValidationReport>;
|
|
8
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,cAAc,EAEpB,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,EAAE,SAAS,cAAc,EAAE,CAAC;IACvC,EAAE,EAAE,OAAO,CAAC;CACb,CAAC;AAEF,wBAAsB,qBAAqB,CACzC,WAAW,SAAgB,GAC1B,OAAO,CAAC,gBAAgB,CAAC,CAmB3B;AAED,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,gBAAgB,CAAC,CAiB3B"}
|
package/dist/validate.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { loadBundle } from "@lovision/plugin-host";
|
|
3
|
+
import { buildPluginBundle } from "./build.js";
|
|
4
|
+
import { manifestDiagnosticToToolDiagnostic, ToolingError, } from "./shared.js";
|
|
5
|
+
export async function validatePluginProject(projectRoot = process.cwd()) {
|
|
6
|
+
try {
|
|
7
|
+
const built = await buildPluginBundle({
|
|
8
|
+
projectRoot,
|
|
9
|
+
write: false,
|
|
10
|
+
});
|
|
11
|
+
return {
|
|
12
|
+
diagnostics: built.warnings,
|
|
13
|
+
ok: true,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
if (error instanceof ToolingError) {
|
|
18
|
+
return {
|
|
19
|
+
diagnostics: error.diagnostics,
|
|
20
|
+
ok: false,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export async function validateBundleFile(bundlePath) {
|
|
27
|
+
const input = await readFile(bundlePath, "utf8");
|
|
28
|
+
const result = loadBundle(input);
|
|
29
|
+
if (!result.ok) {
|
|
30
|
+
return {
|
|
31
|
+
diagnostics: result.errors
|
|
32
|
+
.map(manifestDiagnosticToToolDiagnostic)
|
|
33
|
+
.concat(result.warnings.map(manifestDiagnosticToToolDiagnostic)),
|
|
34
|
+
ok: false,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
diagnostics: result.warnings.map(manifestDiagnosticToToolDiagnostic),
|
|
39
|
+
ok: true,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EACL,kCAAkC,EAElC,YAAY,GACb,MAAM,aAAa,CAAC;AAOrB,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE;IAE3B,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,iBAAiB,CAAC;YACpC,WAAW;YACX,KAAK,EAAE,KAAK;SACb,CAAC,CAAC;QACH,OAAO;YACL,WAAW,EAAE,KAAK,CAAC,QAAQ;YAC3B,EAAE,EAAE,IAAI;SACT,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,YAAY,EAAE,CAAC;YAClC,OAAO;gBACL,WAAW,EAAE,KAAK,CAAC,WAAW;gBAC9B,EAAE,EAAE,KAAK;aACV,CAAC;QACJ,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,UAAkB;IAElB,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IACjD,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IAEjC,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QACf,OAAO;YACL,WAAW,EAAE,MAAM,CAAC,MAAM;iBACvB,GAAG,CAAC,kCAAkC,CAAC;iBACvC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;YAClE,EAAE,EAAE,KAAK;SACV,CAAC;IACJ,CAAC;IAED,OAAO;QACL,WAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,kCAAkC,CAAC;QACpE,EAAE,EAAE,IAAI;KACT,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lovision/plugin-dev",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./package.json": "./package.json"
|
|
13
|
+
},
|
|
14
|
+
"bin": {
|
|
15
|
+
"plugin-dev": "./dist/cli.js",
|
|
16
|
+
"create-instinct-plugin": "./dist/create-plugin.js"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"README.md",
|
|
20
|
+
"dist/**"
|
|
21
|
+
],
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/choice-form/instinct.git",
|
|
25
|
+
"directory": "packages/plugin-dev"
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"engines": {
|
|
31
|
+
"bun": ">=1.3.0"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json && bun ../../scripts/rewrite-dts-extensions.ts dist && cp -R src/templates dist/templates",
|
|
35
|
+
"prepack": "bun run build",
|
|
36
|
+
"test": "bun run --filter @lovision/plugin-spec build && bun run --filter @lovision/plugin-host build && bun run --filter @lovision/plugin-sdk build && bun run build && bun test src/toolchain.test.ts src/package-surface.test.ts",
|
|
37
|
+
"lint:types": "bun run --filter @lovision/plugin-spec build && bun run --filter @lovision/plugin-host build && tsc -b"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@lovision/plugin-host": "1.0.0",
|
|
41
|
+
"@lovision/plugin-spec": "1.0.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"bun-types": "^1.3.9"
|
|
45
|
+
}
|
|
46
|
+
}
|