@plitzi/sdk-authoring 0.36.1 → 0.37.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plitzi/sdk-authoring",
3
- "version": "0.36.1",
3
+ "version": "0.37.0",
4
4
  "license": "AGPL-3.0",
5
5
  "files": [
6
6
  "dist/index.js",
@@ -31,6 +31,7 @@
31
31
  "test": "vitest run",
32
32
  "test:watch": "vitest",
33
33
  "build:dev": "vite build --mode development",
34
+ "generate:attribute-names": "node scripts/generate-attribute-names.ts",
34
35
  "build:prod": "vite build"
35
36
  },
36
37
  "peerDependencies": {
@@ -44,16 +45,16 @@
44
45
  "devDependencies": {
45
46
  "@microsoft/api-extractor": "^7.59.1",
46
47
  "@plitzi/plitzi-ui": "^1.6.21",
47
- "@plitzi/sdk-elements": "0.36.1",
48
- "@plitzi/sdk-interactions": "0.36.1",
49
- "@plitzi/sdk-schema": "0.36.1",
50
- "@plitzi/sdk-shared": "0.36.1",
51
- "@plitzi/sdk-style": "0.36.1",
48
+ "@plitzi/sdk-elements": "0.37.0",
49
+ "@plitzi/sdk-interactions": "0.37.0",
50
+ "@plitzi/sdk-schema": "0.37.0",
51
+ "@plitzi/sdk-shared": "0.37.0",
52
+ "@plitzi/sdk-style": "0.37.0",
52
53
  "@types/react": "^19.3.0",
53
54
  "eslint": "^9.39.5",
54
55
  "typescript": "^6.0.3",
55
56
  "vite": "^8.3.0",
56
57
  "vite-plugin-dts": "^5.1.0",
57
- "vitest": "^5.0.0"
58
+ "vitest": "^5.0.1"
58
59
  }
59
60
  }
@@ -99,7 +99,11 @@ property outside the vocabulary is an error naming the correct key (`paddingTop`
99
99
  - **Fonts are declared, not assumed.** A `font-family` loads only if the space lists the face in `fonts`
100
100
  (`{ source: 'google', family: 'Fraunces', fallback: 'Georgia, serif', weights: [400, 600], styles: ['normal'] }`);
101
101
  the page server writes exactly that list into the document, and anything else renders in the fallback.
102
- - Per element TYPE defaults go in `elements: { heading: { base: …, variants: { … } } }`.
102
+ - Per element TYPE defaults go in `elements: { heading: { base: …, states: { … }, variants: { … }, slots: { … } } }`
103
+ — `slots` dresses the type's other selectors (a modal's `rootContainer`) for every element of the type.
104
+ - **`:hover` is part of the selector, not a rule in `customCss`.** `styles('card', { css: { … }, states: { hover: { … } },
105
+ variants: { active: { … } } })`, and `states` beside an element's own `css`. Written in `customCss` it renders and
106
+ then cannot be read back or edited per breakpoint.
103
107
 
104
108
  **Share a rule as a class, never as a spread.** Writing a rule set once in a `const` and spreading it into each
105
109
  element's `css` shares the source and duplicates the document — one selector per element, so re-theming the card
@@ -115,8 +119,13 @@ Accepted anywhere a class name is — `class`, a `slot`, a page's `class` — an
115
119
  names it. One name declared twice with rules that disagree is refused. `classes` at the top of the space is the
116
120
  same mechanism for what describes the space rather than one section of it.
117
121
 
118
- An element has exactly ONE base selector, so a variant is its own class over a shared plain object
119
- (`styles('button-primary', { ...base, … })`), never two classes layered on top of each other.
122
+ An element has exactly ONE base selector, so a look that never changes is its own class over a shared plain object
123
+ (`styles('button-primary', { ...base, … })`), never two classes layered on top of each other. A class's `variants`
124
+ are for what the page switches while it runs — a binding with the `styleVariant` transformer picks one.
125
+
126
+ **Shells go in `layouts`.** A header or a sidebar every page shows is a layout the pages name —
127
+ `layout: { id: 'app-shell', slot: 'main' }`, the slot being the element in the shell where the body goes — never a
128
+ copy on each page. `visible: false` starts an element hidden for a flow to reveal.
120
129
 
121
130
  ## Data
122
131
 
@@ -137,6 +146,13 @@ is the quietest failure a space can carry.
137
146
  Server-resolved sections are an `apiContainer` with `runtime: 'server'` naming a connector or an action, and a
138
147
  space that has any needs `rsc: { enabled: true }`.
139
148
 
149
+ **A provider has no box unless you give it a tag.** An `apiContainer` renders no element of its own while its
150
+ `subType` is empty — the default, the builder's "Container Tag: None" — so its children sit directly in the parent's
151
+ layout. That is usually what you want (the provider stays invisible to the layout), and it means a `class` or `css`
152
+ on it styles nothing: the `gap` you wrote between its sections is simply not there. Put the layout on the parent, or
153
+ give the provider a tag (`attributes: { subType: 'div' }`) when it should be the box. `validateSpace` — and so
154
+ `authorSpace` and the MCP — warns with `STYLE_WITHOUT_TAG`.
155
+
140
156
  **Never ask the data for a field's opposite.** Both sides of one question are `visible: 'x'` and `visible: '!x'` —
141
157
  not an `x` and a `notX` beside it in the server's answer. The `!` is the `not` transformer, which reads a boolean
142
158
  that travelled as text (`"false"`, `"0"`) and treats an empty array as false; an empty object is true. Only for a
@@ -247,6 +263,14 @@ Everything a space is held to still applies, and two more things apply because a
247
263
  `validateTemplate(template)` runs the same gate over a manifest you did not author here — one exported by the
248
264
  builder, or edited by hand — before you publish it.
249
265
 
266
+ ## From an exported JSON
267
+
268
+ Never rewrite an exported space by hand. `specFromSpace({ schema, style })` reads it into the spec that authors it,
269
+ repairing what an older builder left behind and listing each repair in `corrections`; `specToSource(spec,
270
+ { exportName })` writes that spec as factory calls; `compareSpaces(original, authorSpace(spec))` must list nothing but
271
+ what `corrections` explains. The builder's **Export** (and `POST /utils/transform-to-authoring`) does all three. Edit
272
+ the code it writes from then on, not the JSON.
273
+
250
274
  ## Rules
251
275
 
252
276
  1. **Never hand-write `flat`, element ids, `styleSelectors`, `beforeNode`/`afterNode`/`flowId`.** They are derived.