@ebitex/content-sdk 0.18.81 → 0.19.84

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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,58 @@
1
+ import type { LocaleTreeNode, SiteAddressing } from '../types.js';
2
+ /**
3
+ * Spec 712-locale-addressing — the pure half of how the SDK addresses a site whose locale lives in
4
+ * the address. No I/O here: the client supplies the site's `addressing` (from `GET /sites`) and the
5
+ * locale tree (from `GET /locales`), and these decide.
6
+ *
7
+ * The rule the whole spec rests on: **if a node's address varies by locale, the locale is determined
8
+ * by the address.** So under a non-`invariant` site the SDK never *chooses* a locale for `/path` —
9
+ * the path's prefix or the page's host already says it, and the server refuses a `locale=` beside
10
+ * it. The client still needs to *know* that locale, for the calls that have no address to carry one
11
+ * (a component, a list, a stream) and for its own cache keys; that is what these functions derive.
12
+ */
13
+ /** A strategy the SDK acts on. `invariant` is never one: an absent member and an explicit `invariant` are the same thing. */
14
+ export type ActiveAddressing = Exclude<SiteAddressing, {
15
+ strategy: 'invariant';
16
+ }>;
17
+ /**
18
+ * The site's strategy, or `undefined` for `invariant` — which is what an absent member, an explicit
19
+ * `{ strategy: 'invariant' }`, and any shape this SDK version does not recognize all mean. The last
20
+ * case is deliberate: a future strategy an old SDK cannot address is better treated as today's
21
+ * behaviour, which the server then refuses loudly, than guessed at.
22
+ */
23
+ export declare function activeAddressing(site: {
24
+ addressing?: unknown;
25
+ } | undefined): ActiveAddressing | undefined;
26
+ /** The organization's root locale — `GET /locales`' own root, the locale the `default` slot speaks for (spec 712 confirm D). */
27
+ export declare function rootLocale(tree: readonly LocaleTreeNode[]): string | undefined;
28
+ /**
29
+ * `pathPrefix`: the leading segment when it names a locale in the tree (case-insensitive, returned
30
+ * in the tree's own casing), else the root locale — a bare address is the default locale's, whether
31
+ * `prefixDefaultLocale` is set or not (when it is, the server redirects the bare address rather than
32
+ * serving it, but the locale it names is the same). A leading segment naming no locale is simply
33
+ * part of the path, exactly as the server parses it.
34
+ */
35
+ export declare function localeFromPrefix(pathname: string, tree: readonly LocaleTreeNode[]): string | undefined;
36
+ /**
37
+ * `localeHost`: the locale the site maps this hostname to, or `undefined` when it maps none — the
38
+ * caller then falls back to the root locale. Case-insensitive, hostname only (the server stores
39
+ * hosts port-less).
40
+ */
41
+ export declare function localeForHost(addressing: Extract<ActiveAddressing, {
42
+ strategy: 'localeHost';
43
+ }>, hostname: string | undefined): string | undefined;
44
+ /**
45
+ * The part of a cache key that stands where the locale stands for an `invariant` site. Under a
46
+ * non-`invariant` site the *address* determines the locale, so the address is the identity: the
47
+ * path (already in every key) for `pathPrefix`, the path plus the host for `localeHost`. Keying on
48
+ * the address rather than on a derived locale is also what lets `peekLocation` rebuild the key
49
+ * synchronously, with no locale tree in hand.
50
+ *
51
+ * Both markers start with `@`, which no locale code does, so a key written for a site before its
52
+ * strategy flipped can never be read back as one written after.
53
+ *
54
+ * `undefined` for `localeHost` with no hostname — there is no address to key on, and no request to
55
+ * make either.
56
+ */
57
+ export declare function addressKey(addressing: ActiveAddressing, hostname: string | undefined): string | undefined;
58
+ //# sourceMappingURL=addressing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addressing.d.ts","sourceRoot":"","sources":["../../src/content/addressing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjE;;;;;;;;;;GAUG;AAEH,6HAA6H;AAC7H,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,cAAc,EAAE;IAAE,QAAQ,EAAE,WAAW,CAAA;CAAE,CAAC,CAAA;AAEjF;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,GAAG,gBAAgB,GAAG,SAAS,CAuBzG;AAED,gIAAgI;AAChI,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,GAAG,SAAS,CAE9E;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,GAAG,SAAS,CAWtG;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,UAAU,EAAE,OAAO,CAAC,gBAAgB,EAAE;IAAE,QAAQ,EAAE,YAAY,CAAA;CAAE,CAAC,EACjE,QAAQ,EAAE,MAAM,GAAG,SAAS,GAC3B,MAAM,GAAG,SAAS,CAOpB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAMzG"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * The site's strategy, or `undefined` for `invariant` — which is what an absent member, an explicit
3
+ * `{ strategy: 'invariant' }`, and any shape this SDK version does not recognize all mean. The last
4
+ * case is deliberate: a future strategy an old SDK cannot address is better treated as today's
5
+ * behaviour, which the server then refuses loudly, than guessed at.
6
+ */
7
+ export function activeAddressing(site) {
8
+ const addressing = site?.addressing;
9
+ if (typeof addressing !== 'object' || addressing === null) {
10
+ return undefined;
11
+ }
12
+ const candidate = addressing;
13
+ if (candidate.strategy === 'pathPrefix') {
14
+ return { strategy: 'pathPrefix', prefixDefaultLocale: candidate.prefixDefaultLocale === true };
15
+ }
16
+ if (candidate.strategy === 'localeHost' && Array.isArray(candidate.hosts)) {
17
+ const hosts = candidate.hosts.filter((entry) => typeof entry === 'object' &&
18
+ entry !== null &&
19
+ typeof entry.host === 'string' &&
20
+ typeof entry.locale === 'string');
21
+ return { strategy: 'localeHost', hosts: hosts.map(({ host, locale }) => ({ host, locale })) };
22
+ }
23
+ return undefined;
24
+ }
25
+ /** The organization's root locale — `GET /locales`' own root, the locale the `default` slot speaks for (spec 712 confirm D). */
26
+ export function rootLocale(tree) {
27
+ return tree.find((node) => node.parentCode === null)?.code;
28
+ }
29
+ /**
30
+ * `pathPrefix`: the leading segment when it names a locale in the tree (case-insensitive, returned
31
+ * in the tree's own casing), else the root locale — a bare address is the default locale's, whether
32
+ * `prefixDefaultLocale` is set or not (when it is, the server redirects the bare address rather than
33
+ * serving it, but the locale it names is the same). A leading segment naming no locale is simply
34
+ * part of the path, exactly as the server parses it.
35
+ */
36
+ export function localeFromPrefix(pathname, tree) {
37
+ const first = pathname.split('/').find((segment) => segment !== '');
38
+ if (first !== undefined) {
39
+ const wanted = first.toLowerCase();
40
+ const match = tree.find((node) => node.code.toLowerCase() === wanted);
41
+ if (match !== undefined) {
42
+ return match.code;
43
+ }
44
+ }
45
+ return rootLocale(tree);
46
+ }
47
+ /**
48
+ * `localeHost`: the locale the site maps this hostname to, or `undefined` when it maps none — the
49
+ * caller then falls back to the root locale. Case-insensitive, hostname only (the server stores
50
+ * hosts port-less).
51
+ */
52
+ export function localeForHost(addressing, hostname) {
53
+ if (!hostname) {
54
+ return undefined;
55
+ }
56
+ const wanted = hostname.toLowerCase();
57
+ return addressing.hosts.find((entry) => entry.host.toLowerCase() === wanted)?.locale;
58
+ }
59
+ /**
60
+ * The part of a cache key that stands where the locale stands for an `invariant` site. Under a
61
+ * non-`invariant` site the *address* determines the locale, so the address is the identity: the
62
+ * path (already in every key) for `pathPrefix`, the path plus the host for `localeHost`. Keying on
63
+ * the address rather than on a derived locale is also what lets `peekLocation` rebuild the key
64
+ * synchronously, with no locale tree in hand.
65
+ *
66
+ * Both markers start with `@`, which no locale code does, so a key written for a site before its
67
+ * strategy flipped can never be read back as one written after.
68
+ *
69
+ * `undefined` for `localeHost` with no hostname — there is no address to key on, and no request to
70
+ * make either.
71
+ */
72
+ export function addressKey(addressing, hostname) {
73
+ if (addressing.strategy === 'pathPrefix') {
74
+ return '@prefix';
75
+ }
76
+ return hostname ? `@host:${hostname.toLowerCase()}` : undefined;
77
+ }
78
+ //# sourceMappingURL=addressing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addressing.js","sourceRoot":"","sources":["../../src/content/addressing.ts"],"names":[],"mappings":"AAiBA;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAA0C;IACzE,MAAM,UAAU,GAAG,IAAI,EAAE,UAAU,CAAA;IACnC,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;QAC1D,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,MAAM,SAAS,GAAG,UAAqC,CAAA;IACvD,IAAI,SAAS,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;QACxC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,mBAAmB,EAAE,SAAS,CAAC,mBAAmB,KAAK,IAAI,EAAE,CAAA;IAChG,CAAC;IAED,IAAI,SAAS,CAAC,QAAQ,KAAK,YAAY,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1E,MAAM,KAAK,GAAI,SAAS,CAAC,KAAmB,CAAC,MAAM,CACjD,CAAC,KAAK,EAA6C,EAAE,CACnD,OAAO,KAAK,KAAK,QAAQ;YACzB,KAAK,KAAK,IAAI;YACd,OAAQ,KAAiC,CAAC,IAAI,KAAK,QAAQ;YAC3D,OAAQ,KAAiC,CAAC,MAAM,KAAK,QAAQ,CAChE,CAAA;QACD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAA;IAC/F,CAAC;IAED,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,gIAAgI;AAChI,MAAM,UAAU,UAAU,CAAC,IAA+B;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CAAA;IAClB,CAAC;IAED,OAAO,QAAQ,CAAC,CAAC,CAAC,SAAS,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AACjE,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { type DeliveryClient, type DeliveryClientOptions } from '../delivery/client.js';
2
- import type { ComponentValue, ContentDocument, ContextBag, ExpandedReference, LocaleTreeNode, NavigationInclude, PresentationEnvelope, SiteSummary } from '../types.js';
2
+ import type { ComponentValue, ContentDocument, ContextBag, ExpandedReference, LocaleTreeNode, NavigationInclude, PresentationEnvelope, SiteAddressing, SiteSummary } from '../types.js';
3
3
  import { type CacheOptions } from './cache.js';
4
4
  import { type NavigationTree } from './navigation.js';
5
5
  import { type ResolveStrategy } from './strategy.js';
@@ -12,6 +12,14 @@ export interface NavigationOptions {
12
12
  /** Bypasses the in-memory cache for this call. */
13
13
  fresh?: boolean;
14
14
  signal?: AbortSignal;
15
+ /**
16
+ * Spec 712-locale-addressing: the page this navigation is for, under a site with a locale
17
+ * addressing strategy. It supplies the host a `localeHost` site needs for a path anchor, and the
18
+ * locale a node-id (or absent) anchor is asked in. Defaults to the browser's own location, so a
19
+ * browser never needs it; a server must pass the request's URL, since the SDK never reads a
20
+ * forwarded host (spec 355). Ignored for an `invariant` site.
21
+ */
22
+ location?: LocationLike;
15
23
  }
16
24
  export interface ContentClientOptions extends DeliveryClientOptions {
17
25
  /**
@@ -74,6 +82,8 @@ export interface ResolvedSite {
74
82
  rootNodeId: string;
75
83
  name?: string;
76
84
  hosts?: string[];
85
+ /** Spec 712 — present when the site was looked up from `GET /sites` and has a locale addressing strategy. */
86
+ addressing?: SiteAddressing;
77
87
  }
78
88
  export interface PresentationExperience {
79
89
  kind: 'presentation';
@@ -87,8 +97,20 @@ export interface PresentationExperience {
87
97
  */
88
98
  title?: string;
89
99
  titleSource?: 'content' | 'name';
100
+ /**
101
+ * Spec 712 — the locale slot the path was found in, carried through from the delivery response.
102
+ * Present only for a site with a locale addressing strategy, and `default` when the locale's own
103
+ * slot is not materialized yet.
104
+ */
105
+ localeSlot?: string;
90
106
  presentation: PresentationEnvelope;
91
107
  site: ResolvedSite;
108
+ /**
109
+ * The locale this page was resolved in. For an `invariant` site, the one the client chose (the
110
+ * `locale` option, else the browser's languages) and sent. For a site with a locale addressing
111
+ * strategy (spec 712), the one the **address** names — its prefix or its host — as the server
112
+ * reports it: set `<html lang>` from this. `undefined` only when nothing names one.
113
+ */
92
114
  locale: string | undefined;
93
115
  strategy: ResolveStrategy;
94
116
  }
@@ -103,8 +125,14 @@ export interface NotFoundExperience {
103
125
  path: string;
104
126
  }
105
127
  export type ExperienceResult = PresentationExperience | RedirectExperience | NotFoundExperience;
128
+ /**
129
+ * A path, a full URL, a `URL`, or any `{ pathname }` — a react-router location, `window.location`.
130
+ * `hostname` is read, when present, only for a `localeHost` site (spec 712), where the host is the
131
+ * locale; a bare path then falls back to the browser's own hostname.
132
+ */
106
133
  export type LocationLike = string | URL | {
107
134
  pathname: string;
135
+ hostname?: string;
108
136
  };
109
137
  /** A persisted `resolveLocation` result (spec 413) — only ever a `presentation`, per SPEC.md's "what is persisted" rule. */
110
138
  export interface PersistedExperience {
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/content/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAK7G,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EAEjB,oBAAoB,EAEpB,WAAW,EACZ,MAAM,aAAa,CAAA;AACpB,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,YAAY,CAAA;AAG5D,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAG3E,OAAO,EAA4C,KAAK,eAAe,EAAE,MAAM,eAAe,CAAA;AAmB9F,sGAAsG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