@tinyvolt/pie 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.
Files changed (139) hide show
  1. package/README.md +18 -1
  2. package/dist/components/SplitPane.d.ts +21 -0
  3. package/dist/components/SplitPane.jsx +113 -0
  4. package/dist/components/icons.d.ts +12 -0
  5. package/dist/components/icons.jsx +45 -0
  6. package/dist/lib/autodiff/index.d.ts +28 -0
  7. package/dist/lib/autodiff/index.js +39 -0
  8. package/dist/lib/customModules.d.ts +19 -0
  9. package/dist/lib/customModules.js +52 -0
  10. package/dist/lib/markdown/compile.d.ts +27 -0
  11. package/dist/lib/markdown/compile.js +26 -0
  12. package/dist/lib/markdown/components/CanvasPage.d.ts +9 -0
  13. package/dist/lib/markdown/components/CanvasPage.jsx +16 -0
  14. package/dist/lib/markdown/components/MarkdownBody.d.ts +11 -0
  15. package/dist/lib/markdown/components/MarkdownBody.jsx +37 -0
  16. package/dist/lib/markdown/components/PiePage.d.ts +14 -0
  17. package/dist/lib/markdown/components/PiePage.jsx +42 -0
  18. package/dist/lib/markdown/components/PythonEditor.d.ts +10 -0
  19. package/dist/lib/markdown/components/PythonEditor.jsx +209 -0
  20. package/dist/lib/markdown/features/build.d.ts +60 -0
  21. package/dist/lib/markdown/features/build.js +36 -0
  22. package/dist/lib/markdown/features/glossary/View.d.ts +9 -0
  23. package/dist/lib/markdown/features/glossary/View.jsx +62 -0
  24. package/dist/lib/markdown/features/glossary/build.d.ts +6 -0
  25. package/dist/lib/markdown/features/glossary/build.js +81 -0
  26. package/dist/lib/markdown/features/sidebar/View.d.ts +11 -0
  27. package/dist/lib/markdown/features/sidebar/View.jsx +45 -0
  28. package/dist/lib/markdown/features/sidebar/build.d.ts +3 -0
  29. package/dist/lib/markdown/features/sidebar/build.js +7 -0
  30. package/dist/lib/markdown/features/tags/build.d.ts +7 -0
  31. package/dist/lib/markdown/features/tags/build.js +22 -0
  32. package/dist/lib/markdown/features/tags/url.d.ts +6 -0
  33. package/dist/lib/markdown/features/tags/url.js +10 -0
  34. package/dist/lib/markdown/features/toc/build.d.ts +7 -0
  35. package/dist/lib/markdown/features/toc/build.js +62 -0
  36. package/dist/lib/markdown/features/views.d.ts +4 -0
  37. package/dist/lib/markdown/features/views.jsx +11 -0
  38. package/dist/lib/markdown/frontmatter.d.ts +44 -0
  39. package/dist/lib/markdown/frontmatter.js +109 -0
  40. package/dist/lib/markdown/render.d.ts +6 -0
  41. package/dist/lib/markdown/render.js +95 -0
  42. package/dist/lib/nodes/animation.d.ts +14 -0
  43. package/dist/lib/nodes/animation.js +34 -0
  44. package/dist/lib/nodes/components/CenteredGrid.d.ts +20 -0
  45. package/dist/lib/nodes/components/CenteredGrid.jsx +44 -0
  46. package/dist/lib/nodes/components/NodeCanvas.d.ts +7 -0
  47. package/dist/lib/nodes/components/NodeCanvas.jsx +50 -0
  48. package/dist/lib/nodes/execute.d.ts +27 -0
  49. package/dist/lib/nodes/execute.js +159 -0
  50. package/dist/lib/nodes/functions/Node2NodeFunc.d.ts +70 -0
  51. package/dist/lib/nodes/functions/Node2NodeFunc.js +223 -0
  52. package/dist/lib/nodes/functions/array.d.ts +12 -0
  53. package/dist/lib/nodes/functions/array.js +31 -0
  54. package/dist/lib/nodes/functions/autodiff.d.ts +12 -0
  55. package/dist/lib/nodes/functions/autodiff.js +60 -0
  56. package/dist/lib/nodes/functions/basic.d.ts +111 -0
  57. package/dist/lib/nodes/functions/basic.js +275 -0
  58. package/dist/lib/nodes/functions/registry.d.ts +9 -0
  59. package/dist/lib/nodes/functions/registry.js +45 -0
  60. package/dist/lib/nodes/functions/sideEffects.d.ts +78 -0
  61. package/dist/lib/nodes/functions/sideEffects.js +201 -0
  62. package/dist/lib/nodes/hooks/useCanvasGestures.d.ts +9 -0
  63. package/dist/lib/nodes/hooks/useCanvasGestures.js +120 -0
  64. package/dist/lib/nodes/hooks/useCanvasResize.d.ts +2 -0
  65. package/dist/lib/nodes/hooks/useCanvasResize.js +33 -0
  66. package/dist/lib/nodes/jax.d.ts +46 -0
  67. package/dist/lib/nodes/jax.js +120 -0
  68. package/dist/lib/nodes/render/renderLogic.d.ts +13 -0
  69. package/dist/lib/nodes/render/renderLogic.jsx +234 -0
  70. package/dist/lib/nodes/state/NameGenerator.d.ts +10 -0
  71. package/dist/lib/nodes/state/NameGenerator.js +29 -0
  72. package/dist/lib/nodes/state/Node.d.ts +134 -0
  73. package/dist/lib/nodes/state/Node.js +57 -0
  74. package/dist/lib/nodes/state/NodeStore.d.ts +49 -0
  75. package/dist/lib/nodes/state/NodeStore.js +138 -0
  76. package/dist/lib/nodes/tensors/broadcast.d.ts +18 -0
  77. package/dist/lib/nodes/tensors/broadcast.js +92 -0
  78. package/dist/lib/nodes/tensors/tensor.d.ts +13 -0
  79. package/dist/lib/nodes/tensors/tensor.js +34 -0
  80. package/dist/lib/python/lift.d.ts +51 -0
  81. package/dist/lib/python/lift.js +155 -0
  82. package/dist/lib/python/py/pie.py +303 -0
  83. package/dist/lib/python/py/pie_mpl.py +15 -0
  84. package/dist/lib/python/py/show_figures.py +5 -0
  85. package/dist/lib/python/runPage.d.ts +21 -0
  86. package/dist/lib/python/runPage.js +60 -0
  87. package/dist/lib/python/runner.d.ts +68 -0
  88. package/dist/lib/python/runner.js +243 -0
  89. package/dist/lib/python/worker.d.ts +1 -0
  90. package/dist/lib/python/worker.js +111 -0
  91. package/dist/lib/ui/UiLayer.d.ts +2 -0
  92. package/dist/lib/ui/UiLayer.jsx +15 -0
  93. package/dist/lib/ui/UiView.d.ts +23 -0
  94. package/dist/lib/ui/UiView.jsx +56 -0
  95. package/dist/lib/ui/components/checkboxes.d.ts +10 -0
  96. package/dist/lib/ui/components/checkboxes.jsx +30 -0
  97. package/dist/lib/ui/components/latex.d.ts +8 -0
  98. package/dist/lib/ui/components/latex.jsx +41 -0
  99. package/dist/lib/ui/components/radio.d.ts +6 -0
  100. package/dist/lib/ui/components/radio.jsx +19 -0
  101. package/dist/lib/ui/components/slider.d.ts +8 -0
  102. package/dist/lib/ui/components/slider.jsx +7 -0
  103. package/dist/lib/ui/components/textbox.d.ts +5 -0
  104. package/dist/lib/ui/components/textbox.jsx +21 -0
  105. package/dist/lib/ui/dragUi.d.ts +10 -0
  106. package/dist/lib/ui/dragUi.js +129 -0
  107. package/dist/lib/ui/nodeHandle.d.ts +15 -0
  108. package/dist/lib/ui/nodeHandle.js +37 -0
  109. package/dist/lib/ui/registry.d.ts +10 -0
  110. package/dist/lib/ui/registry.js +42 -0
  111. package/dist/runtime.css +696 -0
  112. package/dist/runtime.d.ts +10 -0
  113. package/dist/runtime.jsx +7 -0
  114. package/init/index.js +2 -2
  115. package/init/site-agents.md +2 -1
  116. package/package.json +15 -6
  117. package/runtime-agents.md +168 -0
  118. package/src/app.css +7 -665
  119. package/src/lib/customModules.ts +67 -0
  120. package/src/lib/markdown/compile.ts +49 -0
  121. package/src/lib/markdown/components/PiePage.tsx +49 -0
  122. package/src/lib/markdown/features/build.ts +15 -6
  123. package/src/lib/markdown/features/sidebar/View.tsx +4 -2
  124. package/src/lib/markdown/features/tags/build.ts +6 -3
  125. package/src/lib/markdown/pages.ts +1 -9
  126. package/src/lib/markdown/vitePlugin.ts +4 -8
  127. package/src/lib/nodes/functions/registry.ts +30 -21
  128. package/src/lib/nodes/functions/sideEffects.ts +14 -8
  129. package/src/lib/nodes/functions/vitePlugin.ts +8 -10
  130. package/src/lib/nodes/state/Node.ts +27 -19
  131. package/src/lib/python/runPage.ts +78 -0
  132. package/src/lib/python/runner.ts +189 -164
  133. package/src/lib/siteModules.ts +13 -0
  134. package/src/lib/ui/dragUi.ts +4 -2
  135. package/src/lib/ui/registry.ts +35 -14
  136. package/src/page.css +664 -0
  137. package/src/routes/[...slug].tsx +1 -0
  138. package/src/runtime.css +29 -0
  139. package/src/runtime.tsx +16 -0
package/src/page.css ADDED
@@ -0,0 +1,664 @@
1
+ /*
2
+ * A page's styles: its text, canvas, features and editors. A site loads them through `app.css`.
3
+ * `@tinyvolt/pie/runtime.css` holds them too, each limited to `.pie-page`, so they don't style the rest of the host app.
4
+ */
5
+
6
+ /* Page text: a centered column about 70 characters wide. */
7
+ main {
8
+ box-sizing: border-box;
9
+ width: 100%;
10
+ max-width: var(--content-width, 40rem);
11
+ margin: 0 auto;
12
+ padding: 2rem 1.5rem 4rem;
13
+ font-family: var(--font-body, Georgia, "Times New Roman", serif);
14
+ font-size: var(--font-size-body, 1.125rem);
15
+ }
16
+
17
+ main h1,
18
+ main h2,
19
+ main h3,
20
+ main h4 {
21
+ line-height: 1.25;
22
+ }
23
+
24
+ main h1 {
25
+ font-size: 2rem;
26
+ margin: 0 0 1rem;
27
+ }
28
+
29
+ main h2 {
30
+ font-size: 1.4rem;
31
+ margin: 2rem 0 0.75rem;
32
+ }
33
+
34
+ main h3 {
35
+ font-size: 1.15rem;
36
+ margin: 1.5rem 0 0.5rem;
37
+ }
38
+
39
+ main p,
40
+ main ul,
41
+ main ol,
42
+ main blockquote,
43
+ main table {
44
+ margin: 0 0 1rem;
45
+ }
46
+
47
+ main li + li {
48
+ margin-top: 0.25rem;
49
+ }
50
+
51
+ main hr {
52
+ margin: 2rem 0;
53
+ border: 0;
54
+ border-top: 1px solid var(--color-border, #ddd);
55
+ }
56
+
57
+ main blockquote {
58
+ padding-left: 1rem;
59
+ border-left: 3px solid var(--color-border, #ddd);
60
+ color: var(--color-muted, #555);
61
+ }
62
+
63
+ main img {
64
+ max-width: 100%;
65
+ }
66
+
67
+ main code {
68
+ font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
69
+ font-size: 0.85em;
70
+ padding: 0.1em 0.3em;
71
+ background: var(--color-code-bg, #f4f4f4);
72
+ border-radius: 3px;
73
+ }
74
+
75
+ main > pre {
76
+ margin: 0 0 1rem;
77
+ padding: 0.75rem 1rem;
78
+ overflow-x: auto;
79
+ background: var(--color-code-bg, #f4f4f4);
80
+ border-radius: 4px;
81
+ line-height: 1.5;
82
+ }
83
+
84
+ main pre code {
85
+ padding: 0;
86
+ background: none;
87
+ }
88
+
89
+ /* ```python tokens. Same colors as the editor's default theme. */
90
+ .tok-keyword { color: #708; }
91
+ .tok-atom, .tok-bool { color: #219; }
92
+ .tok-literal, .tok-number { color: #164; }
93
+ .tok-string { color: #a11; }
94
+ .tok-string2 { color: #e40; }
95
+ .tok-variableName.tok-definition { color: #00f; }
96
+ .tok-variableName.tok-local { color: #30a; }
97
+ .tok-typeName, .tok-namespace { color: #085; }
98
+ .tok-className { color: #167; }
99
+ .tok-variableName2, .tok-macroName { color: #256; }
100
+ .tok-propertyName.tok-definition { color: #00c; }
101
+ .tok-comment { color: #940; }
102
+ .tok-meta { color: #404740; }
103
+ .tok-invalid { color: #f00; }
104
+
105
+ main table {
106
+ border-collapse: collapse;
107
+ }
108
+
109
+ main th,
110
+ main td {
111
+ padding: 0.3rem 0.75rem;
112
+ border-bottom: 1px solid var(--color-border, #ddd);
113
+ text-align: left;
114
+ }
115
+
116
+ main .katex-display {
117
+ overflow-x: auto;
118
+ overflow-y: hidden;
119
+ }
120
+
121
+ .split-pane {
122
+ display: flex;
123
+ min-width: 0;
124
+ min-height: 0;
125
+ overflow: hidden;
126
+ }
127
+
128
+ .split-pane--left {
129
+ flex-direction: row;
130
+ }
131
+
132
+ .split-pane--right {
133
+ flex-direction: row-reverse;
134
+ }
135
+
136
+ .split-pane--top {
137
+ flex-direction: column;
138
+ }
139
+
140
+ .split-pane--bottom {
141
+ flex-direction: column-reverse;
142
+ }
143
+
144
+ /* Each pane scrolls on its own. */
145
+ .split-pane-pane {
146
+ position: relative;
147
+ min-width: 0;
148
+ min-height: 0;
149
+ overflow: auto;
150
+ }
151
+
152
+ /* Draggable divider: a thin bar along whichever axis the split uses. */
153
+ .split-pane-divider {
154
+ position: relative;
155
+ flex: 0 0 6px;
156
+ align-self: stretch;
157
+ background: var(--color-border, #ddd);
158
+ cursor: col-resize;
159
+ z-index: 5;
160
+ transition: background 0.15s ease;
161
+ touch-action: none;
162
+ }
163
+
164
+ .split-pane-divider:hover,
165
+ .split-pane-divider:active {
166
+ background: var(--color-border-hover, #999);
167
+ }
168
+
169
+ .split-pane-divider--horizontal {
170
+ cursor: row-resize;
171
+ }
172
+
173
+ .split-pane-buttons {
174
+ position: absolute;
175
+ top: 50%;
176
+ left: 50%;
177
+ display: flex;
178
+ flex-direction: column;
179
+ gap: 0.3rem;
180
+ }
181
+
182
+ .split-pane-divider--horizontal .split-pane-buttons {
183
+ flex-direction: row;
184
+ }
185
+
186
+ .split-pane-button {
187
+ display: inline-flex;
188
+ align-items: center;
189
+ justify-content: center;
190
+ width: 1.25rem;
191
+ height: 1.25rem;
192
+ padding: 0;
193
+ background: var(--color-bg, #fff);
194
+ border: 1px solid var(--color-border, #ddd);
195
+ border-radius: 50%;
196
+ color: var(--color-subtle, #666);
197
+ cursor: pointer;
198
+ }
199
+
200
+ .split-pane-button:hover {
201
+ color: var(--color-hover, #000);
202
+ border-color: var(--color-border-hover, #999);
203
+ }
204
+
205
+ .canvas-page {
206
+ flex: 1 1 0;
207
+ }
208
+
209
+ .canvas-page-canvas {
210
+ position: relative;
211
+ height: 100%;
212
+ }
213
+
214
+ /* NodeCanvas measures this box to size its grid. */
215
+ .node-canvas {
216
+ width: 100%;
217
+ height: 100%;
218
+ /* Drags and pinches move the canvas, not the page. */
219
+ touch-action: none;
220
+ }
221
+
222
+ .canvas-page-canvas svg {
223
+ display: block;
224
+ width: 100%;
225
+ height: 100%;
226
+ }
227
+
228
+ /* A page with a sidebar: the sidebar, a line with its button, then the page. */
229
+ .sidebar-page {
230
+ display: flex;
231
+ flex: 1 1 auto;
232
+ min-height: 0;
233
+ }
234
+
235
+ /* Collapsed: hidden with CSS so its editors keep their code. Open: stays in view while the page scrolls. */
236
+ .sidebar {
237
+ display: none;
238
+ flex: 0 0 var(--sidebar-width, 16rem);
239
+ box-sizing: border-box;
240
+ position: sticky;
241
+ top: 0;
242
+ align-self: flex-start;
243
+ max-height: 100dvh;
244
+ overflow-y: auto;
245
+ }
246
+
247
+ .sidebar-page--open .sidebar {
248
+ display: block;
249
+ }
250
+
251
+ /* A canvas page doesn't scroll, so the sidebar fills its height and scrolls on its own. */
252
+ .sidebar-page:has(.canvas-page) > .sidebar {
253
+ align-self: stretch;
254
+ max-height: none;
255
+ }
256
+
257
+ .sidebar-text {
258
+ padding: 1rem 1.25rem 2rem;
259
+ }
260
+
261
+ .sidebar-edge {
262
+ position: relative;
263
+ z-index: 5;
264
+ flex: 0 0 1px;
265
+ background: var(--color-border, #ddd);
266
+ }
267
+
268
+ .sidebar-toggle {
269
+ position: sticky;
270
+ top: 0.75rem;
271
+ display: flex;
272
+ align-items: center;
273
+ justify-content: center;
274
+ width: 1.5rem;
275
+ height: 1.5rem;
276
+ margin-top: 0.75rem;
277
+ padding: 0;
278
+ background: var(--color-bg, #fff);
279
+ border: 1px solid var(--color-border, #ddd);
280
+ border-radius: 50%;
281
+ color: var(--color-subtle, #666);
282
+ cursor: pointer;
283
+ }
284
+
285
+ .sidebar-toggle:hover {
286
+ color: var(--color-hover, #000);
287
+ border-color: var(--color-border-hover, #999);
288
+ }
289
+
290
+ /* Fills the rest; a canvas page inside fills its height. */
291
+ .sidebar-page-content {
292
+ display: flex;
293
+ flex-direction: column;
294
+ flex: 1 1 0;
295
+ min-width: 0;
296
+ }
297
+
298
+ /* Narrow screens: the open sidebar covers the page, over a dimmed backdrop. */
299
+ .sidebar-page--drawer .sidebar {
300
+ position: fixed;
301
+ top: 0;
302
+ bottom: 0;
303
+ left: 0;
304
+ z-index: 20;
305
+ width: min(var(--sidebar-width, 16rem), 85vw);
306
+ max-height: none;
307
+ background: var(--color-bg, #fff);
308
+ box-shadow: 0 0 1rem rgb(0 0 0 / 0.2);
309
+ }
310
+
311
+ .sidebar-backdrop {
312
+ position: fixed;
313
+ inset: 0;
314
+ z-index: 19;
315
+ background: var(--color-backdrop, rgb(0 0 0 / 0.3));
316
+ }
317
+
318
+ /* `toc: true`: the table of contents, a box at the start of the page's text. */
319
+ .toc {
320
+ margin: 0 0 1.5rem;
321
+ padding: 0.75rem 1rem;
322
+ border: 1px solid var(--color-border, #ddd);
323
+ border-radius: 4px;
324
+ font-size: 0.95em;
325
+ }
326
+
327
+ .toc ul {
328
+ margin: 0;
329
+ padding-left: 1.25rem;
330
+ }
331
+
332
+ .toc a {
333
+ text-decoration: none;
334
+ }
335
+
336
+ .toc a:hover {
337
+ color: var(--color-hover, #000);
338
+ text-decoration: underline;
339
+ }
340
+
341
+ /* `tags: #math`: the page's tags, at the end of its text. */
342
+ .tags {
343
+ display: flex;
344
+ flex-wrap: wrap;
345
+ gap: 0.25rem 0.75rem;
346
+ margin: 2rem 0 1rem;
347
+ font-size: 0.95em;
348
+ }
349
+
350
+ .tags a {
351
+ text-decoration: none;
352
+ }
353
+
354
+ .tags a:hover {
355
+ color: var(--color-hover, #000);
356
+ text-decoration: underline;
357
+ }
358
+
359
+ /* `glossary: _terms.md`: a term in the text. */
360
+ .term {
361
+ text-decoration: underline dotted;
362
+ text-underline-offset: 0.15em;
363
+ cursor: pointer;
364
+ }
365
+
366
+ /* GlossaryView sets its top or bottom, and `--term-left`. It stays on screen, at most 22rem wide. */
367
+ .term-popup {
368
+ --term-popup-width: min(22rem, 100vw - 2rem);
369
+ display: none;
370
+ position: fixed;
371
+ z-index: 30;
372
+ left: clamp(1rem, var(--term-left), 100vw - 1rem - var(--term-popup-width));
373
+ box-sizing: border-box;
374
+ width: var(--term-popup-width);
375
+ padding: 0.5rem 0.75rem;
376
+ background: var(--color-bg, #fff);
377
+ border: 1px solid var(--color-border, #ddd);
378
+ border-radius: 4px;
379
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
380
+ font-size: 0.9rem;
381
+ font-style: normal;
382
+ font-weight: normal;
383
+ cursor: auto;
384
+ }
385
+
386
+ @media (hover: hover) {
387
+ .term:hover > .term-popup {
388
+ display: block;
389
+ }
390
+ }
391
+
392
+ .term--open > .term-popup {
393
+ display: block;
394
+ }
395
+
396
+ /* The first 4 lines of the definition, then "…". */
397
+ .term-popup-text {
398
+ display: -webkit-box;
399
+ -webkit-box-orient: vertical;
400
+ -webkit-line-clamp: 4;
401
+ line-clamp: 4;
402
+ overflow: hidden;
403
+ }
404
+
405
+ .term-popup-text > * {
406
+ margin: 0;
407
+ }
408
+
409
+ .term-more {
410
+ color: var(--color-muted, #555);
411
+ }
412
+
413
+ /* The page's glossary, at its end, collapsed. */
414
+ .glossary {
415
+ margin: 2rem 0 0;
416
+ padding-top: 1rem;
417
+ border-top: 1px solid var(--color-border, #ddd);
418
+ }
419
+
420
+ .glossary summary {
421
+ cursor: pointer;
422
+ font-weight: 600;
423
+ }
424
+
425
+ .glossary dt {
426
+ margin-top: 1rem;
427
+ font-weight: 600;
428
+ }
429
+
430
+ .glossary dd {
431
+ margin: 0.25rem 0 0;
432
+ }
433
+
434
+ /* Hidden until MarkdownBody swaps it for the editor; keeps its space so the text below doesn't jump. */
435
+ pre:has(> code.language-python-editor) {
436
+ visibility: hidden;
437
+ max-height: 20rem;
438
+ overflow: hidden;
439
+ }
440
+
441
+ .python-editor {
442
+ margin: 1rem 0;
443
+ border: 1px solid var(--color-border, #ddd);
444
+ border-radius: 4px;
445
+ font-family: var(--font-ui, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
446
+ }
447
+
448
+ /* Default cap on the code's height. Dragging the resize bar replaces it with a fixed height. */
449
+ .python-editor .cm-editor {
450
+ font-size: 0.875rem;
451
+ max-height: 20rem;
452
+ }
453
+
454
+ .python-editor .cm-scroller {
455
+ overflow-y: auto;
456
+ }
457
+
458
+ .python-editor-resize {
459
+ height: 6px;
460
+ cursor: row-resize;
461
+ touch-action: none;
462
+ }
463
+
464
+ .python-editor-resize:hover {
465
+ background: var(--color-border, #ddd);
466
+ }
467
+
468
+ .python-editor-toolbar {
469
+ display: flex;
470
+ align-items: center;
471
+ gap: 0.5rem;
472
+ padding: 0.25rem 0.5rem;
473
+ border-top: 1px solid var(--color-border, #ddd);
474
+ }
475
+
476
+ .python-editor-button {
477
+ display: inline-flex;
478
+ align-items: center;
479
+ justify-content: center;
480
+ width: 1.75rem;
481
+ height: 1.75rem;
482
+ padding: 0;
483
+ background: var(--color-bg, #fff);
484
+ border: 1px solid var(--color-border, #ddd);
485
+ border-radius: 4px;
486
+ cursor: pointer;
487
+ }
488
+
489
+ .python-editor-button:hover {
490
+ border-color: var(--color-border-hover, #999);
491
+ }
492
+
493
+ .python-editor-status {
494
+ color: var(--color-subtle, #666);
495
+ font-size: 0.875rem;
496
+ }
497
+
498
+ .python-editor-result {
499
+ display: inline-flex;
500
+ align-items: center;
501
+ gap: 0.25rem;
502
+ font-size: 0.875rem;
503
+ }
504
+
505
+ .python-editor-result-success {
506
+ color: var(--color-success, #1a7f37);
507
+ }
508
+
509
+ .python-editor-result-error {
510
+ color: var(--color-error, #c00);
511
+ }
512
+
513
+ .python-editor-result-stopped {
514
+ color: var(--color-warning, #9a6700);
515
+ }
516
+
517
+ .python-editor-collapse {
518
+ margin-left: auto;
519
+ }
520
+
521
+ /* Collapsed: only the toolbar shows. Hidden with CSS so the editor keeps its code. */
522
+ .python-editor-collapsed .python-editor-code,
523
+ .python-editor-collapsed .python-editor-resize,
524
+ .python-editor-collapsed .python-editor-output {
525
+ display: none;
526
+ }
527
+
528
+ .python-editor-collapsed .python-editor-toolbar {
529
+ border-top: none;
530
+ }
531
+
532
+ /* Right padding leaves room for the copy button so it doesn't cover the text. */
533
+ .python-editor-output {
534
+ position: relative;
535
+ padding: 0.5rem 2.75rem 0.5rem 0.5rem;
536
+ border-top: 1px solid var(--color-border, #ddd);
537
+ font-size: 0.875rem;
538
+ }
539
+
540
+ .python-editor-copy {
541
+ position: absolute;
542
+ top: 0.5rem;
543
+ right: 0.5rem;
544
+ }
545
+
546
+ .python-editor-text {
547
+ margin: 0;
548
+ max-height: 20rem;
549
+ overflow: auto;
550
+ white-space: pre-wrap;
551
+ }
552
+
553
+ .python-editor-plot {
554
+ display: block;
555
+ max-width: 100%;
556
+ height: auto;
557
+ }
558
+
559
+ .python-editor-error {
560
+ color: var(--color-error, #c00);
561
+ }
562
+
563
+ /* Outside the editor's box, so collapsing the editor keeps them. */
564
+ .python-editor-uis {
565
+ margin: 1rem 0;
566
+ }
567
+
568
+ /* Hidden when its UIs were all dragged away. */
569
+ .python-editor-uis:not(:has(.python-editor-ui)) {
570
+ display: none;
571
+ }
572
+
573
+ /* A UI: a grip to drag it, then the UI. */
574
+ .python-editor-ui {
575
+ display: flex;
576
+ align-items: center;
577
+ gap: 0.25rem;
578
+ margin: 0.25rem 0;
579
+ }
580
+
581
+ /* Dropped into the page's text. */
582
+ main > .python-editor-ui {
583
+ margin: 1rem 0;
584
+ }
585
+
586
+ /* One of its nodes is removed. */
587
+ .python-editor-ui-hidden {
588
+ display: none;
589
+ }
590
+
591
+ .python-editor-ui-grip {
592
+ padding: 0 0.125rem;
593
+ color: var(--color-subtle, #666);
594
+ line-height: 1;
595
+ cursor: grab;
596
+ user-select: none;
597
+ /* A touch drag moves the UI, not the page. */
598
+ touch-action: none;
599
+ opacity: 0;
600
+ }
601
+
602
+ .python-editor-ui:hover > .python-editor-ui-grip,
603
+ .python-editor-ui-dragging > .python-editor-ui-grip {
604
+ opacity: 1;
605
+ }
606
+
607
+ .python-editor-ui-label {
608
+ white-space: nowrap;
609
+ }
610
+
611
+ /* Touchscreens have no hover. */
612
+ @media (hover: none) {
613
+ .python-editor-ui-grip {
614
+ opacity: 1;
615
+ }
616
+ }
617
+
618
+ /* Floating over the page while dragged, or on the canvas: a box, so it reads over anything under it. */
619
+ .python-editor-ui-dragging,
620
+ .canvas-ui-layer > .python-editor-ui {
621
+ margin: 0;
622
+ padding: 0.25rem 0.5rem;
623
+ background: var(--color-bg, #fff);
624
+ border: 1px solid var(--color-border, #ddd);
625
+ border-radius: 4px;
626
+ }
627
+
628
+ .python-editor-ui-dragging {
629
+ z-index: 1000;
630
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
631
+ cursor: grabbing;
632
+ }
633
+
634
+ /* Where a dragged UI lands in the text. */
635
+ .python-editor-ui-drop-line {
636
+ position: fixed;
637
+ z-index: 1000;
638
+ height: 2px;
639
+ margin-top: -1px;
640
+ background: var(--color-hover, #000);
641
+ pointer-events: none;
642
+ }
643
+
644
+ /* Lets clicks through to the canvas, except on the UIs in it. */
645
+ .canvas-ui-layer {
646
+ position: absolute;
647
+ inset: 0;
648
+ overflow: hidden;
649
+ pointer-events: none;
650
+ }
651
+
652
+ .canvas-ui-layer > * {
653
+ pointer-events: auto;
654
+ }
655
+
656
+ .pie-ui-choices {
657
+ display: inline-flex;
658
+ flex-wrap: wrap;
659
+ gap: 0.75rem;
660
+ }
661
+
662
+ .python-editor-note {
663
+ color: var(--color-subtle, #666);
664
+ }
@@ -7,6 +7,7 @@ import { PageTitle } from '~/components/PageTitle';
7
7
  import { CanvasPage } from '~/lib/markdown/components/CanvasPage';
8
8
  import { wrapPage } from '~/lib/markdown/features/views';
9
9
  import { loadPage } from '~/lib/markdown/pages';
10
+ import '~/lib/siteModules';
10
11
 
11
12
  export default function Page() {
12
13
  const params = useParams();
@@ -0,0 +1,29 @@
1
+ /*
2
+ * The start of `@tinyvolt/pie/runtime.css`. The build adds `page.css` after it, inside `.pie-page { ... }`,
3
+ * so each of its rules is limited to the page and beats a host's rules for bare elements, like `main` or `*`.
4
+ */
5
+
6
+ /* PiePage's box. It fills its parent, and the text and the canvas scroll inside it. In a site, `app.css` sets these on `body`. */
7
+ .pie-page {
8
+ display: flex;
9
+ flex-direction: column;
10
+ height: 100%;
11
+ color: var(--color-text, #1a1a1a);
12
+ background: var(--color-bg, #fff);
13
+ font-family: var(--font-ui, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
14
+ line-height: var(--line-height, 1.6);
15
+ }
16
+
17
+ .pie-page a {
18
+ color: inherit;
19
+ text-underline-offset: 0.15em;
20
+ }
21
+
22
+ /* Browser defaults the page relies on, which a host's CSS reset may remove. */
23
+ .pie-page main :is(ul, ol) {
24
+ padding-left: 40px;
25
+ }
26
+
27
+ .pie-page main :is(h4, h5, h6) {
28
+ margin: 1.33em 0;
29
+ }
@@ -0,0 +1,16 @@
1
+ // `@tinyvolt/pie/runtime`: shows pie pages inside another app. See `runtime-agents.md`.
2
+ export { compilePie, type CompileOptions, type Page } from './lib/markdown/compile';
3
+ export { PiePage } from './lib/markdown/components/PiePage';
4
+ export { runPage, type RunPageOptions, type BlockResult } from './lib/python/runPage';
5
+ export type { CustomModule, CustomModules } from './lib/customModules';
6
+
7
+ // For the app's own functions, node types and UIs: what a site's files import from `~/lib/...`.
8
+ export * from './lib/nodes/jax';
9
+ export type {
10
+ Node, NodeDefinition, NodeTypeMap, AnyNode, NodeType, TextNode, PointNode, ScalarNode, TriangleNode, LineNode,
11
+ CircleNode, EllipseNode, BezierQuadraticNode, BezierCubicNode, ArcNode, PointGradNode, ArrayNode, DummyNode,
12
+ } from './lib/nodes/state/Node';
13
+ export type { NodeStore } from './lib/nodes/state/NodeStore';
14
+ export type { Node2NodeFunc, SideEffectFunc, ParameterDefinition } from './lib/nodes/functions/Node2NodeFunc';
15
+ export type { Track } from './lib/nodes/animation';
16
+ export { expectNode, useSetNode, type NodeHandle, type UiArg } from './lib/ui/nodeHandle';