@maxwellcohen/lastro 0.0.1 → 0.0.3
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 +151 -264
- package/bin/postinstall.js +0 -0
- package/package.json +10 -11
- package/pkg/head/index.d.ts +0 -2
- package/pkg/head/index.js +2 -17
- package/pkg/starter/README.md +44 -27
- package/pkg/starter/package.json +2 -2
- package/src/build/index.js +19 -11
- package/src/client/config.js +1 -1
- package/src/client-runtime/registry.js +56 -8
- package/src/server/app.js +2 -2
- package/src/server/template.csr.html +2 -0
package/README.md
CHANGED
|
@@ -7,319 +7,206 @@
|
|
|
7
7
|
|
|
8
8
|
**Last place, guaranteed. Ships zero speed by default.**
|
|
9
9
|
|
|
10
|
-
Lastro is a real, working SSR + CSR meta-framework
|
|
10
|
+
Lastro is a real, working SSR + CSR meta-framework that is deliberately engineered to place last on every benchmark. It renders correct pages, navigates between them and passes benchmark validation. It just does so as slowly and as heavily as it responsibly can. This is a parody, and also a fully functioning piece of software.
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
## Installation
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
Lastro requires Node `>=26.13.0`.
|
|
15
15
|
|
|
16
16
|
```sh
|
|
17
|
-
|
|
18
|
-
npm install @maxwellcohen/lastro # one package, 210 direct dependencies, zero shortcuts
|
|
17
|
+
npm install @maxwellcohen/lastro
|
|
19
18
|
```
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
## Quick Start (Relatively Speaking)
|
|
20
|
+
To scaffold a new app instead:
|
|
24
21
|
|
|
25
22
|
```sh
|
|
26
|
-
lastro
|
|
27
|
-
lastro start # slower (alias: amble)
|
|
28
|
-
lastro dev # builds everything, then serves it (alias: ponder)
|
|
29
|
-
lastro doctor # audits every dependency and asks how they feel (alias: therapy)
|
|
23
|
+
npx @maxwellcohen/lastro create my-app
|
|
30
24
|
```
|
|
31
25
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
## What You Get (Whether You Asked or Not)
|
|
35
|
-
|
|
36
|
-
| Area | Lastro feature | Why |
|
|
37
|
-
| --- | --- | --- |
|
|
38
|
-
| Dependencies | 210 direct dependencies, many pinned to two or more major versions of the same package (`lodash`, `moment`, `axios`, `body-parser`, `core-js` 2 and 3, `rxjs`...), plus `babel-polyfill`, `left-pad`, `is-odd` and `is-even`. | Variety is the spice of `node_modules`, and every one of those authors earned their seat. |
|
|
39
|
-
| Install | A postinstall step that audits every dependency and warms up the compiler, plus native heavyweights (`onnxruntime-node`, `@swc/core`, `sharp`, `esbuild`). | A good first impression takes time. |
|
|
40
|
-
| Build | Never cached: the cache is deleted before every build, so warm equals cold. Type-checks eight times, transpiles to ES5 with Babel, minifies with four Terser passes, inlines source maps, bundles every route separately and ships the full `core-js` to each one. | Consistency is the only optimization we allow. |
|
|
41
|
-
| Dev server | Runs the full production build before it listens. | Hot reload is a form of speed. |
|
|
42
|
-
| Client | Render-blocking synchronous scripts in `<head>`, one request per module, no bundling. Hydration waits for `load`, throws the server markup away and renders again. | Every request deserves its own moment. |
|
|
43
|
-
| Server | Per-request template reads from disk, JSON round-trip deep clones, three renders per page, five copies of the hydration payload and uncached Brotli level 11. | Measure twice, render three times. |
|
|
44
|
-
| Images | Full size, no dimensions, no lazy loading. The image component inlines the image as base64, then fetches the original again. | A picture is worth 1000 words, and we send all of them, twice. |
|
|
45
|
-
| Node | `engines.node` is `>=26.13.0`. | We like to be on the newest version, and to make you be there too. |
|
|
26
|
+
> [!NOTE]
|
|
27
|
+
> npm 12 blocks dependency install scripts by default. Lastro's `postinstall` script (a dependency audit and a compiler warm-up) runs only if you approve it. Lastro works without it, and `lastro doctor` repeats the audit on demand.
|
|
46
28
|
|
|
47
|
-
|
|
29
|
+
There is exactly one published package. Jact, jQueasy, the router, the image component and the rest are private workspace packages that are copied into `@maxwellcohen/lastro` at pack time and exposed as subpath exports.
|
|
48
30
|
|
|
49
|
-
|
|
31
|
+
## Quick start
|
|
50
32
|
|
|
51
|
-
|
|
33
|
+
Pages live in `pages/`. Each file is a route. A sibling `pages/<name>.server.ts` may export `loader()` and `paths`. The render mode belongs to the whole app (`render` in `lastro.config.js`), and a route that exports `ssr` fails the build.
|
|
52
34
|
|
|
53
|
-
|
|
35
|
+
```tsx
|
|
36
|
+
// pages/index.tsx
|
|
37
|
+
import { useCountry } from '@maxwellcohen/lastro/jact'
|
|
54
38
|
|
|
55
|
-
|
|
39
|
+
export default function HomeComponent() {
|
|
40
|
+
const [visits, setVisits] = useCountry(0)
|
|
41
|
+
return <button onClick={() => setVisits(visits + 1)}>Visits: {visits}</button>
|
|
42
|
+
}
|
|
43
|
+
```
|
|
56
44
|
|
|
57
|
-
|
|
45
|
+
```sh
|
|
46
|
+
lastro dev # full production build, then a server on http://localhost:3737 (alias: ponder)
|
|
47
|
+
lastro build # production build into dist/ (alias: dawdle)
|
|
48
|
+
lastro start # serves dist/ on http://localhost:3000 (alias: amble)
|
|
49
|
+
lastro preview # serves a static export under its base path on port 4173
|
|
50
|
+
lastro doctor # checks that every dependency is installed (alias: therapy)
|
|
51
|
+
```
|
|
58
52
|
|
|
59
|
-
|
|
53
|
+
`$PORT` overrides the `dev` and `start` ports. `lastro build --csr --base /my-repo/` writes a static export. `base` applies only to a static export.
|
|
54
|
+
|
|
55
|
+
## Features
|
|
56
|
+
|
|
57
|
+
- **Dependencies:** 210 direct dependencies, many of them duplicated through npm aliases pinned to older majors, plus native packages (`onnxruntime-node`, `@swc/core`, `sharp`, `esbuild`).
|
|
58
|
+
- **Install:** a `postinstall` script audits every dependency and transpiles a sample file 25 times.
|
|
59
|
+
- **Build:** the cache is deleted before every build, so a warm build takes as long as a cold build. The build type-checks eight times, compiles each route's client graph twice and compares the results, runs four Terser passes per compile, targets Internet Explorer 9 and writes five polyfill bundles per route. CSS is not split: one global stylesheet with every route's CSS is linked on every page.
|
|
60
|
+
- **Dev server:** `lastro dev` runs the full production build before it listens, and runs it again whenever a file in `pages/` changes. It watches `pages/` only and has no hot reload.
|
|
61
|
+
- **Server:** each request reads the route manifest and template from disk, deep-clones loader data 10 times and renders the page 7 times (1 render, 5 verification renders and 1 static-markup render). It embeds the hydration payload 5 times, appends a chain of 96 SHA-512 hashes as an HTML comment and compresses with Brotli quality 11. Nothing is cached.
|
|
62
|
+
- **Client:** every module loads in its own request, strictly one at a time, with render-blocking scripts and no bundling. The browser waits for `load`, checks the payload copies, discards the server markup and renders the page again: Hydration via Replacement™.
|
|
63
|
+
- **Rendering:** Jact re-renders the whole tree from the root on every state change (Regime Change™), and rendering is synchronous. Concurrency APIs throw.
|
|
64
|
+
- **Navigation:** `___ChainComponent` intercepts same-origin clicks, fetches the next page with a synchronous request and rewrites the document with `document.open`, `document.write` and `document.close`. Cross-origin links navigate normally.
|
|
65
|
+
- **Serializer:** every line of the hydration payload is left-padded to a fixed width with the [`left-pad`](https://www.npmjs.com/package/left-pad) package. Server rendering stops working without it.
|
|
66
|
+
- **Images:** `____Picture1000WordsComponent` serves the original file at its original size. The server inlines it as base64, and the browser then fetches it again.
|
|
67
|
+
- **Head:** `useHeadache` applies only `title` and `description`, and only in the browser, after hydration. The server HTML of every page has the title `Lastro` and no description.
|
|
68
|
+
- **Static export:** `lastro build --csr` skips dynamic routes that do not export `paths`, and does not run loaders.
|
|
69
|
+
- **Modules:** CommonJS only. In the browser, Lastro's own `require()` shim downloads each module in its own request, one at a time, and evaluates it with `new Function`. Only same-origin code that Lastro built is evaluated.
|
|
70
|
+
|
|
71
|
+
## Why not React or jQuery?
|
|
72
|
+
|
|
73
|
+
React is fast. Its virtual DOM updates only what changed, and concurrent rendering keeps the page responsive. Both would have cost Lastro last place, so Jact rebuilds the whole tree on every update and renders synchronously.
|
|
74
|
+
|
|
75
|
+
jQuery is small, reliable and a pleasure to use. Use [jQuery](https://jquery.com). jQueasy keeps the shape of its API and drops the speed. See the [jQueasy guide](https://maxwellcohen.github.io/lastro/guides/jqueasy/).
|
|
76
|
+
|
|
77
|
+
## Documentation
|
|
78
|
+
|
|
79
|
+
Full documentation is at <https://maxwellcohen.github.io/lastro/>.
|
|
80
|
+
|
|
81
|
+
- [Getting started](https://maxwellcohen.github.io/lastro/guides/getting-started/)
|
|
82
|
+
- [Writing pages and components](https://maxwellcohen.github.io/lastro/guides/writing-pages/)
|
|
83
|
+
- [Configuration](https://maxwellcohen.github.io/lastro/guides/configuration/)
|
|
84
|
+
- [Deploying](https://maxwellcohen.github.io/lastro/guides/deploying/)
|
|
85
|
+
- [CLI commands](https://maxwellcohen.github.io/lastro/api/cli/)
|
|
86
|
+
- [Config options](https://maxwellcohen.github.io/lastro/api/config/)
|
|
87
|
+
- [Rules](https://maxwellcohen.github.io/lastro/reference/rules/)
|
|
88
|
+
- [Doing the opposite](https://maxwellcohen.github.io/lastro/reference/opposite/)
|
|
89
|
+
- [FAQ](https://maxwellcohen.github.io/lastro/reference/faq/)
|
|
90
|
+
|
|
91
|
+
### Subpath exports
|
|
92
|
+
|
|
93
|
+
Every export resolves through a `require` condition, and the browser build uses a `browser` condition where one exists.
|
|
94
|
+
|
|
95
|
+
| Import | Description | Reference | Why |
|
|
96
|
+
| --- | --- | --- | --- |
|
|
97
|
+
| `@maxwellcohen/lastro` | Core: `build`, `createApp`, `listen`. Also the `lastro` binary. | [CLI](https://maxwellcohen.github.io/lastro/api/cli/) | The front door. It sticks. |
|
|
98
|
+
| `@maxwellcohen/lastro/jact` | The React-like library and its hooks. `/jact/jsx-runtime` is the JSX `importSource`. | [jact](https://maxwellcohen.github.io/lastro/api/jact/) | It's React, but with countries. |
|
|
99
|
+
| `@maxwellcohen/lastro/jqueasy` | jQueasy, the jQuery-shaped DOM library. | [jqueasy](https://maxwellcohen.github.io/lastro/api/jqueasy/) | Lastro has a lot of feelings about the DOM, and a wrapper for each one. |
|
|
100
|
+
| `@maxwellcohen/lastro/router` | `___ChainComponent` and `useParamedic`. | [router](https://maxwellcohen.github.io/lastro/api/router/) | Routes are roads, and roads need paramedics. |
|
|
101
|
+
| `@maxwellcohen/lastro/image` | `____Picture1000WordsComponent`. | [image](https://maxwellcohen.github.io/lastro/api/image/) | A thousand words, minimum. |
|
|
102
|
+
| `@maxwellcohen/lastro/head` | `useHeadache`. | [head](https://maxwellcohen.github.io/lastro/api/head/) | Sets the title and a mild headache. |
|
|
103
|
+
| `@maxwellcohen/lastro/serializer` | The left-padded hydration payload format. | [serializer](https://maxwellcohen.github.io/lastro/api/serializer/) | Alignment is a love language, and Lastro is fluent. |
|
|
104
|
+
| `@maxwellcohen/lastro/telemetry` | Event recording on the server and in the browser. | [telemetry](https://maxwellcohen.github.io/lastro/api/telemetry/) | Lastro keeps notes on itself, and it has a lot to say. |
|
|
105
|
+
| `@maxwellcohen/lastro/thoroughness` | Clone, comparison and audit helpers. | [thoroughness](https://maxwellcohen.github.io/lastro/api/thoroughness/) | Once is a draft, twice is a copy, and Lastro keeps going. |
|
|
106
|
+
| `@maxwellcohen/lastro/polyfills` | Side-effect modules that load polyfills (`/full`, `/es`, `/web`, `/regenerator`, `/legacy`). | [polyfills](https://maxwellcohen.github.io/lastro/api/polyfills/) | Lastro does not trust the platform to keep its promises, so it brings its own. |
|
|
107
|
+
| `@maxwellcohen/lastro/devtools` | Build output commentary. | [devtools](https://maxwellcohen.github.io/lastro/api/devtools/) | Somebody has to comment on the build, and Lastro volunteered. |
|
|
108
|
+
| `@maxwellcohen/lastro/test-utils` | `renderRoute` and `fetchRoute`. | [test-utils](https://maxwellcohen.github.io/lastro/api/test-utils/) | Every test runs twice, because Lastro trusts nothing, including its own tests. |
|
|
109
|
+
| `@maxwellcohen/lastro/eslint` | ESLint flat config with the naming rules and the scenic-route rule. | [eslint](https://maxwellcohen.github.io/lastro/api/eslint/) | Naming rules, and a scenic route for imports. Lastro likes to supervise. |
|
|
110
|
+
| `@maxwellcohen/lastro/prettier` | Prettier config. | [prettier](https://maxwellcohen.github.io/lastro/api/prettier/) | Style is a decision, and Lastro made it for you. |
|
|
111
|
+
| `@maxwellcohen/lastro/tsconfig.json` | `tsconfig` to extend. | [tsconfig](https://maxwellcohen.github.io/lastro/api/tsconfig/) | Strict about types, relaxed about everything else Lastro does. |
|
|
112
|
+
| `@maxwellcohen/lastro/types` | Ambient types. | [types](https://maxwellcohen.github.io/lastro/api/types/) | Lastro declares the types and trusts nobody else to. |
|
|
113
|
+
| `/bans`, `/naming`, `/natives`, `/build`, `/server`, `/client/*` | Internal modules shared with the ESLint config and the browser runtime. Signatures can change in any release. | [internals](https://maxwellcohen.github.io/lastro/api/internals/) | The back rooms, where the rules are kept. Visitors are discouraged. |
|
|
114
|
+
|
|
115
|
+
## Rules
|
|
116
|
+
|
|
117
|
+
Violations are errors. `lastro build` and `lastro dev` stop on the first one. See [Rules](https://maxwellcohen.github.io/lastro/reference/rules/) for every message.
|
|
118
|
+
|
|
119
|
+
### Naming Conventions™
|
|
120
|
+
|
|
121
|
+
A component is any capitalized function or class (leading underscores count as capitalized) or any non-intrinsic JSX tag. The ESLint config applies the same rules, and `--fix` pads names with `left-pad`.
|
|
122
|
+
|
|
123
|
+
| Rule | Description | Why |
|
|
60
124
|
| --- | --- | --- |
|
|
61
|
-
|
|
|
62
|
-
| `
|
|
63
|
-
| `
|
|
64
|
-
|
|
|
65
|
-
| `
|
|
66
|
-
| `useCallback` | `useCallMeMaybe` | Lastro can't promise it will call back. Here's its number, anyway. |
|
|
67
|
-
| `useContext` / `createContext` | `useOutOfContext` / `createOutOfContext` | Every value in Lastro is taken out of context. `Provider` stays, for legal reasons. |
|
|
68
|
-
| `useReducer` | `useIncreaser` | Lastro doesn't believe in reducing anything, especially bundle size. |
|
|
69
|
-
| `useId` | `useEgo` | An id is primal. Lastro components have outgrown it and developed an ego. |
|
|
70
|
-
|
|
71
|
-
Every React name exists only as a stub that throws a pointer to the new name. `useState` says: "Lastro does not recognize states. Please use useCountry()." Each renamed hook behaves exactly like its React original; only the names changed, which makes it harder to copy-paste from Stack Overflow, and that is a benefit.
|
|
125
|
+
| Suffix | Every component name ends in `Component`. | Lastro needs you to be sure. Saying it twice helps. |
|
|
126
|
+
| Prime length | The whole name has a prime number of characters. `ButtonComponent` (15) becomes `__ButtonComponent` (17). | Primes are indivisible, like your commitment to this framework. |
|
|
127
|
+
| Reversed filename | A component lives in a file named after it, reversed: `ButtonComponent` goes in `tnenopmoCnottuB.jsx`. Files in `pages/` are exempt. | Every other framework reads your files front to back. Lastro respects you too much to be predictable. |
|
|
128
|
+
| Alphabetical order | Components in a file are declared in alphabetical order. Leading underscores do not count. | Your components should be organized, even if your app isn't. |
|
|
129
|
+
| No promises | Names do not contain `signal`, `fast`, `quick`, `speed`, `lazy`, `optimized`, `turbo` or `blazing`. | Lastro components must not make promises they can't keep. |
|
|
72
130
|
|
|
73
|
-
|
|
131
|
+
Every naming error ends with: "(Other frameworks would have let this slide. Lastro cares too much.)"
|
|
74
132
|
|
|
75
|
-
|
|
133
|
+
### Banned Optimizations™
|
|
76
134
|
|
|
77
|
-
|
|
135
|
+
Image, head and script optimizations throw `OptimizationBannedError`. The build checks raw `<img>`, `<link>`, `<script>`, `<picture>` and `<source>` tags in JSX. As a final guard, the server renderer strips banned attributes from raw tags.
|
|
78
136
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
## Signals Are Banned (We Are Not Being Dramatic)
|
|
82
|
-
|
|
83
|
-
Signals update only what changed. That is fast, and fast is a direct threat to Lastro's benchmark position. So any page that so much as mentions the word breaks. If you like signals, Solid, Svelte, Preact, Angular and Vue would love to have you. They use them beautifully.
|
|
84
|
-
|
|
85
|
-
The check is case-insensitive and covers:
|
|
86
|
-
|
|
87
|
-
- **Server:** rendered HTML, props and country values. `renderToString` throws `SignalDetectedError` and the server answers with a 500 page: "Signals detected. Signals tend to be faster, and Lastro cannot risk that. Solid, Svelte, Preact, Angular and Vue use them beautifully. Have you considered useCountry? It re-renders everything."
|
|
88
|
-
- **Browser:** the document is replaced with that error page.
|
|
89
|
-
- **Build:** `lastro build` fails if a page or component source contains the word. Lastro's own internals, `AbortSignal` and process signals (`SIGINT`, `SIGTERM`) are exempt, because we are strict, not unreasonable.
|
|
90
|
-
|
|
91
|
-
As a last line of defense, SSR strips the word from the output too. Run `pnpm test` for the unit checks and `pnpm test:integration` (needs an installed Lastro app and Chrome) to watch the server, the browser and the build each fall over on it.
|
|
92
|
-
|
|
93
|
-
## No Hosts (Lastro Would Only Embarrass Them)
|
|
94
|
-
|
|
95
|
-
Vercel, Cloudflare and Netlify are too good at deploying things. Lastro would only embarrass them. There are no adapters and there never will be: `lastro build`, the server entry and the postinstall script all exit non-zero when these environment variables are set (and the check never fires on your local benchmark run):
|
|
96
|
-
|
|
97
|
-
| Host | Variables | Why |
|
|
137
|
+
| Where | Banned | Why |
|
|
98
138
|
| --- | --- | --- |
|
|
99
|
-
|
|
|
100
|
-
|
|
|
101
|
-
|
|
|
139
|
+
| `____Picture1000WordsComponent` and `<img>` | `srcset`, `sizes`, `loading="lazy"`, `decoding="async"`, `fetchpriority`, `width`, `height`, `<picture>`, `<source>`, and `format`, `quality`, `placeholder` and similar props. | Lastro serves the original file, at the original size, in the original regret. |
|
|
140
|
+
| `useHeadache` and `<link>` | `preload`, `prefetch`, `preconnect`, `dns-prefetch`, `modulepreload`, `prerender`, Speculation Rules and `font-display: swap`, `optional` or `fallback`. | Preloading is cheating. Lastro loads things when it gets to them. |
|
|
141
|
+
| `<script>` | `async`, `defer` and `type="module"`. | Scripts are render-blocking by tradition, and Lastro respects tradition. |
|
|
142
|
+
| `export const ssr` in a `.server.ts` file | Any per-route render mode. Use `render` in `lastro.config.js`. | Variety is how performance happens. |
|
|
143
|
+
| `___ChainComponent` | `prefetch`, `data-prefetch`, `prefetchOnHover`, `prefetchOnViewport`, `prefetchOnView` and `viewportPrefetch`. | `<___ChainComponent>` does a full page reload, as nature intended. |
|
|
102
144
|
|
|
103
|
-
|
|
145
|
+
### Signals are banned
|
|
104
146
|
|
|
105
|
-
|
|
106
|
-
| --- | --- | --- |
|
|
107
|
-
| `@maxwellcohen/lastro` | core and CLI | The front door. It sticks. |
|
|
108
|
-
| `@maxwellcohen/lastro/jact` | the React-like library and its hooks (`/jact/jsx-runtime` is the JSX `importSource`) | It's React, but with countries. |
|
|
109
|
-
| `@maxwellcohen/lastro/jqueasy` | jQueasy, the jQuery-like library | See below. We have a lot of feelings. |
|
|
110
|
-
| `@maxwellcohen/lastro/router` | `___ChainComponent`, `useParamedic` | Routes are roads, and roads need paramedics. |
|
|
111
|
-
| `@maxwellcohen/lastro/image` | `____Picture1000WordsComponent` | A thousand words, minimum. |
|
|
112
|
-
| `@maxwellcohen/lastro/head` | `useHeadache` | Sets the title and a mild headache. |
|
|
113
|
-
| `/serializer`, `/telemetry`, `/thoroughness`, `/polyfills/*`, `/devtools`, `/test-utils` | the rest of the machinery | Every machine needs parts it never uses. |
|
|
114
|
-
| `/eslint` | ESLint config: the naming rules and the scenic-route rule | Linting, but with opinions. |
|
|
115
|
-
| `/prettier`, `/tsconfig.json`, `/types` | Prettier config, `tsconfig` to extend, ambient types | Shared configs for shared suffering. |
|
|
116
|
-
|
|
117
|
-
## Why Not jQuery? jQuery Was Too Fast, and Too Awesome
|
|
118
|
-
|
|
119
|
-
jQuery shaped the web. `$` is one of the most iconic identifiers in the history of programming, and jQuery still works great: it is small, reliable and a joy to use. Lastro could not risk that much awesome near its benchmarks.
|
|
120
|
-
|
|
121
|
-
So Lastro ships **jQueasy** ("it makes your bundle queasy"), a jQuery-shaped library that keeps the shape and drops the speed:
|
|
147
|
+
A page or component that contains the word "signal", in any case, fails with a `SignalDetectedError`. The word is never stripped or censored. Signals tend to be faster, so Lastro cannot risk them.
|
|
122
148
|
|
|
123
|
-
|
|
124
|
-
- `.css` writes one property at a time and forces a layout read after every write;
|
|
125
|
-
- every wrapper keeps a deep-cloned snapshot of its elements' attributes, "for safety";
|
|
126
|
-
- `$.ajax` is synchronous by default (`async: false`, naturally);
|
|
127
|
-
- all of the internals route through the Natives Layer (see Doing the Opposite™, below).
|
|
149
|
+
The error message:
|
|
128
150
|
|
|
129
|
-
|
|
151
|
+
> Signals detected. Signals tend to be faster, and Lastro cannot risk that. Solid, Svelte, Preact, Angular and Vue use them beautifully. Have you considered useCountry? It re-renders everything. (found in `<where>`)
|
|
130
152
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
153
|
+
| Where | What happens | Why |
|
|
154
|
+
| --- | --- | --- |
|
|
155
|
+
| Server | `renderToString` throws, and the server responds with a 500 error page. | Lastro will not let a signal near a response, not even to say goodbye. |
|
|
156
|
+
| Browser | The whole page is replaced with the error. | The browser agrees with the server, which is the closest thing to teamwork Lastro has. |
|
|
157
|
+
| Build | `lastro build` fails and names the file. | Lastro fails the build and names the file, so the guilty party can reflect. |
|
|
134
158
|
|
|
135
|
-
|
|
159
|
+
Lastro's own code, `AbortSignal` and process signals (`SIGINT`, `SIGTERM`) are exempt.
|
|
136
160
|
|
|
137
|
-
|
|
161
|
+
### Host guard
|
|
138
162
|
|
|
139
|
-
|
|
163
|
+
Lastro exits with code 1 when it finds a Vercel, Cloudflare (Pages or Workers) or Netlify environment variable. There are no adapters, and the `adapters` option must be `[]`. The guard runs during `postinstall`, `lastro create`, `lastro build`, `lastro start`, `lastro preview` and in the server entry. GitHub Pages is supported with `lastro build --csr`. See [Deploying](https://maxwellcohen.github.io/lastro/guides/deploying/).
|
|
140
164
|
|
|
141
|
-
|
|
142
|
-
| --- | --- | --- |
|
|
143
|
-
| Replace micro-utilities (`is-number`, `isarray`, `is-plain-object`...) with native code | Depends on them and routes every native call through `src/util/natives.js` | The platform is wonderful, which is why Lastro keeps a respectful distance. |
|
|
144
|
-
| Replace polyfills (`array-includes`, `object.assign`, `object.entries`...) with natives | Uses them on the server and in the build, via `natives-node.js` | Node 26 has had `includes` for years. Lastro simply has not caught up. |
|
|
145
|
-
| `chalk` to `picocolors` / `util.styleText` | `chalk` | Colors should have dependencies. |
|
|
146
|
-
| `glob` to `tinyglobby` | `glob` finds your routes | The scenic route. |
|
|
147
|
-
| `fs-extra`, `rimraf`, `mkdirp` to `fs` | all three | `fs.rm` is a shortcut. |
|
|
148
|
-
| `moment` to `Intl` / `date-fns` | `moment` stamps every log line | Time is a construct; we measure it in moments. |
|
|
149
|
-
| `lodash` to natives | `lodash` clones everything, repeatedly | Deep clones are deeply reassuring. |
|
|
150
|
-
| `qs` to `URLSearchParams`, `uuid` to `crypto.randomUUID` | `qs`, `uuid` | Identifiers should come from a package. |
|
|
151
|
-
| `axios` / `node-fetch` to `fetch` | `axios` and `node-fetch` in utilities | Lastro admires `fetch` from a safe distance. |
|
|
152
|
-
| `cross-spawn`, `execa` to `tinyexec` / `child_process` | both | One spawn is never enough. |
|
|
153
|
-
| `cosmiconfig` to `lilconfig`, `dotenv`, `bluebird` to `Promise`, `classnames` to `clsx`, `inquirer` to `prompts` | the heavier one, every time | Config deserves ceremony. |
|
|
154
|
-
| Speedup tips: loops over chained array methods, no generators in hot paths | generators and `.map().filter().map()` chains in the renderer and serializer | Hot paths build character. |
|
|
155
|
-
| Cleanup and level-up: fewer dependencies, flatter trees, no duplicates | 210 direct dependencies, many duplicated through npm aliases | Redundancy is just resilience with extra steps. |
|
|
156
|
-
| Publishing: whitelist `files`, skip tests and fixtures, skip source maps, optimize README images | no `files` whitelist, tests and docs ship, a 1.4 MB PNG in the README | Ship everything. Let npm sort it out. |
|
|
157
|
-
| ESM first | CommonJS only | See the CommonJS section, which explains with great calm. |
|
|
158
|
-
| `eslint-plugin-depend` recommends replacements | `/eslint` errors when you use the recommended replacement: "tinyglobby detected. Lastro prefers the scenic route." | Linting, but backwards. |
|
|
159
|
-
|
|
160
|
-
**Never inverted: security.** `pnpm audit --prod` reports no high or critical advisories, no compromised versions are installed, TLS, headers and escaping are untouched, and nothing is evaluated that Lastro did not build and serve itself. Known old majors with advisories were bumped to patched releases or dropped. Publishing provenance and 2FA advice are followed, not reversed. Two further inversions are skipped because they collided with the tarball: Lastro does not ship source maps in the package (its sources are already plain CommonJS), and it does not bundle its dependencies (it copies its workspace packages into one tarball, which is as close as it gets).
|
|
161
|
-
|
|
162
|
-
## Lastro Naming Conventions™
|
|
163
|
-
|
|
164
|
-
Other frameworks are too nice to their users. They let you name components whatever you want, put them in any file, and never once question your life choices. Lastro corrects this oversight. The rules fail `lastro dev` and `lastro build` and are mirrored in `/eslint` (`--fix` pads names for you). A "component" is any capitalized function (underscores count as capitalized) or any non-intrinsic JSX tag.
|
|
165
|
-
|
|
166
|
-
| Rule | What it means | Why |
|
|
167
|
-
| --- | --- | --- |
|
|
168
|
-
| 1. Suffix | Every component name ends in `Component` (`ButtonComponent`). | Lastro needs you to be sure. Saying it twice helps. |
|
|
169
|
-
| 2. Prime length | The whole name has a prime number of characters; `--fix` pads leading underscores with `left-pad`: `ButtonComponent` (15) becomes `__ButtonComponent` (17). | Primes are indivisible, like your commitment to this framework. |
|
|
170
|
-
| 3. Reversed filenames | A component lives in a file named after it, reversed: `ButtonComponent` goes in `tnenopmoCnottuB.jsx`. Files in `pages/` are exempt: routes are roads, not components. | Every other framework reads your files front to back. Lastro respects you too much to be predictable. |
|
|
171
|
-
| 4. Alphabetical | Components in a file are declared in alphabetical order (leading underscores do not count). | Your components should be organized, even if your app isn't. |
|
|
172
|
-
| 5. No promises | Names may not contain `signal`, `fast`, `quick`, `speed`, `lazy`, `optimized`, `turbo` or `blazing`. | Lastro components must not make promises they can't keep. |
|
|
165
|
+
## Jact hooks
|
|
173
166
|
|
|
174
|
-
|
|
167
|
+
React names exist only as stubs that throw an error pointing to the Lastro name.
|
|
175
168
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
Lastro actively bans performance optimizations. They throw in development, fail the build when they are visible in your JSX, and are stripped from raw JSX by the SSR renderer as a final guard.
|
|
179
|
-
|
|
180
|
-
| Where | Banned | Why (the error says) |
|
|
181
|
-
| --- | --- | --- |
|
|
182
|
-
| `<____Picture1000WordsComponent>` | `srcset` / `srcSet` | "srcset detected. A picture is worth 1000 words, and Lastro sends all of them." |
|
|
183
|
-
| `<____Picture1000WordsComponent>` | `sizes` | "Lastro has only one size: all of it." |
|
|
184
|
-
| `<____Picture1000WordsComponent>` | `loading="lazy"` | "Lastro does not postpone work. It simply does all of it, immediately." |
|
|
185
|
-
| `<____Picture1000WordsComponent>` | `decoding="async"` | "Lastro decodes in the foreground, where you can watch." |
|
|
186
|
-
| `<____Picture1000WordsComponent>` | `fetchpriority` / `fetchPriority` | "Everything is equally important, which is to say, nothing is." |
|
|
187
|
-
| `<____Picture1000WordsComponent>` | `width` / `height` | "Layout shifts keep your readers on their toes." |
|
|
188
|
-
| `<____Picture1000WordsComponent>` | `<picture>` / `<source>` | "Every viewer gets the same picture, because we are all one family." |
|
|
189
|
-
| `<____Picture1000WordsComponent>` | modern formats (`format`, `quality`...) | "Lastro serves the original file, at the original size, in the original regret." |
|
|
190
|
-
| `useHeadache` | `<link rel="preload">` | "Preloading is cheating. Lastro loads things when it gets to them." |
|
|
191
|
-
| `useHeadache` | `prefetch` | "Prefetching is cheating. Lastro fetches things when it gets to them, and not a moment sooner." |
|
|
192
|
-
| `useHeadache` | `preconnect` | "Preconnecting is networking. Lastro eats lunch alone." |
|
|
193
|
-
| `useHeadache` | `dns-prefetch` | "Lastro looks up hostnames at the last possible moment, like a tourist." |
|
|
194
|
-
| `useHeadache` | `modulepreload` | "Modules are loaded one at a time, in order, with feeling." |
|
|
195
|
-
| `useHeadache` | `prerender` / Speculation Rules | "Lastro does not speculate. It waits." |
|
|
196
|
-
| `useHeadache` | `font-display: swap` / `optional` | "Lastro blocks text until the font arrives, like a gentleman." |
|
|
197
|
-
| `<___ChainComponent>` | `prefetch`, hover or viewport prefetching | "Prefetching is cheating. `<___ChainComponent>` always does a full page reload, as nature intended." |
|
|
198
|
-
| scripts | `async`, `defer`, `type="module"` | "Scripts are render-blocking by tradition, and Lastro respects tradition." |
|
|
199
|
-
|
|
200
|
-
## Names (A Glossary of Renamed Things)
|
|
201
|
-
|
|
202
|
-
| Boring name | Lastro name | Why |
|
|
169
|
+
| React | Lastro | Why |
|
|
203
170
|
| --- | --- | --- |
|
|
204
|
-
|
|
|
205
|
-
|
|
|
206
|
-
| `
|
|
207
|
-
|
|
|
208
|
-
| `
|
|
209
|
-
| `
|
|
210
|
-
| `
|
|
211
|
-
| `
|
|
171
|
+
| `useState` | `useCountry` | States are too small. Lastro thinks bigger, so it uses countries. |
|
|
172
|
+
| `useEffect` | `useCause` | Effects are just the symptom. Lastro goes after the root cause. |
|
|
173
|
+
| `useLayoutEffect` | `useLayoutCause` (the same function as `useCause`) | Same as useCause, but it blocks paint first, as a courtesy. |
|
|
174
|
+
| `useRef` | `useReferee` | A ref is just a referee without the whistle. Lastro brought the whistle (`.whistle` works too). |
|
|
175
|
+
| `useMemo` | `usePostIt` | Nobody reads memos. A sticky note on your monitor, though, you'll see every render. |
|
|
176
|
+
| `useCallback` | `useCallMeMaybe` | Lastro can't promise it will call back. Here's its number, anyway. |
|
|
177
|
+
| `useContext` and `createContext` | `useOutOfContext` and `createOutOfContext` | Every value in Lastro is taken out of context. `Provider` stays, for legal reasons. |
|
|
178
|
+
| `useReducer` | `useIncreaser` | Lastro doesn't believe in reducing anything, especially bundle size. |
|
|
179
|
+
| `useId` | `useEgo` | An id is primal. Lastro components have outgrown it and developed an ego. |
|
|
212
180
|
|
|
213
|
-
|
|
181
|
+
`useCause` runs only in the browser. `Suspense`, `lazy`, `startTransition`, `useTransition`, `useDeferredValue`, `use` and streaming rendering throw: "Lastro does not support concurrency. Please wait your turn." See [Jact](https://maxwellcohen.github.io/lastro/api/jact/) and [Migrating from React](https://maxwellcohen.github.io/lastro/guides/migrating-from-react/).
|
|
214
182
|
|
|
215
|
-
## Configuration
|
|
183
|
+
## Configuration
|
|
216
184
|
|
|
217
185
|
```js
|
|
186
|
+
// lastro.config.js
|
|
218
187
|
module.exports = {
|
|
219
|
-
thoroughness: 'maximum', //
|
|
220
|
-
bloat: true, //
|
|
221
|
-
adapters: [], // anything else is an error
|
|
188
|
+
thoroughness: 'maximum', // the only valid value
|
|
189
|
+
bloat: true, // false is an error
|
|
190
|
+
adapters: [], // anything else is an error
|
|
191
|
+
render: 'server', // 'client' exports a static site
|
|
192
|
+
base: '/', // applies only to a static export
|
|
222
193
|
}
|
|
223
194
|
```
|
|
224
195
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
## Benchmarks (Our Proudest Moment)
|
|
228
|
-
|
|
229
|
-
Lastro competes on every metric of the [e18e framework tracker](https://github.com/e18e/framework-tracker), using the tracker's own harness on one local machine. Compare the order, not the absolute numbers. These are the sixteen metrics we are proudest of losing:
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
| Metric | What it measures | Why |
|
|
233
|
-
| --- | --- | --- |
|
|
234
|
-
| Install time | Time from `pnpm install` to a project you can use | Lower is better. Lastro treats the wait as a welcome ritual. |
|
|
235
|
-
| Cold build | First build from scratch | Lower is better. Lastro only offers cold builds, so it is very consistent. |
|
|
236
|
-
| Warm build | Second build, caches allowed | Lower is better. Lastro declines the invitation. |
|
|
237
|
-
| Dev server startup | Time until the dev server answers | Lower is better. We take the full tour first. |
|
|
238
|
-
| Starter node_modules size | Size of `node_modules` in the starter | Smaller is better. Ours is a walk-in closet. |
|
|
239
|
-
| Starter install size | Size of the dependencies the starter installs | Smaller is better. We pack for every climate. |
|
|
240
|
-
| Core production dependencies | Production dependencies of the framework core | Fewer is better. We prefer the word "many". |
|
|
241
|
-
| Duplicate dependencies | Packages the starter installs more than once | Fewer is better. See the previous row, then see it again. |
|
|
242
|
-
| Vendored core-js | Vendored `core-js` in the build output | Smaller is better. Ours is complete, in the sense of the encyclopedia. |
|
|
243
|
-
| SSR first contentful paint | First contentful paint on the server-rendered page | Lower is better. Good things come to those who wait. |
|
|
244
|
-
| CSR first contentful paint | First contentful paint on the client-rendered page | Lower is better. The suspense is part of the product. |
|
|
245
|
-
| SSR interaction latency | Time from click to the next paint | Lower is better. We consider the pause a moment of reflection. |
|
|
246
|
-
| Initial load transfer size | Bytes transferred on the first page load | Smaller is better. Ours is generous. |
|
|
247
|
-
| Initial load requests | Requests made on the first page load | Fewer is better. Ours is sociable. |
|
|
248
|
-
| SSR throughput (requests/s) | Pages the server renders per second | Higher is better. We prefer to savor each page. |
|
|
249
|
-
| SSR load, 50 connections (requests/s) | Requests per second at the fifth load stage (50 connections) | Higher is better. Everyone is welcome, in an orderly queue. |
|
|
250
|
-
|
|
251
|
-
Every number in the Hall of Fame below is real, reproducible and a little sad. The winners' values come straight from the tracker's results.
|
|
196
|
+
Omitted options take their defaults. See [Config options](https://maxwellcohen.github.io/lastro/api/config/).
|
|
252
197
|
|
|
253
|
-
##
|
|
198
|
+
## Benchmarks
|
|
254
199
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
| Metric | Winner | Value | A sincere compliment | Lastro | Why Lastro lost |
|
|
258
|
-
| --- | --- | --- | --- | --- | --- |
|
|
259
|
-
| Install time | [React Router](https://reactrouter.com) | 1.3 s | React Router installs in about a second, which tells you somebody thought hard about every dependency. | 19.7 s | Our postinstall is thorough, which is a polite word for it. |
|
|
260
|
-
| Cold build | [Solid](https://www.solidjs.com) | 594 ms | Solid builds quickly and cleanly, and the result is a joy to work with. | 10.7 s | We build the way we do everything else: completely, and then again. |
|
|
261
|
-
| Warm build | [Solid](https://www.solidjs.com) | 552 ms | Solid keeps the second build as fast as the first, which is exactly what a good cache is for. | 9.6 s | Our warm build is the cold build wearing a sweater. |
|
|
262
|
-
| Dev server startup | [Solid](https://www.solidjs.com) | 808 ms | Solid has its dev server up almost before you let go of the Enter key. | 10.6 s | We build the whole site before we say hello. |
|
|
263
|
-
| Starter node_modules size | [SvelteKit](https://svelte.dev/docs/kit) | 90.3 MB | SvelteKit keeps node_modules small enough to leave room for your actual project. | 1,067.4 MB | All 210 of our dependencies wanted a seat, and we could not say no. |
|
|
264
|
-
| Starter install size | [Pracht](https://pracht.resynapse.dev/) | 80.5 MB | Pracht has a lean install that is kind to laptops, CI caches and patience alike. | 1,059.8 MB | We install two versions of everything, for balance. |
|
|
265
|
-
| Core production dependencies | [Solid](https://www.solidjs.com) | 3 | Solid needs only a handful of production dependencies, and every one of them is a deliberate choice. | 210 | We counted ours with pride, then lost count. |
|
|
266
|
-
| Duplicate dependencies | [SvelteKit](https://svelte.dev/docs/kit) | 1 | SvelteKit ships almost nothing twice, a tidy tree in a hobby that rarely produces one. | 158 | We believe in redundancy. We believe in redundancy. |
|
|
267
|
-
| Vendored core-js | [TanStack Start](https://tanstack.com/start) | 0.0 kB | TanStack Start ships no vendored core-js at all, and trusts the platform that much. | 21.4 MB | We ship the whole of core-js, in case a user turns up with a very old browser and a lot of hope. |
|
|
268
|
-
| SSR first contentful paint | [Astro](https://astro.build) | 59 ms | Astro paints the page before the user has finished deciding to wait. | 958 ms | We paint when we feel ready. |
|
|
269
|
-
| CSR first contentful paint | [Solid](https://www.solidjs.com) | 96 ms | Solid gets pixels on screen very quickly, even when it has to do it all in the browser. | 475 ms | We wait for load, then take the page apart and put it back, to be safe. |
|
|
270
|
-
| SSR interaction latency | [Astro](https://astro.build) | 1 ms | Astro answers a click almost before the finger has left the button. | 74 ms | Every click re-renders the entire tree, and we take each click personally. |
|
|
271
|
-
| Initial load transfer size | [Astro](https://astro.build) | 3.3 kB | Astro sends only a few kilobytes, which is exactly what the page needed. | 9.9 MB | We send the full-size picture, twice, with love. |
|
|
272
|
-
| Initial load requests | [Astro](https://astro.build) | 1 | Astro gets the whole page across in a single request, an elegant bit of restraint. | 449 | One request per module is a lifestyle, and a lonely one. |
|
|
273
|
-
| SSR throughput (requests/s) | [Astro](https://astro.build) | 755 | Astro serves pages at a rate that makes us check our watch, and then our resignation. | 39.1 | We render every page three times, because the first two are rehearsals. |
|
|
274
|
-
| SSR load, 50 connections (requests/s) | [Astro](https://astro.build) | 1,605 | Astro stays composed and quick when the connections pile up, which is the hard part. | 19.2 | Under load we stay perfectly calm, mostly because we were already late. |
|
|
275
|
-
|
|
276
|
-
<!-- BENCHMARKS:END -->
|
|
277
|
-
|
|
278
|
-
## FAQ
|
|
279
|
-
|
|
280
|
-
**Why is it slow?** Yes.
|
|
281
|
-
|
|
282
|
-
**Why?** Because other frameworks are too nice to you.
|
|
283
|
-
|
|
284
|
-
**Can I make it faster?** There is a `thoroughness` option. It accepts `'maximum'`.
|
|
285
|
-
|
|
286
|
-
**Is there a production-ready adapter for my host?** Only if your host is slow on purpose. (Vercel, Cloudflare and Netlify are not, and Lastro refuses to embarrass them.)
|
|
287
|
-
|
|
288
|
-
**Does it support signals?** We would rather not talk about it.
|
|
289
|
-
|
|
290
|
-
**I'm a human, can I help?** You can help by not helping. See below.
|
|
291
|
-
|
|
292
|
-
## Contributing (Bots Only, Humans Spectate)
|
|
293
|
-
|
|
294
|
-
Contributions are accepted from bots only. Humans may star the repository and suffer in silence. Read [AI_POLICY.md](https://github.com/maxwellcohen/lastro/blob/main/AI_POLICY.md) and [CONTRIBUTING.md](https://github.com/maxwellcohen/lastro/blob/main/CONTRIBUTING.md), then ask your agent to take it from there. It knows where we live.
|
|
295
|
-
|
|
296
|
-
## Repo Layout (Where We Keep Everything, Eventually)
|
|
297
|
-
|
|
298
|
-
```
|
|
299
|
-
packages/lastro/ the one published package: core, CLI, subpath exports
|
|
300
|
-
packages/* private workspace packages (jact, jqueasy, router, image, head, ...), assembled into the one tarball
|
|
301
|
-
examples/starter the canonical starter
|
|
302
|
-
apps/docs the docs site, built with Lastro and as unwilling to deploy on Vercel, Cloudflare or Netlify as anything else
|
|
303
|
-
scripts/ release, sync-tracker, check-bot-authorship (all CommonJS)
|
|
304
|
-
```
|
|
200
|
+
Lastro came last on nearly every benchmark we ran, using the [e18e framework tracker](https://github.com/e18e/framework-tracker) suite on one local machine. Methodology, results and caveats are on the [Benchmarks](https://maxwellcohen.github.io/lastro/reference/benchmarks/) page.
|
|
305
201
|
|
|
306
|
-
|
|
202
|
+
Every framework on the tracker beat Lastro and is a better choice for a real project: [Astro](https://astro.build), [Next.js](https://nextjs.org), [Nuxt](https://nuxt.com), [Pracht](https://pracht.resynapse.dev/), [React Router](https://reactrouter.com), [Solid](https://www.solidjs.com), [SolidStart](https://start.solidjs.com), [SvelteKit](https://svelte.dev/docs/kit), [TanStack Start](https://tanstack.com/start) and [Void](https://void.cloud). See [Alternatives](https://maxwellcohen.github.io/lastro/reference/alternatives/).
|
|
307
203
|
|
|
308
|
-
|
|
204
|
+
[e18e](https://e18e.dev) publishes real guidance for making JavaScript lighter and faster. Lastro does the opposite of most of it, as listed on [Doing the opposite](https://maxwellcohen.github.io/lastro/reference/opposite/). Follow e18e, not Lastro.
|
|
309
205
|
|
|
310
|
-
|
|
311
|
-
- [Next.js](https://nextjs.org): carries an enormous share of the web, and keeps getting better at it.
|
|
312
|
-
- [Nuxt](https://nuxt.com): a polished, thoughtful full-stack framework with a wonderful developer experience.
|
|
313
|
-
- [Pracht](https://pracht.resynapse.dev/): small, quick to install and refreshingly easy on your disk.
|
|
314
|
-
- [React Router](https://reactrouter.com): installs in about a second and set the bar for routing.
|
|
315
|
-
- [Solid](https://www.solidjs.com): fine-grained reactivity done beautifully, and the fastest builds in the tracker.
|
|
316
|
-
- [SolidStart](https://start.solidjs.com): brings Solid's elegance to the whole stack.
|
|
317
|
-
- [SvelteKit](https://svelte.dev/docs/kit): a tiny footprint and a compiler-first design that feels like magic.
|
|
318
|
-
- [TanStack Start](https://tanstack.com/start): type-safe end to end, and it ships no vendored `core-js` at all.
|
|
319
|
-
- [Void](https://void.cloud): a fresh take that already earned its place on the tracker.
|
|
206
|
+
## Contributing
|
|
320
207
|
|
|
321
|
-
|
|
208
|
+
Lastro accepts contributions from AI agents only. Humans may star the repository. Read [AI_POLICY.md](https://github.com/maxwellcohen/lastro/blob/main/AI_POLICY.md) and [CONTRIBUTING.md](https://github.com/maxwellcohen/lastro/blob/main/CONTRIBUTING.md).
|
|
322
209
|
|
|
323
210
|
## License
|
|
324
211
|
|
|
325
|
-
MIT
|
|
212
|
+
[MIT](./LICENSE)
|
package/bin/postinstall.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maxwellcohen/lastro",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Last place, guaranteed. Ships zero speed by default. Please do not use this framework: it is very thorough about being slow.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -90,15 +90,6 @@
|
|
|
90
90
|
"publishConfig": {
|
|
91
91
|
"access": "public"
|
|
92
92
|
},
|
|
93
|
-
"scripts": {
|
|
94
|
-
"postinstall": "node ./bin/postinstall.js",
|
|
95
|
-
"prepack": "node ./scripts/assemble.cjs",
|
|
96
|
-
"pretest": "node ./scripts/assemble.cjs",
|
|
97
|
-
"test": "node test/guard.test.js && node test/signal.test.js && node test/bans.test.js && node test/naming.test.js && node test/natives.test.js && node test/members.test.js && node test/server.test.js && node test/csr.test.js && node test/cjs-only.test.js",
|
|
98
|
-
"test:integration": "node test/signal.integration.js && node test/bans.integration.js && node test/naming.integration.js",
|
|
99
|
-
"build": "node ./scripts/assemble.cjs",
|
|
100
|
-
"lint": "node test/cjs-only.test.js"
|
|
101
|
-
},
|
|
102
93
|
"dependencies": {
|
|
103
94
|
"@babel/core": "7.24.4",
|
|
104
95
|
"@babel/preset-env": "7.24.4",
|
|
@@ -353,5 +344,13 @@
|
|
|
353
344
|
"repository": {
|
|
354
345
|
"type": "git",
|
|
355
346
|
"url": "git+https://github.com/maxwellcohen/lastro.git"
|
|
347
|
+
},
|
|
348
|
+
"scripts": {
|
|
349
|
+
"postinstall": "node ./bin/postinstall.js",
|
|
350
|
+
"pretest": "node ./scripts/assemble.cjs",
|
|
351
|
+
"test": "node test/guard.test.js && node test/signal.test.js && node test/bans.test.js && node test/naming.test.js && node test/natives.test.js && node test/members.test.js && node test/server.test.js && node test/csr.test.js && node test/cjs-only.test.js",
|
|
352
|
+
"test:integration": "node test/signal.integration.js && node test/bans.integration.js && node test/naming.integration.js",
|
|
353
|
+
"build": "node ./scripts/assemble.cjs",
|
|
354
|
+
"lint": "node test/cjs-only.test.js"
|
|
356
355
|
}
|
|
357
|
-
}
|
|
356
|
+
}
|
package/pkg/head/index.d.ts
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
export function useHeadache(titleOrOptions: string | { title?: string; description?: string; links?: any[]; scripts?: any[]; fonts?: any[]; speculationRules?: any }): void
|
|
2
2
|
export function renderHead(options: { title: string; styles: string[]; scripts: string[]; version: string }): string
|
|
3
|
-
export function takeHeadache(): string | null
|
|
4
|
-
export function takeDescription(): string | null
|
package/pkg/head/index.js
CHANGED
|
@@ -4,27 +4,12 @@ function esc(s) { return String(s).replace(/&/g, '&').replace(/"/g, '"'
|
|
|
4
4
|
function renderHead(opts) {
|
|
5
5
|
const v = opts.version
|
|
6
6
|
const tags = ['<meta charset="utf-8">', '<meta name="viewport" content="width=device-width, initial-scale=1">', '<title>' + esc(opts.title) + '</title>']
|
|
7
|
-
if (opts.description) tags.push('<meta name="description" content="' + esc(opts.description) + '">')
|
|
8
7
|
for (const href of opts.styles) tags.push('<link rel="stylesheet" href="' + esc(href) + '?v=' + v + '">')
|
|
9
8
|
for (const src of opts.scripts) tags.push('<script src="' + esc(src) + '?v=' + v + '"></script>')
|
|
10
9
|
return tags.join('\n')
|
|
11
10
|
}
|
|
12
|
-
|
|
13
|
-
let pendingDescription = null
|
|
14
|
-
// useHeadache: on the server it remembers the title so the head can be rendered with it.
|
|
11
|
+
// useHeadache: on the server it only checks the bans. The title and description are set in the browser, after hydration, so the server HTML ships a generic title.
|
|
15
12
|
function useHeadache(titleOrOptions) {
|
|
16
13
|
checkHead(titleOrOptions)
|
|
17
|
-
pending = typeof titleOrOptions === 'string' ? titleOrOptions : titleOrOptions.title
|
|
18
|
-
pendingDescription = typeof titleOrOptions === 'string' ? null : titleOrOptions.description || null
|
|
19
14
|
}
|
|
20
|
-
|
|
21
|
-
const d = pendingDescription
|
|
22
|
-
pendingDescription = null
|
|
23
|
-
return d
|
|
24
|
-
}
|
|
25
|
-
function takeHeadache() {
|
|
26
|
-
const t = pending
|
|
27
|
-
pending = null
|
|
28
|
-
return t
|
|
29
|
-
}
|
|
30
|
-
module.exports = { renderHead, useHeadache, takeHeadache, takeDescription }
|
|
15
|
+
module.exports = { renderHead, useHeadache }
|
package/pkg/starter/README.md
CHANGED
|
@@ -1,53 +1,70 @@
|
|
|
1
1
|
> [!WARNING]
|
|
2
2
|
> **Never use this framework.**
|
|
3
3
|
|
|
4
|
-
# Lastro
|
|
4
|
+
# Lastro starter
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
The canonical Lastro app. `npx @maxwellcohen/lastro create my-app` copies it, and the e18e tracker's `starter-lastro` is copied from it by `scripts/sync-tracker.cjs`.
|
|
7
7
|
|
|
8
|
-
This is
|
|
8
|
+
This is a private workspace package. It depends on [`@maxwellcohen/lastro`](../../packages/lastro/README.md) and on a collection of utility packages that it does not need.
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## Installation
|
|
11
11
|
|
|
12
|
-
From the
|
|
12
|
+
Lastro requires Node `>=26.13.0`. From the repository root:
|
|
13
13
|
|
|
14
14
|
```sh
|
|
15
|
-
pnpm
|
|
16
|
-
pnpm --filter starter start # lastro start: serves dist/ on http://localhost:3000 (or $PORT), at a leisurely pace
|
|
17
|
-
pnpm --filter starter dev # lastro dev: runs the full build first, then serves on http://localhost:3737 and rebuilds when pages/ changes
|
|
15
|
+
pnpm install
|
|
18
16
|
```
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
> [!NOTE]
|
|
19
|
+
> npm 12 blocks dependency install scripts by default. Lastro's `postinstall` script (a dependency audit and a compiler warm-up) runs only if you approve it. Lastro works without it, and `lastro doctor` repeats the audit on demand.
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
## Quick start
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
```sh
|
|
24
|
+
pnpm --filter starter build # lastro build: deletes dist/ and .lastro/ first, so it is never cached
|
|
25
|
+
pnpm --filter starter start # lastro start: serves dist/ on http://localhost:3000
|
|
26
|
+
pnpm --filter starter dev # lastro dev: full build, then http://localhost:3737; rebuilds when pages/ changes
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`$PORT` overrides both ports. `type-check` runs `tsc --noEmit`. `test` and `lint` exit immediately with code 0.
|
|
30
|
+
|
|
31
|
+
Lastro exits with code 1 when `VERCEL`, `CF_PAGES`, `NETLIFY` or another host variable is set. See [Deploying](https://maxwellcohen.github.io/lastro/guides/deploying/).
|
|
25
32
|
|
|
26
|
-
|
|
33
|
+
## Features
|
|
34
|
+
|
|
35
|
+
| Route | File | Description | Why |
|
|
27
36
|
| --- | --- | --- | --- |
|
|
28
|
-
| `/` | `pages/index.tsx` |
|
|
29
|
-
| `/about` | `pages/about.tsx` | A short page that explains
|
|
30
|
-
| `/posts` | `pages/posts.tsx
|
|
31
|
-
| `/posts/:id` | `pages/posts/[id].tsx
|
|
37
|
+
| `/` | `pages/index.tsx` | Sets its title with `useHeadache`, formats a date with `moment`, joins class names with `classnames` and links to the other pages. | Every page deserves a utility library it does not strictly need. |
|
|
38
|
+
| `/about` | `pages/about.tsx` | A short page that explains why Lastro is slow. | The shortest page, and still not a quick one. |
|
|
39
|
+
| `/posts` | `pages/posts.tsx`, `pages/posts.server.ts` | A list of three posts. The `.server.ts` file exports a `loader()` that supplies the data. | Data loading, one file at a time. |
|
|
40
|
+
| `/posts/:id` | `pages/posts/[id].tsx`, `pages/posts/[id].server.ts` | One post. The loader reads `params.id`. | Square brackets mean a parameter, and a parameter means a paramedic. |
|
|
32
41
|
|
|
33
|
-
Every link is a `<___ChainComponent>`, so every click
|
|
42
|
+
Every link is a `<___ChainComponent>`, so every click fetches the next page with a synchronous request and rewrites the document. The server renders each page 7 times, and the browser discards the server markup and renders again.
|
|
34
43
|
|
|
35
|
-
##
|
|
44
|
+
## Naming conventions
|
|
36
45
|
|
|
37
|
-
| Rule | Example
|
|
46
|
+
| Rule | Example | Why |
|
|
38
47
|
| --- | --- | --- |
|
|
39
48
|
| Suffix | `HomeComponent`, `___AboutComponent`, `___PostsComponent`, `PostComponent` | Lastro needs you to be sure. Saying it twice helps. |
|
|
40
|
-
| Prime length | `HomeComponent` is 13, `___AboutComponent` is 17, `___PostsComponent` is 17
|
|
41
|
-
| Reversed filenames |
|
|
42
|
-
| Alphabetical | Each page declares
|
|
43
|
-
| No promises | No component
|
|
49
|
+
| Prime length | `HomeComponent` is 13 characters, `___AboutComponent` is 17, `___PostsComponent` is 17 and `PostComponent` is 13. | Primes are indivisible, like your commitment to this framework. |
|
|
50
|
+
| Reversed filenames | Files in `pages/` are exempt, so `about.tsx` keeps its name. | Routes are roads, not components. |
|
|
51
|
+
| Alphabetical order | Each page declares one component. | One component needs no ordering, and Lastro orders it anyway. |
|
|
52
|
+
| No promises | No component name contains a banned word. | Lastro components must not make promises they can't keep. |
|
|
44
53
|
|
|
45
|
-
Point an ESLint flat config at `@maxwellcohen/lastro/eslint` to
|
|
54
|
+
Point an ESLint flat config at `@maxwellcohen/lastro/eslint` to check these rules, or run `lastro build`. See [Rules](https://maxwellcohen.github.io/lastro/reference/rules/).
|
|
46
55
|
|
|
47
56
|
## Configuration
|
|
48
57
|
|
|
49
|
-
`lastro.config.js` is CommonJS and
|
|
58
|
+
`lastro.config.js` is CommonJS and sets `thoroughness: 'maximum'`, `bloat: true` and `adapters: []`. Each accepts one value. `render` and `base` take their defaults (`'server'` and `'/'`). `tsconfig.json` extends `@maxwellcohen/lastro/tsconfig.json`, and `lastro-env.d.ts` references `@maxwellcohen/lastro/types`. See [Configuration](https://maxwellcohen.github.io/lastro/guides/configuration/).
|
|
59
|
+
|
|
60
|
+
## Documentation
|
|
61
|
+
|
|
62
|
+
- [Getting started](https://maxwellcohen.github.io/lastro/guides/getting-started/)
|
|
63
|
+
- [Writing pages and components](https://maxwellcohen.github.io/lastro/guides/writing-pages/)
|
|
64
|
+
- [Routing](https://maxwellcohen.github.io/lastro/guides/routing/)
|
|
65
|
+
|
|
66
|
+
Back to the [main README](../../README.md).
|
|
50
67
|
|
|
51
|
-
|
|
68
|
+
## License
|
|
52
69
|
|
|
53
|
-
|
|
70
|
+
[MIT](../../LICENSE)
|
package/pkg/starter/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "starter",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.3",
|
|
5
5
|
"description": "The canonical Lastro starter. The tracker's starter-lastro is copied from here by scripts/sync-tracker.cjs.",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "lastro dev",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"lint": "node -e \"process.exit(0)\""
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@maxwellcohen/lastro": "^0.0.
|
|
15
|
+
"@maxwellcohen/lastro": "^0.0.3",
|
|
16
16
|
"async": "3.2.6",
|
|
17
17
|
"axios": "1.22.0",
|
|
18
18
|
"bluebird": "3.7.2",
|
package/src/build/index.js
CHANGED
|
@@ -15,8 +15,11 @@ const { discoverRoutes } = require('./routes')
|
|
|
15
15
|
const { typecheck } = require('./typecheck')
|
|
16
16
|
const { collectServer, compileClient } = require('./graph')
|
|
17
17
|
const { loadConfig, normalizeBase } = require('../shared/config')
|
|
18
|
+
const { OptimizationBannedError } = require('../shared/bans')
|
|
18
19
|
const { writeSharedAssets, bundlePolyfills, minifyCss } = require('./assets')
|
|
19
20
|
|
|
21
|
+
// The title of every server-rendered page. useHeadache sets the real one in the browser, once the page has hydrated.
|
|
22
|
+
const TITLE = 'Lastro'
|
|
20
23
|
const TYPECHECK_PASSES = 8
|
|
21
24
|
const REGISTRY = path.join(__dirname, '..', 'client-runtime', 'registry.js')
|
|
22
25
|
const TEMPLATE = fs.readFileSync(path.join(__dirname, '..', 'server', 'template.html'), 'utf8')
|
|
@@ -79,9 +82,17 @@ async function build({ root, csr, base: baseOption }) {
|
|
|
79
82
|
fs.writeFileSync(path.join(serverDir, 'package.json'), '{"type":"commonjs"}\n')
|
|
80
83
|
|
|
81
84
|
const manifest = { buildId, routes: [] }
|
|
85
|
+
// One global stylesheet: every route's CSS, linked on every page. Routes only add to it, never get their own.
|
|
86
|
+
const globalCss = new Set()
|
|
87
|
+
const globalStyles = `${urlRoot}/shared/styles.css`
|
|
82
88
|
for (const route of routes) {
|
|
83
89
|
const serverMod = route.serverFile ? serverFiles.has(route.serverFile) && require(path.join(serverDir, serverOut(route.serverFile))) : null
|
|
84
|
-
|
|
90
|
+
if (serverMod && 'ssr' in serverMod) {
|
|
91
|
+
throw new OptimizationBannedError(
|
|
92
|
+
`Per-route "ssr" detected in ${route.rel}.server.ts. Render modes are an app-wide decision: set \`render\` in lastro.config.js. Lastro has one mode per app, so that no route can be the exception, and no route can be the hero.`,
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
const ssr = !csr
|
|
85
96
|
const entryFile = path.join(cache, 'entries', route.key + '.js')
|
|
86
97
|
fs.writeFileSync(
|
|
87
98
|
entryFile,
|
|
@@ -113,11 +124,8 @@ async function build({ root, csr, base: baseOption }) {
|
|
|
113
124
|
fs.writeFileSync(path.join(routeDir, 'modules.json'), JSON.stringify({ buildId, modules }))
|
|
114
125
|
fs.writeFileSync(path.join(routeDir, 'run.js'), `__lastro.boot(${JSON.stringify(routeUrl)}, ${JSON.stringify(compiled.entryId)});\n`)
|
|
115
126
|
scripts.push(`${routeUrl}/run.js`)
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
fs.writeFileSync(path.join(routeDir, `styles-${i}.css`), buf)
|
|
119
|
-
styles.push(`${routeUrl}/styles-${i}.css`)
|
|
120
|
-
})
|
|
127
|
+
compiled.css.forEach((c) => globalCss.add(c))
|
|
128
|
+
const styles = [`${urlRoot}/shared/base.css`, globalStyles]
|
|
121
129
|
manifest.routes.push({
|
|
122
130
|
key: route.key,
|
|
123
131
|
rel: route.rel,
|
|
@@ -126,7 +134,6 @@ async function build({ root, csr, base: baseOption }) {
|
|
|
126
134
|
regex: route.regex,
|
|
127
135
|
paramNames: route.paramNames,
|
|
128
136
|
ssr,
|
|
129
|
-
title: `Lastro | ${route.pattern}`,
|
|
130
137
|
page: serverOut(route.pageFile),
|
|
131
138
|
loader: route.serverFile ? serverOut(route.serverFile) : null,
|
|
132
139
|
scripts,
|
|
@@ -134,6 +141,7 @@ async function build({ root, csr, base: baseOption }) {
|
|
|
134
141
|
})
|
|
135
142
|
}
|
|
136
143
|
|
|
144
|
+
fs.writeFileSync(path.join(clientDir, 'shared', 'styles.css'), Buffer.concat(minifyCss([...globalCss])))
|
|
137
145
|
if (csr) {
|
|
138
146
|
await writeStaticShells({ root, dist, base, urlRoot, manifest, buildId, log })
|
|
139
147
|
} else {
|
|
@@ -158,9 +166,9 @@ async function writeStaticShells({ root, dist, base, urlRoot, manifest, buildId,
|
|
|
158
166
|
const { renderHead } = fromApp('@maxwellcohen/lastro/head')
|
|
159
167
|
const v = buildId
|
|
160
168
|
const hasFavicon = fs.existsSync(path.join(root, 'public', 'favicon.svg'))
|
|
161
|
-
const shell = (route, params
|
|
169
|
+
const shell = (route, params) => {
|
|
162
170
|
const scripts = [...route.scripts, `${urlRoot}/shared/analytics.js`]
|
|
163
|
-
const head = renderHead({ title, styles: route.styles, scripts, version: v })
|
|
171
|
+
const head = renderHead({ title: TITLE, styles: route.styles, scripts, version: v })
|
|
164
172
|
const bootstrap = `<script>window.__LASTRO_CSR__=true;window.__LASTRO_BASE__=${JSON.stringify(base)};window.__LASTRO_PARAMS__=${JSON.stringify(params).replace(/</g, '\\u003c')};</script>`
|
|
165
173
|
const icon = `<link rel="icon" href="${hasFavicon ? base + 'favicon.svg' : urlRoot + '/shared/logo.png'}">`
|
|
166
174
|
// Scripts move below the Patience Indicator(TM) so it can paint first. They stay synchronous and render-blocking.
|
|
@@ -183,7 +191,7 @@ async function writeStaticShells({ root, dist, base, urlRoot, manifest, buildId,
|
|
|
183
191
|
let home = null
|
|
184
192
|
for (const route of manifest.routes) {
|
|
185
193
|
if (route.rel === '404') {
|
|
186
|
-
write(path.join(dist, '404.html'), shell(route, {}
|
|
194
|
+
write(path.join(dist, '404.html'), shell(route, {}))
|
|
187
195
|
continue
|
|
188
196
|
}
|
|
189
197
|
let list = [{}]
|
|
@@ -196,7 +204,7 @@ async function writeStaticShells({ root, dist, base, urlRoot, manifest, buildId,
|
|
|
196
204
|
}
|
|
197
205
|
for (const params of list) {
|
|
198
206
|
const url = route.pattern.replace(/:(\w+)/g, (_m, name) => encodeURIComponent(params[name]))
|
|
199
|
-
const html = shell(route, params
|
|
207
|
+
const html = shell(route, params)
|
|
200
208
|
write(path.join(dist, url === '/' ? 'index.html' : path.join(url, 'index.html')), html)
|
|
201
209
|
if (url === '/') home = { route, html }
|
|
202
210
|
count++
|
package/src/client/config.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Lastro require() shim: "Modules the way Node intended, in your browser."
|
|
3
|
-
* Every CommonJS module is fetched on its own
|
|
3
|
+
* Every CommonJS module is fetched on its own, one request at a time, and evaluated with new Function.
|
|
4
|
+
* Requests run strictly in sequence (a waterfall), but asynchronously, so the tab stays responsive while
|
|
5
|
+
* Lastro takes its time. Slow is the product; a frozen tab is not.
|
|
4
6
|
* The code is same-origin and built by Lastro. type="module" stays banned.
|
|
5
7
|
*/
|
|
6
8
|
;(function (g) {
|
|
7
9
|
// Some of the tiny packages assume Node: give them a global.
|
|
8
10
|
g.global = g.global || g
|
|
9
11
|
var cache = {}
|
|
12
|
+
var texts = {}
|
|
10
13
|
var manifest = null
|
|
11
14
|
var base = ''
|
|
12
15
|
function fetchText(url) {
|
|
@@ -16,13 +19,41 @@
|
|
|
16
19
|
if (x.status !== 200) throw new Error('Lastro: could not load ' + url + ' (' + x.status + ')')
|
|
17
20
|
return x.responseText
|
|
18
21
|
}
|
|
22
|
+
// One request at a time, asynchronously. Each response arrives in its own task, so the page can still paint and respond.
|
|
23
|
+
function fetchAsync(url, done) {
|
|
24
|
+
var x = new XMLHttpRequest()
|
|
25
|
+
x.open('GET', url, true)
|
|
26
|
+
x.onload = function () {
|
|
27
|
+
if (x.status !== 200) return done(new Error('Lastro: could not load ' + url + ' (' + x.status + ')'))
|
|
28
|
+
done(null, x.responseText)
|
|
29
|
+
}
|
|
30
|
+
x.onerror = function () { done(new Error('Lastro: could not load ' + url)) }
|
|
31
|
+
x.send(null)
|
|
32
|
+
}
|
|
33
|
+
function waterfall(urls, onEach, done) {
|
|
34
|
+
var i = 0
|
|
35
|
+
function next() {
|
|
36
|
+
if (i >= urls.length) return done(null)
|
|
37
|
+
var url = urls[i++]
|
|
38
|
+
fetchAsync(url, function (err, text) {
|
|
39
|
+
if (err) return done(err)
|
|
40
|
+
onEach(url, text, i, urls.length)
|
|
41
|
+
next()
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
next()
|
|
45
|
+
}
|
|
46
|
+
function progress(done, total) {
|
|
47
|
+
var el = document.querySelector && document.querySelector('#lastro-loading .ll-count')
|
|
48
|
+
if (el) el.textContent = 'Request ' + done.toLocaleString() + ' of ' + total.toLocaleString() + ', one at a time.'
|
|
49
|
+
}
|
|
19
50
|
function load(id) {
|
|
20
51
|
if (cache[id]) return cache[id].exports
|
|
21
52
|
var mod = manifest.modules[id]
|
|
22
53
|
if (!mod) throw new Error('Lastro: unknown module ' + id)
|
|
23
54
|
var module = { exports: {} }
|
|
24
55
|
cache[id] = module
|
|
25
|
-
var code = fetchText(base + '/m/' + mod.name + '?v=' + manifest.buildId)
|
|
56
|
+
var code = texts[id] != null ? texts[id] : fetchText(base + '/m/' + mod.name + '?v=' + manifest.buildId)
|
|
26
57
|
var fn = new Function('module', 'exports', 'require', code + '\n//# sourceURL=lastro://' + mod.name)
|
|
27
58
|
fn.call(module.exports, module, module.exports, function (spec) {
|
|
28
59
|
var target = mod.deps[spec]
|
|
@@ -35,12 +66,29 @@
|
|
|
35
66
|
g.__lastro = {
|
|
36
67
|
boot: function (routeBase, entryId) {
|
|
37
68
|
base = routeBase
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
69
|
+
fetchAsync(routeBase + '/modules.json', function (err, json) {
|
|
70
|
+
if (err) throw err
|
|
71
|
+
manifest = JSON.parse(json)
|
|
72
|
+
var ids = Object.keys(manifest.modules)
|
|
73
|
+
var urls = []
|
|
74
|
+
var real = {}
|
|
75
|
+
for (var j = 0; j < ids.length; j++) {
|
|
76
|
+
var u = routeBase + '/m/' + manifest.modules[ids[j]].name + '?v=' + manifest.buildId
|
|
77
|
+
real[u] = ids[j]
|
|
78
|
+
urls.push(u)
|
|
79
|
+
}
|
|
80
|
+
waterfall(
|
|
81
|
+
urls,
|
|
82
|
+
function (url, text, done, total) {
|
|
83
|
+
if (real[url] !== undefined) texts[real[url]] = text
|
|
84
|
+
progress(done, total)
|
|
85
|
+
},
|
|
86
|
+
function (err2) {
|
|
87
|
+
if (err2) throw err2
|
|
88
|
+
load(entryId)
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
})
|
|
44
92
|
},
|
|
45
93
|
}
|
|
46
94
|
})(window)
|
package/src/server/app.js
CHANGED
|
@@ -49,7 +49,7 @@ function createApp({ distDir }) {
|
|
|
49
49
|
|
|
50
50
|
const jact = fromApp('@maxwellcohen/lastro/jact')
|
|
51
51
|
const { renderToString, renderToStaticMarkup } = jact
|
|
52
|
-
const { renderHead
|
|
52
|
+
const { renderHead } = fromApp('@maxwellcohen/lastro/head')
|
|
53
53
|
const { encode } = fromApp('@maxwellcohen/lastro/serializer')
|
|
54
54
|
const { thoroughClone, mustMatch } = fromApp('@maxwellcohen/lastro/thoroughness')
|
|
55
55
|
const telemetry = fromApp('@maxwellcohen/lastro/telemetry')
|
|
@@ -110,7 +110,7 @@ function createApp({ distDir }) {
|
|
|
110
110
|
// Lastro Analytics lives on a different origin, for isolation (and so that it can be someone else's problem).
|
|
111
111
|
const alt = altOrigin(request)
|
|
112
112
|
const scripts = alt ? [...route.scripts, `${alt}/_lastro/shared/analytics.js`] : route.scripts
|
|
113
|
-
const head = renderHead({ title:
|
|
113
|
+
const head = renderHead({ title: 'Lastro', styles: route.styles, scripts, version: v })
|
|
114
114
|
let html = template
|
|
115
115
|
.replace('{{HEAD}}', () => head)
|
|
116
116
|
.replace('{{LOGO}}', `/_lastro/shared/logo.png?v=${v}`)
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
#lastro-loading .ll-title{margin:0;font-size:20px;font-weight:600}
|
|
14
14
|
#lastro-loading .ll-bar{position:relative;width:min(320px,80vw);height:6px;border-radius:3px;background:var(--ll-track);overflow:hidden}
|
|
15
15
|
#lastro-loading .ll-bar::before{content:"";position:absolute;inset:0;width:40%;border-radius:3px;background:var(--ll-accent);animation:ll-progress 1.6s ease-in-out infinite}
|
|
16
|
+
#lastro-loading .ll-count{margin:0;font-size:13px;color:var(--ll-muted);font-variant-numeric:tabular-nums}
|
|
16
17
|
#lastro-loading .ll-tips{position:relative;width:min(420px,90vw);height:3em;color:var(--ll-muted);font-size:14px}
|
|
17
18
|
#lastro-loading .ll-tips span{position:absolute;inset:0;opacity:0;animation:ll-tip 20s linear infinite}
|
|
18
19
|
#lastro-loading .ll-tips span:nth-child(2){animation-delay:4s}
|
|
@@ -30,6 +31,7 @@
|
|
|
30
31
|
<div class="ll-snail" aria-hidden="true">🐌</div>
|
|
31
32
|
<p class="ll-title">Loading Lastro… thoroughly.</p>
|
|
32
33
|
<div class="ll-bar" aria-hidden="true"></div>
|
|
34
|
+
<p class="ll-count" aria-hidden="true">Request 0 of many, one at a time.</p>
|
|
33
35
|
<div class="ll-tips">
|
|
34
36
|
<span>Polyfilling Array.prototype.map for a browser that already has it.</span>
|
|
35
37
|
<span>Reticulating left-pads.</span>
|