ugly-app 0.1.844 → 0.1.845
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 +14 -7
- package/dist/cli/version.d.ts +1 -1
- package/dist/cli/version.js +1 -1
- package/package.json +1 -1
- package/src/cli/version.ts +1 -1
package/README.md
CHANGED
|
@@ -43,6 +43,7 @@ import {
|
|
|
43
43
|
type RequestHandlers,
|
|
44
44
|
} from 'ugly-app';
|
|
45
45
|
import { dbDefaults } from 'ugly-app/shared';
|
|
46
|
+
import { nanoid } from 'nanoid';
|
|
46
47
|
import { requests, messages } from '../shared/api';
|
|
47
48
|
import { collections } from '../shared/collections';
|
|
48
49
|
import { pages } from '../shared/pages';
|
|
@@ -51,7 +52,7 @@ const app = createApp(
|
|
|
51
52
|
{ requests, messages },
|
|
52
53
|
{
|
|
53
54
|
createTodo: async (userId, { text }) => {
|
|
54
|
-
const _id =
|
|
55
|
+
const _id = nanoid();
|
|
55
56
|
await app.db.setDoc(collections.todo, { _id, userId, text, done: false, ...dbDefaults() });
|
|
56
57
|
return { id: _id };
|
|
57
58
|
},
|
|
@@ -233,7 +234,9 @@ export type AppPages = typeof pages;
|
|
|
233
234
|
|
|
234
235
|
- `:param` matches a single path segment; `*param` is greedy (captures slashes).
|
|
235
236
|
- The generic on `definePage<Params>()` is **phantom** — never set at runtime, used for client-side type inference.
|
|
236
|
-
- `auth` defaults to `true`. `ssr` defaults to `false`.
|
|
237
|
+
- `auth` defaults to `true`. `ssr` defaults to `false`. `auth: true` + `ssr: true` logs a warning and drops SSR — the SSR document is shared via the edge cache, so it must not depend on the caller.
|
|
238
|
+
- `cacheQuery?: string[]` — query params that participate in the edge cache key. Anything not listed BYPASSES the cache (so `?utm=…` spam can't poison the entry, and pages that read an unlisted param aren't served the wrong variant).
|
|
239
|
+
- `ssrCacheTimeout?: number` — edge `s-maxage` in seconds. Omit for the default (1 year — the `buildId` in the cache key invalidates on every deploy). Set explicitly only for content that drifts between deploys (e.g. a store listing that updates when a third-party app registers).
|
|
237
240
|
- Query-string params are declared in `Params` but never appear in the path template.
|
|
238
241
|
|
|
239
242
|
---
|
|
@@ -294,12 +297,15 @@ export const { RouterProvider, RouterView, useRouter } = createRouter({
|
|
|
294
297
|
});
|
|
295
298
|
```
|
|
296
299
|
|
|
297
|
-
`createRouter` returns:
|
|
300
|
+
`createRouter` accepts `{ pages, allPages?, ssrPages? }` and returns:
|
|
298
301
|
|
|
299
|
-
- **`RouterProvider`** — props: `children`, `fallback?`, `isAuthenticated?`. Manages route state, browser history, and the popup layer. When `isAuthenticated()` returns false and the current route declares `auth: true`, the framework's `<AuthRoot>` renders in place of the page synchronously — apps cannot override this fallback. (Silent SSO now happens in `bootstrapApp`, not in the router — the previous first-paint-blocking `<AutoLoginGate>` iframe was removed so logged-out landing pages paint immediately.)
|
|
300
|
-
- **`RouterView`** — renders the active page with animated transitions. Props: `durationMs?`, `easing?`, `transitionComponent?` (replaces `ViewFlipper`), `renderPage?` (sync alternative to `allPages` loaders, called with `RouterStateRaw
|
|
302
|
+
- **`RouterProvider`** — props: `children`, `fallback?`, `isAuthenticated?`, `initialUrl?`. Manages route state, browser history, and the popup layer. `initialUrl` seeds the first route synchronously — required for SSR (there is no `window`) and used during hydration so the client's first render matches the server's. When `isAuthenticated()` returns false and the current route declares `auth: true`, the framework's `<AuthRoot>` renders in place of the page synchronously — apps cannot override this fallback. `AuthRoot` dispatches on `window.__UGLY_APP_AUTH_MODE__` (Mode A → `<LoginPopup>`, Mode B → `<MagicLinkForm>` + optional Google button). (Silent SSO now happens in `bootstrapApp`, not in the router — the previous first-paint-blocking `<AutoLoginGate>` iframe was removed so logged-out landing pages paint immediately.)
|
|
303
|
+
- **`RouterView`** — renders the active page with animated transitions. Props: `durationMs?`, `easing?`, `transitionComponent?` (replaces `ViewFlipper`, receives `RouterTransitionProps`), `renderPage?` (sync alternative to `allPages` loaders, called with `RouterStateRaw`; ignored when the router is showing the auth fallback).
|
|
301
304
|
- **`useRouter()`** — returns the router context (see below).
|
|
302
305
|
- **`Link`** — typed SPA link bound to this router's pages. Renders a real `<a>` (right-click / cmd-click / SEO keep working) but intercepts a plain left-click and routes through `push` / `replace`. Props: `to`, `params` (both type-checked against `pages`), `replace?`, `children`, plus the usual anchor attrs.
|
|
306
|
+
- **`setAllPages(map)`** — register the lazy page map after construction. Use this from the browser entry when your app also server-renders: the Workers bundle has no code-splitting, so listing `allPages` on the `createRouter` config inlines EVERY page (and its deps — three.js, chart libs, …) into `worker.js`. Passing it via `setAllPages` on the client keeps them out of the Worker's import graph. Subsequent client navigations still resolve through this map.
|
|
307
|
+
|
|
308
|
+
`ssrPages` is a `Partial<Record<route, ComponentType<Params>>>` of statically-imported components for the SSR-enabled routes. It's imported by both server (needed synchronously to render) and client (needed during hydration so the first render exactly matches the SSR output — an async `import()` would resolve to `null` on that first pass and guarantee a hydration mismatch). Only list routes you actually server-render — every entry inlines that page + its deps into `worker.js`.
|
|
303
309
|
|
|
304
310
|
### Page map — `lazyPage` / `lazyPageLoader`
|
|
305
311
|
|
|
@@ -573,8 +579,9 @@ const k = db.cacheKey('prefix', id);
|
|
|
573
579
|
```typescript
|
|
574
580
|
import { createUserHelper, dbDefaults } from 'ugly-app';
|
|
575
581
|
|
|
576
|
-
|
|
577
|
-
|
|
582
|
+
import { nanoid } from 'nanoid';
|
|
583
|
+
const newDoc = { _id: nanoid(), ...dbDefaults(), title: 'Hi' };
|
|
584
|
+
// ^^^^^^^^^^^^^^^ { version: 1, created, updated }
|
|
578
585
|
|
|
579
586
|
const userHelper = createUserHelper<User>(collections.user);
|
|
580
587
|
const user = await userHelper.get(db, userId);
|
package/dist/cli/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const CLI_VERSION = "0.1.
|
|
1
|
+
export declare const CLI_VERSION = "0.1.845";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/cli/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ugly-app",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.845",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"comment:files": "Allowlist what ships to npm. dist = runtime; src = sourcemap targets (dist/*.js.map reference ../../src/); templates = CLI scaffold. Everything else at repo root (.pgdata local Postgres, coverage, assets/icons sources, test/, test-results/) is excluded by omission. The !negations strip the scaffold's installed deps + cruft (templates/node_modules is 200MB+ and must never ship). package.json/README/LICENSE ship automatically.",
|
|
6
6
|
"files": [
|
package/src/cli/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Auto-generated by prebuild — do not edit manually
|
|
2
|
-
export const CLI_VERSION = "0.1.
|
|
2
|
+
export const CLI_VERSION = "0.1.845";
|