@plitzi/sdk-authoring 0.39.11 → 0.39.12

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.
@@ -76,8 +76,12 @@ The space is not written until these are fixed.
76
76
  | `element-runtime` | a `runtime` the element does not run in | one of the values the message lists |
77
77
  | `element-shape` | an element that is not an object with a `type`, `attributes` and a list of `children` | build elements with their factories — `text(…)`, `container(…)` |
78
78
  | `element-slot-unknown` | a `slots` key the element type does not have — its class would dress nothing | one of the slots `plitzi explain <type>` lists; the element itself takes `class` |
79
+ | `experiment-name` | by chance, a `variants`' `experiment` that a template cannot read as `experiments.x` | letters, digits and `_`, starting with a letter or `_` — or empty, for the element's own name |
80
+ | `experiment-unknown` | a template, a binding or a `when` reading an experiment no `variants` chosen by chance runs | the name it suggests, or a `variants` with that `experiment` |
81
+ | `experiment-weight` | by chance, a `variantItem`'s `weight` that is not a whole number from 0 to 100, or variants that all weigh 0 | `weight: 50`; 0 shows a variant to nobody, and at least one has to show |
79
82
  | `flag-gate` | an element's or a page's `flag` that is not a flag name | `flag: 'newCheckout'`, or `flag: '!newCheckout'` for "only while off" |
80
83
  | `flag-name` | a flag whose name a template cannot read as `flags.x` | letters, digits and `_` |
84
+ | `flag-rollout` | a flag's `rollout` that is not `{ percent, value }` — a whole share from 0 to 100 and the answer it gives | `rollout: { percent: 10, value: true }` |
81
85
  | `flag-rule-shape` | a flag rule that is not `{ when, value }`, or whose `value` is not `true` or `false` | `{ when: { … }, value: true }` |
82
86
  | `flag-shape` | a flag whose `value` is not `true` or `false` | `{ value: false, rules: [] }` |
83
87
  | `flag-undeclared` | a gate on a flag the space does not declare — it reads as off, so the element never (or always) renders | declare it in `flags`, or remove the gate |
@@ -180,6 +184,7 @@ The space is not written until these are fixed.
180
184
  | `template-text-into-value` | a template, which renders text, feeding an attribute that holds a list or an object | `bindTemplate('items', source, '{{ … }}', { returns: 'value' })` |
181
185
  | `template-unknown-name` | a name in a template that is not a source, a variable or a route param | the full source name (`list_rows.item`), `navigation.queryParams.x`, or `source` for the bound value |
182
186
  | `template-unreadable` | a template with an operator, a filter or a function that does not exist, or broken syntax | an operator, a filter or a function the interpreter has — the message names the one it could not read; `matches` never exists |
187
+ | `time-window-bound` | a `timeWindow`'s `startsAt` or `endsAt` that is not an instant with its offset — never read, so no bound | `startsAt: '2026-12-01T09:00:00Z'` (or `+01:00`); empty for no bound |
183
188
  | `transformer-params` | a transformer param that does not exist, or a value outside its options | the params and values it lists |
184
189
  | `trigger-interval` | an `onInterval` that never ticks: not a whole number of milliseconds, or below 250 | `onInterval(5000)` |
185
190
  | `trigger-keys` | an `onKey` shortcut that cannot fire: two keys at once, only modifiers, or a name that is not a key | `onKey('f')`, `onKey('shift+f')`, `onKey('mod+k, escape')` |
@@ -193,6 +198,9 @@ The space is not written until these are fixed.
193
198
  | `unknown-transformer` | a transformer that does not exist | one of the transformers it lists |
194
199
  | `utility-module` | a utility sent to a module — a utility takes none | drop the `on` |
195
200
  | `variant-bound-twice` | two bindings (`variantFrom`, `activeOn`, `activeWhen`) setting the variant of one class on one element — the second always wins | one `variantFrom` whose template answers every case: `{{ wide ? 'roomy' : current ? 'active' : 'idle' }}`; two things that change apart (a size, a lit state) are two classes, each with its own `variantFrom` |
201
+ | `variants-choose-by` | a `variants`' `chooseBy` that is neither `'chance'` nor `'rules'` — it chooses by chance | `chooseBy: 'chance'` or `chooseBy: 'rules'` |
202
+ | `variants-items` | a `variants` holding something beside its `variantItem`s, or too few — two to five by chance, one by rules | `variants({ children: [variantItem([…]), variantItem([…])] })` |
203
+ | `variants-rule` | a `variantItem`'s `when` that is not a rule group | `when: { combinator: 'and', rules: [{ field: 'visitor.device', operator: '=', value: 'mobile' }] }` |
196
204
  | `visibility-as-attribute` | `visibility` bound as an attribute, which no element reads | `visible: { source, template }` |
197
205
  | `visible-expression` | `visible` written as an expression (`"state.plan == 'pro'"`, `"a && !b"`) — it takes a source, read as one, which resolves to nothing | `visible: { source: 'state.plan', template: "{{ state.plan == 'pro' }}" }` — or a source alone, `'state.open'`, `'!state.open'` |
198
206
  | `visitor-roles` | `settings.visitorRoles` written in a shape the runtime does not read | the shape the message gives |
@@ -218,6 +226,8 @@ The space renders, and renders something you probably did not mean. Fix every on
218
226
  | `default-content-beside-children` | a button printing its default "Button" beside its children | `content: ''` |
219
227
  | `dropdown-without-control` | a dropdown opened from a box or an icon — no keyboard opens it | a `button` as what opens it (`title` if it is only an icon) |
220
228
  | `embed-without-title` | an `embed` with no `title` — a frame a screen reader cannot describe | say what it shows in `title` |
229
+ | `experiment-weights-differ` | two `variants` running the same test with different weights — they share it, so one set is ignored | the same weights on both, or a test name of its own for each |
230
+ | `experiment-weights-total` | by chance, `variant`s whose `weight`s do not add up to 100 — each is read as its part of their total | percents adding up to 100: 50/25/20/5, or the proportions the warning gives |
221
231
  | `flag-rule-empty` | a flag rule with no conditions — skipped, never read as "always" | give it a condition, or set the flag's `value` instead |
222
232
  | `flag-unused` | a declared flag nothing gates on and no template reads | gate what it switches (`flag: 'x'`), or remove it once the feature has shipped |
223
233
  | `focus-on-field-box` | a `focus` or `focus-visible` state on a text field's or a select's `input` slot — the box the field is drawn in, which never takes focus, so no ring is ever shown | `'focus-within'` on the same class, or the state on the `field` slot |
@@ -259,12 +269,16 @@ The space renders, and renders something you probably did not mean. Fix every on
259
269
  | `template-or-value` | a template's `or` (or `and`) beside a text or a number — `sort or 'listeners'` — which answers true or false, never the value | a fallback value with `??`: `sort ?? 'listeners'`; a test with `or` between two conditions |
260
270
  | `test-account-role-gone` | a test account holds a visitor role the space does not declare in `settings.visitorRoles` — removed since, or never there: a journey plays it without that role, and one that needed what it gave fails | one of the space’s roles for the account — or the role declared again |
261
271
  | `test-unreadable` | a test of the space — an element check or a flow — that cannot be read as it is written: a page no page of the space answers, an element it no longer has, a relation that is none. A snapshot and a publish wait for it | the test as the message says — or the space back to what the test expects |
272
+ | `time-window-empty` | a `timeWindow` that ends before it starts — it never shows what it holds | `endsAt` after `startsAt` |
262
273
  | `transient-state-without-keep-state` | `transientState` without `keepState` — nothing is kept in the first place | `settings.keepState: true`, or remove `transientState` |
263
274
  | `unknown-element-type` | a type no built-in element has | the built-in it suggests; a plugin's declaration goes in `authorSpace(space, { plugins: [declaration] })` |
264
275
  | `unknown-global-callback` | a global callback no built-in source declares — it runs only if something registers it | the built-in it suggests, or make sure a plugin or module of the space registers it |
265
276
  | `unknown-utility` | a utility that is not one of the built-in ones | one of the built-in utilities |
266
277
  | `unknown-variable` | a `var(--x)` nothing in the space declares — the property it is in is dropped | declare it under `variables`, fix the name, or give it a fallback: `var(--x, …)` |
267
278
  | `unknown-variant` | a variant no class of the element and no style of its type declares — nothing applies | declare it (`styles(name, { variants: { … } })`), or name one that is |
279
+ | `variants-builder-variant` | a `variants`' `builderVariant` that is not the place of one of its variants — the builder shows the first | the place of a variant it has, from 0 |
280
+ | `variants-no-fallback` | by rules, a `variants` whose every variant has a rule: a visitor matching none is shown nothing | end it with a `variantItem` with no `when`, for everybody else |
281
+ | `variants-unreachable` | by rules, a `variantItem` after one with no rule, which takes everybody left — it is never shown | move the variant with no rule last, or give it one |
268
282
 
269
283
  ## Suggested
270
284
 
@@ -58,6 +58,13 @@ declare is an error (`flag-unknown`).
58
58
  Prefer a gate to `visible: 'flags.x'`: a visibility bound to a flag still renders the hidden half and ships it in the
59
59
  HTML. Reach for the source only for what a gate cannot say — a label that changes, a step that branches.
60
60
 
61
+ ## Rolling out gradually
62
+
63
+ `rollout: { percent: 10, value: true }` on a flag turns it on for 10% of the visitors when none of its rules matches;
64
+ the rest get its `value`. Each visitor keeps their place (a cookie), so raising the percent keeps everyone who was in —
65
+ 10, then 50, then 100, then remove the flag. Rules still come first: a rule for staff answers before the rollout. Not
66
+ access control — a visitor's place is theirs to change. A malformed one is `flag-rollout`.
67
+
61
68
  ## Who decides
62
69
 
63
70
  The space's declaration answers first. Above it, in order, each may override a flag — only one the space declares:
@@ -76,3 +83,57 @@ and a self-hosted server keeps the last ones it fetched — so a published site
76
83
 
77
84
  Remove the gate from what stays, delete what it replaced, and remove the flag. A declared flag nothing reads is a
78
85
  warning (`flag-unused`): it is a switch nobody can see the effect of.
86
+
87
+ ## Variants: A/B tests and audiences
88
+
89
+ A flag shows the same side to everyone its rules match; `variants` shows each visitor one of its `variantItem`s, chosen
90
+ **by chance** (an A/B test, the default) or **by rules** (who the visitor is). Only the variant shown is drawn.
91
+
92
+ ```ts
93
+ variants({
94
+ children: [
95
+ variantItem({ weight: 90, children: [heading({ content: 'Build faster' })] }), // A: 90% of the visitors
96
+ variantItem({ weight: 10, children: [heading({ content: 'Ship today' })] }) // B: 10%
97
+ ]
98
+ });
99
+ ```
100
+
101
+ **By chance**, it holds two to five variants — A first, then B… A `weight` is the percent of the visitors it
102
+ is shown to, and the variants' add up to 100 — 50/25/20/5, any split (`experiment-weights-total` warns otherwise; 50
103
+ each by default). The server draws the visitor's variant and keeps it in a cookie, so a reload or a later visit shows the same,
104
+ and a visitor keeps theirs when the shares change; 0 shows a variant to nobody, one left with a share ends the test. Its
105
+ `experiment` names the test — left empty, the element's id does (`pricing-test` runs `pricing_test`) — and two with the
106
+ same name show a visitor the same variant (`experiment-weights-differ` warns when their shares disagree). Count a
107
+ conversion with the `reachGoal('signup')` step: Plitzi's analytics shows each variant's visitors, conversions and rate
108
+ against A's. `{{ experiments.<name> }}` is `'a'`, `'b'`… for a flow. To see a variant you were not drawn, where debugging
109
+ is authorized: the dev tools' **Experiments** tab, or `?ab=heroTest:b` in the address.
110
+
111
+ **By rules** — `chooseBy: 'rules'` — it shows the first variant whose `when` the visitor matches: a rule group over what a
112
+ flag's rules see, `queryParams.utm_source` included, and the visitor: `visitor.returning`, `visitor.language` (`es`),
113
+ `visitor.device` (`mobile`, `tablet`, `desktop`). End it with a variant with no `when`, for everybody else
114
+ (`variants-no-fallback` warns otherwise):
115
+
116
+ ```ts
117
+ variants({
118
+ chooseBy: 'rules',
119
+ children: [
120
+ variantItem({
121
+ when: { combinator: 'and', rules: [{ field: 'visitor.device', operator: '=', value: 'mobile' }] },
122
+ children: [text({ content: 'Get the app' })]
123
+ }),
124
+ variantItem([text({ content: 'Welcome' })])
125
+ ]
126
+ });
127
+ ```
128
+
129
+ A variant keeps its `weight` and its `when` whichever way it chooses, so switching loses neither. In the builder its
130
+ settings list the variants with their share or their rule; the canvas shows the one picked there (`builderVariant`, its
131
+ place from 0) while editing, and the preview the visitor chosen in the State Manager's **Visitor** tab.
132
+
133
+ ## Showing something for a while
134
+
135
+ `timeWindow({ startsAt: '2026-12-01T09:00:00Z', endsAt: '2026-12-08T09:00:00Z', children })` shows what it holds only
136
+ between the two instants — ISO 8601 with the offset, never a local time (`time-window-bound`); either empty is no
137
+ bound. An open page shows or hides it when the window opens or closes. In the builder it always shows while editing;
138
+ the preview reads it at the date chosen in the Visitor tab.
139
+
@@ -15,7 +15,7 @@ Read one only when the task names its subject.
15
15
  | [data-and-visibility.md](data-and-visibility.md) | Bindings, providers, offline data, loading/empty/error states, live data, caching, showing and hiding, kept state |
16
16
  | [kept-state.md](kept-state.md) | State that outlives a reload: `keepState`, transient and painted keys |
17
17
  | [auth.md](auth.md) | Signing people in: providers, `authLogin`, `auth.*`, visitor roles |
18
- | [feature-flags.md](feature-flags.md) | Switching a part of the space on or off — a beta, a rollout, the old version kept until the new one ships |
18
+ | [feature-flags.md](feature-flags.md) | Switching a part of the space on or off — a beta, a rollout, the old version kept until the new one ships; an A/B test; an audience; a time window |
19
19
  | [lists.md](lists.md) | Rendering rows, filtering and sorting them, a detail page for one record, carousels |
20
20
  | [typed-sources.md](typed-sources.md) | Data typed by a sample of it: `source()`, typed rows, `twig` for templates |
21
21
  | [validation.md](validation.md) | How `authorSpace` checks, the loop that wastes no attempts, and what it cannot see |
@@ -39,7 +39,7 @@ A text template feeding `items` is refused: the list would receive the array wri
39
39
  ## Naming sources inside a template
40
40
 
41
41
  Always the full name — the element's kind, an underscore, its id: `apiContainer_stats`, `list_rows`,
42
- `modalContainer_credits`. The globals (`state`, `auth`, `navigation`, `variables`, `host`, `theme`, `flags`, `computed`) are
42
+ `modalContainer_credits`. The globals (`state`, `auth`, `navigation`, `variables`, `host`, `theme`, `flags`, `experiments`, `computed`) are
43
43
  named as themselves — `{{ flags.newCheckout }}` is `true` or `false`, see [feature flags](feature-flags.md). In a flow, an earlier step is read by the name given with `named('quote', …)`: `{{ quote.output.total }}`.
44
44
 
45
45
  An id with a hyphen is one name inside a template — `{{ apiContainer_tn-data.data.total }}` reads that provider. So