@usethrottle/builder-react 0.5.1 → 0.5.3

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/dist/server.d.cts CHANGED
@@ -48,9 +48,16 @@ type LoadBuilderPageOptions = ClientOptions & {
48
48
  declare const isOwnPath: (path: unknown) => path is string;
49
49
  /**
50
50
  * Reads the page that answers at its own path, or the redirect of an older path of a page (`slug_redirects`).
51
- * Uses the client's `pages.getByPath` when it has one; otherwise the page list (its summaries carry `path`), which
52
- * also answers a 308 for a listed slug whose own path has moved. An older path that is no longer any page's slug
53
- * is only found by `getByPath` (no Worker call is made per unknown path). Rejects with `BuilderNotFoundError` when nothing is at the path.
51
+ * Stateless: nothing is remembered between requests or shared between clients and locales. The page list (cached,
52
+ * `pages`-tagged, read with this request's client and locale; its summaries carry `path`) answers an own path, and
53
+ * a 308 for a listed slug whose own path has moved. A path outside the list never reaches the Builder: an unknown
54
+ * path costs one cached list read, so crawlers cannot amplify into upstream requests. A page answer is used only
55
+ * when it lives at exactly this own path (`isOwnPath` and equal), so no other path becomes a code route.
56
+ * Rejects with `BuilderNotFoundError` when nothing is at the path.
57
+ *
58
+ * TODO(B-BACKEND): old paths (`slug_redirects`, E25e, including multi-segment ones) cannot be answered here, because
59
+ * neither the pages list nor the site answer exposes them. When the list summaries carry `redirectFrom` paths, look
60
+ * the request path up in that set and only then call `pages.getByPath` (which already exists on the clients).
54
61
  */
55
62
  declare function loadBuilderPageByPath(options: Omit<LoadBuilderPageOptions, 'slug'> & {
56
63
  path: string;
@@ -87,6 +94,106 @@ declare function loadBuilderTemplate(options: LoadBuilderTemplateOptions): Promi
87
94
  meta: TemplateAnswer['meta'];
88
95
  }>;
89
96
 
97
+ /** JSON-LD builders (spec §11.4). Each answers a plain object with the schema.org required properties. */
98
+ type JsonLd = Record<string, unknown>;
99
+ declare function organizationJsonLd(input: {
100
+ name: string;
101
+ url: string;
102
+ logo?: string | undefined;
103
+ sameAs?: readonly string[] | undefined;
104
+ }): {
105
+ sameAs?: string[] | undefined;
106
+ logo?: string | undefined;
107
+ '@context': "https://schema.org";
108
+ '@type': "Organization";
109
+ name: string;
110
+ url: string;
111
+ };
112
+ /** `WebSite` with a `SearchAction` that targets the store's search route (`/search?q=` by default). */
113
+ declare function webSiteJsonLd(input: {
114
+ name: string;
115
+ url: string;
116
+ searchPath?: string | undefined;
117
+ }): {
118
+ '@context': "https://schema.org";
119
+ '@type': "WebSite";
120
+ name: string;
121
+ url: string;
122
+ potentialAction: {
123
+ '@type': "SearchAction";
124
+ target: {
125
+ '@type': "EntryPoint";
126
+ urlTemplate: string;
127
+ };
128
+ 'query-input': string;
129
+ };
130
+ };
131
+ declare function breadcrumbJsonLd(items: readonly {
132
+ name: string;
133
+ url: string;
134
+ }[]): {
135
+ '@context': "https://schema.org";
136
+ '@type': "BreadcrumbList";
137
+ itemListElement: {
138
+ '@type': "ListItem";
139
+ position: number;
140
+ name: string;
141
+ item: string;
142
+ }[];
143
+ };
144
+ declare function faqJsonLd(items: readonly {
145
+ question: string;
146
+ answer: string;
147
+ }[]): {
148
+ '@context': "https://schema.org";
149
+ '@type': "FAQPage";
150
+ mainEntity: {
151
+ '@type': "Question";
152
+ name: string;
153
+ acceptedAnswer: {
154
+ '@type': "Answer";
155
+ text: string;
156
+ };
157
+ }[];
158
+ };
159
+ /** `VideoObject`. Google requires name, thumbnailUrl and uploadDate: the caller emits it only when it has all three. */
160
+ declare function videoJsonLd(input: {
161
+ name: string;
162
+ thumbnailUrl: string;
163
+ uploadDate: string;
164
+ description?: string | undefined;
165
+ embedUrl?: string | undefined;
166
+ contentUrl?: string | undefined;
167
+ }): {
168
+ contentUrl?: string | undefined;
169
+ embedUrl?: string | undefined;
170
+ thumbnailUrl: string[];
171
+ uploadDate: string;
172
+ description?: string | undefined;
173
+ '@context': "https://schema.org";
174
+ '@type': "VideoObject";
175
+ name: string;
176
+ };
177
+ /** `LocalBusiness` (or `Store`): name and address are the required properties. */
178
+ declare function localBusinessJsonLd(input: {
179
+ name: string;
180
+ url: string;
181
+ address: string;
182
+ phone?: string | undefined;
183
+ openingHours?: readonly string[] | undefined;
184
+ type?: 'LocalBusiness' | 'Store' | undefined;
185
+ }): {
186
+ openingHours?: string[] | undefined;
187
+ telephone?: string | undefined;
188
+ '@context': "https://schema.org";
189
+ '@type': "LocalBusiness" | "Store";
190
+ name: string;
191
+ url: string;
192
+ address: string;
193
+ };
194
+ /** The text for `<script type="application/ld+json">`: `<` is escaped so a value cannot close the element. */
195
+ declare function jsonLdString(value: unknown): string;
196
+
90
197
  type BuilderSitemapOptions = ClientOptions & {
91
198
  /** The store's origin (`https://shop.example.com`). The Builder does not publish it, so it is required: without a valid one the sitemap is empty. */
92
199
  storeUrl?: string;
@@ -170,88 +277,6 @@ declare function builderRobots(site: SeoSite, options?: SeoSiteOptions): string;
170
277
  /** `builderRobots` as a `text/plain` response, for an `app/robots.txt/route.ts` handler (`export const GET = ...`). */
171
278
  declare function builderRobotsResponse(site: SeoSite, options?: SeoSiteOptions): Response;
172
279
 
173
- /** JSON-LD builders (spec §11.4). Each answers a plain object with the schema.org required properties. */
174
- type JsonLd = Record<string, unknown>;
175
- declare function organizationJsonLd(input: {
176
- name: string;
177
- url: string;
178
- logo?: string | undefined;
179
- sameAs?: readonly string[] | undefined;
180
- }): {
181
- sameAs?: string[] | undefined;
182
- logo?: string | undefined;
183
- '@context': "https://schema.org";
184
- '@type': "Organization";
185
- name: string;
186
- url: string;
187
- };
188
- /** `WebSite` with a `SearchAction` that targets the store's search route (`/search?q=` by default). */
189
- declare function webSiteJsonLd(input: {
190
- name: string;
191
- url: string;
192
- searchPath?: string | undefined;
193
- }): {
194
- '@context': "https://schema.org";
195
- '@type': "WebSite";
196
- name: string;
197
- url: string;
198
- potentialAction: {
199
- '@type': "SearchAction";
200
- target: {
201
- '@type': "EntryPoint";
202
- urlTemplate: string;
203
- };
204
- 'query-input': string;
205
- };
206
- };
207
- declare function breadcrumbJsonLd(items: readonly {
208
- name: string;
209
- url: string;
210
- }[]): {
211
- '@context': "https://schema.org";
212
- '@type': "BreadcrumbList";
213
- itemListElement: {
214
- '@type': "ListItem";
215
- position: number;
216
- name: string;
217
- item: string;
218
- }[];
219
- };
220
- declare function faqJsonLd(items: readonly {
221
- question: string;
222
- answer: string;
223
- }[]): {
224
- '@context': "https://schema.org";
225
- '@type': "FAQPage";
226
- mainEntity: {
227
- '@type': "Question";
228
- name: string;
229
- acceptedAnswer: {
230
- '@type': "Answer";
231
- text: string;
232
- };
233
- }[];
234
- };
235
- /** `LocalBusiness` (or `Store`): name and address are the required properties. */
236
- declare function localBusinessJsonLd(input: {
237
- name: string;
238
- url: string;
239
- address: string;
240
- phone?: string | undefined;
241
- openingHours?: readonly string[] | undefined;
242
- type?: 'LocalBusiness' | 'Store' | undefined;
243
- }): {
244
- openingHours?: string[] | undefined;
245
- telephone?: string | undefined;
246
- '@context': "https://schema.org";
247
- '@type': "LocalBusiness" | "Store";
248
- name: string;
249
- url: string;
250
- address: string;
251
- };
252
- /** The text for `<script type="application/ld+json">`: `<` is escaped so a value cannot close the element. */
253
- declare function jsonLdString(value: unknown): string;
254
-
255
280
  type BuilderStaticParamsOptions = ClientOptions & {
256
281
  /** The dynamic segment of the route, as in `createBuilderPage({ fromParams })`. Default `handle`. */
257
282
  param?: string;
@@ -271,4 +296,4 @@ type BuilderStaticParamsOptions = ClientOptions & {
271
296
  */
272
297
  declare function builderStaticParams(options: BuilderStaticParamsOptions): Promise<Record<string, string>[]>;
273
298
 
274
- export { type BuilderSitemapExtras, type BuilderSitemapOptions, type BuilderStaticParamsOptions, DEFAULT_ROBOTS_DISALLOW, type JsonLd, type LoadBuilderPageOptions, type LoadBuilderTemplateOptions, type LoadSiteOptions, LoadedPage, LoadedRedirect, LoadedSite, SITEMAP_MAX_URLS, type SeoSite, type SeoSiteOptions, type SitemapContributor, type SitemapContributorContext, type SitemapEntry, type SitemapToggles, breadcrumbJsonLd, builderRobots, builderRobotsResponse, builderSitemap, builderSitemapParts, builderStaticParams, faqJsonLd, isOwnPath, jsonLdString, loadBuilderPage, loadBuilderPageByPath, loadBuilderTemplate, loadOwnPagePaths, loadSite, localBusinessJsonLd, organizationJsonLd, siteOriginOf, webSiteJsonLd };
299
+ export { type BuilderSitemapExtras, type BuilderSitemapOptions, type BuilderStaticParamsOptions, DEFAULT_ROBOTS_DISALLOW, type JsonLd, type LoadBuilderPageOptions, type LoadBuilderTemplateOptions, type LoadSiteOptions, LoadedPage, LoadedRedirect, LoadedSite, SITEMAP_MAX_URLS, type SeoSite, type SeoSiteOptions, type SitemapContributor, type SitemapContributorContext, type SitemapEntry, type SitemapToggles, breadcrumbJsonLd, builderRobots, builderRobotsResponse, builderSitemap, builderSitemapParts, builderStaticParams, faqJsonLd, isOwnPath, jsonLdString, loadBuilderPage, loadBuilderPageByPath, loadBuilderTemplate, loadOwnPagePaths, loadSite, localBusinessJsonLd, organizationJsonLd, siteOriginOf, videoJsonLd, webSiteJsonLd };
package/dist/server.d.ts CHANGED
@@ -48,9 +48,16 @@ type LoadBuilderPageOptions = ClientOptions & {
48
48
  declare const isOwnPath: (path: unknown) => path is string;
49
49
  /**
50
50
  * Reads the page that answers at its own path, or the redirect of an older path of a page (`slug_redirects`).
51
- * Uses the client's `pages.getByPath` when it has one; otherwise the page list (its summaries carry `path`), which
52
- * also answers a 308 for a listed slug whose own path has moved. An older path that is no longer any page's slug
53
- * is only found by `getByPath` (no Worker call is made per unknown path). Rejects with `BuilderNotFoundError` when nothing is at the path.
51
+ * Stateless: nothing is remembered between requests or shared between clients and locales. The page list (cached,
52
+ * `pages`-tagged, read with this request's client and locale; its summaries carry `path`) answers an own path, and
53
+ * a 308 for a listed slug whose own path has moved. A path outside the list never reaches the Builder: an unknown
54
+ * path costs one cached list read, so crawlers cannot amplify into upstream requests. A page answer is used only
55
+ * when it lives at exactly this own path (`isOwnPath` and equal), so no other path becomes a code route.
56
+ * Rejects with `BuilderNotFoundError` when nothing is at the path.
57
+ *
58
+ * TODO(B-BACKEND): old paths (`slug_redirects`, E25e, including multi-segment ones) cannot be answered here, because
59
+ * neither the pages list nor the site answer exposes them. When the list summaries carry `redirectFrom` paths, look
60
+ * the request path up in that set and only then call `pages.getByPath` (which already exists on the clients).
54
61
  */
55
62
  declare function loadBuilderPageByPath(options: Omit<LoadBuilderPageOptions, 'slug'> & {
56
63
  path: string;
@@ -87,6 +94,106 @@ declare function loadBuilderTemplate(options: LoadBuilderTemplateOptions): Promi
87
94
  meta: TemplateAnswer['meta'];
88
95
  }>;
89
96
 
97
+ /** JSON-LD builders (spec §11.4). Each answers a plain object with the schema.org required properties. */
98
+ type JsonLd = Record<string, unknown>;
99
+ declare function organizationJsonLd(input: {
100
+ name: string;
101
+ url: string;
102
+ logo?: string | undefined;
103
+ sameAs?: readonly string[] | undefined;
104
+ }): {
105
+ sameAs?: string[] | undefined;
106
+ logo?: string | undefined;
107
+ '@context': "https://schema.org";
108
+ '@type': "Organization";
109
+ name: string;
110
+ url: string;
111
+ };
112
+ /** `WebSite` with a `SearchAction` that targets the store's search route (`/search?q=` by default). */
113
+ declare function webSiteJsonLd(input: {
114
+ name: string;
115
+ url: string;
116
+ searchPath?: string | undefined;
117
+ }): {
118
+ '@context': "https://schema.org";
119
+ '@type': "WebSite";
120
+ name: string;
121
+ url: string;
122
+ potentialAction: {
123
+ '@type': "SearchAction";
124
+ target: {
125
+ '@type': "EntryPoint";
126
+ urlTemplate: string;
127
+ };
128
+ 'query-input': string;
129
+ };
130
+ };
131
+ declare function breadcrumbJsonLd(items: readonly {
132
+ name: string;
133
+ url: string;
134
+ }[]): {
135
+ '@context': "https://schema.org";
136
+ '@type': "BreadcrumbList";
137
+ itemListElement: {
138
+ '@type': "ListItem";
139
+ position: number;
140
+ name: string;
141
+ item: string;
142
+ }[];
143
+ };
144
+ declare function faqJsonLd(items: readonly {
145
+ question: string;
146
+ answer: string;
147
+ }[]): {
148
+ '@context': "https://schema.org";
149
+ '@type': "FAQPage";
150
+ mainEntity: {
151
+ '@type': "Question";
152
+ name: string;
153
+ acceptedAnswer: {
154
+ '@type': "Answer";
155
+ text: string;
156
+ };
157
+ }[];
158
+ };
159
+ /** `VideoObject`. Google requires name, thumbnailUrl and uploadDate: the caller emits it only when it has all three. */
160
+ declare function videoJsonLd(input: {
161
+ name: string;
162
+ thumbnailUrl: string;
163
+ uploadDate: string;
164
+ description?: string | undefined;
165
+ embedUrl?: string | undefined;
166
+ contentUrl?: string | undefined;
167
+ }): {
168
+ contentUrl?: string | undefined;
169
+ embedUrl?: string | undefined;
170
+ thumbnailUrl: string[];
171
+ uploadDate: string;
172
+ description?: string | undefined;
173
+ '@context': "https://schema.org";
174
+ '@type': "VideoObject";
175
+ name: string;
176
+ };
177
+ /** `LocalBusiness` (or `Store`): name and address are the required properties. */
178
+ declare function localBusinessJsonLd(input: {
179
+ name: string;
180
+ url: string;
181
+ address: string;
182
+ phone?: string | undefined;
183
+ openingHours?: readonly string[] | undefined;
184
+ type?: 'LocalBusiness' | 'Store' | undefined;
185
+ }): {
186
+ openingHours?: string[] | undefined;
187
+ telephone?: string | undefined;
188
+ '@context': "https://schema.org";
189
+ '@type': "LocalBusiness" | "Store";
190
+ name: string;
191
+ url: string;
192
+ address: string;
193
+ };
194
+ /** The text for `<script type="application/ld+json">`: `<` is escaped so a value cannot close the element. */
195
+ declare function jsonLdString(value: unknown): string;
196
+
90
197
  type BuilderSitemapOptions = ClientOptions & {
91
198
  /** The store's origin (`https://shop.example.com`). The Builder does not publish it, so it is required: without a valid one the sitemap is empty. */
92
199
  storeUrl?: string;
@@ -170,88 +277,6 @@ declare function builderRobots(site: SeoSite, options?: SeoSiteOptions): string;
170
277
  /** `builderRobots` as a `text/plain` response, for an `app/robots.txt/route.ts` handler (`export const GET = ...`). */
171
278
  declare function builderRobotsResponse(site: SeoSite, options?: SeoSiteOptions): Response;
172
279
 
173
- /** JSON-LD builders (spec §11.4). Each answers a plain object with the schema.org required properties. */
174
- type JsonLd = Record<string, unknown>;
175
- declare function organizationJsonLd(input: {
176
- name: string;
177
- url: string;
178
- logo?: string | undefined;
179
- sameAs?: readonly string[] | undefined;
180
- }): {
181
- sameAs?: string[] | undefined;
182
- logo?: string | undefined;
183
- '@context': "https://schema.org";
184
- '@type': "Organization";
185
- name: string;
186
- url: string;
187
- };
188
- /** `WebSite` with a `SearchAction` that targets the store's search route (`/search?q=` by default). */
189
- declare function webSiteJsonLd(input: {
190
- name: string;
191
- url: string;
192
- searchPath?: string | undefined;
193
- }): {
194
- '@context': "https://schema.org";
195
- '@type': "WebSite";
196
- name: string;
197
- url: string;
198
- potentialAction: {
199
- '@type': "SearchAction";
200
- target: {
201
- '@type': "EntryPoint";
202
- urlTemplate: string;
203
- };
204
- 'query-input': string;
205
- };
206
- };
207
- declare function breadcrumbJsonLd(items: readonly {
208
- name: string;
209
- url: string;
210
- }[]): {
211
- '@context': "https://schema.org";
212
- '@type': "BreadcrumbList";
213
- itemListElement: {
214
- '@type': "ListItem";
215
- position: number;
216
- name: string;
217
- item: string;
218
- }[];
219
- };
220
- declare function faqJsonLd(items: readonly {
221
- question: string;
222
- answer: string;
223
- }[]): {
224
- '@context': "https://schema.org";
225
- '@type': "FAQPage";
226
- mainEntity: {
227
- '@type': "Question";
228
- name: string;
229
- acceptedAnswer: {
230
- '@type': "Answer";
231
- text: string;
232
- };
233
- }[];
234
- };
235
- /** `LocalBusiness` (or `Store`): name and address are the required properties. */
236
- declare function localBusinessJsonLd(input: {
237
- name: string;
238
- url: string;
239
- address: string;
240
- phone?: string | undefined;
241
- openingHours?: readonly string[] | undefined;
242
- type?: 'LocalBusiness' | 'Store' | undefined;
243
- }): {
244
- openingHours?: string[] | undefined;
245
- telephone?: string | undefined;
246
- '@context': "https://schema.org";
247
- '@type': "LocalBusiness" | "Store";
248
- name: string;
249
- url: string;
250
- address: string;
251
- };
252
- /** The text for `<script type="application/ld+json">`: `<` is escaped so a value cannot close the element. */
253
- declare function jsonLdString(value: unknown): string;
254
-
255
280
  type BuilderStaticParamsOptions = ClientOptions & {
256
281
  /** The dynamic segment of the route, as in `createBuilderPage({ fromParams })`. Default `handle`. */
257
282
  param?: string;
@@ -271,4 +296,4 @@ type BuilderStaticParamsOptions = ClientOptions & {
271
296
  */
272
297
  declare function builderStaticParams(options: BuilderStaticParamsOptions): Promise<Record<string, string>[]>;
273
298
 
274
- export { type BuilderSitemapExtras, type BuilderSitemapOptions, type BuilderStaticParamsOptions, DEFAULT_ROBOTS_DISALLOW, type JsonLd, type LoadBuilderPageOptions, type LoadBuilderTemplateOptions, type LoadSiteOptions, LoadedPage, LoadedRedirect, LoadedSite, SITEMAP_MAX_URLS, type SeoSite, type SeoSiteOptions, type SitemapContributor, type SitemapContributorContext, type SitemapEntry, type SitemapToggles, breadcrumbJsonLd, builderRobots, builderRobotsResponse, builderSitemap, builderSitemapParts, builderStaticParams, faqJsonLd, isOwnPath, jsonLdString, loadBuilderPage, loadBuilderPageByPath, loadBuilderTemplate, loadOwnPagePaths, loadSite, localBusinessJsonLd, organizationJsonLd, siteOriginOf, webSiteJsonLd };
299
+ export { type BuilderSitemapExtras, type BuilderSitemapOptions, type BuilderStaticParamsOptions, DEFAULT_ROBOTS_DISALLOW, type JsonLd, type LoadBuilderPageOptions, type LoadBuilderTemplateOptions, type LoadSiteOptions, LoadedPage, LoadedRedirect, LoadedSite, SITEMAP_MAX_URLS, type SeoSite, type SeoSiteOptions, type SitemapContributor, type SitemapContributorContext, type SitemapEntry, type SitemapToggles, breadcrumbJsonLd, builderRobots, builderRobotsResponse, builderSitemap, builderSitemapParts, builderStaticParams, faqJsonLd, isOwnPath, jsonLdString, loadBuilderPage, loadBuilderPageByPath, loadBuilderTemplate, loadOwnPagePaths, loadSite, localBusinessJsonLd, organizationJsonLd, siteOriginOf, videoJsonLd, webSiteJsonLd };
package/dist/server.js CHANGED
@@ -20,9 +20,10 @@ import {
20
20
  partOf,
21
21
  siteLocales,
22
22
  staticDataFor,
23
+ videoJsonLd,
23
24
  warnOnce,
24
25
  webSiteJsonLd
25
- } from "./chunk-G6I4RIXU.js";
26
+ } from "./chunk-HE6MD2RZ.js";
26
27
 
27
28
  // src/server/load-site.ts
28
29
  import { BuilderUnavailableError } from "@usethrottle/builder";
@@ -291,5 +292,6 @@ export {
291
292
  localBusinessJsonLd,
292
293
  organizationJsonLd,
293
294
  siteOriginOf,
295
+ videoJsonLd,
294
296
  webSiteJsonLd
295
297
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usethrottle/builder-react",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "Renders a published Throttle Builder page document as React in a merchant's store: responsive CSS, header, footer, slots and the site design provider.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -57,8 +57,8 @@
57
57
  "nextjs"
58
58
  ],
59
59
  "dependencies": {
60
- "@usethrottle/builder": "^0.6.0",
61
- "@usethrottle/builder-schema": "^0.4.0",
60
+ "@usethrottle/builder": "^0.7.0",
61
+ "@usethrottle/builder-schema": "^0.4.2",
62
62
  "@usethrottle/ui": "^0.1.3"
63
63
  },
64
64
  "peerDependencies": {