@decocms/blocks 8.5.1 → 8.6.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.
Files changed (121) hide show
  1. package/dist/async/default.d.ts +10 -0
  2. package/dist/async/default.d.ts.map +1 -0
  3. package/dist/async/default.js +5 -0
  4. package/dist/async/default.js.map +1 -0
  5. package/dist/async/node.d.ts +3 -0
  6. package/dist/async/node.d.ts.map +1 -0
  7. package/dist/async/node.js +11 -0
  8. package/dist/async/node.js.map +1 -0
  9. package/dist/async/types.d.ts +6 -0
  10. package/dist/async/types.d.ts.map +1 -0
  11. package/dist/async/types.js +2 -0
  12. package/dist/async/types.js.map +1 -0
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +1 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/v8/bucketing.d.ts +24 -0
  18. package/dist/v8/bucketing.d.ts.map +1 -0
  19. package/dist/v8/bucketing.js +78 -0
  20. package/dist/v8/bucketing.js.map +1 -0
  21. package/dist/v8/builtins/campaigns.d.ts +36 -0
  22. package/dist/v8/builtins/campaigns.d.ts.map +1 -0
  23. package/dist/v8/builtins/campaigns.js +107 -0
  24. package/dist/v8/builtins/campaigns.js.map +1 -0
  25. package/dist/v8/builtins/data.d.ts +2 -2
  26. package/dist/v8/builtins/data.js +2 -2
  27. package/dist/v8/builtins/experiments.d.ts +27 -0
  28. package/dist/v8/builtins/experiments.d.ts.map +1 -0
  29. package/dist/v8/builtins/experiments.js +62 -0
  30. package/dist/v8/builtins/experiments.js.map +1 -0
  31. package/dist/v8/builtins/index.d.ts.map +1 -1
  32. package/dist/v8/builtins/index.js +7 -2
  33. package/dist/v8/builtins/index.js.map +1 -1
  34. package/dist/v8/builtins/matchers.d.ts +0 -14
  35. package/dist/v8/builtins/matchers.d.ts.map +1 -1
  36. package/dist/v8/builtins/matchers.js +0 -19
  37. package/dist/v8/builtins/matchers.js.map +1 -1
  38. package/dist/v8/cli/builtins.d.ts +6 -0
  39. package/dist/v8/cli/builtins.d.ts.map +1 -1
  40. package/dist/v8/cli/builtins.js +19 -0
  41. package/dist/v8/cli/builtins.js.map +1 -1
  42. package/dist/v8/cli/check/index.d.ts.map +1 -1
  43. package/dist/v8/cli/check/index.js +231 -8
  44. package/dist/v8/cli/check/index.js.map +1 -1
  45. package/dist/v8/cli/schema/builtinSchemas.d.ts.map +1 -1
  46. package/dist/v8/cli/schema/builtinSchemas.js +76 -21
  47. package/dist/v8/cli/schema/builtinSchemas.js.map +1 -1
  48. package/dist/v8/cli/schema/generate.d.ts.map +1 -1
  49. package/dist/v8/cli/schema/generate.js +48 -2
  50. package/dist/v8/cli/schema/generate.js.map +1 -1
  51. package/dist/v8/client.d.ts +25 -0
  52. package/dist/v8/client.d.ts.map +1 -1
  53. package/dist/v8/client.js +58 -10
  54. package/dist/v8/client.js.map +1 -1
  55. package/dist/v8/cms.d.ts.map +1 -1
  56. package/dist/v8/cms.js +93 -42
  57. package/dist/v8/cms.js.map +1 -1
  58. package/dist/v8/content.d.ts +45 -0
  59. package/dist/v8/content.d.ts.map +1 -1
  60. package/dist/v8/content.js +68 -2
  61. package/dist/v8/content.js.map +1 -1
  62. package/dist/v8/current.d.ts +28 -0
  63. package/dist/v8/current.d.ts.map +1 -0
  64. package/dist/v8/current.js +77 -0
  65. package/dist/v8/current.js.map +1 -0
  66. package/dist/v8/draft.d.ts +40 -21
  67. package/dist/v8/draft.d.ts.map +1 -1
  68. package/dist/v8/draft.js +160 -25
  69. package/dist/v8/draft.js.map +1 -1
  70. package/dist/v8/experiments.d.ts +107 -0
  71. package/dist/v8/experiments.d.ts.map +1 -0
  72. package/dist/v8/experiments.js +292 -0
  73. package/dist/v8/experiments.js.map +1 -0
  74. package/dist/v8/hosts.d.ts +3 -2
  75. package/dist/v8/hosts.d.ts.map +1 -1
  76. package/dist/v8/hosts.js +3 -2
  77. package/dist/v8/hosts.js.map +1 -1
  78. package/dist/v8/index.d.ts +7 -5
  79. package/dist/v8/index.d.ts.map +1 -1
  80. package/dist/v8/index.js +6 -4
  81. package/dist/v8/index.js.map +1 -1
  82. package/dist/v8/remoteLoader.d.ts.map +1 -1
  83. package/dist/v8/remoteLoader.js +166 -20
  84. package/dist/v8/remoteLoader.js.map +1 -1
  85. package/dist/v8/resolver.d.ts +4 -2
  86. package/dist/v8/resolver.d.ts.map +1 -1
  87. package/dist/v8/resolver.js +11 -3
  88. package/dist/v8/resolver.js.map +1 -1
  89. package/dist/v8/settings.d.ts +16 -4
  90. package/dist/v8/settings.d.ts.map +1 -1
  91. package/dist/v8/settings.js +24 -21
  92. package/dist/v8/settings.js.map +1 -1
  93. package/dist/v8/types.d.ts +126 -21
  94. package/dist/v8/types.d.ts.map +1 -1
  95. package/package.json +35 -1
  96. package/src/async/default.ts +13 -0
  97. package/src/async/node.ts +12 -0
  98. package/src/async/types.ts +5 -0
  99. package/src/index.ts +4 -0
  100. package/src/v8/bucketing.ts +88 -0
  101. package/src/v8/builtins/campaigns.ts +120 -0
  102. package/src/v8/builtins/data.ts +2 -2
  103. package/src/v8/builtins/experiments.ts +72 -0
  104. package/src/v8/builtins/index.ts +7 -2
  105. package/src/v8/builtins/matchers.ts +0 -26
  106. package/src/v8/cli/builtins.ts +23 -0
  107. package/src/v8/cli/check/index.ts +289 -8
  108. package/src/v8/cli/schema/builtinSchemas.ts +82 -22
  109. package/src/v8/cli/schema/generate.ts +48 -3
  110. package/src/v8/client.ts +76 -10
  111. package/src/v8/cms.ts +108 -43
  112. package/src/v8/content.ts +86 -2
  113. package/src/v8/current.ts +98 -0
  114. package/src/v8/draft.ts +170 -30
  115. package/src/v8/experiments.ts +340 -0
  116. package/src/v8/hosts.ts +3 -2
  117. package/src/v8/index.ts +8 -4
  118. package/src/v8/remoteLoader.ts +190 -25
  119. package/src/v8/resolver.ts +14 -4
  120. package/src/v8/settings.ts +35 -29
  121. package/src/v8/types.ts +128 -19
@@ -3,6 +3,7 @@
3
3
  * (`/next/api-reference#types`) — every type here is documented there.
4
4
  */
5
5
  import type { ReactNode } from "react";
6
+ import type { Assignments, Visitor } from "./experiments.ts";
6
7
  /**
7
8
  * A block as stored: the JSON in `.deco/blocks`, and what `client.list` and
8
9
  * `{ run: false }` return. Props never use it: a field's type is the value the
@@ -36,6 +37,13 @@ export type Snapshot = {
36
37
  * module, a build outside git), the bundled content counts as the oldest.
37
38
  */
38
39
  committedAt?: string;
40
+ /**
41
+ * The hosts this release may be previewed on (host patterns), as Studio
42
+ * wrote them into the release metadata on delivery.decocms.com
43
+ * (`latest.json` and `revisions/<sha>.json`). Previews are checked against
44
+ * the current release's list; the bundled content has none.
45
+ */
46
+ previewHosts?: string[];
39
47
  };
40
48
  /**
41
49
  * The content module `deco content` writes: a snapshot plus `root`, the
@@ -87,10 +95,14 @@ export interface Seo {
87
95
  title: string;
88
96
  description: string;
89
97
  }
90
- /** The built-in `page` block, resolved: without `seo`, the site's defaults apply. */
91
- export interface Page extends Route {
98
+ /**
99
+ * The built-in `page` block, resolved: without `seo`, the site's defaults
100
+ * apply. Its sections are whatever its section blocks return: React
101
+ * elements by default, or a site's descriptors (`Page<{ component, props }>`).
102
+ */
103
+ export interface Page<Section = ReactNode> extends Route {
92
104
  seo?: Seo;
93
- sections: ReactNode[];
105
+ sections: Section[];
94
106
  }
95
107
  /** The built-in `redirect` block. */
96
108
  export interface Redirect {
@@ -141,16 +153,19 @@ export interface Variant<T> {
141
153
  * caps (see /next/built-in-blocks#cms-settings).
142
154
  */
143
155
  export interface CMSSettings {
144
- /** Host patterns previews are allowed on, within `createCMS`'s `preview.hosts`. */
145
- preview?: {
146
- hosts?: string[];
147
- };
148
156
  telemetry?: Telemetry;
149
157
  analytics?: Analytics;
150
158
  }
151
159
  /** What `cms.settings()` returns: every section, defaults filled in, caps applied. */
152
160
  export interface EffectiveSettings {
153
- /** `["*"]` means every host; an empty list, none. */
161
+ /**
162
+ * The hosts previews are allowed on, as known in memory: the current
163
+ * release's `previewHosts` (Studio writes them into the release metadata)
164
+ * plus `createCMS`'s `preview.hosts`. A site with no list published (no
165
+ * `latest.json` yet, or one without `previewHosts`) and content with no
166
+ * remote site and no `preview.hosts` give `["*"]`, every host; an empty
167
+ * list, none (as before this process has read the release metadata).
168
+ */
154
169
  preview: {
155
170
  hosts: string[];
156
171
  };
@@ -241,8 +256,12 @@ export interface CMSConfig {
241
256
  telemetry?: false | TelemetryConfig;
242
257
  preview?: {
243
258
  /**
244
- * The most content may allow previews on, in the host pattern format
245
- * (/next/api-reference#host-patterns). Without it, content may allow any host.
259
+ * Hosts previews are allowed on besides the release's own (Studio writes
260
+ * those into the release metadata), in the host pattern format
261
+ * (/next/api-reference#host-patterns). Without `site`, the only list:
262
+ * left out, previews are allowed on every host. With `site`, it adds to
263
+ * the release's list; a site with no list published previews on every
264
+ * host anyway.
246
265
  */
247
266
  hosts?: string[];
248
267
  /**
@@ -278,13 +297,14 @@ export interface ListOptions<T> {
278
297
  run?: boolean;
279
298
  }
280
299
  /**
281
- * Reads one revision for one request.
300
+ * Reads one revision for one request, for one visitor, at one moment.
282
301
  *
283
302
  * Results are read-only. A client runs each block function once per distinct
284
303
  * input, so the same block at two places in a request hands both places the
285
304
  * same object; mutating it in place changes the other occurrence too. Copy a
286
305
  * result before changing it. (The memo belongs to one client, so nothing is
287
- * shared across requests.)
306
+ * shared across requests; it is also why tests and campaigns are decided once
307
+ * per client, however many rules ask.)
288
308
  */
289
309
  export interface Client {
290
310
  resolve<T = unknown>(target: unknown, options?: ResolveOptions): Promise<Result<T>>;
@@ -295,15 +315,85 @@ export interface Client {
295
315
  * can't load, since there is no revision to report.
296
316
  */
297
317
  revision(): Promise<string>;
318
+ /** Who is visiting, as passed to `cms.client()` (a frozen copy); `null` for none. */
319
+ readonly visitor: Visitor | null;
320
+ /**
321
+ * The version it reads: the release's commit SHA, or the draft pointer, as
322
+ * passed to `cms.client()`. For the current release, the SHA of the release
323
+ * it loaded (`undefined` until its first `resolve`, `list` or `revision()`).
324
+ */
325
+ readonly version: string | undefined;
326
+ /** The date campaigns run at: the one passed to `cms.client()`, otherwise when the client was created. */
327
+ readonly date: Date;
328
+ }
329
+ /**
330
+ * What one client is created with, all read by the app outside blocks and
331
+ * passed in. The visitor and the date decide; `experiments` and `campaigns`
332
+ * override what they decide, name by name. Given every test and campaign and
333
+ * no visitor, a client is fully decided in advance (a page rendering what a
334
+ * proxy in front of it decided).
335
+ */
336
+ export interface ClientOptions {
337
+ /**
338
+ * What to read: `undefined` (or `null`) for the current release; a
339
+ * published release's commit SHA (40 hex characters), read from hosted
340
+ * releases; or a draft pointer, the draft's changes over the current
341
+ * release. Only a version: a Studio link's moment and switched tests are
342
+ * the options below (`cms.readVersion(request)` reads all of them).
343
+ */
344
+ version?: string | null;
345
+ /**
346
+ * Who is visiting (`readVisitor`, `parseVisitor` or `newVisitor` from
347
+ * `@decocms/blocks/experiments`): the saved block `experiments` decides
348
+ * its tests for them. Without one, every test not in `experiments` is off.
349
+ */
350
+ visitor?: Visitor | null;
351
+ /**
352
+ * The moment the saved block `campaigns` checks its windows at
353
+ * (`client.date`). Default: when the client is created.
354
+ */
355
+ date?: Date | null;
356
+ /**
357
+ * Tests on (`true`) or off (`false`) by name, whatever the visitor and the
358
+ * test's percentage; the others are decided for the visitor. A name the
359
+ * saved block `experiments` doesn't have stays out.
360
+ */
361
+ experiments?: Partial<Assignments> | null;
362
+ /**
363
+ * Campaigns on (`true`) or off (`false`) by name, whatever their window;
364
+ * the others are checked at `date`. A name the saved block `campaigns`
365
+ * doesn't have stays out.
366
+ */
367
+ campaigns?: Partial<Assignments> | null;
368
+ }
369
+ /**
370
+ * What a Studio link asks for (`cms.readVersion`, `parseVersion`): the
371
+ * version, and the preview's moment and the tests and campaigns it switches,
372
+ * in the shape of `ClientOptions`, so it spreads into `cms.client()`.
373
+ */
374
+ export interface RequestVersion {
375
+ /** A draft pointer, or a published release's commit SHA. */
376
+ version: string;
377
+ /** The moment the preview shows (`__at`). */
378
+ date?: Date;
379
+ /** The tests the preview switches on or off (`__test=<name>=on|off`). */
380
+ experiments?: Assignments;
381
+ /** The campaigns the preview switches on or off (`__campaign=<name>=on|off`). */
382
+ campaigns?: Assignments;
298
383
  }
299
384
  export interface CMS {
300
- /** A client reading the current release. */
385
+ /**
386
+ * A client: the version it reads and the visitor it decides tests for, both
387
+ * passed in. Create one per request.
388
+ */
389
+ client(options?: ClientOptions): Client;
390
+ /** A client reading the current release: `cms.client()`. */
301
391
  forRelease(): Client;
302
392
  /**
303
- * A client reading the draft a pointer names: its changes, fetched from a
304
- * draft host (`*.decocms.com` and loopback by default;
305
- * `createCMS({ preview: { draftHosts } })` replaces the list), over this
306
- * server's production content.
393
+ * A client reading the draft a pointer names: `cms.client({ version: pointer })`.
394
+ * Its changes are fetched from a draft host (`*.decocms.com` and loopback by
395
+ * default; `createCMS({ preview: { draftHosts } })` replaces the list) and
396
+ * laid over this server's production content.
307
397
  */
308
398
  forDraft(pointer: string): Client;
309
399
  /** Ask the content source for newer content now; never throws. */
@@ -317,11 +407,26 @@ export interface CMS {
317
407
  */
318
408
  settings(): Promise<EffectiveSettings>;
319
409
  /**
320
- * The request's draft pointer: `?__draft=` first, then the `__deco_draft`
321
- * cookie. `null` when neither is present, for `?__draft=off`, on a host
322
- * outside `settings().preview.hosts`, and for a value that doesn't parse
323
- * (ignored, as if absent): in each case the request gets the release.
410
+ * What a Studio link asks for: `?__draft=` first, then the `__deco_draft`
411
+ * cookie, holding a draft pointer or a published release's commit SHA,
412
+ * with the preview's moment (`__at`) and switched tests (`__test`) and
413
+ * campaigns (`__campaign`) as `date`, `experiments` and `campaigns`.
414
+ * `null` when neither is present, for `?__draft=off`, on a host outside
415
+ * the preview hosts (the current release's `previewHosts`, which Studio
416
+ * writes into the release metadata, plus `createCMS`'s `preview.hosts`;
417
+ * every host while the site has published no list, or without `site` and
418
+ * `preview.hosts`; no host while the metadata can't be read, besides
419
+ * `preview.hosts`), and for a value that doesn't parse (ignored,
420
+ * as if absent): in each case the request gets the current release. A
421
+ * draft and an older release's SHA are both checked against the current
422
+ * release's list.
423
+ *
424
+ * ```ts
425
+ * const client = cms.client({ visitor, ...(await cms.readVersion(request)) });
426
+ * ```
324
427
  */
428
+ readVersion(request: RequestLike): Promise<RequestVersion | null>;
429
+ /** The version alone (`readVersion(request)`'s `version`), under its earlier name. */
325
430
  draftPointer(request: RequestLike): Promise<string | null>;
326
431
  /**
327
432
  * The `Set-Cookie` value that starts a preview (a valid `?__draft=` on an
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/v8/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAMvC;;;;GAIG;AACH,MAAM,MAAM,KAAK,GAAG;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAExE,mCAAmC;AACnC,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAExE,oEAAoE;AACpE,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAEnD,2FAA2F;AAC3F,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CA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,YAAY,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC3D;;;OAGG;IACH,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC3D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/blocks",
3
- "version": "8.5.1",
3
+ "version": "8.6.0",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=24"
@@ -13,6 +13,35 @@
13
13
  },
14
14
  "main": "./dist/index.js",
15
15
  "types": "./dist/index.d.ts",
16
+ "imports": {
17
+ "#async-store": {
18
+ "node": {
19
+ "types": "./dist/async/node.d.ts",
20
+ "source": "./src/async/node.ts",
21
+ "default": "./dist/async/node.js"
22
+ },
23
+ "workerd": {
24
+ "types": "./dist/async/node.d.ts",
25
+ "source": "./src/async/node.ts",
26
+ "default": "./dist/async/node.js"
27
+ },
28
+ "bun": {
29
+ "types": "./dist/async/node.d.ts",
30
+ "source": "./src/async/node.ts",
31
+ "default": "./dist/async/node.js"
32
+ },
33
+ "deno": {
34
+ "types": "./dist/async/node.d.ts",
35
+ "source": "./src/async/node.ts",
36
+ "default": "./dist/async/node.js"
37
+ },
38
+ "default": {
39
+ "types": "./dist/async/default.d.ts",
40
+ "source": "./src/async/default.ts",
41
+ "default": "./dist/async/default.js"
42
+ }
43
+ }
44
+ },
16
45
  "files": [
17
46
  "bin",
18
47
  "dist",
@@ -43,6 +72,11 @@
43
72
  "source": "./src/v8/cli/index.ts",
44
73
  "default": "./dist/v8/cli/index.js"
45
74
  },
75
+ "./experiments": {
76
+ "types": "./dist/v8/experiments.d.ts",
77
+ "source": "./src/v8/experiments.ts",
78
+ "default": "./dist/v8/experiments.js"
79
+ },
46
80
  "./fetch": {
47
81
  "types": "./dist/v8/fetch.d.ts",
48
82
  "source": "./src/v8/fetch.ts",
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The async store where `node:async_hooks` isn't there to import (browsers,
3
+ * React Native, edge runtimes). A runtime that exposes `AsyncLocalStorage` as
4
+ * a global (Vercel's edge runtime) still gets one; elsewhere there is none,
5
+ * and `currentClient()` works from the start of a block function, before its
6
+ * first `await`. Picked by the `#async-store` import's `default` condition.
7
+ */
8
+ import type { AsyncStore } from "./types.ts";
9
+
10
+ export function createAsyncStore<T>(): AsyncStore<T> | undefined {
11
+ const Storage = (globalThis as { AsyncLocalStorage?: new () => AsyncStore<T> }).AsyncLocalStorage;
12
+ return typeof Storage === "function" ? new Storage() : undefined;
13
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The async store on servers with `AsyncLocalStorage` (Node, Bun, Deno, and
3
+ * Workers with `nodejs_compat`), so `currentClient()` survives `await`.
4
+ * Picked by the `#async-store` import's `node`, `workerd`, `bun` and `deno`
5
+ * conditions; the runtime core (`src/v8`) never imports a Node built-in.
6
+ */
7
+ import { AsyncLocalStorage } from "node:async_hooks";
8
+ import type { AsyncStore } from "./types.ts";
9
+
10
+ export function createAsyncStore<T>(): AsyncStore<T> | undefined {
11
+ return new AsyncLocalStorage<T>();
12
+ }
@@ -0,0 +1,5 @@
1
+ /** The part of `AsyncLocalStorage` the client slot uses. */
2
+ export interface AsyncStore<T> {
3
+ run<R>(value: T, fn: () => R): R;
4
+ getStore(): T | undefined;
5
+ }
package/src/index.ts CHANGED
@@ -6,10 +6,12 @@ export {
6
6
  type BlockFunction,
7
7
  type Blocks,
8
8
  type Client,
9
+ type ClientOptions,
9
10
  type CMS,
10
11
  type CMSError,
11
12
  type CMSSettings,
12
13
  createCMS,
14
+ currentClient,
13
15
  type DraftPointer,
14
16
  type EffectiveSettings,
15
17
  formatDraftPointer,
@@ -20,8 +22,10 @@ export {
20
22
  matchRoute,
21
23
  type Page,
22
24
  parseDraftPointer,
25
+ parseVersion,
23
26
  type Redirect,
24
27
  type RequestLike,
28
+ type RequestVersion,
25
29
  type Result,
26
30
  type Route,
27
31
  remoteLoader,
@@ -0,0 +1,88 @@
1
+ /**
2
+ * The arithmetic behind `@decocms/blocks/experiments`: the hash, the roll and
3
+ * the visitor id. Internal: not in the exports map, so the public surface is
4
+ * `assign` and the visitor helpers alone, and the tests import this by path.
5
+ *
6
+ * A hash bug here fails silently: every visitor still gets an answer, it is
7
+ * just the wrong one, and the test's result is quietly meaningless. That is
8
+ * why `experiments.test.ts` pins MurmurHash3's published vectors and a table
9
+ * of rolls, and why changing anything here moves visitors already allocated.
10
+ */
11
+
12
+ /** Fills `bytes` with random values. `newId` takes one so tests can pin the id. */
13
+ export type RandomBytes = (bytes: Uint8Array<ArrayBuffer>) => void;
14
+
15
+ const ID_BYTES = 16;
16
+
17
+ const encoder = new TextEncoder();
18
+
19
+ /** MurmurHash3 x86 32-bit, seed 0 by default, over `bytes`, as an unsigned 32-bit number. */
20
+ export function murmur3_32(bytes: Uint8Array, seed = 0): number {
21
+ const c1 = 0xcc9e2d51;
22
+ const c2 = 0x1b873593;
23
+ const len = bytes.length;
24
+ const blocks = len & ~3;
25
+ let h = seed >>> 0;
26
+
27
+ for (let i = 0; i < blocks; i += 4) {
28
+ let k =
29
+ ((bytes[i] as number) |
30
+ ((bytes[i + 1] as number) << 8) |
31
+ ((bytes[i + 2] as number) << 16) |
32
+ ((bytes[i + 3] as number) << 24)) >>>
33
+ 0;
34
+ k = Math.imul(k, c1);
35
+ k = (k << 15) | (k >>> 17);
36
+ k = Math.imul(k, c2);
37
+ h ^= k;
38
+ h = (h << 13) | (h >>> 19);
39
+ h = (Math.imul(h, 5) + 0xe6546b64) | 0;
40
+ }
41
+
42
+ const tail = len & 3;
43
+ if (tail > 0) {
44
+ let k = 0;
45
+ if (tail === 3) k ^= (bytes[blocks + 2] as number) << 16;
46
+ if (tail >= 2) k ^= (bytes[blocks + 1] as number) << 8;
47
+ k ^= bytes[blocks] as number;
48
+ k = Math.imul(k, c1);
49
+ k = (k << 15) | (k >>> 17);
50
+ k = Math.imul(k, c2);
51
+ h ^= k;
52
+ }
53
+
54
+ h ^= len;
55
+ h ^= h >>> 16;
56
+ h = Math.imul(h, 0x85ebca6b);
57
+ h ^= h >>> 13;
58
+ h = Math.imul(h, 0xc2b2ae35);
59
+ h ^= h >>> 16;
60
+ return h >>> 0;
61
+ }
62
+
63
+ /**
64
+ * This visitor's number for this experiment: a fixed value in [0, 100) with a
65
+ * step of 0.01, the same on every runtime. The visitor is in when it is below
66
+ * the allocation, which is what makes a ramp only ever add people: the roll
67
+ * does not move, the threshold does.
68
+ */
69
+ export function roll(name: string, id: string): number {
70
+ return (murmur3_32(encoder.encode(`${name}:${id}`)) % 10000) / 100;
71
+ }
72
+
73
+ function toBase64Url(bytes: Uint8Array): string {
74
+ let binary = "";
75
+ for (const byte of bytes) binary += String.fromCharCode(byte);
76
+ return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
77
+ }
78
+
79
+ const defaultRandom: RandomBytes = (bytes) => {
80
+ crypto.getRandomValues(bytes);
81
+ };
82
+
83
+ /** A fresh visitor id: 128 bits as 22 base64url characters. */
84
+ export function newId(random: RandomBytes = defaultRandom): string {
85
+ const bytes = new Uint8Array(ID_BYTES);
86
+ random(bytes);
87
+ return toBase64Url(bytes);
88
+ }
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Campaign dates as content (see /next/built-in-blocks#calendar): the
3
+ * built-in type `calendar`, which the saved block `campaigns` has, and the
4
+ * built-in rule `campaign`.
5
+ *
6
+ * - `campaigns` maps each campaign's name to one window, `{ start?, end? }`,
7
+ * ISO date-times with an offset. Resolving it gives each name and whether
8
+ * the client's date is inside its window, never a date.
9
+ * - `campaign { name }` is `true` when that answer is `true`. A rule always
10
+ * names a campaign: there are no inline `{ start, end }` dates, so
11
+ * `calendar` is the only place date logic lives.
12
+ *
13
+ * The date is the client's (`client.date`: `cms.client({ date })`, or when
14
+ * the client was created), read through `currentClient()` before any
15
+ * `await`. A campaign the client is given (`cms.client({ campaigns })`) is
16
+ * on or off as given, whatever its window; a name the block doesn't have
17
+ * stays out.
18
+ */
19
+ import { campaignOverrides, currentClient } from "../current.ts";
20
+
21
+ /** The saved block every `campaign` rule reads, and its built-in type. */
22
+ export const CAMPAIGNS_BLOCK = "campaigns";
23
+ export const CALENDAR_TYPE = "calendar";
24
+
25
+ /** The built-in rule that reads a campaign. */
26
+ export const CAMPAIGN_RULE = "campaign";
27
+
28
+ /** What resolving `campaigns` gives: each campaign and whether it is running. */
29
+ type Campaigns = Record<string, boolean>;
30
+
31
+ /**
32
+ * `calendar`: each campaign and whether the current client's date is inside
33
+ * its window, or, for a campaign the client was given, what it was given.
34
+ */
35
+ export const calendar = (windows: Record<string, unknown> = {}): Campaigns => {
36
+ const client = currentClient();
37
+ const given = campaignOverrides(client);
38
+ const at = client.date.getTime();
39
+ const out = Object.create(null) as Campaigns;
40
+ for (const name of Object.keys(windows)) {
41
+ out[name] =
42
+ given !== undefined && Object.hasOwn(given, name)
43
+ ? given[name] === true
44
+ : inside(windows[name], at);
45
+ }
46
+ return out;
47
+ };
48
+
49
+ /**
50
+ * Whether `at` (ms since the epoch) is inside `window`, `{ start?, end? }`:
51
+ * from `start` (inclusive) until `end` (exclusive); an empty or absent bound
52
+ * is open. A window that isn't an object, or a bound that isn't an ISO 8601
53
+ * date-time with an offset, is outside, so a typo can't switch a campaign
54
+ * on. See `campaignTime` for how a bound reads.
55
+ */
56
+ function inside(window: unknown, at: number): boolean {
57
+ if (typeof window !== "object" || window === null || Array.isArray(window)) return false;
58
+ const { start, end } = window as Record<string, unknown>;
59
+ const from = campaignTime(start);
60
+ const until = campaignTime(end);
61
+ if (from === null || until === null) return false;
62
+ return (from === undefined || at >= from) && (until === undefined || at < until);
63
+ }
64
+
65
+ /** An ISO 8601 date-time with its offset (`Z` or `±hh:mm`). */
66
+ const ISO_RE = /^(\d{4}-\d{2}-\d{2})T\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?(?:Z|[+-]\d{2}:\d{2})$/;
67
+
68
+ /**
69
+ * A campaign bound's time in ms since the epoch: `undefined` when absent or
70
+ * empty (open), `null` when it can't be one. A bound is an ISO 8601
71
+ * date-time with an explicit offset (`Z` or `±hh:mm`), so it names the same
72
+ * moment on every runtime. A date without a time, a date-time without an
73
+ * offset (whose moment depends on where it is read), a day the calendar
74
+ * doesn't have and anything else, such as `"Nov 27 2026"`, can't be one,
75
+ * so that campaign never runs.
76
+ */
77
+ export function campaignTime(value: unknown): number | undefined | null {
78
+ if (value === undefined || value === null || value === "") return undefined;
79
+ if (typeof value !== "string") return null;
80
+ const match = ISO_RE.exec(value);
81
+ if (match === null || !isCalendarDate(match[1] as string)) return null;
82
+ const time = Date.parse(value);
83
+ return Number.isNaN(time) ? null : time;
84
+ }
85
+
86
+ /** Whether `yyyy-mm-dd` is a day of the calendar (some runtimes roll February 30 into March, others refuse it). */
87
+ function isCalendarDate(date: string): boolean {
88
+ const [y, m, d] = date.split("-").map(Number) as [number, number, number];
89
+ const day = new Date(Date.UTC(y, m - 1, d));
90
+ return day.getUTCFullYear() === y && day.getUTCMonth() === m - 1 && day.getUTCDate() === d;
91
+ }
92
+
93
+ /** Inputs of the built-in `campaign` rule. */
94
+ interface CampaignProps {
95
+ /** A campaign in the saved block `campaigns`. */
96
+ name?: string;
97
+ }
98
+
99
+ /**
100
+ * `campaign`: `true` while the campaign `name` of the saved block
101
+ * `campaigns` is running for the client. An unknown name, no `campaigns`
102
+ * block, or a rule without a name give `false`. The block is resolved once
103
+ * per client, however many rules ask.
104
+ */
105
+ export const campaign = ({ name }: CampaignProps = {}): boolean | Promise<boolean> => {
106
+ const client = currentClient();
107
+ if (typeof name !== "string") return false;
108
+ return client
109
+ .resolve<Record<string, unknown>>(CAMPAIGNS_BLOCK)
110
+ .then(([campaigns]) => isTrueAt(campaigns, name));
111
+ };
112
+
113
+ function isTrueAt(record: unknown, name: string): boolean {
114
+ return (
115
+ typeof record === "object" &&
116
+ record !== null &&
117
+ Object.hasOwn(record, name) &&
118
+ (record as Record<string, unknown>)[name] === true
119
+ );
120
+ }
@@ -49,8 +49,8 @@ export function analyticsSection(section: unknown): Required<Analytics> {
49
49
 
50
50
  /**
51
51
  * `cms-settings`: the type of the well-known saved block `CMS`. Returns its
52
- * input with the telemetry and analytics defaults filled in; `preview` stays
53
- * as saved, since its default depends on code (`cms.settings()` applies it).
52
+ * input with the telemetry and analytics defaults filled in. Preview hosts
53
+ * aren't here: Studio writes them into the release metadata.
54
54
  */
55
55
  export const cmsSettings = (
56
56
  props: CMSSettings = {},
@@ -0,0 +1,72 @@
1
+ /**
2
+ * A/B tests as content (see /next/built-in-blocks#split-traffic): the
3
+ * built-in type `split-traffic`, which the saved block `experiments` has, and
4
+ * the built-in rule `experiment`.
5
+ *
6
+ * - `experiments` maps each test's name to the whole percentage of visitors
7
+ * in it (0–100: 0 off, 100 everyone). Resolving it gives each name and
8
+ * whether the client's visitor is in it, never a percentage.
9
+ * - `experiment { name }` is `true` when that answer is `true`.
10
+ *
11
+ * The visitor arrives as an argument to `cms.client({ visitor })`; these
12
+ * read it through `currentClient()`, before any `await`. A test the client
13
+ * is given (`cms.client({ experiments })`) is on or off as given, whatever
14
+ * the visitor and its percentage (a preview may switch on a test at 0%); a
15
+ * name the block doesn't have stays out.
16
+ */
17
+ import { currentClient, experimentOverrides } from "../current.ts";
18
+ import { type Assignments, assign } from "../experiments.ts";
19
+
20
+ /** The saved block every `experiment` rule reads, and its built-in type. */
21
+ export const EXPERIMENTS_BLOCK = "experiments";
22
+ export const SPLIT_TRAFFIC_TYPE = "split-traffic";
23
+
24
+ /** The built-in rule that reads a test. */
25
+ export const EXPERIMENT_RULE = "experiment";
26
+
27
+ /**
28
+ * `split-traffic`: each test and whether the current client's visitor is in
29
+ * it (`assign` from `@decocms/blocks/experiments`), with the tests the
30
+ * client was given applied on top. Without a visitor every test it wasn't
31
+ * given is off.
32
+ */
33
+ export const splitTraffic = (allocations: Record<string, number> = {}): Assignments => {
34
+ const client = currentClient();
35
+ const assignments = assign(allocations, client.visitor);
36
+ const given = experimentOverrides(client);
37
+ if (given !== undefined) {
38
+ for (const name of Object.keys(given)) {
39
+ if (Object.hasOwn(assignments, name)) assignments[name] = given[name] === true;
40
+ }
41
+ }
42
+ return assignments;
43
+ };
44
+
45
+ /** Inputs of the built-in `experiment` rule. */
46
+ interface ExperimentProps {
47
+ /** A test in the saved block `experiments`. */
48
+ name?: string;
49
+ }
50
+
51
+ /**
52
+ * `experiment`: `true` when the current client's visitor is in the test
53
+ * `name` of the saved block `experiments`. An unknown name, no `experiments`
54
+ * block, or no visitor give `false`. The block is resolved once per client,
55
+ * however many rules ask.
56
+ */
57
+ export const experiment = ({ name }: ExperimentProps = {}): boolean | Promise<boolean> => {
58
+ const client = currentClient();
59
+ if (typeof name !== "string") return false;
60
+ return client
61
+ .resolve<Record<string, unknown>>(EXPERIMENTS_BLOCK)
62
+ .then(([tests]) => isTrueAt(tests, name));
63
+ };
64
+
65
+ function isTrueAt(record: unknown, name: string): boolean {
66
+ return (
67
+ typeof record === "object" &&
68
+ record !== null &&
69
+ Object.hasOwn(record, name) &&
70
+ (record as Record<string, unknown>)[name] === true
71
+ );
72
+ }