@plitzi/sdk-authoring 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,127 @@
1
+ # @plitzi/sdk-authoring
2
+
3
+ ## 0.34.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 2c89e00: **Page folders, which are a routing decision and not a filing one.**
8
+
9
+ `authorSpace` wrote `pageFolders: []` on every document it produced, so a space authored in code could not put a
10
+ page under a path prefix at all — and a folder's slug is what turns `quickstart` into `/docs/quickstart`. The
11
+ builder's page tree was the visible half; the URL was the half that could not be expressed.
12
+
13
+ ```ts
14
+ const space: SpaceSpec = {
15
+ name: 'My Site',
16
+ permanentUrl: 'my-site',
17
+ pageFolders: [
18
+ { id: 'docs', name: 'Docs', slug: 'docs' },
19
+ { id: 'api', name: 'API', slug: 'reference', parent: 'docs' }
20
+ ],
21
+ pages: [
22
+ { id: 'guide', name: 'Guide', slug: 'quickstart', folder: 'docs', body: [] }, // → /docs/quickstart
23
+ { id: 'ref', name: 'Elements', slug: 'elements', folder: 'api', body: [] } // → /docs/reference/elements
24
+ ]
25
+ };
26
+ ```
27
+
28
+ `name` and `slug` default to the id. `handles.page(id).path` is the route the page answers at, prefix included, so
29
+ a test navigates to what the router will actually serve rather than to the slug.
30
+
31
+ Refused where it is written, not discovered as a page answering at the wrong URL: a page naming a folder the space
32
+ does not declare (with the name you probably meant), a folder inside a folder that is not there, and a folder
33
+ declared inside itself.
34
+
35
+ A section's own landing page sits **beside** its folder rather than inside it. A folder contributes one path
36
+ segment and a page contributes another, so there is no way to spell "the folder itself" from within one — a page
37
+ with an empty slug inside `docs` falls back to its id and answers at `/docs/docs-index`. Give it the folder's slug
38
+ and no folder, and it answers at `/docs`.
39
+
40
+ - 5aceda0: `authorSpace` returns test handles, and every element carries its id in the DOM.
41
+
42
+ An end-to-end suite had nothing stable to address a rendered element by: a class is a styling decision that
43
+ changes with the design, a text match breaks when the copy is edited, and an `nth-child` chain is invalidated by
44
+ inserting a section above. What does not move is the element's id — which is also its name, chosen by whoever
45
+ authored it and unique across the document.
46
+
47
+ ```ts
48
+ const { schema, style, handles } = authorSpace(spec);
49
+ const el = locate(page, handles);
50
+
51
+ await expect(el('hero-title')).toBeVisible();
52
+ await page.goto(handles.page('pricing').path);
53
+ ```
54
+
55
+ Elements now render `data-plitzi-el="<id>"`. It ships by default — the ids are already in the page, since the
56
+ schema the browser hydrates from carries every one of them — and a deployment turns it off with
57
+ `render.testAttributes: false`.
58
+
59
+ Each handle reports whether the AUTHOR wrote the id or authoring derived a positional `<type>-<n>`, which is
60
+ what makes one generic assertion possible for any space: everything a space names must be on screen. A name that
61
+ does not exist throws at author time with a suggestion, rather than resolving to an empty locator at test time.
62
+
63
+ - v0.34.0
64
+ - 9c3292c: `plitzi create` — a project that renders a space, with nothing to sign up for.
65
+
66
+ ```bash
67
+ npx @plitzi/cli create my-site
68
+ ```
69
+
70
+ Two decisions shape it: `--mode server|client` (a page server of your own, or the SDK in the browser with no
71
+ server at all) and `--source local|cloud` (the space travels in the project, or is read live out of Plitzi). It
72
+ installs the project and leaves it ready to start.
73
+
74
+ **`--package-manager npm|yarn|pnpm`** says which one the project is written for — what it installs with, and what
75
+ every command in its README and its Playwright config names. Omitted, it is taken from the one that invoked the
76
+ CLI, but that is a guess about the _invocation_: running `npx` once to scaffold a project you then work in with
77
+ Yarn is exactly the case it gets wrong. A Yarn project also gets a `.yarnrc.yml` pinning `nodeLinker:
78
+ node-modules` — Yarn 4 installs Plug'n'Play by default and a server-mode project cannot start under it, since
79
+ `node --import tsx` dies resolving its own entry.
80
+
81
+ **The blank space moved into `@plitzi/sdk-authoring` as a declaration.** It was checked-in JSON inside the
82
+ platform's seeds, which meant anything else that wanted it kept a copy — and a copy of a fixture is a fixture
83
+ that is wrong six months later with nothing to say so. `blankSpaceSpec` is now the source both the platform's
84
+ `POST /spaces` and `plitzi create` author from; `blankSpace()` returns the documents, and `blankSpaceSource()`
85
+ returns the declaration as a file a project can own and edit.
86
+
87
+ A local project therefore gets `src/space.ts` — its own copy of that declaration, complete and self-contained —
88
+ rather than an import. It exports `space`, not `blankSpaceSpec`: whoever receives it is looking at their own site,
89
+ not at Plitzi's blank one.
90
+
91
+ `blankSpaceSource(name)` takes the name the copy should carry, so the scaffold no longer knows which literals the
92
+ declaration happens to contain — a rename that finds nothing to replace throws instead of quietly handing back a
93
+ space still called "New space", and `permanentUrl` is slugged, since it is a DNS label at the platform and what
94
+ every element id and style selector is derived from. The import rewrite reads the block one statement at a time
95
+ rather than by single-line regex (Prettier wraps a long import, and the old one read that as no import at all,
96
+ dropping names the copy uses), and refuses to return a file that still points at anything relative.
97
+
98
+ A browser-rendered project also serves the dev tools' stylesheet. They draw into a shadow root, which cannot see
99
+ the page's styles, so they fetch `/plitzi-sdk-devtools.css` — a path that exists on a server serving the SDK's
100
+ assets and nowhere else, which left the panel unstyled in a Vite app. The generated `vite.config.ts` serves it
101
+ from `node_modules` in development, so it cannot go stale and nothing is copied into the project.
102
+
103
+ **A plugin of the project's own.** `src/plugins/StatCard` is a React component the generated space renders
104
+ through a `custom` element — the one thing about Plitzi a page of built-in elements cannot show, and a project
105
+ with no example of it leaves people assuming the catalogue is the ceiling. A plugin's props ARE the hosting
106
+ element's attributes, so a data source pointed at that element later reaches the component with nothing in
107
+ between; it renders `RootElement`, so the element's id, classes and authored CSS land on what it draws. Server
108
+ mode registers it with `action: 'compile'` and activates it through the deployment's `pluginNames` — registering
109
+ a plugin says it exists, the deployment says which ones a space renders with, and leaving the second half out
110
+ renders "Custom Component … Not Found" with no error anywhere. The blank space in `@plitzi/sdk-authoring` is
111
+ unchanged: `blankSpaceSource({ plugin })` adds the host element only for callers that carry a component to fill
112
+ it, because the platform authors new spaces from the same declaration and hosts nobody's plugins.
113
+
114
+ **`render()`'s third argument takes a component, not a decorated one.** It asked for `ComponentPlugin` — the type
115
+ carrying `type`, `assets`, `origin` and `content`, all of which `App` stamps on itself from the keys of that very
116
+ object. Nobody registering a component of their own could satisfy it without a cast, which is also why
117
+ `<Sdk.Plugin component>` already declared the plain one.
118
+
119
+ **Prettier and ESLint in the generated project**, configured rather than mentioned: type-checked rules scoped to
120
+ the files a type checker can see, Prettier owning layout, and `eslint-config-prettier` last so the two do not
121
+ argue on save. `lint` and `format` are scripts from the first commit, which is the only moment a repository's
122
+ style is cheap to decide.
123
+
124
+ **`render()` now returns `{ unmount }`.** A second `render()` into the same element used to create a second React
125
+ root over the first: two live trees on one node, neither aware of the other. Anything that re-renders on its own
126
+ needs to take the first one down, and hot module replacement is the case that forced it — a generated client
127
+ project swaps the space module and remounts, so a save updates the page without reloading it.