rshow 0.0.0-stage → 0.0.2

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.
Files changed (84) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +50 -2
  3. package/dist/main.js +8500 -0
  4. package/package.json +48 -4
  5. package/skills/rshow/SKILL.md +144 -0
  6. package/skills/rshow/reference/cli.md +263 -0
  7. package/skills/rshow/reference/dashboard.md +122 -0
  8. package/skills/rshow/reference/mockups.md +113 -0
  9. package/skills/rshow/reference/page-contract.md +83 -0
  10. package/skills/rshow/reference/pages.md +174 -0
  11. package/skills/rshow/reference/poster.md +137 -0
  12. package/skills/rshow/reference/project-page.md +132 -0
  13. package/skills/rshow/reference/reports.md +158 -0
  14. package/skills/rshow/reference/sketch.md +78 -0
  15. package/skills/rshow/reference/terminal.md +148 -0
  16. package/skills/rshow/reference/themes.md +139 -0
  17. package/skills/rshow-implement/SKILL.md +112 -0
  18. package/skills/rshow-implement/reference/compare.md +156 -0
  19. package/skills/rshow-implement/reference/handoff.md +125 -0
  20. package/skills/rshow-implement/reference/map.md +151 -0
  21. package/skills/rshow-slides/SKILL.md +136 -0
  22. package/skills/rshow-slides/reference/layouts.md +251 -0
  23. package/themes/default/dashboard.css +521 -0
  24. package/themes/default/dashboard.js +1390 -0
  25. package/themes/default/deck.css +586 -0
  26. package/themes/default/deck.js +741 -0
  27. package/themes/default/example/capture.ans +1 -0
  28. package/themes/default/example/dashboard.html +106 -0
  29. package/themes/default/example/demo.cast +14 -0
  30. package/themes/default/example/drawing.excalidraw +377 -0
  31. package/themes/default/example/index.html +311 -0
  32. package/themes/default/example/mockup-desktop.html +331 -0
  33. package/themes/default/example/mockup-platforms.html +742 -0
  34. package/themes/default/example/mockup.html +416 -0
  35. package/themes/default/example/page.html +153 -0
  36. package/themes/default/example/poster-figure.svg +58 -0
  37. package/themes/default/example/poster.html +181 -0
  38. package/themes/default/example/project.html +229 -0
  39. package/themes/default/example/report.html +404 -0
  40. package/themes/default/example/results.csv +61 -0
  41. package/themes/default/example/sketch.html +178 -0
  42. package/themes/default/example/teaser.svg +66 -0
  43. package/themes/default/example/terminal.html +231 -0
  44. package/themes/default/example/tui.html +223 -0
  45. package/themes/default/fonts/IBMPlexMono-Regular-Latin1.woff2 +0 -0
  46. package/themes/default/fonts/IBMPlexSans-Light-Latin1.woff2 +0 -0
  47. package/themes/default/fonts/IBMPlexSans-Regular-Latin1.woff2 +0 -0
  48. package/themes/default/fonts/IBMPlexSans-SemiBold-Latin1.woff2 +0 -0
  49. package/themes/default/fonts/OFL.txt +93 -0
  50. package/themes/default/fonts.css +63 -0
  51. package/themes/default/index.html +573 -0
  52. package/themes/default/mockup.css +1078 -0
  53. package/themes/default/mockup.js +1433 -0
  54. package/themes/default/mode.js +242 -0
  55. package/themes/default/page.css +320 -0
  56. package/themes/default/poster.css +480 -0
  57. package/themes/default/poster.js +223 -0
  58. package/themes/default/project.css +482 -0
  59. package/themes/default/project.js +116 -0
  60. package/themes/default/report.css +776 -0
  61. package/themes/default/report.js +427 -0
  62. package/themes/default/sketch.css +166 -0
  63. package/themes/default/sketch.js +681 -0
  64. package/themes/default/skins/adwaita.css +669 -0
  65. package/themes/default/skins/custom.css +596 -0
  66. package/themes/default/skins/egui.css +639 -0
  67. package/themes/default/skins/fluent.css +1093 -0
  68. package/themes/default/skins/fluent.js +458 -0
  69. package/themes/default/skins/mac.css +647 -0
  70. package/themes/default/skins/material.css +692 -0
  71. package/themes/default/skins/sketch.css +436 -0
  72. package/themes/default/skins/sketch.js +494 -0
  73. package/themes/default/skins/wire.css +561 -0
  74. package/themes/default/terminal.css +292 -0
  75. package/themes/default/terminal.js +433 -0
  76. package/themes/default/theme.json +149 -0
  77. package/themes/default/tokens.css +255 -0
  78. package/themes/default/tui.css +703 -0
  79. package/themes/default/tui.js +472 -0
  80. package/worker/index.js +6918 -0
  81. package/worker/migrations/0001_init.sql +52 -0
  82. package/worker/migrations/0002_blobs.sql +5 -0
  83. package/worker/migrations/0003_projects.sql +31 -0
  84. package/worker/migrations/0004_page_data_blob.sql +19 -0
@@ -0,0 +1,494 @@
1
+ /*
2
+ * rshow theme "default": the sketch pencil.
3
+ *
4
+ * sketch.css holds the geometry and the type of the sketch skin; this file
5
+ * holds the pencil. Every wf-* element on a screen gets a rough outline drawn
6
+ * behind it in one SVG per screen, sized in the screen's own coordinates, so
7
+ * the drawing scales with a zoom and never needs a redraw for it.
8
+ *
9
+ * rough.js is fetched once, from jsdelivr, at one pinned version, and only when
10
+ * a mockup is actually in the sketch skin. The seed of a shape comes from its
11
+ * index and its class, so the same box is drawn the same way on every render
12
+ * and a reader does not see the sketch jitter when a screen is focused.
13
+ *
14
+ * If the fetch fails, the skin becomes wire: a half drawn screen is worse than
15
+ * a plain one.
16
+ */
17
+ (function () {
18
+ 'use strict';
19
+
20
+ var main = document.querySelector('.mockup');
21
+ if (!main) {
22
+ return;
23
+ }
24
+
25
+ var ROUGH_URL = 'https://cdn.jsdelivr.net/npm/roughjs@4.6.6/bundled/rough.js';
26
+ var SVG_NS = 'http://www.w3.org/2000/svg';
27
+ var SELECTOR = [
28
+ '.wf-box',
29
+ '.wf-card',
30
+ '.wf-image',
31
+ '.wf-avatar',
32
+ '.wf-icon',
33
+ '.wf-text',
34
+ '.wf-heading',
35
+ '.wf-button',
36
+ '.wf-input',
37
+ '.wf-select',
38
+ '.wf-checkbox',
39
+ '.wf-toggle',
40
+ '.wf-chart',
41
+ '.wf-table',
42
+ '.wf-modal',
43
+ '.wf-toast',
44
+ '.wf-nav',
45
+ '.wf-sidebar',
46
+ '.wf-tabs'
47
+ ].join(', ');
48
+
49
+ var api = null;
50
+ var phase = 'idle';
51
+ var waiting = [];
52
+ var timer = null;
53
+
54
+ function isSketch() {
55
+ return main.getAttribute('data-skin') === 'sketch';
56
+ }
57
+
58
+ function skinLink() {
59
+ return document.querySelector('link[data-mk-skin]') || document.getElementById('mk-skin');
60
+ }
61
+
62
+ function announce() {
63
+ try {
64
+ document.dispatchEvent(new window.CustomEvent('mkchange', { detail: { skin: 'wire' } }));
65
+ } catch (err) {
66
+ // A browser without CustomEvent keeps the attribute and loses the event.
67
+ }
68
+ }
69
+
70
+ // ------------------------------------------------------------- loading --
71
+
72
+ function fallback() {
73
+ phase = 'failed';
74
+ var link = skinLink();
75
+ main.setAttribute('data-skin', 'wire');
76
+ if (link && link.href) {
77
+ link.href = new window.URL('wire.css', link.href).href;
78
+ }
79
+ var select = document.querySelector('select[data-mk="skin"]');
80
+ if (select) {
81
+ select.value = 'wire';
82
+ }
83
+ announce();
84
+ }
85
+
86
+ function settle(found) {
87
+ var callbacks = waiting;
88
+ waiting = [];
89
+ if (found && typeof found.svg === 'function') {
90
+ api = found;
91
+ phase = 'ready';
92
+ for (var i = 0; i < callbacks.length; i += 1) {
93
+ callbacks[i]();
94
+ }
95
+ return;
96
+ }
97
+ fallback();
98
+ }
99
+
100
+ function ensure(done) {
101
+ if (phase === 'ready') {
102
+ if (done) {
103
+ done();
104
+ }
105
+ return;
106
+ }
107
+ if (phase === 'failed') {
108
+ return;
109
+ }
110
+ if (done) {
111
+ waiting.push(done);
112
+ }
113
+ if (phase === 'loading') {
114
+ return;
115
+ }
116
+ phase = 'loading';
117
+ var script = document.createElement('script');
118
+ script.src = ROUGH_URL;
119
+ script.async = true;
120
+ script.onload = function () {
121
+ settle(window.rough || null);
122
+ };
123
+ script.onerror = function () {
124
+ settle(null);
125
+ };
126
+ document.head.appendChild(script);
127
+ window.setTimeout(function () {
128
+ if (phase === 'loading') {
129
+ settle(window.rough || null);
130
+ }
131
+ }, 8000);
132
+ }
133
+
134
+ // -------------------------------------------------------------- drawing --
135
+
136
+ function token(node, name, fallbackValue) {
137
+ var value = window.getComputedStyle(node).getPropertyValue(name);
138
+ value = value === null ? '' : value.trim();
139
+ return value === '' ? fallbackValue : value;
140
+ }
141
+
142
+ function seedFor(node, index) {
143
+ var text = String(node.className || '') + '|' + String(node.textContent || '').slice(0, 24);
144
+ var hash = (2166136261 ^ (index + 1)) >>> 0;
145
+ for (var i = 0; i < text.length; i += 1) {
146
+ hash ^= text.charCodeAt(i);
147
+ hash = Math.imul(hash, 16777619) >>> 0;
148
+ }
149
+ return hash % 100000;
150
+ }
151
+
152
+ function paint(ctx) {
153
+ var node = ctx.node;
154
+ var svg = ctx.svg;
155
+ var rc = ctx.rc;
156
+ var x = ctx.x;
157
+ var y = ctx.y;
158
+ var w = ctx.w;
159
+ var h = ctx.h;
160
+ var seed = ctx.seed;
161
+ var cls = node.classList;
162
+ var ink = token(node, '--mk-line', '#3a3a3a');
163
+ var accent = token(node, '--mk-accent', '#1f4fd8');
164
+ var base = {
165
+ seed: seed,
166
+ stroke: ink,
167
+ strokeWidth: 1.3,
168
+ roughness: 1.05,
169
+ bowing: 1,
170
+ preserveVertices: true
171
+ };
172
+ var i;
173
+ var options;
174
+
175
+ function add(shape) {
176
+ if (shape) {
177
+ svg.appendChild(shape);
178
+ }
179
+ }
180
+
181
+ if (cls.contains('wf-text')) {
182
+ if (node.childElementCount === 0 && String(node.textContent || '').trim() === '') {
183
+ var lines = parseInt(node.getAttribute('data-lines') || '2', 10);
184
+ if (!(lines > 0)) {
185
+ lines = 2;
186
+ }
187
+ var step = h / lines;
188
+ for (i = 0; i < lines; i += 1) {
189
+ var lineY = y + step * i + step * 0.62;
190
+ var ratio = i === lines - 1 && lines > 2 ? 0.58 : 0.94;
191
+ options = {
192
+ seed: seed + i * 13,
193
+ stroke: ink,
194
+ strokeWidth: 1.1,
195
+ roughness: 0.9,
196
+ bowing: 0.8
197
+ };
198
+ add(rc.line(x, lineY, x + w * ratio, lineY, options));
199
+ }
200
+ }
201
+ return;
202
+ }
203
+
204
+ if (cls.contains('wf-heading')) {
205
+ if (String(node.textContent || '').trim() === '') {
206
+ options = { seed: seed, stroke: ink, strokeWidth: 3, roughness: 0.8, bowing: 0.6 };
207
+ add(rc.line(x, y + h / 2, x + w, y + h / 2, options));
208
+ }
209
+ return;
210
+ }
211
+
212
+ if (cls.contains('wf-image')) {
213
+ add(rc.rectangle(x, y, w, h, base));
214
+ add(rc.line(x, y, x + w, y + h, { seed: seed + 1, stroke: ink, strokeWidth: 1, roughness: 0.9 }));
215
+ add(rc.line(x + w, y, x, y + h, { seed: seed + 2, stroke: ink, strokeWidth: 1, roughness: 0.9 }));
216
+ return;
217
+ }
218
+
219
+ if (cls.contains('wf-avatar')) {
220
+ add(rc.circle(x + w / 2, y + h / 2, Math.min(w, h), base));
221
+ return;
222
+ }
223
+
224
+ if (cls.contains('wf-checkbox')) {
225
+ add(rc.rectangle(x, y, w, h, base));
226
+ if (node.getAttribute('data-checked') === 'true') {
227
+ add(rc.line(x + w * 0.2, y + h * 0.55, x + w * 0.45, y + h * 0.8, {
228
+ seed: seed + 3,
229
+ stroke: accent,
230
+ strokeWidth: 1.8,
231
+ roughness: 0.8
232
+ }));
233
+ add(rc.line(x + w * 0.45, y + h * 0.8, x + w * 0.85, y + h * 0.2, {
234
+ seed: seed + 4,
235
+ stroke: accent,
236
+ strokeWidth: 1.8,
237
+ roughness: 0.8
238
+ }));
239
+ }
240
+ return;
241
+ }
242
+
243
+ if (cls.contains('wf-toggle')) {
244
+ add(rc.rectangle(x, y, w, h, base));
245
+ var knob = Math.min(h - 8, 14);
246
+ var knobX = cls.contains('on') ? x + w - knob - 4 : x + 4;
247
+ add(rc.circle(knobX + knob / 2, y + h / 2, knob, {
248
+ seed: seed + 5,
249
+ stroke: ink,
250
+ strokeWidth: 1.2,
251
+ roughness: 0.9
252
+ }));
253
+ return;
254
+ }
255
+
256
+ if (cls.contains('wf-button')) {
257
+ // A primary button is the same pencil in a heavier hand, not a fill: a
258
+ // hatch of accent under accent text cannot be read.
259
+ var primary = cls.contains('primary');
260
+ options = {
261
+ seed: seed,
262
+ stroke: primary ? accent : ink,
263
+ strokeWidth: primary ? 2.2 : 1.3,
264
+ roughness: 0.9,
265
+ bowing: 1
266
+ };
267
+ add(rc.rectangle(x, y, w, h, options));
268
+ return;
269
+ }
270
+
271
+ if (cls.contains('wf-table')) {
272
+ add(rc.rectangle(x, y, w, h, base));
273
+ var rows = parseInt(node.getAttribute('data-rows') || '4', 10);
274
+ var cols = parseInt(node.getAttribute('data-cols') || '3', 10);
275
+ if (!(rows > 0)) {
276
+ rows = 4;
277
+ }
278
+ if (!(cols > 0)) {
279
+ cols = 3;
280
+ }
281
+ for (i = 1; i < rows; i += 1) {
282
+ var ry = y + (h / rows) * i;
283
+ add(rc.line(x, ry, x + w, ry, {
284
+ seed: seed + i * 7,
285
+ stroke: ink,
286
+ strokeWidth: 0.9,
287
+ roughness: 0.7
288
+ }));
289
+ }
290
+ for (i = 1; i < cols; i += 1) {
291
+ var cx = x + (w / cols) * i;
292
+ add(rc.line(cx, y, cx, y + h, {
293
+ seed: seed + i * 11,
294
+ stroke: ink,
295
+ strokeWidth: 0.9,
296
+ roughness: 0.7
297
+ }));
298
+ }
299
+ return;
300
+ }
301
+
302
+ if (cls.contains('wf-chart')) {
303
+ add(rc.line(x, y, x, y + h, { seed: seed + 1, stroke: ink, strokeWidth: 1.1, roughness: 0.8 }));
304
+ add(rc.line(x, y + h, x + w, y + h, { seed: seed + 2, stroke: ink, strokeWidth: 1.1, roughness: 0.8 }));
305
+ for (i = 0; i < node.children.length; i += 1) {
306
+ var bar = node.children[i];
307
+ var barRect = bar.getBoundingClientRect();
308
+ if (barRect.width === 0 || barRect.height === 0) {
309
+ continue;
310
+ }
311
+ var bx = (barRect.left - ctx.origin.left) * ctx.k;
312
+ var by = (barRect.top - ctx.origin.top) * ctx.k;
313
+ var bw = barRect.width * ctx.k;
314
+ var bh = barRect.height * ctx.k;
315
+ add(
316
+ rc.rectangle(bx, by, bw, bh, {
317
+ seed: seedFor(bar, i),
318
+ stroke: bar.classList.contains('is-accent') ? accent : ink,
319
+ strokeWidth: 1.2,
320
+ roughness: 1,
321
+ fill: bar.classList.contains('is-accent') ? accent : undefined,
322
+ fillStyle: 'hachure',
323
+ hachureGap: 6,
324
+ hachureAngle: -41
325
+ })
326
+ );
327
+ }
328
+ return;
329
+ }
330
+
331
+ // Everything else is a rectangle: a box, a card, a field, a bar, a window.
332
+ add(rc.rectangle(x, y, w, h, base));
333
+ }
334
+
335
+ function roughLayer(screen) {
336
+ for (var c = 0; c < screen.children.length; c += 1) {
337
+ if (screen.children[c].classList.contains('mk-rough')) {
338
+ return screen.children[c];
339
+ }
340
+ }
341
+ var svg = document.createElementNS(SVG_NS, 'svg');
342
+ svg.setAttribute('class', 'mk-rough');
343
+ svg.setAttribute('aria-hidden', 'true');
344
+ svg.setAttribute('focusable', 'false');
345
+ screen.appendChild(svg);
346
+ return svg;
347
+ }
348
+
349
+ function drawScreen(screen) {
350
+ var width = screen.offsetWidth;
351
+ var height = screen.offsetHeight;
352
+ if (width === 0 || height === 0) {
353
+ return;
354
+ }
355
+ var origin = screen.getBoundingClientRect();
356
+ var k = origin.width === 0 ? 1 : width / origin.width;
357
+ var nodes = screen.querySelectorAll(SELECTOR);
358
+ // A modal or a toast has a background of its own, so it gets a pencil layer
359
+ // of its own: one layer per screen would draw its contents under its paper.
360
+ var layers = [];
361
+ var byHost = new Map();
362
+ for (var i = 0; i < nodes.length; i += 1) {
363
+ var node = nodes[i];
364
+ if (node.getClientRects().length === 0) {
365
+ continue;
366
+ }
367
+ var rect = node.getBoundingClientRect();
368
+ if (rect.width * k < 3 || rect.height * k < 3) {
369
+ continue;
370
+ }
371
+ var host = node.closest('.wf-modal, .wf-toast');
372
+ if (host === null || host === undefined || host === screen) {
373
+ host = screen;
374
+ }
375
+ var bucket = byHost.get(host);
376
+ if (bucket === undefined) {
377
+ bucket = [];
378
+ byHost.set(host, bucket);
379
+ layers.push(host);
380
+ }
381
+ bucket.push({ node: node, rect: rect, seed: seedFor(node, i) });
382
+ }
383
+ for (var l = 0; l < layers.length; l += 1) {
384
+ drawLayer(layers[l], byHost.get(layers[l]), k);
385
+ }
386
+ }
387
+
388
+ function drawLayer(host, items, k) {
389
+ var width = host.offsetWidth;
390
+ var height = host.offsetHeight;
391
+ if (width === 0 || height === 0) {
392
+ return;
393
+ }
394
+ var svg = roughLayer(host);
395
+ while (svg.firstChild) {
396
+ svg.removeChild(svg.firstChild);
397
+ }
398
+ svg.setAttribute('viewBox', '0 0 ' + width + ' ' + height);
399
+ svg.setAttribute('preserveAspectRatio', 'none');
400
+ var rc = api.svg(svg);
401
+ var origin = host.getBoundingClientRect();
402
+ for (var i = 0; i < items.length; i += 1) {
403
+ var item = items[i];
404
+ paint({
405
+ node: item.node,
406
+ svg: svg,
407
+ rc: rc,
408
+ x: (item.rect.left - origin.left) * k,
409
+ y: (item.rect.top - origin.top) * k,
410
+ w: item.rect.width * k,
411
+ h: item.rect.height * k,
412
+ seed: item.seed,
413
+ origin: origin,
414
+ k: k
415
+ });
416
+ }
417
+ }
418
+
419
+ function draw() {
420
+ if (api === null || !isSketch()) {
421
+ return;
422
+ }
423
+ var screens = main.querySelectorAll('.mk-screen');
424
+ for (var s = 0; s < screens.length; s += 1) {
425
+ drawScreen(screens[s]);
426
+ }
427
+ }
428
+
429
+ function schedule(delay) {
430
+ if (timer !== null) {
431
+ window.clearTimeout(timer);
432
+ }
433
+ timer = window.setTimeout(function () {
434
+ timer = null;
435
+ draw();
436
+ }, delay === undefined ? 80 : delay);
437
+ }
438
+
439
+ function start() {
440
+ if (!isSketch()) {
441
+ return;
442
+ }
443
+ ensure(function () {
444
+ draw();
445
+ });
446
+ }
447
+
448
+ // --------------------------------------------------------------- wiring --
449
+
450
+ document.addEventListener('mkchange', function () {
451
+ if (isSketch()) {
452
+ start();
453
+ schedule(120);
454
+ }
455
+ });
456
+
457
+ window.addEventListener('resize', function () {
458
+ if (isSketch()) {
459
+ schedule(140);
460
+ }
461
+ });
462
+
463
+ document.addEventListener('transitionend', function () {
464
+ if (isSketch()) {
465
+ schedule(140);
466
+ }
467
+ });
468
+
469
+ if (typeof window.MutationObserver === 'function') {
470
+ var observer = new window.MutationObserver(function (records) {
471
+ for (var i = 0; i < records.length; i += 1) {
472
+ var target = records[i].target;
473
+ if (target && target.closest && target.closest('.mk-rough')) {
474
+ continue;
475
+ }
476
+ if (isSketch()) {
477
+ schedule(150);
478
+ }
479
+ return;
480
+ }
481
+ });
482
+ observer.observe(main, {
483
+ attributes: true,
484
+ attributeFilter: ['style', 'class', 'data-state', 'data-skin', 'data-view'],
485
+ subtree: true
486
+ });
487
+ }
488
+
489
+ if (document.readyState === 'loading') {
490
+ document.addEventListener('DOMContentLoaded', start);
491
+ } else {
492
+ start();
493
+ }
494
+ }());