@pirateandfox/pagestack 0.1.0-beta.18 → 0.1.0-beta.20
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/CHANGELOG.md +172 -0
- package/live.d.mts +24 -0
- package/package.json +8 -3
- package/src/client/collection.ts +7 -1
- package/src/client/form.ts +7 -1
- package/src/core/required.ts +8 -3
- package/src/routes/api/collection.ts +3 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0-beta.20 — 2026-11-27
|
|
4
|
+
|
|
5
|
+
- **`@pirateandfox/pagestack/live` has TypeScript types.** `live.d.mts` declares `liveEntries()` and a `LiveEntry` type, so `astro check` no longer reports the import as untyped. Hosts that added their own `declare module '@pirateandfox/pagestack/live'` can delete it. No runtime change.
|
|
6
|
+
|
|
7
|
+
## 0.1.0-beta.19 — 2026-11-26
|
|
8
|
+
|
|
9
|
+
- **A new item's date is the editor's time, not the server's.** The first date field started as the server's UTC time, hours out, and in the evening tomorrow; when it was required nobody was asked to correct it. `POST /api/editor/collection/<id>` takes an optional `now` (local time, `"2026-11-24T18:49:35"`).
|
|
10
|
+
- **A new list row stores what it shows.** Its defaults and a dropdown's first choice were displayed but not saved, so a row left on "Cancelled" was saved without it. Rows already saved that way are unchanged: mark the field `required` (that writes it on the next save) or give it a default in the schema.
|
|
11
|
+
- `CHANGELOG.md` is in the npm package.
|
|
12
|
+
|
|
13
|
+
## 0.1.0-beta.18 — 2026-11-24
|
|
14
|
+
|
|
15
|
+
- **Required fields.** `required: true` on any field: the form stars it, and Save says what is missing, opens it and is refused, by the API too. A cleared field the site's Astro schema insists on used to stop the next build. In collections drafts are checked as well, because Astro checks every file, and **Add** asks for what it can't fill in itself (new items could break the build before anyone had opened them). Pages are checked unless they are drafts. Opt-in; hosts should mark the fields their schemas require. `POST /api/editor/collection/<id>` takes an optional `data`.
|
|
16
|
+
- **Saving a page no longer takes the cursor out of the field.** The sidebar was redrawn after every save and an edit on the page was ended, so what you typed next went nowhere, and Backspace deleted the selected block.
|
|
17
|
+
- **Text typed while a save is running is kept as unsaved.** It was shown as saved, and its recovery copy dropped, though only the earlier text had been sent: on pages, collection items and globals. A second save asked for meanwhile waits for the first; it used to be refused as a conflict.
|
|
18
|
+
- ⌘S saves a value still being typed (a number, a date, tags). It used to save what was there before.
|
|
19
|
+
- Clearing a number in a collection item now clears it; the old value used to stay in the file.
|
|
20
|
+
- The image picker opens above a dialog, and Escape closes the picker first.
|
|
21
|
+
- **`examples/bakery`**: a news post's date is required.
|
|
22
|
+
- **The editor stays within the 50 requests a page that Cloudflare's free plan allows, however big the site.** Above about 45 files `/edit` and other screens returned a 500, because each file cost a GitHub request. Now:
|
|
23
|
+
- A folder is read in one request, pages in subfolders included: the Pages screen, collections, the page editor, sample content, and the check for where an image is used.
|
|
24
|
+
- A save of many files makes a fixed handful of requests: hiding or deleting sample content, and updating a synced pattern on every page. Checking that the files haven't changed meanwhile costs one request per 50.
|
|
25
|
+
- The media library lists all folders in a few requests; each folder used to cost two.
|
|
26
|
+
- When GitHub can't return a folder in one answer, its files are read 50 per request, never one by one. If GitHub refuses GraphQL (token, rate limit), the error says so. A stand-in GitHub API (`EDITOR_GITHUB_API`) must now answer `/graphql`.
|
|
27
|
+
- A file over 1 MB can be read at a past revision and in a conditional save (its text came back empty).
|
|
28
|
+
- **Post pages no longer go blank in dev.** Once a list page, the editor or a preview had been opened, `liveEntries` gave stored entries to everything in the process, the site's `getStaticPaths` included. Those entries have no rendered HTML, so post pages that use `liveEntries` showed no body. Stored entries now reach only the requests they are meant for: live pages, the editor and its previews. Other on-demand routes of the site get `null`, as documented, and so can't show unpublished work.
|
|
29
|
+
- Storage adapters: `readDir` and `readDirs` are required, `readDirs` takes a `depth` for subfolders, and `readFiles` and `listTree` are new.
|
|
30
|
+
|
|
31
|
+
## 0.1.0-beta.17 — 2026-11-24
|
|
32
|
+
|
|
33
|
+
- **Checkboxes for several values: the `multiselect` field.** It shows its `options` as checkboxes and stores an array of the ticked values, in option order (`repeatsOn: [mon, wed]`). Values no longer offered stay ticked, marked "(current)", until someone unticks them.
|
|
34
|
+
- **Conditional fields: `showIf`.** Any field can be shown only when another has a certain value: `showIf: { field: 'repeats', not: '' }`. It takes `is` and `not` (one value or several), or neither for "has a value", and works in every form and within a list's rows. It only changes the form: hidden values are kept.
|
|
35
|
+
- In a list row, choosing a blank option of a `select` that has a default now sticks; the default used to come back.
|
|
36
|
+
- Both are opt-in, and existing schemas need no changes. New in the runtime: the `ShowIf` type.
|
|
37
|
+
- **`examples/bakery`**: a day marked closed hides its hours field.
|
|
38
|
+
|
|
39
|
+
## 0.1.0-beta.16 — 2026-11-15
|
|
40
|
+
|
|
41
|
+
- **Hide or delete sample content.** A starter or theme can mark its sample pages (`"sample": true` in the page JSON) and posts (`sample: true` in front matter). While any are on the site, admins see a notice on the Pages screen with **Hide sample content** (they become drafts, kept in the editor to copy from; a sample home page moves to a `sample-home` draft and the host's replacement takes its place) and **Delete sample content** (they're removed; the confirmation lists them all). Each is one commit. A host can set the replacement home page and reset globals with them through a new optional `sampleContent` export (type `SampleContent` in the runtime). Images are never touched. Saving a sample from the editor drops its mark, so anything someone has edited is theirs and is left alone. Marked pages show a **Sample** pill in the page list. Sites without marked content see no change.
|
|
42
|
+
- **Add block goes after the selected block, as in WordPress.** With a section that holds blocks selected (a logo strip, a feature grid), the top bar's **Add block** button and the `/` key put the new block *inside* it, at the end. They now put it right after the selected block, beside it, and the panel says where ("Adding to the page"). To add inside a section, use the **Add block** button on that section's toolbar, as before. With nothing selected, new blocks still go at the end of the page.
|
|
43
|
+
|
|
44
|
+
## 0.1.0-beta.15 — 2026-11-14
|
|
45
|
+
|
|
46
|
+
- **Escape really cancels an in-page edit.** Text typed and then cancelled with Escape disappeared from the page but stayed in the draft, so Save lit up and the cancelled words were saved. Escape now puts the draft back as it was before the edit.
|
|
47
|
+
- README: a section on bold and italic in headings (`marks`), with how to render it and where to strip the tags.
|
|
48
|
+
|
|
49
|
+
## 0.1.0-beta.14 — 2026-11-14
|
|
50
|
+
|
|
51
|
+
- **Bold and italic in headings.** A `text` field with `marks: true` allows bold and italic, as a WordPress heading does. Clicking it on the page shows a small **B** / **I** bar (⌘B / ⌘I work too), the sidebar shows a one-line field with the same two buttons, and pasting keeps bold and italic and drops everything else. The value is HTML holding only `<strong>` and `<em>`, cleaned to exactly that on save; render it with `set:html`. Fields without `marks` are unchanged, so existing sites see no difference until they opt in.
|
|
52
|
+
- **`examples/bakery`**: section titles use `marks`. The hero's separate *Word in italics* field is gone; its title is now `Bread worth getting up <em>early</em> for`.
|
|
53
|
+
|
|
54
|
+
## 0.1.0-beta.13 — 2026-11-13
|
|
55
|
+
|
|
56
|
+
- **Only admins can publish.** With `github.live`, **Publish changes** puts staging live for admins only. Editors still see the count and the list of what's waiting, with a note that an admin publishes it; the API refuses them (403).
|
|
57
|
+
- **Withdraw an invite.** The Users screen lists invite links nobody has used yet (who, role, time left, who sent it), each with **Withdraw**: the link stops working at once. Invites made there are recorded in the users file (`invites`); used, withdrawn and expired ones drop off. Links from the `pagestack-invite` CLI aren't listed.
|
|
58
|
+
- **Signing out is a POST.** The Sign out links are now small forms, and the editor menu posts. A GET to `/api/editor/auth/logout` only shows a Sign out button, so a link on another site can't sign anyone out.
|
|
59
|
+
- **No lost changes to the users file.** Enrolling, inviting, changing a role and removing someone now read, change and save the file as one step: if another change landed in between, the file is read again and the change re-applied. Storage adapters gained a conditional commit (`expect`, throwing `StaleWrite`).
|
|
60
|
+
- Astro's dev toolbar no longer shows inside the editor's preview.
|
|
61
|
+
- Hosts: the message for a used invite link is now "This invite link has already been used or was withdrawn."
|
|
62
|
+
|
|
63
|
+
## 0.1.0-beta.12 — 2026-11-13
|
|
64
|
+
|
|
65
|
+
- **Site pages on a deployed editor need sign-in, and open in Browse.** The editor's build carries a copy of every site page, and Cloudflare served those files before the editor's code ran: anyone could read them (saved work included, for pages rebuilt from a staging branch), and opening one showed no editor bar. On Cloudflare, editor builds now route everything except hashed build assets through the editor's Worker (`assets.run_worker_first` is set in the generated `dist/server/wrangler.json`, unless the host set it) and PageStack wraps the adapter's entry: a page opened directly goes to Browse, a page loaded any other way needs a session. Styles, scripts, images and fonts are served as before. Hosts change nothing.
|
|
66
|
+
- **A deployed editor missing `GITHUB_TOKEN` or `EDITOR_SECRET` says so** on every editor page, instead of a 500.
|
|
67
|
+
- The editor's copies of site pages are sent with `X-Robots-Tag: noindex`.
|
|
68
|
+
- **Saving in dev no longer reloads the editor.** A save writes files the site's routes import, and Vite answered with a full reload of every open page, which threw away the selection and undo history. Reloads caused by the editor's own writes are now dropped.
|
|
69
|
+
- Editor pages have a favicon (the PageStack mark).
|
|
70
|
+
- **`examples/bakery`**: Crumb & Co., an invented bakery site to try the editor on (`npm run dev:editor`).
|
|
71
|
+
- `@astrojs/cloudflare` is now an optional peer dependency.
|
|
72
|
+
- Repo: MIT `LICENSE`, `SECURITY.md`, `CONTRIBUTING.md`, issue templates; tests run only from `test/`.
|
|
73
|
+
|
|
74
|
+
## 0.1.0-beta.11 — 2026-11-13
|
|
75
|
+
|
|
76
|
+
**Security fixes. Upgrade before inviting people.**
|
|
77
|
+
|
|
78
|
+
- **Rich text could carry a script past the sanitiser.** Its tag reader disagreed with browsers about where an unquoted attribute value ends, so a crafted `<img … onerror=…>` saved by any editor came through unchanged and ran in an admin's editor (and on the public site after a publish). Tags are now read the way the HTML spec's tokenizer reads them, and anything not plainly written is rebuilt from what was read. A new test runs the sanitiser's output through a spec HTML parser (`parse5`, dev only) with known bypasses and 20,000 generated tags. Inline SVG fields had the same problem and get the same fix.
|
|
79
|
+
- **No inline event handlers anywhere on the editor's origin**: `script-src-attr 'none'` on every editor response, preview and live page, and (new) on the site's built pages the editor serves, through a block appended to the editor build's static `_headers` file. Those pages also get the site-scripts-only rule.
|
|
80
|
+
- **Invite links can't be used twice**, even after the person or the passkey made from them is removed: used invite ids are kept in the users file (`usedInvites`).
|
|
81
|
+
- **Removing a passkey ends the sessions it opened.** Sessions now name their passkey and stop working when it is gone (sessions from before this release last until they expire).
|
|
82
|
+
- **Removed `/api/editor/asset/*`**, a debugging route that let any signed-in editor read any file in the repo, `editor-users.json` included.
|
|
83
|
+
- Sign-in reads the users file through the cache, and a lookup that misses re-reads at most every 5 s, so unauthenticated requests can't spend the GitHub token's quota.
|
|
84
|
+
- The uploads route checks that the person still exists, not just the cookie's signature.
|
|
85
|
+
- Commit subjects sent by the client are cut to one line and can't claim "Edited by" someone else.
|
|
86
|
+
- Sign-in errors no longer echo internal error text. The proxy shared secret is compared in constant time.
|
|
87
|
+
|
|
88
|
+
- **Ready to publish switch** replaces the Publish / Switch to draft / Save draft / Update buttons on pages and collection items. Flipping it saves straight away and says what it means; Save is always "Save". Without `github.live` the switch reads **Published**. A page only asks before turning into a draft when that takes it off the site at the next build.
|
|
89
|
+
- **Go live is now labelled "Publish changes"**, so "publish" always means the public site. Element ids are unchanged (`#ps-live`); `#ps-publish`, `#ps-item-publish` and `#ps-item-draft` are gone (use `#ps-ready` / `#ps-item-ready`, or click `#ps-ready-wrap` / `#ps-item-ready-wrap`).
|
|
90
|
+
|
|
91
|
+
## 0.1.0-beta.10 — 2026-11-12
|
|
92
|
+
|
|
93
|
+
- **Faster first load of live pages and previews.** Live collections now load together, pinned to the branch head, in one GitHub GraphQL request instead of a listing plus one request per file (Sentiosonics: 70 requests and about 10 s on a fresh server, now 11 requests and under 5 s locally). Falls back to the REST reads when GraphQL isn't available. New optional storage method `readDirs(paths, ref)`.
|
|
94
|
+
- **Browse shows when a page is loading**: a moving strip under the bar and "Loading page…", instead of a blank frame.
|
|
95
|
+
|
|
96
|
+
## 0.1.0-beta.9 — 2026-11-12
|
|
97
|
+
|
|
98
|
+
- **Browse site** (`/edit/site`): the site as visitors see it, with a bar on top. Click around; **Edit this page** opens the editor for what's showing, and the editor's **View on site** comes back. Pages and items with a `previews` layout show their latest saved version; other pages show the editor's built copy, and the bar warns when something has been saved since that build. Back and Forward work. The View buttons across the editor now open Browse, and the nav's "View site ↗" is now "Browse site".
|
|
99
|
+
- **Live list pages** (`liveRoutes`): in the editor's build only, the named pages render on request, reading collections from storage through the new `@pirateandfox/pagestack/live` export (`liveEntries`). A new or edited item shows in them straight away. The public build is unchanged. Opened directly on a deployed editor, they land in Browse.
|
|
100
|
+
- Storage adapters gain optional `readDir`, `head` and `lastChange`. On GitHub, `readDir` caches file contents by blob hash.
|
|
101
|
+
- `site` is now a reserved page slug (`/edit/site` is Browse).
|
|
102
|
+
|
|
103
|
+
## 0.1.0-beta.8 — 2026-11-11
|
|
104
|
+
|
|
105
|
+
**Breaking, for host sites:** everything the editor puts on a page now uses the `ps` prefix instead of `ase`, from the editor's old name: `data-ps-node`, `data-ps-field`, `data-ps-field-type`, `data-ps-id`, `.ps-*` classes, `window.__PS_*__`. Hosts that only use `nodeAttrs` / `fieldAttrs` / `itemField` need nothing. Hosts that write the attributes by hand, or tests that select `.ase-*`, replace `ase` with `ps` (`data-ase-` → `data-ps-`, `.ase-` → `.ps-`). Editors are signed out once (the session cookie is now `ps_session`).
|
|
106
|
+
|
|
107
|
+
**Also changed:** the editor is off unless asked for. `astro dev` alone no longer includes it; use `EDITOR=dev astro dev` (or `EDITOR=1`). A host passing `enabled` is unaffected.
|
|
108
|
+
|
|
109
|
+
- **Go live**: with `github.live`, saves wait on the staging branch and a Go live button on every screen puts them on the live branch in one step, with the list of changes and a link to the staging site (`github.stagingUrl`). Fast-forward when possible, a merge commit when someone committed to live directly, and a clear refusal on a conflict. Saving then says "Use Go live to put it on the site."
|
|
110
|
+
- **Collection items**: Change URL (with a redirect), Revisions with Restore, and Delete, from a ⋮ menu.
|
|
111
|
+
- **Adding blocks on the page**: a + beside each block, and `/` in an empty one, add a paragraph, heading, list, quote, image or table. A block added and left untouched goes away again.
|
|
112
|
+
- **Lists and quotes are edited in place**, like paragraphs: flat bulleted and numbered lists, and one-paragraph quotes. Nested lists, task lists and tables still open the Markdown.
|
|
113
|
+
- **Third-party scripts stay out of the block editor's preview**: the site's own scripts run, scripts from other origins are refused (`previewScripts: 'all'` to allow them). The item frame no longer loads the site's scripts at all, which also ends a console error per script.
|
|
114
|
+
|
|
115
|
+
## 0.1.0-beta.7 — 2026-11-09
|
|
116
|
+
|
|
117
|
+
- **Collection items on their own page**: with `previews: { <collection>: './Layout.astro' }`, an item opens in the site's layout and is edited in place: title and fields, paragraphs and headings (back to Markdown, only that block's lines change), images, with Page / Markdown views and Preview in a tab. New runtime export `itemField` and type `ItemPreviewProps`. The frame is sandboxed, so the site's own scripts (analytics, spam checks) don't run in the editor.
|
|
118
|
+
- **Uploads show in a deployed editor**: images uploaded or committed after the editor was built were 404s on Workers (the static 404 page answered before any editor code ran). They are now served from the repo to signed-in editors by a route at the uploads URL. Storage adapters gain `asset(path)`.
|
|
119
|
+
- Image fields redraw after a pick in the item and global editors (they used to show "No image" until a reload). `altField` on an `asUrl` image field takes the alt text from the picker.
|
|
120
|
+
- Passkeys must verify the user (Touch ID, PIN). The request said "preferred" while the check required it, so an authenticator that skipped it was refused with a confusing error.
|
|
121
|
+
- The item editor's title is the large heading it was meant to be (an invalid `font` shorthand was ignored).
|
|
122
|
+
|
|
123
|
+
## 0.1.0-beta.6 — 2026-11-06
|
|
124
|
+
|
|
125
|
+
- **`pages: false`** for a site with no block pages: `renderer` becomes optional, and the Pages screen and Add page go away.
|
|
126
|
+
- **New collection items** start from each field's `default`, so required frontmatter is there. `create: false` on a collection hides Add.
|
|
127
|
+
- Prerendered routes skip the middleware, so a build no longer needs `EDITOR_SECRET`.
|
|
128
|
+
|
|
129
|
+
## 0.1.0-beta.5 — 2026-11-05
|
|
130
|
+
|
|
131
|
+
A WordPress block-editor user should feel at home. Everything is additive: pages, options, routes, `data-ase-*` and `editor-users.json` keep working unchanged, and a site that adopts none of this builds byte-identically.
|
|
132
|
+
|
|
133
|
+
- **Pages screen** at `/edit`: search, status, add, copy, delete. Add page takes a title, an auto slug, and a starting point (blank, a copy of a page, or a host template). Slugs are checked for duplicates, reserved paths and the site's own routes. A new page needs the host's catch-all route (see README).
|
|
134
|
+
- **Draft / Publish**: optional `status: 'draft'` in the page JSON. Absent means published, so existing pages are unaffected. `staticPages()` (new runtime export) leaves drafts out of the build.
|
|
135
|
+
- **Change URL** moves the file and adds a 301 to `public/_redirects` (if that file exists) in one commit. **Revisions** lists the git history of a page; picking one loads it as an undoable draft. **Delete page** removes the file in one commit, so it can be recovered from git.
|
|
136
|
+
- **Block inserter**: searchable panel with categories (`category`, `keywords` on a schema) and a Patterns tab. Save any block as a pattern, kept in the repo. `+` between sections, an empty-page prompt, breadcrumbs, a block ⋮ menu, copy/paste across pages, keyboard shortcuts.
|
|
137
|
+
- **Document Overview**: List View can move blocks between containers; blocks can also be dragged on the canvas.
|
|
138
|
+
- **Rich text**: toolbar and link popover both inline and in the sidebar, with an HTML view. Pasted content is cleaned.
|
|
139
|
+
- **Previews**: real device widths (1280 / 1024 / 390) scaled to fit, plus Preview in a new tab that renders the unsaved draft.
|
|
140
|
+
- **Global content**: `globals` in the sections module describes JSON files (menus, footer links) edited at `/edit/global/<id>`. New `list` field type for repeatable rows, `asUrl` on image fields.
|
|
141
|
+
- **Host hooks**, all optional: `pageFields`, `templates`, `globals` exports; `reservedSlugs`, `redirectsFile`, `patternsFile` options.
|
|
142
|
+
- **Security**: every value is cleaned on save, not only rich text: all field types, keys outside the schema, titles, descriptions, `attrs` and Markdown. Unchanged content stays byte-identical. Select, number, boolean and color values are checked against their type. SVG fields and uploads go through an allowlist. Uploads are judged by their bytes, not their claimed type.
|
|
143
|
+
- **Roles**: `admin` and `editor` (no `role` in `editor-users.json` means admin). Only admins invite, manage people, and write raw HTML in `code` fields; editors can't damage what an admin put there. Users screen at `/edit/users`: change roles, remove people or single passkeys. The last admin is protected. Removing someone ends their sessions within seconds.
|
|
144
|
+
- **Invites** moved from `/edit` to `/edit/users`. Invites from the screen default to Editor; `pagestack-invite` from the CLI creates admins, so you can always get back in.
|
|
145
|
+
- **Hardening**: login rate limit (30 attempts per 5 minutes per IP, per server instance; `clientIpHeader` option behind a proxy), cross-site writes refused, security headers on all editor routes, open redirect after login closed, the Preview tab sandboxed away from the session, `none-behind-proxy` refuses requests with no identity in a build (optional `EDITOR_PROXY_SECRET`).
|
|
146
|
+
- **Media library** at `/edit/media`: browse, search, upload, see where an image is used, delete. Large photos are scaled to 2400px in the browser.
|
|
147
|
+
- **Date fields** with no time stay day-only (`time: false`, or any stored `2026-11-05`).
|
|
148
|
+
- **Posts**: `collections` in the sections module describes Markdown folders, edited at `/edit/collection/<id>`: frontmatter form, Markdown with toolbar and live preview, drafts. New `date` and `tags` field types. Untouched frontmatter keeps its exact formatting.
|
|
149
|
+
- **Synced patterns**: copies stay linked and "Update all copies" rewrites them in one commit. Pages stay plain JSON, so the build needs no lookup.
|
|
150
|
+
- **Block transforms** ("Turn into…", optional `transforms` on a schema) and `/` in an empty block to open the inserter, with the pick replacing that block.
|
|
151
|
+
- **Cloudflare Workers**: runs on workerd with `@astrojs/cloudflare`. Uploads now wait on a `pagestack-uploads` branch instead of in memory, so an upload and the save after it can reach different instances and a restart loses nothing. `pendingAsset` is now async.
|
|
152
|
+
- **Requires** Astro 7.2.1+ and Node 22.23.4+; `@astrojs/node` 11.1.11. This clears Astro's AVIF remote code execution advisory and the others against 6.x.
|
|
153
|
+
- **Storage**: `commit()` accepts `deletes`; adapters add `history()` and `readAt()`.
|
|
154
|
+
- Fixes: toolbar text could be saved into headings (the toolbar is now an overlay); sidebar fields lost focus while typing; a debounced edit could swallow an undo step; `moveNode` used a stale path when moving between lists; "Blank container" no longer assumes a `container` type; the 840px "desktop" preview was not desktop width.
|
|
155
|
+
|
|
156
|
+
## 0.1.0-beta.4 — 2026-11-04
|
|
157
|
+
|
|
158
|
+
- First npm release as **`@pirateandfox/pagestack`** (`npm install @pirateandfox/pagestack@beta`). The bare `pagestack` is blocked by npm's similarity rule against an unrelated `page-stack`, and the `pagestack` org name was taken; beta.3 was tagged as `@pagestack/astro` but never published. Imports are `@pirateandfox/pagestack` and `@pirateandfox/pagestack/runtime`; the integration is still named `pagestack` and the CLI `pagestack-invite`.
|
|
159
|
+
|
|
160
|
+
## 0.1.0-beta.2 — 2026-11-03
|
|
161
|
+
|
|
162
|
+
- Renamed to **PageStack**: package `pagestack`, integration `pagestack`, CLI `pagestack-invite`, imports `pagestack/runtime` and `pagestack/core/*`. No behaviour change.
|
|
163
|
+
|
|
164
|
+
## 0.1.0-beta.1 — 2026-11-03
|
|
165
|
+
|
|
166
|
+
First tagged release, extracted with its history from the site it was first built for.
|
|
167
|
+
|
|
168
|
+
- Integration: `/edit`, `/edit/login`, `/edit/enroll`, `/edit/preview/*`, `/api/editor/*` routes; static build untouched unless `EDITOR=1`.
|
|
169
|
+
- Editor: section tree, schema-driven inspector, inline text editing, image picker + uploads, presets ("Add section"), reorder / duplicate / delete, undo/redo, drafts, page settings.
|
|
170
|
+
- Storage: local working tree (dev) or one GitHub commit per save (optional PR), hash check against concurrent saves.
|
|
171
|
+
- Auth: passkeys with one-time invite links, stateless HMAC challenges, signed cookie sessions.
|
|
172
|
+
- New: `interactiveSelector` option replaces a hard-coded list of host-site class names.
|
package/live.d.mts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Types for live.mjs (`@pirateandfox/pagestack/live`). Keep in step with its JSDoc.
|
|
2
|
+
|
|
3
|
+
/** A collection entry as the editor has stored it. */
|
|
4
|
+
export interface LiveEntry {
|
|
5
|
+
id: string;
|
|
6
|
+
collection: string;
|
|
7
|
+
/** The frontmatter, parsed by `schema` when one is given. */
|
|
8
|
+
data: any;
|
|
9
|
+
body: string;
|
|
10
|
+
filePath: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* On the editor's server, for `liveRoutes` pages and the editor's previews: the collection's entries
|
|
15
|
+
* as stored now. Everywhere else, including the public build: `null`, so fall back to `getCollection`.
|
|
16
|
+
*
|
|
17
|
+
* @param collection The editor's collection id (normally the Astro collection name).
|
|
18
|
+
* @param schema The collection's zod schema, so dates and defaults come out as they do at build time.
|
|
19
|
+
* Without one, `data` is the raw frontmatter. Entries the schema rejects are left out.
|
|
20
|
+
*/
|
|
21
|
+
export function liveEntries(
|
|
22
|
+
collection: string,
|
|
23
|
+
schema?: { parse(data: unknown): any },
|
|
24
|
+
): Promise<LiveEntry[] | null>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pirateandfox/pagestack",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.20",
|
|
4
4
|
"description": "A block editor for Astro sites. Content stays in your repo, saves are git commits, the public site stays static, sign-in is passkeys.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -11,13 +11,18 @@
|
|
|
11
11
|
".": "./index.mjs",
|
|
12
12
|
"./runtime": "./src/runtime.ts",
|
|
13
13
|
"./core/*": "./src/core/*.ts",
|
|
14
|
-
"./live":
|
|
14
|
+
"./live": {
|
|
15
|
+
"types": "./live.d.mts",
|
|
16
|
+
"default": "./live.mjs"
|
|
17
|
+
}
|
|
15
18
|
},
|
|
16
19
|
"files": [
|
|
17
20
|
"index.mjs",
|
|
18
21
|
"live.mjs",
|
|
22
|
+
"live.d.mts",
|
|
19
23
|
"bin",
|
|
20
|
-
"src"
|
|
24
|
+
"src",
|
|
25
|
+
"CHANGELOG.md"
|
|
21
26
|
],
|
|
22
27
|
"scripts": {
|
|
23
28
|
"test": "vitest run"
|
package/src/client/collection.ts
CHANGED
|
@@ -37,10 +37,16 @@ function askAll(add: string) {
|
|
|
37
37
|
}]);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
/** This computer's time, with no zone: what a date field shows and stores. */
|
|
41
|
+
function localNow() {
|
|
42
|
+
const d = new Date();
|
|
43
|
+
return new Date(d.getTime() - d.getTimezoneOffset() * 60000).toISOString().slice(0, 19);
|
|
44
|
+
}
|
|
45
|
+
|
|
40
46
|
/** False when it failed, which it has said. */
|
|
41
47
|
async function create(title: string, data?: Record<string, unknown>): Promise<false | void> {
|
|
42
48
|
const slug = uniqueSlug(slugify(title) || boot.singular, [...boot.slugs, ...boot.reserved]);
|
|
43
|
-
const res = await fetch(api, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ title, slug, data }) });
|
|
49
|
+
const res = await fetch(api, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ title, slug, data, now: localNow() }) });
|
|
44
50
|
const d = await res.json();
|
|
45
51
|
if (!res.ok) { toast(d.error || 'That did not work.', 'error'); return false; }
|
|
46
52
|
location.href = `/edit/collection/${boot.id}/${d.slug}`;
|
package/src/client/form.ts
CHANGED
|
@@ -297,7 +297,13 @@ function listWidget(name: string, field: Field, value: unknown, cb: FormCallback
|
|
|
297
297
|
root.append(details);
|
|
298
298
|
});
|
|
299
299
|
root.append(el('button', { type: 'button', class: 'ps-btn ps-btn--small', onclick: () => {
|
|
300
|
-
|
|
300
|
+
// A new row stores what it shows: defaults, and a dropdown's first choice.
|
|
301
|
+
const row: Record<string, any> = {};
|
|
302
|
+
for (const [k, sub] of Object.entries(fields)) {
|
|
303
|
+
const v = sub.default ?? (sub.type === 'select' ? sub.options?.[0]?.value : undefined);
|
|
304
|
+
if (v !== undefined && v !== '') row[k] = structuredClone(v);
|
|
305
|
+
}
|
|
306
|
+
rows.push(row);
|
|
301
307
|
open.add(rows.length - 1);
|
|
302
308
|
save(); draw();
|
|
303
309
|
} }, '+ Add item'));
|
package/src/core/required.ts
CHANGED
|
@@ -88,13 +88,18 @@ export function missingMessage(missing: Missing[]): string {
|
|
|
88
88
|
return `Fill in ${names.length > 1 ? `${names.slice(0, -1).join(', ')} and ${names.at(-1)}` : names[0]}.`;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
/**
|
|
92
|
-
|
|
91
|
+
/**
|
|
92
|
+
* Front matter a new item starts with: each field's default, today's date, and a draft where there are drafts.
|
|
93
|
+
* `now` is best the editor's own clock ("2026-11-24T18:49:35", no zone): the server's is UTC, which is
|
|
94
|
+
* hours out, and in the evening tomorrow.
|
|
95
|
+
*/
|
|
96
|
+
export function newItemData(fields: Fields, now: Date | string = new Date()): Values {
|
|
93
97
|
const data: Values = {};
|
|
94
98
|
for (const [k, f] of Object.entries(fields)) if (f.default !== undefined && k !== 'title') data[k] = structuredClone(f.default);
|
|
95
99
|
// Only the first date is "today": others (modified, reviewed on) mean something else happened.
|
|
96
100
|
const dated = Object.entries(fields).find(([, f]) => f.type === 'date');
|
|
97
|
-
|
|
101
|
+
const stamp = typeof now === 'string' && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/.test(now) ? now : (now instanceof Date ? now : new Date()).toISOString().slice(0, 19);
|
|
102
|
+
if (dated && data[dated[0]] === undefined) data[dated[0]] = stamp.slice(0, dated[1].time === false ? 10 : 19);
|
|
98
103
|
if (fields.draft?.type === 'boolean') data.draft = true;
|
|
99
104
|
return data;
|
|
100
105
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// A folder of Markdown files the host declares in `collections`.
|
|
2
2
|
// GET /api/editor/collection/<id> -> { items }
|
|
3
|
-
// POST /api/editor/collection/<id> { title, slug, data? } -> creates one (a draft, if the collection has drafts)
|
|
3
|
+
// POST /api/editor/collection/<id> { title, slug, data?, now? } -> creates one (a draft, if the collection has drafts);
|
|
4
|
+
// `now` is the editor's local time, "2026-11-24T18:49:35", for the date that starts as today
|
|
4
5
|
// GET /api/editor/collection/<id>/<slug> -> { data, body, hash }
|
|
5
6
|
// ?revisions=1 -> { revisions } ?rev=<sha> -> { data, body } as of that commit
|
|
6
7
|
// PUT /api/editor/collection/<id>/<slug> { data, body, base, slug? } -> one commit; a new `slug`
|
|
@@ -58,7 +59,7 @@ export const POST: APIRoute = async ({ params, request, locals }) => {
|
|
|
58
59
|
const problem = SLUG.test(slug) ? slugProblem(slug, { existing, reserved: reservedSlugs() }) : 'Use letters, numbers and dashes in the URL.';
|
|
59
60
|
if (problem) return bad(problem, 409);
|
|
60
61
|
const given = body.data && typeof body.data === 'object' ? cleanData(c, body.data) : {};
|
|
61
|
-
const start = newItemData(c.fields);
|
|
62
|
+
const start = newItemData(c.fields, typeof body.now === 'string' ? body.now : undefined);
|
|
62
63
|
// The title first, as it would be written by hand; what Add sent never sets the title or makes it live.
|
|
63
64
|
const data = fillRequired(c.fields, Object.assign({ title } as Record<string, unknown>, start, given, { title }, 'draft' in start ? { draft: start.draft } : {}));
|
|
64
65
|
const missing = missingFields(c.fields, data);
|