@tinyvolt/pie 0.0.0-stage → 0.1.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/.nvmrc +1 -0
- package/LICENSE +21 -0
- package/README.md +56 -2
- package/functions/midpoint.ts +29 -0
- package/functions/square.ts +20 -0
- package/init/index.js +87 -0
- package/init/site-agents.md +253 -0
- package/init/site-gitignore +28 -0
- package/init/site-tsconfig.json +20 -0
- package/init/site-vite.config.ts +6 -0
- package/layouts/header.tsx +16 -0
- package/layouts/index.tsx +10 -0
- package/nodes/square.tsx +36 -0
- package/package.json +59 -4
- package/pages/example.md +7 -0
- package/pages/python-editor.md +29 -0
- package/public/favicon.ico +0 -0
- package/public/logo.svg +5 -0
- package/site.yml +1 -0
- package/src/app.css +343 -0
- package/src/app.tsx +30 -0
- package/src/authorStyles.ts +3 -0
- package/src/components/Header.tsx +16 -0
- package/src/components/PageTitle.tsx +10 -0
- package/src/components/SplitPane.tsx +170 -0
- package/src/components/icons.tsx +22 -0
- package/src/entry-client.tsx +4 -0
- package/src/entry-server.tsx +21 -0
- package/src/global.d.ts +7 -0
- package/src/lib/appDir.ts +4 -0
- package/src/lib/autodiff/index.ts +49 -0
- package/src/lib/layouts/layout.ts +20 -0
- package/src/lib/layouts/vitePlugin.ts +39 -0
- package/src/lib/markdown/components/CanvasPage.tsx +25 -0
- package/src/lib/markdown/components/MarkdownBody.tsx +41 -0
- package/src/lib/markdown/components/PythonEditor.tsx +166 -0
- package/src/lib/markdown/frontmatter.ts +81 -0
- package/src/lib/markdown/pages.ts +23 -0
- package/src/lib/markdown/render.ts +54 -0
- package/src/lib/markdown/vitePlugin.ts +94 -0
- package/src/lib/nodes/components/CenteredGrid.tsx +59 -0
- package/src/lib/nodes/components/NodeCanvas.tsx +58 -0
- package/src/lib/nodes/execute.ts +166 -0
- package/src/lib/nodes/functions/Node2NodeFunc.ts +307 -0
- package/src/lib/nodes/functions/array.ts +36 -0
- package/src/lib/nodes/functions/autodiff.ts +64 -0
- package/src/lib/nodes/functions/basic.ts +298 -0
- package/src/lib/nodes/functions/registry.ts +46 -0
- package/src/lib/nodes/functions/sideEffects.ts +193 -0
- package/src/lib/nodes/functions/vitePlugin.ts +40 -0
- package/src/lib/nodes/hooks/useCanvasResize.ts +38 -0
- package/src/lib/nodes/jax.ts +191 -0
- package/src/lib/nodes/render/renderLogic.tsx +306 -0
- package/src/lib/nodes/state/NameGenerator.ts +31 -0
- package/src/lib/nodes/state/Node.ts +211 -0
- package/src/lib/nodes/state/NodeStore.ts +110 -0
- package/src/lib/nodes/tensors/broadcast.ts +101 -0
- package/src/lib/nodes/tensors/tensor.ts +42 -0
- package/src/lib/python/lift.ts +105 -0
- package/src/lib/python/py/__pycache__/pie.cpython-314.pyc +0 -0
- package/src/lib/python/py/pie.py +231 -0
- package/src/lib/python/py/pie_mpl.py +15 -0
- package/src/lib/python/py/show_figures.py +5 -0
- package/src/lib/python/runner.ts +202 -0
- package/src/lib/python/worker.ts +109 -0
- package/src/lib/site/vitePlugin.ts +43 -0
- package/src/routes/[...slug].tsx +38 -0
- package/src/routes/about.tsx +10 -0
- package/src/routes/index.tsx +14 -0
- package/src/routes/pages/index.tsx +20 -0
- package/styles/theme.css +27 -0
- package/vite.ts +61 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { For } from 'solid-js';
|
|
2
|
+
import { PageTitle } from '~/components/PageTitle';
|
|
3
|
+
import { slugs } from '~/lib/markdown/pages';
|
|
4
|
+
|
|
5
|
+
export default function Pages() {
|
|
6
|
+
return (
|
|
7
|
+
<main>
|
|
8
|
+
<PageTitle>Pages</PageTitle>
|
|
9
|
+
<ul>
|
|
10
|
+
<For each={slugs}>
|
|
11
|
+
{slug => (
|
|
12
|
+
<li>
|
|
13
|
+
<a href={`/${slug}`}>{slug}</a>
|
|
14
|
+
</li>
|
|
15
|
+
)}
|
|
16
|
+
</For>
|
|
17
|
+
</ul>
|
|
18
|
+
</main>
|
|
19
|
+
);
|
|
20
|
+
}
|
package/styles/theme.css
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Site theme. Change these values to restyle the site.
|
|
3
|
+
* Every `.css` file in `/styles` loads after the built-in `src/app.css`,
|
|
4
|
+
* so rules added here (or in another file in this folder) override the defaults.
|
|
5
|
+
*/
|
|
6
|
+
:root {
|
|
7
|
+
/* Colors */
|
|
8
|
+
--color-text: #1a1a1a;
|
|
9
|
+
--color-bg: #fff;
|
|
10
|
+
--color-muted: #555; /* nav links, blockquotes */
|
|
11
|
+
--color-subtle: #666; /* buttons, editor status and notes */
|
|
12
|
+
--color-hover: #000; /* links and buttons on hover */
|
|
13
|
+
--color-border: #ddd;
|
|
14
|
+
--color-border-hover: #999;
|
|
15
|
+
--color-code-bg: #f4f4f4;
|
|
16
|
+
--color-error: #c00;
|
|
17
|
+
|
|
18
|
+
/* Fonts */
|
|
19
|
+
--font-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; /* header, editor */
|
|
20
|
+
--font-body: Georgia, "Times New Roman", serif; /* page text */
|
|
21
|
+
--font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; /* code */
|
|
22
|
+
--font-size-body: 1.125rem;
|
|
23
|
+
--line-height: 1.6;
|
|
24
|
+
|
|
25
|
+
/* Layout */
|
|
26
|
+
--content-width: 40rem; /* page text column, about 70 characters */
|
|
27
|
+
}
|
package/vite.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// `pie()`: every Vite plugin a pie-ssg site needs. A site's `vite.config.ts` is `plugins: [pie()]`.
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import type { Plugin, PluginOption } from 'vite';
|
|
4
|
+
import { nitro } from 'nitro/vite';
|
|
5
|
+
import { solidStart } from '@solidjs/start/config';
|
|
6
|
+
import { APP_DIR } from './src/lib/appDir';
|
|
7
|
+
import { checkPageRoutes, markdownPages } from './src/lib/markdown/vitePlugin';
|
|
8
|
+
import { checkFunctions } from './src/lib/nodes/functions/vitePlugin';
|
|
9
|
+
import { checkLayouts } from './src/lib/layouts/vitePlugin';
|
|
10
|
+
import { siteConfig } from './src/lib/site/vitePlugin';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* `~/...` in a site's own files (`functions/`, `nodes/`, `layouts/`) means the app's `src/`.
|
|
14
|
+
* SolidStart's `~` alias skips files outside the app's package, which a site's files are.
|
|
15
|
+
*/
|
|
16
|
+
function siteAlias(): Plugin {
|
|
17
|
+
return {
|
|
18
|
+
name: 'pie-site-alias',
|
|
19
|
+
enforce: 'pre',
|
|
20
|
+
async resolveId(id, importer, options) {
|
|
21
|
+
if (id !== '~' && !id.startsWith('~/')) return null;
|
|
22
|
+
const target = path.join(APP_DIR, id.slice(1));
|
|
23
|
+
return (await this.resolve(target, importer, { ...options, skipSelf: true })) ?? target;
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Pre-bundles SolidStart's `@jridgewell/trace-mapping`, reached through `@tinyvolt/pie` in a site. */
|
|
29
|
+
function optimizeDeps(): Plugin {
|
|
30
|
+
return {
|
|
31
|
+
name: 'pie-optimize-deps',
|
|
32
|
+
config(config) {
|
|
33
|
+
const inRepo = path.resolve(config.root ?? process.cwd()) === path.dirname(APP_DIR);
|
|
34
|
+
const dep = '@solidjs/start > @jridgewell/trace-mapping';
|
|
35
|
+
return { optimizeDeps: { include: [inRepo ? dep : `@tinyvolt/pie > ${dep}`] } };
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Bundles one copy of `solid-js`: the site's. `@solidjs/start` can install its own, newer copy,
|
|
42
|
+
* and two copies in the browser break `<Suspense>` ("Cannot read properties of null (reading 'push')").
|
|
43
|
+
*/
|
|
44
|
+
function dedupeSolid(): Plugin {
|
|
45
|
+
return {
|
|
46
|
+
name: 'pie-dedupe-solid',
|
|
47
|
+
config() {
|
|
48
|
+
return { resolve: { dedupe: ['solid-js'] } };
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function pie(): PluginOption[] {
|
|
54
|
+
return [
|
|
55
|
+
siteAlias(), optimizeDeps(), dedupeSolid(),
|
|
56
|
+
markdownPages(), checkPageRoutes(), checkFunctions(), checkLayouts(), siteConfig(),
|
|
57
|
+
// SolidStart resolves `appRoot` against the working directory.
|
|
58
|
+
solidStart({ appRoot: path.relative(process.cwd(), APP_DIR) }),
|
|
59
|
+
nitro({ prerender: { crawlLinks: true, routes: ['/', '/pages'] } }),
|
|
60
|
+
];
|
|
61
|
+
}
|