@vielzeug/codex 26.11.14 → 26.11.16

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/data/catalog.json CHANGED
@@ -35,7 +35,7 @@
35
35
  "rune"
36
36
  ],
37
37
  "slug": "archive",
38
- "version": "26.11.13"
38
+ "version": "26.11.15"
39
39
  },
40
40
  {
41
41
  "availableDocPages": [
@@ -108,7 +108,7 @@
108
108
  "coins"
109
109
  ],
110
110
  "slug": "arsenal",
111
- "version": "26.11.13"
111
+ "version": "26.11.15"
112
112
  },
113
113
  {
114
114
  "availableDocPages": [
@@ -160,7 +160,7 @@
160
160
  "refine"
161
161
  ],
162
162
  "slug": "assay",
163
- "version": "26.11.13"
163
+ "version": "26.11.15"
164
164
  },
165
165
  {
166
166
  "availableDocPages": [
@@ -199,7 +199,7 @@
199
199
  "vault"
200
200
  ],
201
201
  "slug": "beacon",
202
- "version": "26.11.13"
202
+ "version": "26.11.15"
203
203
  },
204
204
  {
205
205
  "availableDocPages": [
@@ -241,7 +241,7 @@
241
241
  "ward"
242
242
  ],
243
243
  "slug": "clockwork",
244
- "version": "26.11.13"
244
+ "version": "26.11.15"
245
245
  },
246
246
  {
247
247
  "availableDocPages": [
@@ -273,7 +273,7 @@
273
273
  "refine"
274
274
  ],
275
275
  "slug": "codex",
276
- "version": "26.11.13"
276
+ "version": "26.11.15"
277
277
  },
278
278
  {
279
279
  "availableDocPages": [
@@ -343,7 +343,7 @@
343
343
  "spell"
344
344
  ],
345
345
  "slug": "coins",
346
- "version": "26.11.13"
346
+ "version": "26.11.15"
347
347
  },
348
348
  {
349
349
  "availableDocPages": [
@@ -384,7 +384,7 @@
384
384
  "rune"
385
385
  ],
386
386
  "slug": "conduit",
387
- "version": "26.11.13"
387
+ "version": "26.11.15"
388
388
  },
389
389
  {
390
390
  "availableDocPages": [
@@ -426,7 +426,7 @@
426
426
  "postmaster"
427
427
  ],
428
428
  "slug": "courier",
429
- "version": "26.11.13"
429
+ "version": "26.11.15"
430
430
  },
431
431
  {
432
432
  "availableDocPages": [
@@ -472,7 +472,7 @@
472
472
  "refine"
473
473
  ],
474
474
  "slug": "dnd",
475
- "version": "26.11.13"
475
+ "version": "26.11.15"
476
476
  },
477
477
  {
478
478
  "availableDocPages": [
@@ -514,7 +514,7 @@
514
514
  "herald"
515
515
  ],
516
516
  "slug": "familiar",
517
- "version": "26.11.13"
517
+ "version": "26.11.15"
518
518
  },
519
519
  {
520
520
  "availableDocPages": [
@@ -581,7 +581,7 @@
581
581
  "courier"
582
582
  ],
583
583
  "slug": "flux",
584
- "version": "26.11.13"
584
+ "version": "26.11.15"
585
585
  },
586
586
  {
587
587
  "availableDocPages": [
@@ -621,7 +621,7 @@
621
621
  "ore"
622
622
  ],
623
623
  "slug": "focus",
624
- "version": "26.11.13"
624
+ "version": "26.11.15"
625
625
  },
626
626
  {
627
627
  "availableDocPages": [
@@ -662,7 +662,7 @@
662
662
  "assay"
663
663
  ],
664
664
  "slug": "forge",
665
- "version": "26.11.13"
665
+ "version": "26.11.15"
666
666
  },
667
667
  {
668
668
  "availableDocPages": [
@@ -700,7 +700,7 @@
700
700
  "keymap"
701
701
  ],
702
702
  "slug": "gesture",
703
- "version": "26.11.13"
703
+ "version": "26.11.15"
704
704
  },
705
705
  {
706
706
  "availableDocPages": [
@@ -744,7 +744,7 @@
744
744
  "familiar"
745
745
  ],
746
746
  "slug": "herald",
747
- "version": "26.11.13"
747
+ "version": "26.11.15"
748
748
  },
749
749
  {
750
750
  "availableDocPages": [
@@ -787,7 +787,7 @@
787
787
  "tempo"
788
788
  ],
789
789
  "slug": "illusionist",
790
- "version": "26.11.13"
790
+ "version": "26.11.15"
791
791
  },
792
792
  {
793
793
  "availableDocPages": [
@@ -832,7 +832,7 @@
832
832
  "ore"
833
833
  ],
834
834
  "slug": "keymap",
835
- "version": "26.11.13"
835
+ "version": "26.11.15"
836
836
  },
837
837
  {
838
838
  "availableDocPages": [
@@ -879,7 +879,7 @@
879
879
  "vault"
880
880
  ],
881
881
  "slug": "ledger",
882
- "version": "26.11.13"
882
+ "version": "26.11.15"
883
883
  },
884
884
  {
885
885
  "availableDocPages": [
@@ -924,7 +924,7 @@
924
924
  "courier"
925
925
  ],
926
926
  "slug": "lingua",
927
- "version": "26.11.13"
927
+ "version": "26.11.15"
928
928
  },
929
929
  {
930
930
  "availableDocPages": [
@@ -962,7 +962,7 @@
962
962
  "herald"
963
963
  ],
964
964
  "slug": "mesh",
965
- "version": "26.11.13"
965
+ "version": "26.11.15"
966
966
  },
967
967
  {
968
968
  "availableDocPages": [
@@ -999,7 +999,7 @@
999
999
  "ore"
1000
1000
  ],
1001
1001
  "slug": "necromancer",
1002
- "version": "26.11.13"
1002
+ "version": "26.11.15"
1003
1003
  },
1004
1004
  {
1005
1005
  "availableDocPages": [
@@ -1039,7 +1039,7 @@
1039
1039
  "prism"
1040
1040
  ],
1041
1041
  "slug": "orbit",
1042
- "version": "26.11.13"
1042
+ "version": "26.11.15"
1043
1043
  },
1044
1044
  {
1045
1045
  "availableDocPages": [
@@ -1104,7 +1104,7 @@
1104
1104
  "orbit"
1105
1105
  ],
1106
1106
  "slug": "ore",
1107
- "version": "26.11.13"
1107
+ "version": "26.11.15"
1108
1108
  },
1109
1109
  {
1110
1110
  "availableDocPages": [
@@ -1147,7 +1147,7 @@
1147
1147
  "vault"
1148
1148
  ],
1149
1149
  "slug": "patchwork",
1150
- "version": "26.11.13"
1150
+ "version": "26.11.15"
1151
1151
  },
1152
1152
  {
1153
1153
  "availableDocPages": [
@@ -1191,7 +1191,7 @@
1191
1191
  "ripple"
1192
1192
  ],
1193
1193
  "slug": "postmaster",
1194
- "version": "26.11.13"
1194
+ "version": "26.11.15"
1195
1195
  },
1196
1196
  {
1197
1197
  "availableDocPages": [
@@ -1232,7 +1232,7 @@
1232
1232
  "orbit"
1233
1233
  ],
1234
1234
  "slug": "prism",
1235
- "version": "26.11.13"
1235
+ "version": "26.11.15"
1236
1236
  },
1237
1237
  {
1238
1238
  "availableDocPages": [
@@ -1296,7 +1296,7 @@
1296
1296
  "clockwork"
1297
1297
  ],
1298
1298
  "slug": "pulse",
1299
- "version": "26.11.13"
1299
+ "version": "26.11.15"
1300
1300
  },
1301
1301
  {
1302
1302
  "availableDocPages": [
@@ -1426,7 +1426,7 @@
1426
1426
  "keymap"
1427
1427
  ],
1428
1428
  "slug": "refine",
1429
- "version": "26.11.13"
1429
+ "version": "26.11.15"
1430
1430
  },
1431
1431
  {
1432
1432
  "availableDocPages": [
@@ -1471,7 +1471,7 @@
1471
1471
  "ledger"
1472
1472
  ],
1473
1473
  "slug": "ripple",
1474
- "version": "26.11.13"
1474
+ "version": "26.11.15"
1475
1475
  },
1476
1476
  {
1477
1477
  "availableDocPages": [
@@ -1525,7 +1525,7 @@
1525
1525
  "familiar"
1526
1526
  ],
1527
1527
  "slug": "rune",
1528
- "version": "26.11.13"
1528
+ "version": "26.11.15"
1529
1529
  },
1530
1530
  {
1531
1531
  "availableDocPages": [
@@ -1566,7 +1566,7 @@
1566
1566
  "refine"
1567
1567
  ],
1568
1568
  "slug": "sandbox",
1569
- "version": "26.11.13"
1569
+ "version": "26.11.15"
1570
1570
  },
1571
1571
  {
1572
1572
  "availableDocPages": [
@@ -1617,7 +1617,7 @@
1617
1617
  "ripple"
1618
1618
  ],
1619
1619
  "slug": "scout",
1620
- "version": "26.11.13"
1620
+ "version": "26.11.15"
1621
1621
  },
1622
1622
  {
1623
1623
  "availableDocPages": [
@@ -1659,7 +1659,7 @@
1659
1659
  "archive"
1660
1660
  ],
1661
1661
  "slug": "scribe",
1662
- "version": "26.11.13"
1662
+ "version": "26.11.15"
1663
1663
  },
1664
1664
  {
1665
1665
  "availableDocPages": [
@@ -1712,7 +1712,7 @@
1712
1712
  "refine"
1713
1713
  ],
1714
1714
  "slug": "scroll",
1715
- "version": "26.11.13"
1715
+ "version": "26.11.15"
1716
1716
  },
1717
1717
  {
1718
1718
  "availableDocPages": [
@@ -1759,7 +1759,7 @@
1759
1759
  "gesture"
1760
1760
  ],
1761
1761
  "slug": "sentinel",
1762
- "version": "26.11.13"
1762
+ "version": "26.11.15"
1763
1763
  },
1764
1764
  {
1765
1765
  "availableDocPages": [
@@ -1799,7 +1799,7 @@
1799
1799
  "refine"
1800
1800
  ],
1801
1801
  "slug": "sigil",
1802
- "version": "26.11.13"
1802
+ "version": "26.11.15"
1803
1803
  },
1804
1804
  {
1805
1805
  "availableDocPages": [
@@ -1844,7 +1844,7 @@
1844
1844
  "wayfinder"
1845
1845
  ],
1846
1846
  "slug": "sourcerer",
1847
- "version": "26.11.13"
1847
+ "version": "26.11.15"
1848
1848
  },
1849
1849
  {
1850
1850
  "availableDocPages": [
@@ -1904,7 +1904,7 @@
1904
1904
  "vault"
1905
1905
  ],
1906
1906
  "slug": "spell",
1907
- "version": "26.11.13"
1907
+ "version": "26.11.15"
1908
1908
  },
1909
1909
  {
1910
1910
  "availableDocPages": [
@@ -1947,7 +1947,7 @@
1947
1947
  "archive"
1948
1948
  ],
1949
1949
  "slug": "tabula",
1950
- "version": "26.11.13"
1950
+ "version": "26.11.15"
1951
1951
  },
1952
1952
  {
1953
1953
  "availableDocPages": [
@@ -1988,7 +1988,7 @@
1988
1988
  "ripple"
1989
1989
  ],
1990
1990
  "slug": "tandem",
1991
- "version": "26.11.13"
1991
+ "version": "26.11.15"
1992
1992
  },
1993
1993
  {
1994
1994
  "availableDocPages": [
@@ -2036,7 +2036,7 @@
2036
2036
  "herald"
2037
2037
  ],
2038
2038
  "slug": "tavern",
2039
- "version": "26.11.13"
2039
+ "version": "26.11.15"
2040
2040
  },
2041
2041
  {
2042
2042
  "availableDocPages": [
@@ -2097,7 +2097,7 @@
2097
2097
  "vault"
2098
2098
  ],
2099
2099
  "slug": "tempo",
2100
- "version": "26.11.13"
2100
+ "version": "26.11.15"
2101
2101
  },
2102
2102
  {
2103
2103
  "availableDocPages": [
@@ -2147,7 +2147,7 @@
2147
2147
  "ripple"
2148
2148
  ],
2149
2149
  "slug": "vault",
2150
- "version": "26.11.13"
2150
+ "version": "26.11.15"
2151
2151
  },
2152
2152
  {
2153
2153
  "availableDocPages": [
@@ -2193,7 +2193,7 @@
2193
2193
  "refine"
2194
2194
  ],
2195
2195
  "slug": "ward",
2196
- "version": "26.11.13"
2196
+ "version": "26.11.15"
2197
2197
  },
2198
2198
  {
2199
2199
  "availableDocPages": [
@@ -2250,8 +2250,8 @@
2250
2250
  "herald"
2251
2251
  ],
2252
2252
  "slug": "wayfinder",
2253
- "version": "26.11.13"
2253
+ "version": "26.11.15"
2254
2254
  }
2255
2255
  ],
2256
- "version": "26.11.13"
2256
+ "version": "26.11.15"
2257
2257
  }
@@ -1,6 +1,6 @@
1
1
  # Vielzeug: Full Documentation
2
2
 
3
- > Complete documentation for 46 packages. Version: 26.11.13
3
+ > Complete documentation for 46 packages. Version: 26.11.15
4
4
 
5
5
  ---
6
6
 
@@ -313,8 +313,8 @@ Magic links expire after 15 minutes and work once. The durable per-email budget
313
313
  The issuer-global admission budget is durable D1 state in `auth_sign_in_budget`:
314
314
  20 requests per 60-second window before account creation or email delivery.
315
315
  This supplements, rather than replaces, the durable per-email budget. No external
316
- rate-limiter binding is required for sign-in admission; the budgets do not cover
317
- `POST /auth/verify` or `GET /auth/session`, which deployments rate-limit at the
316
+ rate-limiter binding is required for either sign-in admission route; the budgets do not cover
317
+ `POST /auth/verify`, the device approval and claim routes, or `GET /auth/session`, which deployments rate-limit at the
318
318
  edge. Edge rules should block rather than challenge `GET /auth/session`: clients
319
319
  check it with a `fetch`, which cannot solve a challenge interstitial. The verify
320
320
  GET is a browser navigation from the email link, so a challenge is solvable there.
@@ -323,6 +323,20 @@ Request emails are trimmed and lowercased before validation. `SENDER_ADDRESS`
323
323
  must already be canonical; `OPERATOR_EMAILS` entries are trimmed and lowercased
324
324
  before validation.
325
325
 
326
+ For isolated browser storage, device sign-in binds approval to a secret held by
327
+ the initiating app. Generate 32 random bytes, encode them as an unpadded base64url
328
+ proof, and send the lowercase SHA-256 hex of its UTF-8 representation as
329
+ `challenge`. The email approval page shows the first eight uppercase hex digits;
330
+ the app must show the same code and ask the user to compare them. Approval is
331
+ an explicit POST and does not sign in the confirming browser. The app claims
332
+ with its proof; a pending claim returns 202 and an approved one returns 204 with
333
+ the normal session cookie. Claim returns 409 without consuming the proof if the
334
+ request already carries a valid session, so it cannot replace that account.
335
+ Both requests require the marker and an allowed
336
+ origin. The proof is a credential: do not log it; retain it only until claim,
337
+ cancellation or expiration. Sign-out-all and account deletion revoke pending
338
+ approvals. Existing browser sign-in is unchanged.
339
+
326
340
  Sign-in requests create pending account rows with `lastSignInAt: null`. Successful
327
341
  redemption atomically claims the one-use link and stamps the account's sign-in
328
342
  time. The sweep deletes expired links and closed per-user send windows, then
@@ -415,6 +429,10 @@ Every route below is mounted under `/api/v1`. Mutation guards require an exact a
415
429
  | `POST /auth/sign-out-all` | Requires marker, exact origin, session and captured `ACCOUNT_HEADER`; atomically increments `session_version`, deletes outstanding links, preserves account and catalog data; 200 `{ ok: true }` with an expired cookie only on durable success |
416
430
  | `GET /auth/jwks.json` | Active and configured retired public verification keys |
417
431
  | `POST /auth/sign-in` | `{ email }` (trimmed and lowercased); 202 `{ ok: true }` |
432
+ | `POST /auth/device/sign-in` | `{ email, challenge }`; 64 lowercase SHA-256 hex digits; shared admission and email budgets; 202 `{ ok: true }` |
433
+ | `GET /auth/device/approve?token=…` | Non-destructive confirmation page displaying the matching code; no cookie; expired/invalid signatures return 410 recovery HTML |
434
+ | `POST /auth/device/approve` | `{ token }`; marker and allowed or public origin; atomically authorizes the proof; 204 without a cookie |
435
+ | `POST /auth/device/claim` | `{ token: proof }`; marker and allowed origin; 202 `{ ok: false }` if not claimable, 204 with session cookie when claimed; 409 if the request has a valid session |
418
436
  | `GET /auth/verify?token=…` | Safe no-store click-confirmation HTML; with valid issuer configuration, invalid queries return 400 recovery HTML; no token consumption or session change |
419
437
  | `POST /auth/verify` | JSON `{ token }`, marker and exact allowed origin or `PUBLIC_ORIGIN`; consume once; 204 with session cookie |
420
438
  | `GET /auth/account` | `{ id, email, createdAt, lastSignInAt }`; no tokens or budget data |
@@ -845,6 +863,9 @@ type AuthEvent =
845
863
  readonly requestId: string;
846
864
  readonly route:
847
865
  | '/auth/account'
866
+ | '/auth/device/approve'
867
+ | '/auth/device/claim'
868
+ | '/auth/device/sign-in'
848
869
  | '/auth/health'
849
870
  | '/auth/jwks.json'
850
871
  | '/auth/session'
@@ -1089,13 +1110,14 @@ The issuer first admits sign-in requests through its singleton durable
1089
1110
  `auth_sign_in_budget` table: 20 requests per 60 seconds before creating accounts
1090
1111
  or delivering email. No rate-limiter binding is required. It then
1091
1112
  permits three sign-in emails per email in an hourly durable window.
1092
- Those durable budgets guard `POST /auth/sign-in` only. `POST /auth/verify` and
1113
+ Those durable budgets guard `POST /auth/sign-in` and `POST /auth/device/sign-in`.
1114
+ `POST /auth/verify`, the device approval and claim routes, and
1093
1115
  `GET /auth/session` stay public: tokens are 256-bit, single-use and expire in
1094
1116
  15 minutes, so guessing is not the risk — but every request still costs the
1095
1117
  issuer: the verify GET renders the confirmation page, the verify POST performs a
1096
1118
  D1 token write, and the session check performs an RS256 verification plus an
1097
1119
  account read for a well-formed signed token. Put per-client-IP Cloudflare
1098
- rate-limit rules (or an equivalent edge control) in front of both routes in
1120
+ rate-limit rules (or an equivalent edge control) in front of those routes in
1099
1121
  production. Prefer a block action: applications check `GET /auth/session` with
1100
1122
  a `fetch`, and a fetch cannot solve a challenge interstitial, so challenging
1101
1123
  that route breaks legitimate sign-in. The verify GET is a browser navigation
@@ -1133,6 +1155,28 @@ announces pending, success and recovery states. Without JavaScript it links to
1133
1155
  `${PUBLIC_ORIGIN}/account` as “Request a new sign-in link” and does not pretend
1134
1156
  to complete sign-in.
1135
1157
 
1158
+ ### Sign in an isolated installed app
1159
+
1160
+ When the app and email browser do not share cookies, generate a random 32-byte
1161
+ base64url proof in the app and compute the SHA-256 hex digest of the proof's
1162
+ UTF-8 text. Send `{ email, challenge }` to `POST /auth/device/sign-in` with the
1163
+ request marker. Show the first eight uppercase characters of the digest in the
1164
+ app: the approval page shows the same code, and users should approve only when
1165
+ they match. The link's GET is non-destructive; its confirmation POST authorizes
1166
+ the app but does not sign in the browser.
1167
+
1168
+ The app sends `{ token: proof }` to `POST /auth/device/claim` with credentials,
1169
+ the request marker and an allowed origin. `202 { ok: false }` means no claimable
1170
+ approval; `204` sets the normal cookie in the app. Poll only while needed and
1171
+ while the app is visible, stop after 15 minutes, and serialize a claim with
1172
+ account changes so a late cookie cannot overwrite another choice. Clear the
1173
+ proof on cancellation or completion. Do not log the proof or approval URL.
1174
+ An existing valid session returns 409 without consuming the proof; recheck the
1175
+ session rather than replacing that account.
1176
+ Pending requests share the usual email budgets and are revoked by account
1177
+ deletion or sign-out-all. Add edge rate limits for device approval and claim
1178
+ before enabling the feature; block rather than challenge the programmatic claim.
1179
+
1136
1180
  Archive only serves the confirmation endpoint. Your application must serve its
1137
1181
  sign-in entry at the fixed `${PUBLIC_ORIGIN}/account` recovery destination and
1138
1182
  the success page at `${PUBLIC_ORIGIN}/signed-in`. These are reference issuer
@@ -1261,6 +1305,10 @@ GET /api/v1/me/reports (cursor, limit)
1261
1305
  GET /api/v1/auth/account
1262
1306
  GET /api/v1/auth/jwks.json
1263
1307
  POST /api/v1/auth/sign-in (email)
1308
+ POST /api/v1/auth/device/sign-in (email and challenge)
1309
+ GET /api/v1/auth/device/approve?token=… (confirmation only)
1310
+ POST /api/v1/auth/device/approve (authorizes device)
1311
+ POST /api/v1/auth/device/claim (proof, then session cookie)
1264
1312
  DELETE /api/v1/auth/account (coordinated full erasure)
1265
1313
  DELETE /api/v1/me/account (issuer erasure seam; revokes subject)
1266
1314
  GET /api/v1/auth/verify?token=… (confirmation only)
@@ -14128,6 +14176,8 @@ translator.translate('save');
14128
14176
  | ------------------ | -------------------------------------------------------------------- | ---------------------- |
14129
14177
  | `translate` | `(textKey, options?)` or `(pluralKey, { count, ordinal?, values? })` | Rendered string |
14130
14178
  | `translateUnkeyed` | `(key: string, options?)` | Rendered string |
14179
+ | `parts` | `(textKey, { values? })` or `(pluralKey, { count, ordinal?, values? })` | Render-order `Segment[]` |
14180
+ | `partsUnkeyed` | `(key: string, options?)` | Render-order `Segment[]` |
14131
14181
  | `locale` | `Locale` | Resolved active locale |
14132
14182
 
14133
14183
  ---
@@ -14168,6 +14218,8 @@ i18n.translate('title');
14168
14218
  | ------------------ | ------------------------------------- | -------------------------------------------------------------- |
14169
14219
  | `translate` | Translator method | Rendered string |
14170
14220
  | `translateUnkeyed` | Translator method | Rendered string for a runtime key outside the typed key set |
14221
+ | `parts` | Translator method | Render-order `Segment[]` for the committed locale |
14222
+ | `partsUnkeyed` | Translator method | Render-order `Segment[]` for a runtime key |
14171
14223
  | `load` | `({ locale? })` | `Promise` after the locale and configured fallbacks load |
14172
14224
  | `setLocale` | `(locale)` | `Promise` after an atomic loaded-locale commit |
14173
14225
  | `isLoaded` | `({ locale? })` | `boolean` |
@@ -14180,6 +14232,33 @@ i18n.translate('title');
14180
14232
  | `disposalSignal` | `AbortSignal` | Aborts on disposal |
14181
14233
  | `[Symbol.dispose]` | `()` | Delegates to `dispose()` |
14182
14234
 
14235
+ **Memoization rule:** `translate` and `parts` have a deliberately stable function identity across `setLocale()` — they read the committed engine at call time, while `getSnapshot()` returns the locale string whose identity changes exactly when the locale does. Memoize derived translations on the **locale**, never on the function's identity (`useMemo(..., [i18n.translate])` keeps the previous language).
14236
+
14237
+ ---
14238
+
14239
+ ## Rich content (`parts`)
14240
+
14241
+ `parts()` resolves a message exactly like `translate()` — same plural selection, locale fallback, and `missing` strategy — but returns the message as render-order segments, so framework nodes can enter a sentence without ever being stringified.
14242
+
14243
+ ```ts
14244
+ const segments = i18n.parts('link', { values: { label: Sync } });
14245
+ // [ { type: 'text', value: 'Go to ' }, { type: 'value', name: 'label', value: }, { type: 'text', value: ' now.' } ]
14246
+ ```
14247
+
14248
+ | Contract | Behavior |
14249
+ | ------------ | ------------------------------------------------------------------------------------------------- |
14250
+ | Order | Segments are in render order; a value used twice produces two value segments; unreferenced values are ignored |
14251
+ | Text | Text segments are never empty — adjacent placeholders yield adjacent value segments |
14252
+ | Values | Passed through untouched with identity preserved; never `String()`-ified, escaped, or merged with neighbors |
14253
+ | Missing value | Becomes a **text** segment holding the `missing` strategy's output (`null`/`undefined` count as missing; `''` is a real value) |
14254
+ | Missing key | One text segment holding the strategy's output; `'throw'` still throws |
14255
+ | Plural | `parts(key, { count, ordinal?, values? })`; `count` is interpolated into the selected form and can be overridden by an explicit `count` in `values` |
14256
+ | Equivalence | Joining segments with `String()` reproduces `translate()` exactly, so `parts` is safe as your single resolution path |
14257
+
14258
+ The interpolation contract shared by `translate()` and `parts()`: string values are inserted verbatim (no HTML or entity escaping), non-string values are `String(value)`-ified, and nullish values follow the `missing` strategy. Rich UIs should render `parts` segments instead of smuggling placeholders through a translated string: because values never enter the concatenated string, user data cannot reach an HTML sink through it.
14259
+
14260
+ `V` defaults to `string`; pass your node type to keep rendering type-safe: `i18n.parts('link', { values: { label: } })`.
14261
+
14183
14262
  ---
14184
14263
 
14185
14264
  ## Reactive bridge (`@vielzeug/lingua/ripple`)
@@ -14190,7 +14269,7 @@ i18n.translate('title');
14190
14269
  function createReactiveI18n(i18n: I18n): ReactiveI18n;
14191
14270
  ```
14192
14271
 
14193
- Bridges a lingua instance into `@vielzeug/ripple` so translated strings are reactive. `i18n.translate()` is not ripple-reactive on its own: reading it inside a `computed()` computes once and never re-runs, since it registers no tracked dependency. The bridge's `translate` and `translateUnkeyed` first read the reactive `locale` readable, so any binding built on them re-evaluates the instant `setLocale()` resolves. For runtime-assembled keys inside reactive bindings use the bridge's `translateUnkeyed`: calling `i18n.translateUnkeyed` directly skips the reactive locale and caches the first result.
14272
+ Bridges a lingua instance into `@vielzeug/ripple` so translated strings are reactive. `i18n.translate()` is not ripple-reactive on its own: reading it inside a `computed()` computes once and never re-runs, since it registers no tracked dependency. The bridge's `translate`, `translateUnkeyed`, `parts`, and `partsUnkeyed` first read the reactive `locale` readable, so any binding built on them re-evaluates the instant `setLocale()` resolves. For runtime-assembled keys inside reactive bindings use the bridge's `translateUnkeyed`/`partsUnkeyed`: calling `i18n.translateUnkeyed` directly skips the reactive locale and caches the first result.
14194
14273
 
14195
14274
  `@vielzeug/ripple` is an optional peer dependency: install it only when you use this subpath.
14196
14275
 
@@ -14211,6 +14290,8 @@ await reactive.i18n.setLocale('fr');
14211
14290
  | `locale` | `Readable` | Reactive locale: reading it inside a computed/template registers the dependency |
14212
14291
  | `translate` | `(key, options?)` | Rendered string; re-evaluates whenever the locale changes |
14213
14292
  | `translateUnkeyed` | `(key, options?)` | Rendered string for a runtime key; re-evaluates whenever the locale changes |
14293
+ | `parts` | `(key, options?)` | Render-order `Segment[]`; re-evaluates whenever the locale changes |
14294
+ | `partsUnkeyed` | `(key, options?)` | `Segment[]` for a runtime key; re-evaluates whenever the locale changes |
14214
14295
 
14215
14296
  ---
14216
14297
 
@@ -14359,6 +14440,9 @@ type Translator = {
14359
14440
  translate(key: TextKey, options?: TranslateOptions): string;
14360
14441
  translate(key: PluralKey, options: PluralOptions): string;
14361
14442
  translateUnkeyed(key: string, options?: TranslateOptions | PluralOptions): string;
14443
+ parts(key: TextKey, options?: PartsOptions): readonly Segment[];
14444
+ parts(key: PluralKey, options: PluralPartsOptions): readonly Segment[];
14445
+ partsUnkeyed(key: string, options?: PartsOptions | PluralPartsOptions): readonly Segment[];
14362
14446
  };
14363
14447
  ```
14364
14448
 
@@ -14368,6 +14452,12 @@ type TranslateOptions = { values?: Values };
14368
14452
  type PluralOptions = TranslateOptions & { count: number; ordinal?: boolean };
14369
14453
  type SubscribeOptions = { immediate?: boolean; signal?: AbortSignal };
14370
14454
 
14455
+ type Segment =
14456
+ | { readonly type: 'text'; readonly value: string }
14457
+ | { readonly type: 'value'; readonly name: string; readonly value: V };
14458
+ type PartsOptions = { values?: Record };
14459
+ type PluralPartsOptions = PartsOptions & { count: number; ordinal?: boolean };
14460
+
14371
14461
  type CatalogPaths = Depth extends readonly [unknown, ...infer Rest]
14372
14462
  ? C extends Leaf
14373
14463
  ? Prefix
@@ -14654,6 +14744,55 @@ export function localeStore(i18n: I18n) {
14654
14744
  }
14655
14745
  ```
14656
14746
 
14747
+ ## Rich Content
14748
+
14749
+ `parts()` resolves a message like `translate()` — same plural selection, fallback, and `missing` strategy — but returns render-order segments so framework nodes can enter a sentence without being stringified. Values pass through untouched; joining the segments with `String()` reproduces `translate()` exactly.
14750
+
14751
+ ```ts
14752
+ import { createI18n } from '@vielzeug/lingua';
14753
+
14754
+ const i18n = createI18n({
14755
+ catalogs: { en: { sync: 'Click {link} to sync now.' } },
14756
+ locale: 'en',
14757
+ });
14758
+
14759
+ console.log(i18n.parts('sync', { values: { link: 'here' } }));
14760
+ // [ { type: 'text', value: 'Click ' }, { type: 'value', name: 'link', value: 'here' }, { type: 'text', value: ' to sync now.' } ]
14761
+ ```
14762
+
14763
+ In React, mirror the locale with `useSyncExternalStore` and key memoized translations on the **locale snapshot** — `i18n.translate`/`i18n.parts` keep a stable identity across `setLocale()` on purpose, so `[t]`-style dependency arrays keep the previous language:
14764
+
14765
+ ```tsx
14766
+ import { Fragment, useMemo, useSyncExternalStore } from 'react';
14767
+ import type { ReactNode } from 'react';
14768
+
14769
+ import type { Catalog, I18n, TextKey } from '@vielzeug/lingua';
14770
+
14771
+ export function useI18n(i18n: I18n) {
14772
+ const locale = useSyncExternalStore((onChange) => i18n.subscribe(onChange), i18n.getSnapshot, i18n.getSnapshot);
14773
+
14774
+ // The fresh memo per locale gives `t` a locale-keyed identity, so downstream `[t]` memos recompute correctly.
14775
+ return useMemo(
14776
+ () => ({
14777
+ locale,
14778
+ t: i18n.translate.bind(i18n),
14779
+ rich: (key: TextKey, values: Record) =>
14780
+ i18n.parts(key, { values }).map((segment, index) =>
14781
+ segment.type === 'text'
14782
+ ? segment.value
14783
+ : {segment.value},
14784
+ ),
14785
+ }),
14786
+ [locale],
14787
+ );
14788
+ }
14789
+
14790
+ // {t('sync')}
14791
+ // {rich('sync', { link: here })}
14792
+ ```
14793
+
14794
+ The same segment shape maps directly onto `h()` vnodes in Vue or `{#each}` blocks in Svelte — only the value-segment wrapper is framework-specific. Because values never enter the concatenated string, rich rendering via `parts` also keeps user data out of any HTML-interpolation sink that marker-and-split workarounds would expose.
14795
+
14657
14796
  ## Working with Other Vielzeug Libraries
14658
14797
 
14659
14798
  Bridge Lingua's `getSnapshot()`/`subscribe()` pair directly when templates need reactive locale reads.
@@ -14679,6 +14818,8 @@ Use Courier loaders when locale catalogs come from HTTP rather than bundled modu
14679
14818
  - Keep loader functions out of SSR payloads.
14680
14819
  - Dispose temporary instances after requests, tests, and route lifetimes.
14681
14820
  - Use `missing: 'throw'` in development to catch missing keys and values early.
14821
+ - Memoize derived translations on the `getSnapshot()` locale string, never on `translate` or `parts` function identity.
14822
+ - Render rich messages with `parts()` instead of smuggling markers through `translate()`.
14682
14823
 
14683
14824
  ### Examples
14684
14825
 
package/data/llms.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  # Vielzeug
2
2
 
3
- > 46 focused TypeScript packages. Version: 26.11.13
3
+ > 46 focused TypeScript packages. Version: 26.11.15
4
4
 
5
5
  Install any package independently: `pnpm add @vielzeug/<name>`
6
6