@decocms/blocks 8.5.2 → 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
@@ -1,22 +1,38 @@
1
- /**
2
- * Draft pointers (see /next/api-reference#draft-pointers): the string
3
- * `<host[:port]><path[?query]>@<version>` that names a draft, and what
4
- * `cms.draftPointer` and `cms.draftCookie` read and write to carry one from a
5
- * `?__draft=` link into a cookie. The host check against the preview hosts is
6
- * the CMS's: these read the request only.
7
- *
8
- * The query's reserved `__variant` parameters are the variants a preview
9
- * forces (`<block>@<path>=<index>`, URL-encoded, one per multivariate); the
10
- * parser lifts them out of `path` into `variants`.
11
- */
12
- import type { DraftPointer, RequestLike } from "./types.ts";
1
+ import type { DraftPointer, RequestLike, RequestVersion } from "./types.ts";
13
2
  /** The draft link's query parameter. Shared with `./preview` (the badge's links); not exported from the package. */
14
3
  export declare const DRAFT_PARAM = "__draft";
4
+ /** A version, read: a published release (by its commit SHA) or a draft. */
5
+ type ClientVersion = {
6
+ kind: "revision";
7
+ sha: string;
8
+ } | {
9
+ kind: "draft";
10
+ pointer: DraftPointer;
11
+ };
12
+ /**
13
+ * What `cms.client({ version })` reads: a published release's commit SHA (40
14
+ * lowercase hex, nothing after it) or a draft pointer. `null` for anything
15
+ * else, a preview link's `__at`, `__test` or `__campaign` included: those
16
+ * are the client's `date`, `experiments` and `campaigns` (`parseVersion`).
17
+ */
18
+ export declare function parseClientVersion(value: string): ClientVersion | null;
19
+ /**
20
+ * A Studio link's value (what `?__draft=` and the draft cookie carry): the
21
+ * version, a draft pointer or a published release's commit SHA, and the
22
+ * preview's moment and switched tests and campaigns, lifted out of its query
23
+ * as the client's `date`, `experiments` and `campaigns`. `null` for a value
24
+ * that is neither, or whose preview parameters don't parse (a second `__at`,
25
+ * a state other than `on` or `off`). The last `__test` or `__campaign` for a
26
+ * name wins. Spread it into `cms.client()`.
27
+ */
28
+ export declare function parseVersion(value: string | null | undefined): RequestVersion | null;
15
29
  /**
16
30
  * Parses a pointer, strictly: `null` on a scheme, a stray `@`, an unrooted
17
- * path, an odd character in the host or version, or a port out of range. The
18
- * host is lowercased (DNS names are case-insensitive); path and version are
19
- * kept as they are.
31
+ * path, an odd character in the host or version, a port out of range, or a
32
+ * preview link's `__at`, `__test` or `__campaign` left in its query (they
33
+ * aren't part of a version: `parseVersion` lifts them out). The host is
34
+ * lowercased (DNS names are case-insensitive); path and version are kept as
35
+ * they are.
20
36
  */
21
37
  export declare function parseDraftPointer(raw: string | null | undefined): DraftPointer | null;
22
38
  /**
@@ -26,16 +42,18 @@ export declare function parseDraftPointer(raw: string | null | undefined): Draft
26
42
  */
27
43
  export declare function formatDraftPointer(pointer: DraftPointer): string;
28
44
  /**
29
- * The draft pointer a request carries: `?__draft=` from the URL first, then
30
- * the `__deco_draft` cookie. `null` when neither is present, or when the URL
31
- * says `?__draft=off`. A value that doesn't parse is ignored, as if it were
45
+ * The version a request carries (a draft pointer, or a published release's
46
+ * commit SHA) with its preview's date, tests and campaigns (`parseVersion`):
47
+ * `?__draft=` from the URL first, then the `__deco_draft`
48
+ * cookie. `null` when neither is present, or when the URL says
49
+ * `?__draft=off`. A value that doesn't parse is ignored, as if it were
32
50
  * absent: a stray `?__draft=junk` link or a mangled cookie gets the release,
33
- * never an error from `cms.forDraft`.
51
+ * never an error from `cms.client`.
34
52
  */
35
- export declare function readDraftPointer(request: RequestLike): string | null;
53
+ export declare function readVersion(request: RequestLike): RequestVersion | null;
36
54
  /**
37
55
  * The `Set-Cookie` value for a request whose URL carries `?__draft=`: one that
38
- * stores the pointer, or one that expires the cookie when the value is `off`
56
+ * stores the version (a draft pointer or a release's commit SHA), or one that expires the cookie when the value is `off`
39
57
  * (how the site editor ends a preview). `null` on every other request, and for
40
58
  * a pointer that doesn't parse, so garbage never lands in the cookie.
41
59
  *
@@ -46,4 +64,5 @@ export declare function readDraftPointer(request: RequestLike): string | null;
46
64
  export declare function draftCookieFor(request: RequestLike): string | null;
47
65
  /** Whether the request's URL says `?__draft=off`: the cookie that ends a preview is set on any host. */
48
66
  export declare function endsPreview(request: RequestLike): boolean;
67
+ export {};
49
68
  //# sourceMappingURL=draft.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"draft.d.ts","sourceRoot":"","sources":["../../src/v8/draft.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,YAAY,EAAiB,WAAW,EAAE,MAAM,YAAY,CAAC;AAK3E,oHAAoH;AACpH,eAAO,MAAM,WAAW,YAAY,CAAC;AAarC;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,YAAY,GAAG,IAAI,CAoBrF;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,CAiBhE;AA8ED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAMpE;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAMlE;AAED,wGAAwG;AACxG,wBAAgB,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAEzD"}
1
+ {"version":3,"file":"draft.d.ts","sourceRoot":"","sources":["../../src/v8/draft.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,YAAY,EAAiB,WAAW,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAK3F,oHAAoH;AACpH,eAAO,MAAM,WAAW,YAAY,CAAC;AAsBrC,2EAA2E;AAC3E,KAAK,aAAa,GAAG;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,YAAY,CAAA;CAAE,CAAC;AAElG;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAItE;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,cAAc,GAAG,IAAI,CAsBpF;AAsCD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,YAAY,GAAG,IAAI,CAoBrF;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,CAiBhE;AA0GD;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc,GAAG,IAAI,CAMvE;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAMlE;AAED,wGAAwG;AACxG,wBAAgB,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAEzD"}
package/dist/v8/draft.js CHANGED
@@ -11,12 +11,114 @@ const VERSION_RE = /^[A-Za-z0-9._-]{1,64}$/;
11
11
  const PATH_RE = /^\/[A-Za-z0-9/_.%~=&?-]*$/;
12
12
  const MAX_POINTER_LENGTH = 4096;
13
13
  const VARIANT_PARAM = "__variant=";
14
+ const AT_PARAM = "__at=";
15
+ const TEST_PARAM = "__test=";
16
+ const CAMPAIGN_PARAM = "__campaign=";
17
+ /** The parameters of a preview link that aren't part of the version. */
18
+ const PREVIEW_PARAMS = [AT_PARAM, TEST_PARAM, CAMPAIGN_PARAM];
19
+ /** An ISO 8601 date-time with its offset (`Z` or `±hh:mm`): the moment a preview shows. */
20
+ const AT_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d{1,9})?)?(Z|[+-]\d{2}:\d{2})$/;
14
21
  const INDEX_RE = /^(0|[1-9][0-9]{0,3})$/;
22
+ /** A published release: its git commit SHA (SHA-1, 40 lowercase hex). */
23
+ const REVISION_RE = /^[0-9a-f]{40}$/;
24
+ /**
25
+ * What `cms.client({ version })` reads: a published release's commit SHA (40
26
+ * lowercase hex, nothing after it) or a draft pointer. `null` for anything
27
+ * else, a preview link's `__at`, `__test` or `__campaign` included: those
28
+ * are the client's `date`, `experiments` and `campaigns` (`parseVersion`).
29
+ */
30
+ export function parseClientVersion(value) {
31
+ if (REVISION_RE.test(value))
32
+ return { kind: "revision", sha: value };
33
+ const pointer = parseDraftPointer(value);
34
+ return pointer === null ? null : { kind: "draft", pointer };
35
+ }
36
+ /**
37
+ * A Studio link's value (what `?__draft=` and the draft cookie carry): the
38
+ * version, a draft pointer or a published release's commit SHA, and the
39
+ * preview's moment and switched tests and campaigns, lifted out of its query
40
+ * as the client's `date`, `experiments` and `campaigns`. `null` for a value
41
+ * that is neither, or whose preview parameters don't parse (a second `__at`,
42
+ * a state other than `on` or `off`). The last `__test` or `__campaign` for a
43
+ * name wins. Spread it into `cms.client()`.
44
+ */
45
+ export function parseVersion(value) {
46
+ if (typeof value !== "string" || value.length === 0 || value.length > MAX_POINTER_LENGTH) {
47
+ return null;
48
+ }
49
+ const head = value.indexOf("?");
50
+ if (REVISION_RE.test(head === -1 ? value : value.slice(0, head))) {
51
+ if (head === -1)
52
+ return { version: value };
53
+ const preview = liftPreview(value.slice(head + 1));
54
+ // After a SHA, only the preview's own parameters.
55
+ if (preview === null || preview.kept.length > 0)
56
+ return null;
57
+ return { version: value.slice(0, head), ...preview.options };
58
+ }
59
+ const at = value.lastIndexOf("@");
60
+ if (at <= 0)
61
+ return null;
62
+ const location = value.slice(0, at);
63
+ const q = location.indexOf("?");
64
+ if (q === -1)
65
+ return parseDraftPointer(value) === null ? null : { version: value };
66
+ const preview = liftPreview(location.slice(q + 1));
67
+ if (preview === null)
68
+ return null;
69
+ const query = preview.kept.length === 0 ? "" : `?${preview.kept.join("&")}`;
70
+ const version = `${location.slice(0, q)}${query}${value.slice(at)}`;
71
+ return parseDraftPointer(version) === null ? null : { version, ...preview.options };
72
+ }
73
+ /** A query's preview parameters, read, and the other parameters, kept as they are. */
74
+ function liftPreview(query) {
75
+ const kept = [];
76
+ let at;
77
+ let experiments;
78
+ let campaigns;
79
+ for (const param of query.split("&")) {
80
+ if (param.startsWith(AT_PARAM)) {
81
+ const value = decodeParam(param.slice(AT_PARAM.length));
82
+ if (at !== undefined || value === null || !AT_RE.test(value))
83
+ return null;
84
+ if (Number.isNaN(Date.parse(value)))
85
+ return null;
86
+ at = value;
87
+ }
88
+ else if (param.startsWith(TEST_PARAM)) {
89
+ const test = decodeSwitch(param.slice(TEST_PARAM.length));
90
+ if (test === null)
91
+ return null;
92
+ experiments ??= Object.create(null);
93
+ experiments[test.name] = test.on;
94
+ }
95
+ else if (param.startsWith(CAMPAIGN_PARAM)) {
96
+ const campaign = decodeSwitch(param.slice(CAMPAIGN_PARAM.length));
97
+ if (campaign === null)
98
+ return null;
99
+ campaigns ??= Object.create(null);
100
+ campaigns[campaign.name] = campaign.on;
101
+ }
102
+ else if (param !== "") {
103
+ kept.push(param);
104
+ }
105
+ }
106
+ const options = {};
107
+ if (at !== undefined)
108
+ options.date = new Date(Date.parse(at));
109
+ if (experiments !== undefined)
110
+ options.experiments = experiments;
111
+ if (campaigns !== undefined)
112
+ options.campaigns = campaigns;
113
+ return { kept, options };
114
+ }
15
115
  /**
16
116
  * Parses a pointer, strictly: `null` on a scheme, a stray `@`, an unrooted
17
- * path, an odd character in the host or version, or a port out of range. The
18
- * host is lowercased (DNS names are case-insensitive); path and version are
19
- * kept as they are.
117
+ * path, an odd character in the host or version, a port out of range, or a
118
+ * preview link's `__at`, `__test` or `__campaign` left in its query (they
119
+ * aren't part of a version: `parseVersion` lifts them out). The host is
120
+ * lowercased (DNS names are case-insensitive); path and version are kept as
121
+ * they are.
20
122
  */
21
123
  export function parseDraftPointer(raw) {
22
124
  if (typeof raw !== "string" || raw.length === 0 || raw.length > MAX_POINTER_LENGTH)
@@ -40,9 +142,10 @@ export function parseDraftPointer(raw) {
40
142
  const split = splitVariants(path);
41
143
  if (split === null)
42
144
  return null;
43
- return split.variants.length === 0
44
- ? { host, path, version }
45
- : { host, path: split.path, version, variants: split.variants };
145
+ const pointer = { host, path: split.path, version };
146
+ if (split.variants.length > 0)
147
+ pointer.variants = split.variants;
148
+ return pointer;
46
149
  }
47
150
  /**
48
151
  * Builds a pointer from its parts: the inverse of {@link parseDraftPointer}.
@@ -64,7 +167,11 @@ export function formatDraftPointer(pointer) {
64
167
  }
65
168
  return `${parsed.host}${path}@${parsed.version}`;
66
169
  }
67
- /** The path without its `__variant` parameters, and the variants they force; `null` on a bad one. */
170
+ /**
171
+ * The path without its `__variant` parameters, and the variants they force.
172
+ * `null` on one that doesn't parse, or on a preview link's `__at`, `__test`
173
+ * or `__campaign`.
174
+ */
68
175
  function splitVariants(path) {
69
176
  const q = path.indexOf("?");
70
177
  if (q === -1)
@@ -72,18 +179,41 @@ function splitVariants(path) {
72
179
  const kept = [];
73
180
  const variants = [];
74
181
  for (const param of path.slice(q + 1).split("&")) {
75
- if (!param.startsWith(VARIANT_PARAM)) {
76
- kept.push(param);
77
- continue;
182
+ if (param.startsWith(VARIANT_PARAM)) {
183
+ const variant = decodeVariant(param.slice(VARIANT_PARAM.length));
184
+ if (variant === null)
185
+ return null;
186
+ variants.push(variant);
78
187
  }
79
- const variant = decodeVariant(param.slice(VARIANT_PARAM.length));
80
- if (variant === null)
188
+ else if (PREVIEW_PARAMS.some((prefix) => param.startsWith(prefix))) {
81
189
  return null;
82
- variants.push(variant);
190
+ }
191
+ else {
192
+ kept.push(param);
193
+ }
83
194
  }
84
195
  const base = path.slice(0, q);
85
196
  return { path: kept.length === 0 ? base : `${base}?${kept.join("&")}`, variants };
86
197
  }
198
+ /** `<name>=on|off`: the state after the last `=`, the test's or campaign's name before it. */
199
+ function decodeSwitch(encoded) {
200
+ const raw = decodeParam(encoded);
201
+ if (raw === null)
202
+ return null;
203
+ const eq = raw.lastIndexOf("=");
204
+ const state = raw.slice(eq + 1);
205
+ if (eq <= 0 || (state !== "on" && state !== "off"))
206
+ return null;
207
+ return { name: raw.slice(0, eq), on: state === "on" };
208
+ }
209
+ function decodeParam(encoded) {
210
+ try {
211
+ return decodeURIComponent(encoded);
212
+ }
213
+ catch {
214
+ return null;
215
+ }
216
+ }
87
217
  /** `<block>@<path>=<index>`: the index after the last `=`, the block before the last `@`. */
88
218
  function decodeVariant(encoded) {
89
219
  let raw;
@@ -104,8 +234,11 @@ function decodeVariant(encoded) {
104
234
  return { block: raw.slice(0, at), path, index: Number(index) };
105
235
  }
106
236
  function encodeVariant({ block, path, index }) {
237
+ return encodeParam(`${block}@${path}=${index}`);
238
+ }
239
+ function encodeParam(value) {
107
240
  // encodeURIComponent leaves !'()* as they are; the pointer's path doesn't allow them.
108
- return encodeURIComponent(`${block}@${path}=${index}`).replace(/[!'()*]/g, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`);
241
+ return encodeURIComponent(value).replace(/[!'()*]/g, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`);
109
242
  }
110
243
  function plainVariant({ block, path, index }) {
111
244
  return { block, path, index };
@@ -146,24 +279,26 @@ function normalizeIPv6Host(authority) {
146
279
  return `${host}${rest}`;
147
280
  }
148
281
  /**
149
- * The draft pointer a request carries: `?__draft=` from the URL first, then
150
- * the `__deco_draft` cookie. `null` when neither is present, or when the URL
151
- * says `?__draft=off`. A value that doesn't parse is ignored, as if it were
282
+ * The version a request carries (a draft pointer, or a published release's
283
+ * commit SHA) with its preview's date, tests and campaigns (`parseVersion`):
284
+ * `?__draft=` from the URL first, then the `__deco_draft`
285
+ * cookie. `null` when neither is present, or when the URL says
286
+ * `?__draft=off`. A value that doesn't parse is ignored, as if it were
152
287
  * absent: a stray `?__draft=junk` link or a mangled cookie gets the release,
153
- * never an error from `cms.forDraft`.
288
+ * never an error from `cms.client`.
154
289
  */
155
- export function readDraftPointer(request) {
290
+ export function readVersion(request) {
156
291
  const param = draftParam(request);
157
292
  if (param === DRAFT_OFF)
158
293
  return null;
159
- if (param && parseDraftPointer(param) !== null)
160
- return param;
161
- const cookie = readCookie(request.headers.get("cookie"), DRAFT_COOKIE);
162
- return cookie && parseDraftPointer(cookie) !== null ? cookie : null;
294
+ const fromLink = param ? parseVersion(param) : null;
295
+ if (fromLink !== null)
296
+ return fromLink;
297
+ return parseVersion(readCookie(request.headers.get("cookie"), DRAFT_COOKIE));
163
298
  }
164
299
  /**
165
300
  * The `Set-Cookie` value for a request whose URL carries `?__draft=`: one that
166
- * stores the pointer, or one that expires the cookie when the value is `off`
301
+ * stores the version (a draft pointer or a release's commit SHA), or one that expires the cookie when the value is `off`
167
302
  * (how the site editor ends a preview). `null` on every other request, and for
168
303
  * a pointer that doesn't parse, so garbage never lands in the cookie.
169
304
  *
@@ -177,7 +312,7 @@ export function draftCookieFor(request) {
177
312
  return null;
178
313
  if (param === DRAFT_OFF)
179
314
  return serializeCookie("", ["Max-Age=0"]);
180
- if (parseDraftPointer(param) === null)
315
+ if (parseVersion(param) === null)
181
316
  return null;
182
317
  return serializeCookie(encodeURIComponent(param), []);
183
318
  }
@@ -1 +1 @@
1
- {"version":3,"file":"draft.js","sourceRoot":"","sources":["../../src/v8/draft.ts"],"names":[],"mappings":"AAaA,6GAA6G;AAC7G,MAAM,YAAY,GAAG,cAAc,CAAC;AAEpC,oHAAoH;AACpH,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC;AACrC,MAAM,SAAS,GAAG,KAAK,CAAC;AAExB,mEAAmE;AACnE,MAAM,OAAO,GAAG,mEAAmE,CAAC;AACpF,MAAM,OAAO,GAAG,cAAc,CAAC;AAC/B,MAAM,UAAU,GAAG,wBAAwB,CAAC;AAC5C,wFAAwF;AACxF,MAAM,OAAO,GAAG,2BAA2B,CAAC;AAC5C,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,MAAM,aAAa,GAAG,YAAY,CAAC;AACnC,MAAM,QAAQ,GAAG,uBAAuB,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAA8B;IAC9D,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,KA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Y,IAAI,KAAK,EAAE;QAC1B,QAAQ;QACR,GAAG,KAAK;QACR,UAAU;QACV,QAAQ;QACR,eAAe;QACf,aAAa;KACd,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,SAAS,UAAU,CAAC,OAAoB;IACtC,IAAI,CAAC;QACH,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAChF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,MAAqB,EAAE,IAAY;IACrD,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACrC,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,EAAE,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,IAAI;YAAE,SAAS;QAC7D,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACxC,IAAI,CAAC;YACH,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC;QACnC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * `@decocms/blocks/experiments`: who is in which A/B test, decided the same
3
+ * way on a server, in a browser and in a mobile app.
4
+ *
5
+ * The percentages are content (the saved block `experiments`, of the built-in
6
+ * type `split-traffic`); a decision is arithmetic over the visitor's id. What
7
+ * a visitor gets is never stored: it is recomputed from the percentage and the
8
+ * id, so one id serves every test (each roll hashes `name:id`), a new test
9
+ * needs no new state and two tests are independent.
10
+ *
11
+ * Pure functions over values and strings: no React, no framework, no module
12
+ * state, no environment reads, no network. Nothing here is called for you:
13
+ * the app reads the visitor its own way (`readVisitor` on the web, device
14
+ * storage in an app) and hands it to `cms.client({ visitor })`; the built-in
15
+ * `split-traffic` calls `assign` with it.
16
+ *
17
+ * The stored form is v7's `deco_segment` (the same fields and encoding; names
18
+ * sorted by code unit rather than v7's `localeCompare`) plus an `id`, so a
19
+ * visitor carried over from v7 keeps the group v7 put them in and analytics
20
+ * keeps reading the cookie it already reads. A visitor is written once, when
21
+ * it has no id; v7's stored assignments are read and honoured, never rewritten.
22
+ */
23
+ /** The saved block `experiments`: each test's name and the whole percentage of visitors in it, 0–100. */
24
+ export type Experiments = Record<string, number>;
25
+ /** What a visitor got: each test's name and whether they are in it. */
26
+ export type Assignments = Record<string, boolean>;
27
+ /**
28
+ * Who is visiting: an id every assignment is computed from, plus the
29
+ * assignments v7 stored (`active`, `inactiveDrawn`, `pct`, `exp`), which are honoured and
30
+ * carried, never rewritten.
31
+ */
32
+ export interface Visitor {
33
+ /**
34
+ * 16 random bytes as 22 base64url characters, drawn once per visitor. `""`
35
+ * for a visitor with no id of its own (one built from a cache key's
36
+ * assignments), which is in only the tests `active` names.
37
+ */
38
+ id: string;
39
+ /** Tests v7 put this visitor in. */
40
+ active: string[];
41
+ /** Tests v7 left this visitor out of. */
42
+ inactiveDrawn: string[];
43
+ /** The percentage each of v7's decisions was made at. */
44
+ pct: Record<string, number>;
45
+ /** v7's N-way decisions. Never read; carried as they are. */
46
+ exp?: Record<string, string>;
47
+ }
48
+ /** What `readVisitor` answers. */
49
+ export interface VisitorFromRequest {
50
+ /** The request's visitor, or a new one when it had none. */
51
+ visitor: Visitor;
52
+ /**
53
+ * The `Set-Cookie` line to send when the visitor had no id (a first visit,
54
+ * or a v7 visitor getting theirs); `null` otherwise. Never send it from a
55
+ * preview.
56
+ */
57
+ cookie: string | null;
58
+ }
59
+ /** The fields of a request `readVisitor` reads: a `Request`, or anything with its `headers`. */
60
+ interface RequestWithHeaders {
61
+ url?: string;
62
+ headers: {
63
+ get(name: string): string | null;
64
+ };
65
+ }
66
+ /** A new visitor: a fresh id and nothing else. */
67
+ export declare function newVisitor(): Visitor;
68
+ /**
69
+ * A visitor out of its stored form (what `serializeVisitor` wrote, the value
70
+ * of the `deco_segment` cookie). `null` when the text is missing, doesn't
71
+ * read, or holds no id (a v7 value: `readVisitor` gives it one, keeping its
72
+ * decisions). Never throws.
73
+ */
74
+ export declare function parseVisitor(text: string | null | undefined): Visitor | null;
75
+ /**
76
+ * The visitor's stored form: v7's `btoa(encodeURIComponent(JSON.stringify(...)))`,
77
+ * with a fixed key order and names sorted, so two equal visitors give
78
+ * byte-equal values. Under 2KB: past it, v7's entries are dropped, first the
79
+ * ones the id reproduces anyway.
80
+ */
81
+ export declare function serializeVisitor(visitor: Visitor): string;
82
+ /**
83
+ * The web helper: the visitor out of a request's `deco_segment` cookie, and
84
+ * the `Set-Cookie` line to send back when it had no id (a first visit, or a
85
+ * v7 visitor, whose decisions are kept). The cookie isn't `HttpOnly` (the
86
+ * analytics script reads it, as in v7) and is `Secure` unless the request
87
+ * came over plain http. Never throws.
88
+ */
89
+ export declare function readVisitor(request: RequestWithHeaders): VisitorFromRequest;
90
+ /**
91
+ * This visitor's answer for every test: `true` when they are in it.
92
+ *
93
+ * A visitor is in a test when their roll for it (a fixed number in [0, 100)
94
+ * from the test's name and their id) is under its percentage, so 0 puts
95
+ * nobody in, 100 everybody, and raising a percentage only adds people. A
96
+ * fractional percentage is rounded. An assignment v7 stored is honoured while
97
+ * the percentage it was made at holds (a missing or `-1` percentage, v7's
98
+ * "any", included); once it moves, a v7 visitor in a test that grows stays
99
+ * in and one out of a test that shrinks stays out. Without a visitor every
100
+ * test is `false`. A visitor without an id (`""`, as a page built from a
101
+ * cache key's assignments gives one) has no roll: it is in exactly the tests
102
+ * its stored `active` and `pct` keep it in. Entries that aren't finite numbers are
103
+ * left out. Pure; never throws.
104
+ */
105
+ export declare function assign(experiments: Experiments | null | undefined, visitor: Visitor | null | undefined): Assignments;
106
+ export {};
107
+ //# sourceMappingURL=experiments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"experiments.d.ts","sourceRoot":"","sources":["../../src/v8/experiments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,yGAAyG;AACzG,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEjD,uEAAuE;AACvE,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAElD;;;;GAIG;AACH,MAAM,WAAW,OAAO;IACtB;;;;OAIG;IACH,EAAE,EAAE,MAAM,CAAC;IACX,oCAAoC;IACpC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,yCAAyC;IACzC,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,yDAAyD;IACzD,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,6DAA6D;IAC7D,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED,kCAAkC;AAClC,MAAM,WAAW,kBAAkB;IACjC,4DAA4D;IAC5D,OAAO,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,gGAAgG;AAChG,UAAU,kBAAkB;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,EAAE;QAAE,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;CAC/C;AAkFD,kDAAkD;AAClD,wBAAgB,UAAU,IAAI,OAAO,CAEpC;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EA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