kenryu 0.2.1__py3-none-any.whl

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.
nagare/static/app.js ADDED
@@ -0,0 +1,473 @@
1
+ // nagare: the canvas. Node types come from api/nodes (your functions);
2
+ // runs go to api/run, which answers with a status and preview per node.
3
+ // Addresses are relative so the same page works on its own (at /) and inside
4
+ // kenkyu, which serves it at /nagare/.
5
+ "use strict";
6
+
7
+ const $ = (s) => document.querySelector(s);
8
+
9
+ // Inside kenkyu the canvas edits one of kenkyu's flows: ?flow=ID. kenkyu
10
+ // keeps the graph, so it is loaded from and saved to kenkyu instead of local
11
+ // storage and saved graphs, and the page tells kenkyu (its parent frame)
12
+ // which node is selected so a figure can go into a document.
13
+ const PARAMS = new URLSearchParams(location.search);
14
+ const FLOW = /^\d+$/.test(PARAMS.get("flow") || "") ? PARAMS.get("flow") : null;
15
+ const FLOW_URL = FLOW && `/flows/${FLOW}/graph`;
16
+ const tell = (msg) => { if (FLOW && window.parent !== window) window.parent.postMessage({ ...msg, flow: +FLOW }, location.origin); };
17
+ const TYPE_COLOURS = { DataFrame: "#e0a33a", Series: "#d07a45", Figure: "#5b9bd5", ndarray: "#9a7fd6", AnnData: "#4fb07b", str: "#b0b0b0", "*": "#8c8c8c" };
18
+ const STATUS_COLOURS = { ok: "#5fb36b", error: "#e05a4f", waiting: "#c9a640" };
19
+ const STORE = FLOW ? `nagare.flow.${FLOW}` : "nagare.graph";
20
+
21
+ let specs = {}; // spec id -> spec
22
+ let specsSig = "";
23
+ const graph = new LGraph();
24
+ let canvas;
25
+ let results = {};
26
+ let selected = null;
27
+ let runTimer = null;
28
+ let running = false, again = false;
29
+
30
+ function colourFor(type) {
31
+ if (TYPE_COLOURS[type]) return TYPE_COLOURS[type];
32
+ let h = 0;
33
+ for (const c of type) h = (h * 31 + c.charCodeAt(0)) % 360;
34
+ return `hsl(${h} 45% 60%)`;
35
+ }
36
+
37
+ // ---------- node types from Python functions ----------
38
+
39
+ function registerTypes(list) {
40
+ for (const spec of list) {
41
+ specs[spec.id] = spec;
42
+ const path = spec.category + "/" + spec.id.split(".").pop();
43
+ function NodeCtor() {
44
+ this.spec_id = spec.id;
45
+ this.serialize_widgets = true;
46
+ for (const s of spec.inputs) {
47
+ const c = colourFor(s.type);
48
+ this.addInput(s.name, s.type === "*" ? "" : s.type, { color_on: c, color_off: c });
49
+ }
50
+ for (const s of spec.outputs) {
51
+ const c = colourFor(s.type);
52
+ this.addOutput(s.name, s.type === "*" ? "" : s.type, { color_on: c, color_off: c });
53
+ }
54
+ for (const p of spec.params) addParam(this, p);
55
+ this.size = this.computeSize();
56
+ this.size[0] = Math.max(this.size[0], 210);
57
+ }
58
+ NodeCtor.title = spec.title;
59
+ NodeCtor.desc = spec.doc;
60
+ NodeCtor.prototype.onDrawForeground = drawResult;
61
+ // Called for clicks and for selection from code alike.
62
+ NodeCtor.prototype.onSelected = function () { selected = this; showPanel(this); tellSelection(); };
63
+ NodeCtor.prototype.onDeselected = function () { if (selected === this) { selected = null; showPanel(null); tellSelection(); } };
64
+ LiteGraph.registerNodeType(path, NodeCtor);
65
+ spec.path = path;
66
+ }
67
+ for (const [t, c] of Object.entries(TYPE_COLOURS)) LGraphCanvas.link_type_colors[t] = c;
68
+ for (const spec of list) for (const s of [...spec.inputs, ...spec.outputs]) LGraphCanvas.link_type_colors[s.type] = colourFor(s.type);
69
+ }
70
+
71
+ function addParam(node, p) {
72
+ const changed = () => changedGraph();
73
+ if (p.type === "bool") node.addWidget("toggle", p.name, !!p.default, changed);
74
+ else if (p.type === "int") node.addWidget("number", p.name, p.default, (v, w) => { w.value = Math.round(v); changed(); }, { precision: 0, step: 10 });
75
+ else if (p.type === "float") node.addWidget("number", p.name, p.default, changed, { precision: 3, step: 1 });
76
+ else if (p.type === "choice") node.addWidget("combo", p.name, p.default, changed, { values: p.choices });
77
+ else node.addWidget("text", p.name, p.default ?? "", changed);
78
+ }
79
+
80
+ // The status line and, for figures, a thumbnail inside the node.
81
+ const thumbs = new Map(); // node id -> Image
82
+ function drawResult(ctx) {
83
+ const r = results[this.id];
84
+ if (!r) return;
85
+ const base = this.computeSize()[1];
86
+ ctx.fillStyle = STATUS_COLOURS[r.status] || "#999";
87
+ ctx.beginPath(); ctx.arc(11, base + 7, 4, 0, Math.PI * 2); ctx.fill();
88
+ ctx.fillStyle = "#b8b8bd";
89
+ ctx.font = "11px system-ui, sans-serif";
90
+ let line = r.status === "ok" ? (r.summary || "done") : (r.error || r.status);
91
+ if (r.status === "ok") line += r.cached ? " · cached" : ` · ${r.seconds}s`;
92
+ const max = this.size[0] - 26;
93
+ while (ctx.measureText(line).width > max && line.length > 4) line = line.slice(0, -2);
94
+ ctx.fillText(line, 20, base + 11);
95
+ const img = thumbs.get(this.id);
96
+ if (img && img.complete && img.naturalWidth) {
97
+ const w = this.size[0] - 12, h = Math.min(w * img.naturalHeight / img.naturalWidth, 220);
98
+ const fw = h * img.naturalWidth / img.naturalHeight;
99
+ ctx.fillStyle = "#fff";
100
+ ctx.fillRect(6, base + 20, w, h);
101
+ ctx.drawImage(img, 6 + (w - fw) / 2, base + 20, fw, h);
102
+ }
103
+ }
104
+
105
+ function fitNode(node) {
106
+ const base = node.computeSize()[1];
107
+ const img = thumbs.get(node.id);
108
+ let h = base + 20;
109
+ if (img && img.naturalWidth) {
110
+ node.size[0] = Math.max(node.size[0], 260);
111
+ const w = node.size[0] - 12;
112
+ h += Math.min(w * img.naturalHeight / img.naturalWidth, 220) + 4;
113
+ }
114
+ node.size[1] = h;
115
+ }
116
+
117
+ // ---------- the graph as plain JSON for the engine ----------
118
+
119
+ function plainGraph() {
120
+ const nodes = [], links = [];
121
+ for (const n of graph._nodes) {
122
+ if (!n.spec_id) continue;
123
+ const params = {};
124
+ for (const w of n.widgets || []) params[w.name] = w.value;
125
+ nodes.push({ id: String(n.id), type: n.spec_id, params });
126
+ }
127
+ for (const id in graph.links) {
128
+ const l = graph.links[id];
129
+ if (!l) continue;
130
+ const target = graph.getNodeById(l.target_id);
131
+ if (!target || !target.inputs[l.target_slot]) continue;
132
+ links.push({ from: String(l.origin_id), out: l.origin_slot, to: String(l.target_id), input: target.inputs[l.target_slot].name });
133
+ }
134
+ return { nodes, links };
135
+ }
136
+
137
+ // ---------- running ----------
138
+
139
+ // Tell kenkyu which node is selected and whether it draws a figure.
140
+ function tellSelection() {
141
+ const n = selected;
142
+ const r = n && results[n.id];
143
+ tell({ type: "nagare:select", node: n ? String(n.id) : null, title: n ? n.title : "",
144
+ figure: !!(r && r.status === "ok" && r.preview && r.preview.kind === "image") });
145
+ }
146
+
147
+ function changedGraph() {
148
+ save();
149
+ if ($("#live").checked) {
150
+ clearTimeout(runTimer);
151
+ runTimer = setTimeout(run, 350);
152
+ }
153
+ }
154
+
155
+ async function run() {
156
+ if (running) { again = true; return; }
157
+ running = true;
158
+ $("#status").textContent = "running…";
159
+ const t0 = performance.now();
160
+ try {
161
+ const res = await fetch("api/run", { method: "POST", body: JSON.stringify({ graph: plainGraph() }) });
162
+ const data = await res.json();
163
+ if (data.error) throw new Error(data.error);
164
+ results = {};
165
+ for (const [id, r] of Object.entries(data.results)) results[+id] = r;
166
+ for (const n of graph._nodes) {
167
+ const r = results[n.id];
168
+ n.boxcolor = r ? STATUS_COLOURS[r.status] : null;
169
+ if (r && r.preview && r.preview.kind === "image") {
170
+ const img = new Image();
171
+ img.onload = () => { fitNode(n); canvas.setDirty(true, true); };
172
+ img.src = "data:image/png;base64," + r.preview.png;
173
+ thumbs.set(n.id, img);
174
+ } else {
175
+ thumbs.delete(n.id);
176
+ fitNode(n);
177
+ }
178
+ }
179
+ const counts = Object.values(results).reduce((a, r) => (a[r.status] = (a[r.status] || 0) + 1, a), {});
180
+ const ran = Object.values(results).filter((r) => r.status === "ok" && !r.cached).length;
181
+ $("#status").textContent = `${counts.ok || 0} ok · ${ran} ran · ${counts.error || 0} errors · ${Math.round(performance.now() - t0)} ms`;
182
+ } catch (e) {
183
+ $("#status").textContent = "run failed: " + e.message;
184
+ } finally {
185
+ running = false;
186
+ canvas.setDirty(true, true);
187
+ showPanel(selected);
188
+ tellSelection();
189
+ if (again) { again = false; run(); }
190
+ }
191
+ }
192
+
193
+ // ---------- the preview panel ----------
194
+
195
+ function esc(s) { return String(s).replace(/[&<>"]/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" }[c])); }
196
+
197
+ function showPanel(node) {
198
+ const p = $("#panel");
199
+ if (!node || !node.spec_id) { p.innerHTML = '<p class="muted">Select a node to see its output.</p>'; return; }
200
+ const spec = specs[node.spec_id] || { title: node.title, doc: "" };
201
+ const r = results[node.id];
202
+ let html = `<h2>${esc(spec.title)}</h2><p class="doc">${esc(spec.doc || node.spec_id)}</p>`;
203
+ if (!r) return (p.innerHTML = html + '<p class="muted">Not run yet.</p>');
204
+ html += `<div class="badges"><span class="badge ${r.status}">${r.status}</span>`;
205
+ if (r.status === "ok") html += `<span class="badge">${r.cached ? "from cache" : r.seconds + " s"}</span>${r.summary ? `<span class="badge">${esc(r.summary)}</span>` : ""}`;
206
+ html += "</div>";
207
+ if (r.error) html += `<pre class="pv-error">${esc(r.traceback || r.error)}</pre>`;
208
+ const pv = r.preview;
209
+ if (pv && pv.kind === "image") html += `<img alt="${esc(spec.title)} output" src="data:image/png;base64,${pv.png}">`;
210
+ else if (pv && pv.kind === "table") html += `<p class="muted">${pv.shape[0]} rows × ${pv.shape[1]} columns (first 15 × 12 shown)</p><div class="table-wrap">${pv.html}</div>`;
211
+ else if (pv) html += `<pre>${esc(pv.text)}</pre>`;
212
+ p.innerHTML = html;
213
+ }
214
+
215
+ // ---------- palette ----------
216
+
217
+ function buildPalette(data) {
218
+ const box = $("#palette");
219
+ const q = $("#filter").value.trim().toLowerCase();
220
+ const byCat = {};
221
+ for (const s of Object.values(specs)) {
222
+ if (q && !(s.title + " " + s.doc + " " + s.id).toLowerCase().includes(q)) continue;
223
+ (byCat[s.category] ||= []).push(s);
224
+ }
225
+ let html = "";
226
+ for (const cat of Object.keys(byCat).sort()) {
227
+ html += `<div class="cat">${esc(cat)}</div>`;
228
+ for (const s of byCat[cat]) html += `<button class="pal-item" data-id="${esc(s.id)}">${esc(s.title)}<small>${esc(s.doc)}</small></button>`;
229
+ }
230
+ for (const [f, err] of Object.entries((data && data.errors) || {})) html += `<p class="load-error">${esc(f)}: ${esc(err)}</p>`;
231
+ box.innerHTML = html || '<p class="muted">No functions found.</p>';
232
+ }
233
+
234
+ $("#palette").addEventListener("click", (e) => {
235
+ const b = e.target.closest(".pal-item");
236
+ if (!b) return;
237
+ const spec = specs[b.dataset.id];
238
+ const n = LiteGraph.createNode(spec.path);
239
+ const ds = canvas.ds;
240
+ const c = canvas.canvas;
241
+ n.pos = [(-ds.offset[0] + c.width / 2 / ds.scale) - n.size[0] / 2 + Math.random() * 40, (-ds.offset[1] + c.height / 2 / ds.scale) - 40 + Math.random() * 40];
242
+ graph.add(n);
243
+ canvas.selectNode(n);
244
+ changedGraph();
245
+ });
246
+ $("#filter").addEventListener("input", () => buildPalette());
247
+
248
+ // ---------- saving, loading, export ----------
249
+
250
+ let flowTimer = null, flowSaving = null, flowLoaded = false;
251
+ function save() {
252
+ if (FLOW) {
253
+ if (!flowLoaded) return; // not until kenkyu's copy is on the canvas
254
+ clearTimeout(flowTimer);
255
+ flowTimer = setTimeout(saveFlow, 600);
256
+ return;
257
+ }
258
+ try { localStorage.setItem(STORE, JSON.stringify(graph.serialize())); } catch (_) { /* storage may be off */ }
259
+ }
260
+
261
+ // Saves the graph to kenkyu. kenkyu answers with the graph's hash, which
262
+ // changes only when nodes, settings or links change (not when nodes move).
263
+ async function saveFlow() {
264
+ clearTimeout(flowTimer);
265
+ const body = JSON.stringify({ graph: plainGraph(), canvas: graph.serialize() });
266
+ const job = (async () => {
267
+ try {
268
+ const res = await fetch(FLOW_URL, { method: "POST", headers: { "Content-Type": "application/json" }, body });
269
+ if (!res.ok) throw new Error((await res.text()).trim() || res.status);
270
+ tell({ type: "nagare:saved", ...(await res.json()) });
271
+ } catch (e) {
272
+ $("#status").textContent = "not saved to kenkyu: " + e.message;
273
+ }
274
+ })();
275
+ flowSaving = job;
276
+ await job;
277
+ }
278
+
279
+ async function loadFlow() {
280
+ const res = await fetch(FLOW_URL);
281
+ if (!res.ok) throw new Error((await res.text()).trim() || res.status);
282
+ const data = await res.json();
283
+ document.title = data.name + " · Flow";
284
+ const nameEl = $("#flow-name");
285
+ nameEl.hidden = false;
286
+ nameEl.textContent = data.name;
287
+ return data.canvas;
288
+ }
289
+
290
+ // Select a node and bring it into view (kenkyu asks for this when a figure is clicked).
291
+ function focusNode(id) {
292
+ const n = graph.getNodeById(+id);
293
+ if (!n) return;
294
+ canvas.selectNode(n);
295
+ const c = canvas.canvas, ds = canvas.ds;
296
+ ds.offset = [c.width / 2 / ds.scale - n.pos[0] - n.size[0] / 2, c.height / 2 / ds.scale - n.pos[1] - n.size[1] / 2];
297
+ canvas.setDirty(true, true);
298
+ }
299
+
300
+ window.addEventListener("message", async (e) => {
301
+ if (!FLOW || e.origin !== location.origin || !e.data) return;
302
+ if (e.data.type === "kenkyu:select") focusNode(e.data.node);
303
+ if (e.data.type === "kenkyu:flush") {
304
+ if (flowTimer) await saveFlow(); else if (flowSaving) await flowSaving;
305
+ tell({ type: "nagare:flushed", id: e.data.id });
306
+ }
307
+ });
308
+
309
+ function load(data, focus) {
310
+ results = {}; thumbs.clear();
311
+ graph.configure(data);
312
+ for (const n of graph._nodes) fitNode(n);
313
+ canvas.setDirty(true, true);
314
+ showPanel(null);
315
+ if (FLOW) run(); // opening is not an edit: nothing to save
316
+ else {
317
+ changedGraph();
318
+ if (!$("#live").checked) run();
319
+ }
320
+ setTimeout(() => (focus && graph.getNodeById(+focus) ? focusNode(focus) : fitView()), 600);
321
+ }
322
+
323
+ async function listGraphs() {
324
+ if (FLOW) return;
325
+ const names = await (await fetch("api/graphs")).json();
326
+ $("#graphs").innerHTML = '<option value="">Open…</option>' + names.map((n) => `<option>${esc(n)}</option>`).join("");
327
+ }
328
+
329
+ $("#graphs").addEventListener("change", async (e) => {
330
+ const name = e.target.value;
331
+ e.target.value = "";
332
+ if (!name) return;
333
+ const data = await (await fetch("api/graphs/" + encodeURIComponent(name))).json();
334
+ load(data.litegraph || data);
335
+ $("#status").textContent = "opened " + name;
336
+ });
337
+
338
+ $("#save").addEventListener("click", async () => {
339
+ const name = (prompt("Save graph as (letters, digits, - and _):", "pipeline") || "").trim();
340
+ if (!name) return;
341
+ const res = await fetch("api/graphs/" + encodeURIComponent(name), {
342
+ method: "POST", body: JSON.stringify({ litegraph: graph.serialize(), graph: plainGraph() }),
343
+ });
344
+ const data = await res.json();
345
+ $("#status").textContent = data.error ? data.error : "saved " + name;
346
+ listGraphs();
347
+ });
348
+
349
+ $("#export").addEventListener("click", async () => {
350
+ const res = await fetch("api/export", { method: "POST", body: JSON.stringify({ graph: plainGraph() }) });
351
+ const text = await res.text();
352
+ const a = document.createElement("a");
353
+ a.href = URL.createObjectURL(new Blob([text], { type: "text/x-python" }));
354
+ a.download = (FLOW ? ($("#flow-name").textContent || "flow").replace(/[^\w\- ]+/g, "").trim() || "flow" : "pipeline") + ".py";
355
+ a.click();
356
+ URL.revokeObjectURL(a.href);
357
+ });
358
+
359
+ $("#new").addEventListener("click", () => { graph.clear(); results = {}; thumbs.clear(); save(); showPanel(null); $("#status").textContent = ""; });
360
+ $("#demo").addEventListener("click", () => { buildDemo(); if (FLOW) $("#demo").hidden = true; });
361
+ $("#run").addEventListener("click", run);
362
+ $("#live").addEventListener("change", () => { if ($("#live").checked) run(); });
363
+ document.addEventListener("keydown", (e) => {
364
+ if (e.key.toLowerCase() === "r" && !e.ctrlKey && !e.metaKey && !/INPUT|TEXTAREA|SELECT/.test(document.activeElement.tagName)) run();
365
+ });
366
+
367
+ // The RNA-seq demo: simulate → filter → normalise → PCA / DE → plots.
368
+ function buildDemo() {
369
+ graph.clear(); results = {}; thumbs.clear();
370
+ const at = (type, x, y) => {
371
+ const spec = specs[type];
372
+ if (!spec) throw new Error("missing node " + type);
373
+ const n = LiteGraph.createNode(spec.path);
374
+ n.pos = [x, y];
375
+ graph.add(n);
376
+ return n;
377
+ };
378
+ try {
379
+ const sim = at("rnaseq.simulate_counts", 40, 80);
380
+ const filt = at("rnaseq.filter_low_counts", 320, 80);
381
+ const norm = at("rnaseq.normalise_cpm", 580, 80);
382
+ const pca = at("rnaseq.pca", 840, 20);
383
+ const ppca = at("rnaseq.plot_pca", 1100, 20);
384
+ const de = at("rnaseq.differential_expression", 840, 260);
385
+ const vol = at("rnaseq.volcano_plot", 1100, 330);
386
+ const top = at("rnaseq.top_genes", 840, 470);
387
+ sim.connect(0, filt, 0); filt.connect(0, norm, 0);
388
+ norm.connect(0, pca, 0); pca.connect(0, ppca, 0);
389
+ norm.connect(0, de, 0); de.connect(0, vol, 0); de.connect(0, top, 0);
390
+ changedGraph();
391
+ run();
392
+ setTimeout(fitView, 600); // once the plot thumbnails have sized their nodes
393
+ } catch (e) {
394
+ $("#status").textContent = "demo needs examples/rnaseq.py: " + e.message;
395
+ }
396
+ }
397
+
398
+ // Zoom and pan so every node is in view.
399
+ function fitView() {
400
+ if (!graph._nodes.length) return;
401
+ let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;
402
+ for (const n of graph._nodes) {
403
+ x0 = Math.min(x0, n.pos[0]); y0 = Math.min(y0, n.pos[1] - LiteGraph.NODE_TITLE_HEIGHT);
404
+ x1 = Math.max(x1, n.pos[0] + n.size[0]); y1 = Math.max(y1, n.pos[1] + n.size[1]);
405
+ }
406
+ const c = canvas.canvas, pad = 30;
407
+ // LiteGraph leaves out node text below 0.6x, so in kenkyu's narrower
408
+ // frame the view stops there and starts from the left instead.
409
+ const fit = Math.min(1, (c.width - 2 * pad) / (x1 - x0), (c.height - 2 * pad) / (y1 - y0));
410
+ const scale = FLOW ? Math.max(fit, 0.6) : fit;
411
+ canvas.ds.scale = scale;
412
+ canvas.ds.offset = [pad / scale - x0 + Math.max(0, ((c.width - 2 * pad) / scale - (x1 - x0)) / 2), pad / scale - y0];
413
+ canvas.setDirty(true, true);
414
+ }
415
+
416
+ // ---------- start ----------
417
+
418
+ async function fetchSpecs() {
419
+ const data = await (await fetch("api/nodes")).json();
420
+ return { data, sig: JSON.stringify(data.types) };
421
+ }
422
+
423
+ // When the functions change shape (a new setting or socket), the page has to
424
+ // re-register node types; the graph is kept in local storage across the reload.
425
+ window.addEventListener("focus", async () => {
426
+ const { sig } = await fetchSpecs();
427
+ if (specsSig && sig !== specsSig) {
428
+ const n = $("#notice");
429
+ n.hidden = false;
430
+ n.innerHTML = 'Your functions changed shape. <button id="reload">Reload nodes</button>';
431
+ $("#reload").onclick = () => { save(); location.reload(); };
432
+ } else if ($("#live").checked) {
433
+ run(); // a function's body may have changed: the cache notices and reruns it
434
+ }
435
+ });
436
+
437
+ (async function start() {
438
+ const { data, sig } = await fetchSpecs();
439
+ specsSig = sig;
440
+ registerTypes(data.types);
441
+ buildPalette(data);
442
+
443
+ canvas = new LGraphCanvas("#canvas", graph);
444
+ canvas.background_image = null;
445
+ canvas.render_canvas_border = false;
446
+ canvas.show_info = false;
447
+ graph.onNodeAdded = () => changedGraph();
448
+ graph.onNodeRemoved = (n) => { delete results[n.id]; changedGraph(); };
449
+ graph.onConnectionChange = () => changedGraph();
450
+ const resize = () => { const w = $(".canvas-wrap"); canvas.resize(w.clientWidth, w.clientHeight); };
451
+ window.addEventListener("resize", resize);
452
+ resize();
453
+
454
+ if (FLOW) {
455
+ document.body.classList.add("in-kenkyu");
456
+ for (const el of document.querySelectorAll("[data-standalone]")) el.hidden = true;
457
+ let data = null;
458
+ try { data = await loadFlow(); } catch (e) { $("#status").textContent = "could not open the flow: " + e.message; return; }
459
+ // A page reload keeps unsaved edits only if kenkyu has nothing newer;
460
+ // kenkyu's copy is the one figures follow, so it wins.
461
+ const has = !!(data && data.nodes && data.nodes.length);
462
+ $("#demo").hidden = has || !specs["rnaseq.simulate_counts"];
463
+ if (has) load(data, PARAMS.get("node")); // configuring the canvas is not an edit
464
+ flowLoaded = true;
465
+ if (!has) tellSelection();
466
+ return;
467
+ }
468
+ let saved = null;
469
+ try { saved = JSON.parse(localStorage.getItem(STORE) || "null"); } catch (_) { saved = null; }
470
+ if (saved && saved.nodes && saved.nodes.length) load(saved);
471
+ else if (specs["rnaseq.simulate_counts"]) buildDemo();
472
+ listGraphs();
473
+ })();
@@ -0,0 +1,39 @@
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>nagare</title>
7
+ <link rel="stylesheet" href="vendor/litegraph.css">
8
+ <link rel="stylesheet" href="app.css">
9
+ </head>
10
+ <body>
11
+ <header class="bar">
12
+ <strong class="brand">流 nagare</strong>
13
+ <span id="flow-name" class="flow-name" hidden></span>
14
+ <button id="run" title="Run everything (R)">Run</button>
15
+ <label class="live" title="Re-run whenever something changes; unchanged nodes come from the cache"><input type="checkbox" id="live" checked> Live</label>
16
+ <span class="sep"></span>
17
+ <button id="new" title="Empty canvas" data-standalone>New</button>
18
+ <button id="demo" title="Load the RNA-seq demo graph">Demo</button>
19
+ <select id="graphs" title="Open a saved graph" data-standalone><option value="">Open…</option></select>
20
+ <button id="save" title="Save this graph" data-standalone>Save</button>
21
+ <button id="export" title="Download the graph as a plain Python script">Export .py</button>
22
+ <span id="status" class="status"></span>
23
+ </header>
24
+ <div id="notice" class="notice" hidden></div>
25
+ <main>
26
+ <aside class="palette">
27
+ <input id="filter" placeholder="Find a node…" autocomplete="off">
28
+ <div id="palette"></div>
29
+ <p class="hint">Click to add, or double-click the canvas to search. Drag from a socket to connect; sockets only join matching types.</p>
30
+ </aside>
31
+ <section class="canvas-wrap"><canvas id="canvas"></canvas></section>
32
+ <aside class="panel" id="panel">
33
+ <p class="muted">Select a node to see its output.</p>
34
+ </aside>
35
+ </main>
36
+ <script src="vendor/litegraph.core.min.js"></script>
37
+ <script src="app.js"></script>
38
+ </body>
39
+ </html>
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2013 by Javi Agenjo
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.