dsh-plugin-inspiration-workbench 0.1.1 → 0.3.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 +17 -1
- package/lib/client.js +590 -58
- package/lib/client.js.map +3 -3
- package/package.json +10 -6
- package/scripts/build-client.mjs +1 -1
- package/src/client/board.js +491 -55
- package/src/client/icons.js +5 -0
- package/src/client/index.jsx +56 -0
- package/src/client/persistence.js +27 -0
- package/src/client/popovers.js +2 -0
- package/src/client/styles.css +67 -5
- package/src/host/index.js +61 -1
package/src/client/icons.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
const ICONS = {
|
|
2
2
|
plus: '<path d="M12 5v14M5 12h14"/>',
|
|
3
|
+
flow: '<path d="M4 7h9l-2-2"/><path d="M13 7l-2 2"/><circle cx="18" cy="7" r="2.4"/><path d="M4 17h9l-2-2"/><path d="M13 17l-2 2"/><circle cx="18" cy="17" r="2.4"/>',
|
|
4
|
+
more: '<circle cx="5" cy="12" r="1.7"/><circle cx="12" cy="12" r="1.7"/><circle cx="19" cy="12" r="1.7"/>',
|
|
5
|
+
canvas: '<rect x="3" y="7" width="14" height="14" rx="2"/><path d="M7 7V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-2"/>',
|
|
6
|
+
quote: '<path d="M7 7h5v5a4 4 0 0 1-4 4H7"/><path d="M15 7h5v5a4 4 0 0 1-4 4h-1"/>',
|
|
7
|
+
board: '<rect x="3" y="4" width="5.5" height="16" rx="1.4"/><rect x="9.5" y="4" width="5.5" height="11" rx="1.4"/><rect x="16" y="4" width="5" height="7" rx="1.4"/>',
|
|
3
8
|
arrange:
|
|
4
9
|
'<rect x="3" y="3" width="7" height="7" rx="1.6"/><rect x="14" y="3" width="7" height="7" rx="1.6"/><rect x="3" y="14" width="7" height="7" rx="1.6"/><rect x="14" y="14" width="7" height="7" rx="1.6"/>',
|
|
5
10
|
fit: '<path d="M8 3H5a2 2 0 0 0-2 2v3M16 3h3a2 2 0 0 1 2 2v3M8 21H5a2 2 0 0 1-2-2v-3M16 21h3a2 2 0 0 0 2-2v-3"/>',
|
package/src/client/index.jsx
CHANGED
|
@@ -14,6 +14,25 @@ const zh = {
|
|
|
14
14
|
new: '新建会话卡',
|
|
15
15
|
arrange: '排列',
|
|
16
16
|
'attach.file': '附件',
|
|
17
|
+
canvas: '画布',
|
|
18
|
+
'canvas.title': '画布',
|
|
19
|
+
'canvas.active': '当前画布:{name}',
|
|
20
|
+
'canvas.current': '当前:{name}',
|
|
21
|
+
'canvas.unsaved': '当前画布还没保存',
|
|
22
|
+
'canvas.placeholder': '给这张画布起个名字',
|
|
23
|
+
'canvas.save': '保存',
|
|
24
|
+
'canvas.overwrite': '覆盖「{name}」',
|
|
25
|
+
'canvas.meta': '{n} 张卡 · {time}',
|
|
26
|
+
'canvas.none': '还没有保存过画布',
|
|
27
|
+
'canvas.saved': '已保存画布「{name}」',
|
|
28
|
+
'canvas.updated': '已更新画布「{name}」',
|
|
29
|
+
'canvas.switched': '已切换到「{name}」',
|
|
30
|
+
'canvas.deleted': '已删除画布「{name}」',
|
|
31
|
+
'canvas.delete': '删除这张画布',
|
|
32
|
+
'canvas.nameRequired': '先给画布起个名字',
|
|
33
|
+
'canvas.broken': '这张画布读不出来',
|
|
34
|
+
'card.more': '更多操作',
|
|
35
|
+
'card.unpin': '取消固定',
|
|
17
36
|
boardMode: '看板',
|
|
18
37
|
'board.title': '看板分组',
|
|
19
38
|
'board.byStatus': '按状态分栏',
|
|
@@ -106,6 +125,15 @@ const zh = {
|
|
|
106
125
|
'pipe.linked': '流水线已指向「{name}」',
|
|
107
126
|
'pipe.modeSendHint': '当前:完成后自动发送',
|
|
108
127
|
'pipe.modeDraftHint': '当前:只填入草稿',
|
|
128
|
+
'pipe.port': '拖这条线到另一张卡,建立流水线',
|
|
129
|
+
'pipe.created': '流水线已连到「{name}」',
|
|
130
|
+
'pipe.needTarget': '拖到另一张会话卡上才算连线',
|
|
131
|
+
'pipe.remove': '删除这条流水线',
|
|
132
|
+
'pipe.removed': '流水线已删除',
|
|
133
|
+
'pipe.sendHint': '完成后自动把结果发过去',
|
|
134
|
+
'pipe.draftHint': '只填进下游输入框,等人确认',
|
|
135
|
+
'pipe.modeSend': '已切到:自动发送',
|
|
136
|
+
'pipe.modeDraft': '已切到:只填草稿',
|
|
109
137
|
'pipe.title': '流水线:完成后把结果送到下游卡',
|
|
110
138
|
'pipe.to': '下游卡片',
|
|
111
139
|
'pipe.send': '自动发送到下游',
|
|
@@ -272,6 +300,25 @@ const en = {
|
|
|
272
300
|
new: 'New conversation card',
|
|
273
301
|
arrange: 'Arrange',
|
|
274
302
|
'attach.file': 'Attachment',
|
|
303
|
+
canvas: 'Canvas',
|
|
304
|
+
'canvas.title': 'Canvas',
|
|
305
|
+
'canvas.active': 'Current canvas: {name}',
|
|
306
|
+
'canvas.current': 'Current: {name}',
|
|
307
|
+
'canvas.unsaved': 'This canvas is not saved yet',
|
|
308
|
+
'canvas.placeholder': 'Name this canvas',
|
|
309
|
+
'canvas.save': 'Save',
|
|
310
|
+
'canvas.overwrite': 'Overwrite “{name}”',
|
|
311
|
+
'canvas.meta': '{n} cards · {time}',
|
|
312
|
+
'canvas.none': 'No saved canvases yet',
|
|
313
|
+
'canvas.saved': 'Saved canvas “{name}”',
|
|
314
|
+
'canvas.updated': 'Updated canvas “{name}”',
|
|
315
|
+
'canvas.switched': 'Switched to “{name}”',
|
|
316
|
+
'canvas.deleted': 'Deleted canvas “{name}”',
|
|
317
|
+
'canvas.delete': 'Delete this canvas',
|
|
318
|
+
'canvas.nameRequired': 'Give the canvas a name first',
|
|
319
|
+
'canvas.broken': 'That canvas could not be read',
|
|
320
|
+
'card.more': 'More actions',
|
|
321
|
+
'card.unpin': 'Unpin',
|
|
275
322
|
boardMode: 'Board',
|
|
276
323
|
'board.title': 'Group into columns',
|
|
277
324
|
'board.byStatus': 'By status',
|
|
@@ -364,6 +411,15 @@ const en = {
|
|
|
364
411
|
'pipe.linked': 'Pipeline points at “{name}”',
|
|
365
412
|
'pipe.modeSendHint': 'Currently: auto-send on completion',
|
|
366
413
|
'pipe.modeDraftHint': 'Currently: draft only',
|
|
414
|
+
'pipe.port': 'Drag this line onto another card to wire a pipeline',
|
|
415
|
+
'pipe.created': 'Pipeline wired to “{name}”',
|
|
416
|
+
'pipe.needTarget': 'Drop it on another session card to connect',
|
|
417
|
+
'pipe.remove': 'Remove this pipeline',
|
|
418
|
+
'pipe.removed': 'Pipeline removed',
|
|
419
|
+
'pipe.sendHint': 'Send the result downstream when the turn finishes',
|
|
420
|
+
'pipe.draftHint': 'Only fill the downstream composer',
|
|
421
|
+
'pipe.modeSend': 'Mode: auto-send',
|
|
422
|
+
'pipe.modeDraft': 'Mode: draft only',
|
|
367
423
|
'pipe.title': 'Pipeline: forward this card\'s result downstream',
|
|
368
424
|
'pipe.to': 'Downstream card',
|
|
369
425
|
'pipe.send': 'Auto-send downstream',
|
|
@@ -69,3 +69,30 @@ export function subscribeRemoteLayout(listener) {
|
|
|
69
69
|
source.close();
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
|
+
|
|
73
|
+
/** Named board snapshots, stored on the Host next to the working layout. */
|
|
74
|
+
export async function fetchCanvases() {
|
|
75
|
+
try {
|
|
76
|
+
const response = await request('/canvases', { method: 'GET' });
|
|
77
|
+
const body = await response.json();
|
|
78
|
+
return {
|
|
79
|
+
canvases: Array.isArray(body?.canvases) ? body.canvases : [],
|
|
80
|
+
activeCanvas: typeof body?.activeCanvas === 'string' ? body.activeCanvas : null,
|
|
81
|
+
};
|
|
82
|
+
} catch {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export async function pushCanvases(canvases, activeCanvas) {
|
|
88
|
+
try {
|
|
89
|
+
const response = await request('/canvases', {
|
|
90
|
+
method: 'PUT',
|
|
91
|
+
headers: { 'content-type': 'application/json' },
|
|
92
|
+
body: JSON.stringify({ canvases, activeCanvas }),
|
|
93
|
+
});
|
|
94
|
+
return await response.json().catch(() => ({}));
|
|
95
|
+
} catch {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
}
|
package/src/client/popovers.js
CHANGED
|
@@ -213,6 +213,7 @@ export function createArrangeMenu(deps) {
|
|
|
213
213
|
defaultSize,
|
|
214
214
|
gap,
|
|
215
215
|
anchor,
|
|
216
|
+
afterArrange,
|
|
216
217
|
} = deps;
|
|
217
218
|
const el = makeEl;
|
|
218
219
|
const DEFAULT_W = defaultSize.w;
|
|
@@ -275,6 +276,7 @@ export function createArrangeMenu(deps) {
|
|
|
275
276
|
}
|
|
276
277
|
saveSoon();
|
|
277
278
|
void fitView();
|
|
279
|
+
afterArrange?.();
|
|
278
280
|
toast(t('arrange.done'));
|
|
279
281
|
}
|
|
280
282
|
|
package/src/client/styles.css
CHANGED
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
}
|
|
123
123
|
.iwb-meta {
|
|
124
124
|
font-size: 10.5px; color: var(--dsw-alias-label-tertiary); border: .5px solid var(--dsw-alias-border-l2);
|
|
125
|
-
border-radius: 5px; padding: 0 4px; line-height: 15px; flex: 0
|
|
125
|
+
border-radius: 5px; padding: 0 4px; line-height: 15px; flex: 0 1 auto; max-width: 96px; min-width: 0;
|
|
126
126
|
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
|
127
127
|
background: none; font-family: inherit; cursor: pointer;
|
|
128
128
|
transition: background .12s, border-color .12s, color .12s;
|
|
@@ -202,13 +202,21 @@
|
|
|
202
202
|
font-size: 10px; line-height: 15px; padding: 0 4px; flex: 0 0 auto; color: var(--dsw-alias-label-secondary);
|
|
203
203
|
background: var(--dsw-alias-bg-layer-2); border: .5px solid var(--dsw-alias-border-l2); border-radius: 5px;
|
|
204
204
|
}
|
|
205
|
-
.iwb-actions { display: flex; gap:
|
|
206
|
-
.iwb-card:hover .iwb-actions
|
|
205
|
+
.iwb-actions { display: flex; gap: 0; flex: 0 0 auto; opacity: .92; transition: opacity .12s; }
|
|
206
|
+
.iwb-card:hover .iwb-actions,
|
|
207
|
+
.iwb-card:focus-within .iwb-actions,
|
|
208
|
+
.iwb-card.iwb-focus .iwb-actions { opacity: 1; }
|
|
209
|
+
.iwb-acts-more { display: none; }
|
|
210
|
+
.iwb-act-more { opacity: .9; }
|
|
211
|
+
.iwb-more { min-width: 190px; }
|
|
212
|
+
.iwb-more .iwb-model-row { gap: 8px; }
|
|
213
|
+
.iwb-more-ico { display: inline-flex; color: var(--dsw-alias-label-tertiary); }
|
|
207
214
|
.iwb-actions button {
|
|
208
|
-
width:
|
|
209
|
-
color: var(--dsw-alias-label-
|
|
215
|
+
width: 23px; height: 23px; border-radius: 6px; display: grid; place-items: center;
|
|
216
|
+
color: var(--dsw-alias-label-secondary); background: none; border: 0; cursor: pointer;
|
|
210
217
|
}
|
|
211
218
|
.iwb-actions button:hover { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-primary); }
|
|
219
|
+
.iwb-actions button:focus-visible { outline: 2px solid var(--dsw-alias-label-deep-diving); outline-offset: -1px; }
|
|
212
220
|
|
|
213
221
|
.iwb-body {
|
|
214
222
|
flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 12px 12px 4px;
|
|
@@ -404,6 +412,33 @@
|
|
|
404
412
|
background: color-mix(in srgb, var(--dsw-alias-label-deep-diving) 14%, transparent);
|
|
405
413
|
}
|
|
406
414
|
|
|
415
|
+
/* ── canvas menu ──────────────────────────────────────────────────── */
|
|
416
|
+
.iwb-toolbar .iwb-btn > span { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
417
|
+
.iwb-canvas-menu { min-width: 260px; max-width: 320px; }
|
|
418
|
+
.iwb-canvas-form { display: flex; gap: 6px; padding: 4px 2px 8px; }
|
|
419
|
+
.iwb-canvas-input {
|
|
420
|
+
flex: 1; min-width: 0; height: 26px; padding: 0 8px; box-sizing: border-box;
|
|
421
|
+
border-radius: 6px; border: .5px solid var(--dsw-alias-border-l2);
|
|
422
|
+
background: var(--dsw-alias-bg-layer-2); color: var(--dsw-alias-label-primary);
|
|
423
|
+
font-family: inherit; font-size: 12px; outline: none;
|
|
424
|
+
}
|
|
425
|
+
.iwb-canvas-input:focus { border-color: var(--dsw-alias-label-deep-diving); }
|
|
426
|
+
.iwb-canvas-list { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; max-height: 260px; overflow-y: auto; }
|
|
427
|
+
.iwb-canvas-row { display: flex; align-items: center; gap: 2px; border-radius: 7px; }
|
|
428
|
+
.iwb-canvas-row.current { background: var(--dsw-alias-interactive-bg-hover); }
|
|
429
|
+
.iwb-canvas-pick {
|
|
430
|
+
flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
|
|
431
|
+
padding: 5px 7px; border: 0; border-radius: 7px; background: none; cursor: pointer; text-align: left;
|
|
432
|
+
font-family: inherit;
|
|
433
|
+
}
|
|
434
|
+
.iwb-canvas-pick:hover { background: var(--dsw-alias-interactive-bg-hover); }
|
|
435
|
+
.iwb-canvas-pick .iwb-model-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
436
|
+
.iwb-canvas-remove {
|
|
437
|
+
flex: 0 0 auto; width: 22px; height: 22px; border: 0; border-radius: 6px;
|
|
438
|
+
background: none; color: var(--dsw-alias-label-tertiary); cursor: pointer; font-size: 14px; line-height: 1;
|
|
439
|
+
}
|
|
440
|
+
.iwb-canvas-remove:hover { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-state-error-primary); }
|
|
441
|
+
|
|
407
442
|
/* ── approval card note ───────────────────────────────────────────── */
|
|
408
443
|
.iwb-approval-note {
|
|
409
444
|
font-size: 10.5px; line-height: 15px; color: var(--dsw-alias-label-tertiary);
|
|
@@ -420,6 +455,33 @@
|
|
|
420
455
|
}
|
|
421
456
|
.iwb-msg-attach-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
422
457
|
|
|
458
|
+
/* ── pipeline edges ───────────────────────────────────────────────── */
|
|
459
|
+
.iwb-links {
|
|
460
|
+
position: absolute; left: 0; top: 0; width: 1px; height: 1px;
|
|
461
|
+
overflow: visible; pointer-events: none; z-index: 1;
|
|
462
|
+
}
|
|
463
|
+
.iwb-links path.iwb-link {
|
|
464
|
+
fill: none; stroke: var(--dsw-alias-label-deep-diving); stroke-width: 1.6;
|
|
465
|
+
opacity: .55; pointer-events: stroke; cursor: pointer;
|
|
466
|
+
}
|
|
467
|
+
.iwb-links path.iwb-link:hover { opacity: .95; stroke-width: 2; }
|
|
468
|
+
.iwb-links path.iwb-link-hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }
|
|
469
|
+
.iwb-links path.iwb-link-temp { fill: none; stroke: var(--dsw-alias-label-deep-diving); stroke-width: 2; stroke-dasharray: 5 4; opacity: .9; }
|
|
470
|
+
.iwb-port {
|
|
471
|
+
position: absolute; right: -7px; top: 30px; width: 14px; height: 14px;
|
|
472
|
+
border-radius: 50%; border: 1.5px solid var(--dsw-alias-label-deep-diving);
|
|
473
|
+
background: var(--dsw-alias-bg-layer-1); cursor: crosshair;
|
|
474
|
+
opacity: .55; transition: opacity .12s, transform .12s; z-index: 3;
|
|
475
|
+
}
|
|
476
|
+
.iwb-card:hover .iwb-port, .iwb-card.iwb-focus .iwb-port, .iwb-port:hover { opacity: 1; }
|
|
477
|
+
.iwb-port::after {
|
|
478
|
+
content: "→"; position: absolute; inset: 0; display: grid; place-items: center;
|
|
479
|
+
font-size: 9px; line-height: 1; color: var(--dsw-alias-label-deep-diving);
|
|
480
|
+
}
|
|
481
|
+
.iwb-card.iwb-link-target { outline: 2px dashed var(--dsw-alias-label-deep-diving); outline-offset: 3px; }
|
|
482
|
+
.iwb-link-menu { min-width: 230px; }
|
|
483
|
+
.iwb-link-remove .iwb-model-name { color: var(--dsw-alias-state-error-primary); }
|
|
484
|
+
|
|
423
485
|
/* ── pipeline ─────────────────────────────────────────────────────── */
|
|
424
486
|
.iwb-pipe-badge {
|
|
425
487
|
flex: 0 0 auto; font-size: 10px; padding: 1px 5px; border-radius: 5px;
|
package/src/host/index.js
CHANGED
|
@@ -36,6 +36,9 @@ function createStore() {
|
|
|
36
36
|
let updatedAt = 0;
|
|
37
37
|
let rev = 0;
|
|
38
38
|
let clientId = '';
|
|
39
|
+
/** Named board snapshots: [{ id, name, savedAt, layout }] */
|
|
40
|
+
let canvases = [];
|
|
41
|
+
let activeCanvas = null;
|
|
39
42
|
const listeners = new Set();
|
|
40
43
|
let saveTimer = null;
|
|
41
44
|
let loading = null;
|
|
@@ -52,6 +55,8 @@ function createStore() {
|
|
|
52
55
|
updatedAt = Number(parsed.updatedAt) || 0;
|
|
53
56
|
rev = Number(parsed.rev) || 0;
|
|
54
57
|
}
|
|
58
|
+
if (parsed && Array.isArray(parsed.canvases)) canvases = parsed.canvases;
|
|
59
|
+
if (parsed && typeof parsed.activeCanvas === 'string') activeCanvas = parsed.activeCanvas;
|
|
55
60
|
} catch {
|
|
56
61
|
/* first run, or the document is unreadable: start empty */
|
|
57
62
|
}
|
|
@@ -64,6 +69,26 @@ function createStore() {
|
|
|
64
69
|
return { layout, updatedAt, rev };
|
|
65
70
|
}
|
|
66
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Full canvases, layouts included: the client keeps them in memory so it can
|
|
74
|
+
* switch boards without another round-trip, and a reload must be able to
|
|
75
|
+
* restore any saved canvas, not just its name.
|
|
76
|
+
*/
|
|
77
|
+
function canvasList() {
|
|
78
|
+
return canvases;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async function putCanvases(next, active) {
|
|
82
|
+
await ensureLoaded();
|
|
83
|
+
canvases = Array.isArray(next) ? next : [];
|
|
84
|
+
activeCanvas = typeof active === 'string' ? active : null;
|
|
85
|
+
updatedAt = Date.now();
|
|
86
|
+
rev += 1;
|
|
87
|
+
scheduleSave();
|
|
88
|
+
broadcast();
|
|
89
|
+
return { rev, updatedAt };
|
|
90
|
+
}
|
|
91
|
+
|
|
67
92
|
function scheduleSave() {
|
|
68
93
|
if (saveTimer) return;
|
|
69
94
|
saveTimer = setTimeout(async () => {
|
|
@@ -72,7 +97,7 @@ function createStore() {
|
|
|
72
97
|
await fs.mkdir(join(dataFilePath(), '..'), { recursive: true });
|
|
73
98
|
await fs.writeFile(
|
|
74
99
|
dataFilePath(),
|
|
75
|
-
JSON.stringify({ rev, updatedAt, layout }),
|
|
100
|
+
JSON.stringify({ rev, updatedAt, layout, canvases, activeCanvas }),
|
|
76
101
|
'utf8'
|
|
77
102
|
);
|
|
78
103
|
} catch {
|
|
@@ -107,7 +132,10 @@ function createStore() {
|
|
|
107
132
|
return {
|
|
108
133
|
ensureLoaded,
|
|
109
134
|
snapshot,
|
|
135
|
+
canvases: () => canvasList(),
|
|
136
|
+
active: () => activeCanvas,
|
|
110
137
|
put,
|
|
138
|
+
putCanvases,
|
|
111
139
|
subscribe(res) {
|
|
112
140
|
listeners.add(res);
|
|
113
141
|
return () => listeners.delete(res);
|
|
@@ -208,6 +236,38 @@ export function apply(ctx) {
|
|
|
208
236
|
return;
|
|
209
237
|
}
|
|
210
238
|
|
|
239
|
+
if (route === '/canvases' || route === '/canvases/') {
|
|
240
|
+
if (req.method === 'GET') {
|
|
241
|
+
res.setHeader('content-type', 'application/json');
|
|
242
|
+
res.setHeader('cache-control', 'no-store');
|
|
243
|
+
store
|
|
244
|
+
.ensureLoaded()
|
|
245
|
+
.then(() => store.snapshot())
|
|
246
|
+
.then(() => {
|
|
247
|
+
res.end(JSON.stringify({ canvases: store.canvases(), activeCanvas: store.active() }));
|
|
248
|
+
})
|
|
249
|
+
.catch(() => res.writeHead(500).end());
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
if (req.method === 'PUT' || req.method === 'POST') {
|
|
253
|
+
readBody(req, MAX_BODY_BYTES)
|
|
254
|
+
.then(async (text) => {
|
|
255
|
+
const parsed = JSON.parse(text);
|
|
256
|
+
if (!parsed || !Array.isArray(parsed.canvases)) {
|
|
257
|
+
res.writeHead(400).end('bad canvases');
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
const result = await store.putCanvases(parsed.canvases, parsed.activeCanvas);
|
|
261
|
+
res.setHeader('content-type', 'application/json');
|
|
262
|
+
res.end(JSON.stringify(result));
|
|
263
|
+
})
|
|
264
|
+
.catch(() => res.writeHead(400).end('bad request'));
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
res.writeHead(405, { allow: 'GET, PUT' }).end();
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
|
|
211
271
|
if (route === '/events' || route === '/events/') {
|
|
212
272
|
if (req.method !== 'GET') {
|
|
213
273
|
res.writeHead(405, { allow: 'GET' }).end();
|