@garagem-ai/site-sdk 0.4.1 → 0.4.2
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/README.md +21 -34
- package/dist/index.d.mts +51 -1
- package/dist/index.d.ts +51 -1
- package/dist/index.js +128 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +119 -0
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +212 -179
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +155 -122
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +13 -0
- package/src/react/listing-card.tsx +64 -52
- package/src/react/search-chrome.tsx +14 -12
- package/src/react/styles/search-chrome-css.generated.ts +1 -1
- package/src/react/styles/search-chrome-styles.tsx +22 -3
- package/src/studio-contract.ts +138 -0
package/README.md
CHANGED
|
@@ -245,35 +245,26 @@ option on `createGaragemClient`.
|
|
|
245
245
|
|
|
246
246
|
Headless URL/search helpers live on the main entry (`readPublicSearch`,
|
|
247
247
|
`hrefForPathFilters`, `toListingCardModel`, …). The React adapter is a
|
|
248
|
-
separate subpath — peer `react` + `next
|
|
248
|
+
separate subpath — peer `react` + `next`.
|
|
249
249
|
|
|
250
|
-
|
|
251
|
-
|
|
250
|
+
Studio codegen follows `STUDIO_SDK_CONTRACT`: pin
|
|
251
|
+
`@garagem-ai/site-sdk` to `minNpmVersion` and import only
|
|
252
|
+
`reactExports` (`SearchPage`, `ListingCard`, `usePublicSearch`,
|
|
253
|
+
`ResultsSkeleton` on the Studio pin). Preview, open-in-new-tab, and
|
|
254
|
+
published `next build` all resolve that tarball. Do **not** import npm
|
|
255
|
+
CSS (`@garagem-ai/site-sdk/react/search.css`) in Studio.
|
|
252
256
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
}: {
|
|
256
|
-
children: React.ReactNode;
|
|
257
|
-
}) {
|
|
258
|
-
return (
|
|
259
|
-
<html lang="pt-BR">
|
|
260
|
-
<body>
|
|
261
|
-
<SearchChromeStyles />
|
|
262
|
-
{children}
|
|
263
|
-
</body>
|
|
264
|
-
</html>
|
|
265
|
-
);
|
|
266
|
-
}
|
|
267
|
-
```
|
|
257
|
+
`SearchPage`, `ListingCard`, and `ResultsSkeleton` inject the chrome
|
|
258
|
+
stylesheet (JS `<style>` tag). Layout tags are optional.
|
|
268
259
|
|
|
269
260
|
```tsx
|
|
270
261
|
"use client";
|
|
271
262
|
import { Suspense } from "react";
|
|
272
|
-
import { SearchPage,
|
|
263
|
+
import { SearchPage, ResultsSkeleton } from "@garagem-ai/site-sdk/react";
|
|
273
264
|
|
|
274
265
|
export default function ImoveisPage() {
|
|
275
266
|
return (
|
|
276
|
-
<Suspense fallback={<
|
|
267
|
+
<Suspense fallback={<ResultsSkeleton />}>
|
|
277
268
|
<SearchPage
|
|
278
269
|
siteId={process.env.NEXT_PUBLIC_GARAGEM_SITE_ID!}
|
|
279
270
|
variant="toolbar"
|
|
@@ -283,20 +274,16 @@ export default function ImoveisPage() {
|
|
|
283
274
|
}
|
|
284
275
|
```
|
|
285
276
|
|
|
286
|
-
`variant` is `toolbar` (default), `dialog`, or `sidebar`.
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
`icons`, and `data-slot`. Home and search should share `ListingCard`.
|
|
297
|
-
The search H1 is SEO stable: hit count is a sibling `<span>`, not inside
|
|
298
|
-
`<h1>`. Presentation tokens stay framework-free on the main entry so
|
|
299
|
-
other adapters can reuse them.
|
|
277
|
+
`variant` is `toolbar` (default), `dialog`, or `sidebar`. Customize with
|
|
278
|
+
CSS variables (`SEARCH_CSS_VARS` / `SEARCH_CSS_RECIPE` in `globals.css`),
|
|
279
|
+
`classNames`, `icons`, and `data-slot`. Home and search should share
|
|
280
|
+
`ListingCard`. The search H1 is SEO stable: hit count is a sibling
|
|
281
|
+
`<span>`, not inside `<h1>`. Presentation tokens stay framework-free on
|
|
282
|
+
the main entry so other adapters can reuse them.
|
|
283
|
+
|
|
284
|
+
Hand-written Next apps that prefer a layout tag or a padded search
|
|
285
|
+
fallback can import those after they ship on npm; until then they are
|
|
286
|
+
not part of the Studio pin.
|
|
300
287
|
|
|
301
288
|
## What's NOT in this release
|
|
302
289
|
|
package/dist/index.d.mts
CHANGED
|
@@ -232,6 +232,56 @@ declare function isStudioPreviewHost(host: string): boolean;
|
|
|
232
232
|
*/
|
|
233
233
|
declare function resolvePublicSiteId(options: ResolvePublicSiteIdOptions): Promise<string>;
|
|
234
234
|
|
|
235
|
+
/**
|
|
236
|
+
* Studio ↔ npm contract. Prompt, completeness, and recipes must read this
|
|
237
|
+
* object — do not keep a second list of required `@garagem-ai/site-sdk/react`
|
|
238
|
+
* names in apps/site.
|
|
239
|
+
*
|
|
240
|
+
* `minNpmVersion` is the tarball v0 actually installs. Optional exports exist
|
|
241
|
+
* in git and may already be on npm, but Studio codegen must not name them
|
|
242
|
+
* while chromeStrategy is self-inject (v0 copies identifiers; a layout tag
|
|
243
|
+
* also breaks the pancake stack).
|
|
244
|
+
*/
|
|
245
|
+
declare const STUDIO_SDK_PACKAGE: "@garagem-ai/site-sdk";
|
|
246
|
+
declare const STUDIO_SDK_CONTRACT: {
|
|
247
|
+
readonly package: "@garagem-ai/site-sdk";
|
|
248
|
+
/**
|
|
249
|
+
* Exact pin for generated Studio sites. Must be ≥ `selfInjectSince` so
|
|
250
|
+
* prompts that skip the layout chrome tag match the tarball v0 installs.
|
|
251
|
+
* This PR’s changeset publishes that tarball as 0.4.2 — do not generate
|
|
252
|
+
* against this floor until Version Packages is on npm.
|
|
253
|
+
*/
|
|
254
|
+
readonly minNpmVersion: "0.4.2";
|
|
255
|
+
/** First release where ListingCard and ResultsSkeleton inject the sheet. */
|
|
256
|
+
readonly selfInjectSince: "0.4.2";
|
|
257
|
+
readonly chromeStrategy: "self-inject";
|
|
258
|
+
readonly reactExports: readonly ["SearchPage", "ListingCard", "usePublicSearch", "ResultsSkeleton"];
|
|
259
|
+
/**
|
|
260
|
+
* Names that exist in git / the unpublished patch. Completeness treats an
|
|
261
|
+
* import as `sdk-export-mismatch` when the generated pin is older than
|
|
262
|
+
* `since`. Studio prompts must not mention these names at all (even as
|
|
263
|
+
* “never import”) — v0 copies the identifier and the preview ESM loader
|
|
264
|
+
* throws FatalRendererError.
|
|
265
|
+
*/
|
|
266
|
+
readonly optionalReactExports: {
|
|
267
|
+
readonly SearchPageFallback: "0.4.1";
|
|
268
|
+
readonly SearchChromeStyles: "0.4.1";
|
|
269
|
+
};
|
|
270
|
+
readonly forbiddenImports: readonly ["@garagem-ai/site-sdk/react/search.css"];
|
|
271
|
+
};
|
|
272
|
+
type StudioSdkContract = typeof STUDIO_SDK_CONTRACT;
|
|
273
|
+
declare function coerceNpmVersion(raw: unknown): string | null;
|
|
274
|
+
declare function compareSemver(a: string, b: string): number;
|
|
275
|
+
declare function parseReactSdkNamedImports(source: string): string[];
|
|
276
|
+
declare function unavailableReactImports(source: string, pin: string): string[];
|
|
277
|
+
declare function studioSdkPinInstruction(): string;
|
|
278
|
+
declare function studioChromeInstruction(): string;
|
|
279
|
+
/**
|
|
280
|
+
* Tokens that must not appear in Studio codegen (prompts, recipes, repair).
|
|
281
|
+
* v0 copies identifiers it sees, even inside “never import X”.
|
|
282
|
+
*/
|
|
283
|
+
declare function studioCodegenContractViolations(text: string): string[];
|
|
284
|
+
|
|
235
285
|
interface CreateGaragemClientOptions {
|
|
236
286
|
/** Garagem API base URL. Defaults to `https://app.garagem.ai`. */
|
|
237
287
|
baseUrl?: string;
|
|
@@ -327,4 +377,4 @@ interface GaragemClient {
|
|
|
327
377
|
*/
|
|
328
378
|
declare function createGaragemClient(options?: CreateGaragemClientOptions): GaragemClient;
|
|
329
379
|
|
|
330
|
-
export { AppliedSearchChange, AppliedSearchQuery, CmsCollection, CmsEntriesResult, CmsEntry, type CreateGaragemClientOptions, type FetchLike, type GaragemClient, GaragemSdkError, type GetCmsCollectionOptions, type GetCmsCollectionsOptions, type GetCmsEntriesOptions, type GetCmsEntryOptions, type GetListingOptions, type GetListingsOptions, type GetSearchUiOptions, type GetSimilarListingsOptions, type GetSiteOptions, ListingDetail, ListingFilters, ListingsResult, type LocationFilterInput, QueryListingsFilters, type QueryListingsOptions, QueryListingsParams, QueryListingsResult, RequestNextOptions, type ResolvePublicSiteIdOptions, SEARCH_CSS_RECIPE, SEARCH_CSS_VARS, type SearchListingsOptions, SearchListingsParams, SearchListingsResult, SearchPathFilters, SearchUi, SearchUiDictionary, SimilarListingsResult, Site, composeSearchPublicHref, composeSearchPublicPath, createGaragemClient, formatAreaM2, formatGroupedInteger, formatListingPrice, getCmsCollection, getCmsCollections, getCmsEntries, getCmsEntry, getListing, getListings, getSearchUi, getSimilarListings, getSite, isStudioPreviewHost, listingBusinessLabel, listingLookupKey, listingPublicPath, mergeAppliedSearchQueryIntoSearch, parseAppliedSearchQuery, parseGroupedInteger, parseSearchPublicPath, pathFiltersToQueryFilters, pathLocationToFilterInput, queryListings, reduceAppliedSearchQuery, resolvePublicSiteId, searchListings, serializeAppliedSearchQuery };
|
|
380
|
+
export { AppliedSearchChange, AppliedSearchQuery, CmsCollection, CmsEntriesResult, CmsEntry, type CreateGaragemClientOptions, type FetchLike, type GaragemClient, GaragemSdkError, type GetCmsCollectionOptions, type GetCmsCollectionsOptions, type GetCmsEntriesOptions, type GetCmsEntryOptions, type GetListingOptions, type GetListingsOptions, type GetSearchUiOptions, type GetSimilarListingsOptions, type GetSiteOptions, ListingDetail, ListingFilters, ListingsResult, type LocationFilterInput, QueryListingsFilters, type QueryListingsOptions, QueryListingsParams, QueryListingsResult, RequestNextOptions, type ResolvePublicSiteIdOptions, SEARCH_CSS_RECIPE, SEARCH_CSS_VARS, STUDIO_SDK_CONTRACT, STUDIO_SDK_PACKAGE, type SearchListingsOptions, SearchListingsParams, SearchListingsResult, SearchPathFilters, SearchUi, SearchUiDictionary, SimilarListingsResult, Site, type StudioSdkContract, coerceNpmVersion, compareSemver, composeSearchPublicHref, composeSearchPublicPath, createGaragemClient, formatAreaM2, formatGroupedInteger, formatListingPrice, getCmsCollection, getCmsCollections, getCmsEntries, getCmsEntry, getListing, getListings, getSearchUi, getSimilarListings, getSite, isStudioPreviewHost, listingBusinessLabel, listingLookupKey, listingPublicPath, mergeAppliedSearchQueryIntoSearch, parseAppliedSearchQuery, parseGroupedInteger, parseReactSdkNamedImports, parseSearchPublicPath, pathFiltersToQueryFilters, pathLocationToFilterInput, queryListings, reduceAppliedSearchQuery, resolvePublicSiteId, searchListings, serializeAppliedSearchQuery, studioChromeInstruction, studioCodegenContractViolations, studioSdkPinInstruction, unavailableReactImports };
|
package/dist/index.d.ts
CHANGED
|
@@ -232,6 +232,56 @@ declare function isStudioPreviewHost(host: string): boolean;
|
|
|
232
232
|
*/
|
|
233
233
|
declare function resolvePublicSiteId(options: ResolvePublicSiteIdOptions): Promise<string>;
|
|
234
234
|
|
|
235
|
+
/**
|
|
236
|
+
* Studio ↔ npm contract. Prompt, completeness, and recipes must read this
|
|
237
|
+
* object — do not keep a second list of required `@garagem-ai/site-sdk/react`
|
|
238
|
+
* names in apps/site.
|
|
239
|
+
*
|
|
240
|
+
* `minNpmVersion` is the tarball v0 actually installs. Optional exports exist
|
|
241
|
+
* in git and may already be on npm, but Studio codegen must not name them
|
|
242
|
+
* while chromeStrategy is self-inject (v0 copies identifiers; a layout tag
|
|
243
|
+
* also breaks the pancake stack).
|
|
244
|
+
*/
|
|
245
|
+
declare const STUDIO_SDK_PACKAGE: "@garagem-ai/site-sdk";
|
|
246
|
+
declare const STUDIO_SDK_CONTRACT: {
|
|
247
|
+
readonly package: "@garagem-ai/site-sdk";
|
|
248
|
+
/**
|
|
249
|
+
* Exact pin for generated Studio sites. Must be ≥ `selfInjectSince` so
|
|
250
|
+
* prompts that skip the layout chrome tag match the tarball v0 installs.
|
|
251
|
+
* This PR’s changeset publishes that tarball as 0.4.2 — do not generate
|
|
252
|
+
* against this floor until Version Packages is on npm.
|
|
253
|
+
*/
|
|
254
|
+
readonly minNpmVersion: "0.4.2";
|
|
255
|
+
/** First release where ListingCard and ResultsSkeleton inject the sheet. */
|
|
256
|
+
readonly selfInjectSince: "0.4.2";
|
|
257
|
+
readonly chromeStrategy: "self-inject";
|
|
258
|
+
readonly reactExports: readonly ["SearchPage", "ListingCard", "usePublicSearch", "ResultsSkeleton"];
|
|
259
|
+
/**
|
|
260
|
+
* Names that exist in git / the unpublished patch. Completeness treats an
|
|
261
|
+
* import as `sdk-export-mismatch` when the generated pin is older than
|
|
262
|
+
* `since`. Studio prompts must not mention these names at all (even as
|
|
263
|
+
* “never import”) — v0 copies the identifier and the preview ESM loader
|
|
264
|
+
* throws FatalRendererError.
|
|
265
|
+
*/
|
|
266
|
+
readonly optionalReactExports: {
|
|
267
|
+
readonly SearchPageFallback: "0.4.1";
|
|
268
|
+
readonly SearchChromeStyles: "0.4.1";
|
|
269
|
+
};
|
|
270
|
+
readonly forbiddenImports: readonly ["@garagem-ai/site-sdk/react/search.css"];
|
|
271
|
+
};
|
|
272
|
+
type StudioSdkContract = typeof STUDIO_SDK_CONTRACT;
|
|
273
|
+
declare function coerceNpmVersion(raw: unknown): string | null;
|
|
274
|
+
declare function compareSemver(a: string, b: string): number;
|
|
275
|
+
declare function parseReactSdkNamedImports(source: string): string[];
|
|
276
|
+
declare function unavailableReactImports(source: string, pin: string): string[];
|
|
277
|
+
declare function studioSdkPinInstruction(): string;
|
|
278
|
+
declare function studioChromeInstruction(): string;
|
|
279
|
+
/**
|
|
280
|
+
* Tokens that must not appear in Studio codegen (prompts, recipes, repair).
|
|
281
|
+
* v0 copies identifiers it sees, even inside “never import X”.
|
|
282
|
+
*/
|
|
283
|
+
declare function studioCodegenContractViolations(text: string): string[];
|
|
284
|
+
|
|
235
285
|
interface CreateGaragemClientOptions {
|
|
236
286
|
/** Garagem API base URL. Defaults to `https://app.garagem.ai`. */
|
|
237
287
|
baseUrl?: string;
|
|
@@ -327,4 +377,4 @@ interface GaragemClient {
|
|
|
327
377
|
*/
|
|
328
378
|
declare function createGaragemClient(options?: CreateGaragemClientOptions): GaragemClient;
|
|
329
379
|
|
|
330
|
-
export { AppliedSearchChange, AppliedSearchQuery, CmsCollection, CmsEntriesResult, CmsEntry, type CreateGaragemClientOptions, type FetchLike, type GaragemClient, GaragemSdkError, type GetCmsCollectionOptions, type GetCmsCollectionsOptions, type GetCmsEntriesOptions, type GetCmsEntryOptions, type GetListingOptions, type GetListingsOptions, type GetSearchUiOptions, type GetSimilarListingsOptions, type GetSiteOptions, ListingDetail, ListingFilters, ListingsResult, type LocationFilterInput, QueryListingsFilters, type QueryListingsOptions, QueryListingsParams, QueryListingsResult, RequestNextOptions, type ResolvePublicSiteIdOptions, SEARCH_CSS_RECIPE, SEARCH_CSS_VARS, type SearchListingsOptions, SearchListingsParams, SearchListingsResult, SearchPathFilters, SearchUi, SearchUiDictionary, SimilarListingsResult, Site, composeSearchPublicHref, composeSearchPublicPath, createGaragemClient, formatAreaM2, formatGroupedInteger, formatListingPrice, getCmsCollection, getCmsCollections, getCmsEntries, getCmsEntry, getListing, getListings, getSearchUi, getSimilarListings, getSite, isStudioPreviewHost, listingBusinessLabel, listingLookupKey, listingPublicPath, mergeAppliedSearchQueryIntoSearch, parseAppliedSearchQuery, parseGroupedInteger, parseSearchPublicPath, pathFiltersToQueryFilters, pathLocationToFilterInput, queryListings, reduceAppliedSearchQuery, resolvePublicSiteId, searchListings, serializeAppliedSearchQuery };
|
|
380
|
+
export { AppliedSearchChange, AppliedSearchQuery, CmsCollection, CmsEntriesResult, CmsEntry, type CreateGaragemClientOptions, type FetchLike, type GaragemClient, GaragemSdkError, type GetCmsCollectionOptions, type GetCmsCollectionsOptions, type GetCmsEntriesOptions, type GetCmsEntryOptions, type GetListingOptions, type GetListingsOptions, type GetSearchUiOptions, type GetSimilarListingsOptions, type GetSiteOptions, ListingDetail, ListingFilters, ListingsResult, type LocationFilterInput, QueryListingsFilters, type QueryListingsOptions, QueryListingsParams, QueryListingsResult, RequestNextOptions, type ResolvePublicSiteIdOptions, SEARCH_CSS_RECIPE, SEARCH_CSS_VARS, STUDIO_SDK_CONTRACT, STUDIO_SDK_PACKAGE, type SearchListingsOptions, SearchListingsParams, SearchListingsResult, SearchPathFilters, SearchUi, SearchUiDictionary, SimilarListingsResult, Site, type StudioSdkContract, coerceNpmVersion, compareSemver, composeSearchPublicHref, composeSearchPublicPath, createGaragemClient, formatAreaM2, formatGroupedInteger, formatListingPrice, getCmsCollection, getCmsCollections, getCmsEntries, getCmsEntry, getListing, getListings, getSearchUi, getSimilarListings, getSite, isStudioPreviewHost, listingBusinessLabel, listingLookupKey, listingPublicPath, mergeAppliedSearchQueryIntoSearch, parseAppliedSearchQuery, parseGroupedInteger, parseReactSdkNamedImports, parseSearchPublicPath, pathFiltersToQueryFilters, pathLocationToFilterInput, queryListings, reduceAppliedSearchQuery, resolvePublicSiteId, searchListings, serializeAppliedSearchQuery, studioChromeInstruction, studioCodegenContractViolations, studioSdkPinInstruction, unavailableReactImports };
|
package/dist/index.js
CHANGED
|
@@ -25,11 +25,15 @@ __export(src_exports, {
|
|
|
25
25
|
SEARCH_CSS_RECIPE: () => SEARCH_CSS_RECIPE,
|
|
26
26
|
SEARCH_CSS_VARS: () => SEARCH_CSS_VARS,
|
|
27
27
|
SEARCH_SORT_RELEVANCE: () => SEARCH_SORT_RELEVANCE,
|
|
28
|
+
STUDIO_SDK_CONTRACT: () => STUDIO_SDK_CONTRACT,
|
|
29
|
+
STUDIO_SDK_PACKAGE: () => STUDIO_SDK_PACKAGE,
|
|
28
30
|
TOOLBAR_PRIMARY_FILTER_IDS: () => TOOLBAR_PRIMARY_FILTER_IDS,
|
|
29
31
|
applyPathFilter: () => applyPathFilter,
|
|
30
32
|
buildQueryListingsParams: () => buildQueryListingsParams,
|
|
31
33
|
canonicalizeSearchHref: () => canonicalizeSearchHref,
|
|
32
34
|
clearStagedPathFilters: () => clearStagedPathFilters,
|
|
35
|
+
coerceNpmVersion: () => coerceNpmVersion,
|
|
36
|
+
compareSemver: () => compareSemver,
|
|
33
37
|
composeSearchPublicHref: () => composeSearchPublicHref2,
|
|
34
38
|
composeSearchPublicPath: () => composeSearchPublicPath2,
|
|
35
39
|
countFacetChoices: () => countFacetChoices,
|
|
@@ -61,6 +65,7 @@ __export(src_exports, {
|
|
|
61
65
|
paginationPages: () => paginationPages,
|
|
62
66
|
parseAppliedSearchQuery: () => parseAppliedSearchQuery2,
|
|
63
67
|
parseGroupedInteger: () => parseGroupedInteger,
|
|
68
|
+
parseReactSdkNamedImports: () => parseReactSdkNamedImports,
|
|
64
69
|
parseSearchPublicPath: () => parseSearchPublicPath2,
|
|
65
70
|
pathFilterHasOption: () => pathFilterHasOption,
|
|
66
71
|
pathFilterValue: () => pathFilterValue,
|
|
@@ -76,8 +81,12 @@ __export(src_exports, {
|
|
|
76
81
|
searchResultsHeading: () => searchResultsHeading,
|
|
77
82
|
searchSortOptions: () => searchSortOptions,
|
|
78
83
|
serializeAppliedSearchQuery: () => serializeAppliedSearchQuery2,
|
|
84
|
+
studioChromeInstruction: () => studioChromeInstruction,
|
|
85
|
+
studioCodegenContractViolations: () => studioCodegenContractViolations,
|
|
86
|
+
studioSdkPinInstruction: () => studioSdkPinInstruction,
|
|
79
87
|
toListingCardModel: () => toListingCardModel,
|
|
80
88
|
toolbarFilterIds: () => toolbarFilterIds,
|
|
89
|
+
unavailableReactImports: () => unavailableReactImports,
|
|
81
90
|
visibleSearchFilters: () => visibleSearchFilters
|
|
82
91
|
});
|
|
83
92
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -1283,6 +1292,116 @@ async function resolvePublicSiteId(options) {
|
|
|
1283
1292
|
);
|
|
1284
1293
|
}
|
|
1285
1294
|
|
|
1295
|
+
// src/studio-contract.ts
|
|
1296
|
+
var STUDIO_SDK_PACKAGE = "@garagem-ai/site-sdk";
|
|
1297
|
+
var STUDIO_SDK_CONTRACT = {
|
|
1298
|
+
package: STUDIO_SDK_PACKAGE,
|
|
1299
|
+
/**
|
|
1300
|
+
* Exact pin for generated Studio sites. Must be ≥ `selfInjectSince` so
|
|
1301
|
+
* prompts that skip the layout chrome tag match the tarball v0 installs.
|
|
1302
|
+
* This PR’s changeset publishes that tarball as 0.4.2 — do not generate
|
|
1303
|
+
* against this floor until Version Packages is on npm.
|
|
1304
|
+
*/
|
|
1305
|
+
minNpmVersion: "0.4.2",
|
|
1306
|
+
/** First release where ListingCard and ResultsSkeleton inject the sheet. */
|
|
1307
|
+
selfInjectSince: "0.4.2",
|
|
1308
|
+
chromeStrategy: "self-inject",
|
|
1309
|
+
reactExports: [
|
|
1310
|
+
"SearchPage",
|
|
1311
|
+
"ListingCard",
|
|
1312
|
+
"usePublicSearch",
|
|
1313
|
+
"ResultsSkeleton"
|
|
1314
|
+
],
|
|
1315
|
+
/**
|
|
1316
|
+
* Names that exist in git / the unpublished patch. Completeness treats an
|
|
1317
|
+
* import as `sdk-export-mismatch` when the generated pin is older than
|
|
1318
|
+
* `since`. Studio prompts must not mention these names at all (even as
|
|
1319
|
+
* “never import”) — v0 copies the identifier and the preview ESM loader
|
|
1320
|
+
* throws FatalRendererError.
|
|
1321
|
+
*/
|
|
1322
|
+
optionalReactExports: {
|
|
1323
|
+
SearchPageFallback: "0.4.1",
|
|
1324
|
+
SearchChromeStyles: "0.4.1"
|
|
1325
|
+
},
|
|
1326
|
+
forbiddenImports: ["@garagem-ai/site-sdk/react/search.css"]
|
|
1327
|
+
};
|
|
1328
|
+
var REACT_SDK_NAMED_IMPORT_RE = /(?:^|[\n;])\s*import\s+(?!type\b)(?:type\s+)?\{([^}]+)\}\s+from\s+['"]@garagem-ai\/site-sdk\/react['"]/g;
|
|
1329
|
+
function coerceNpmVersion(raw) {
|
|
1330
|
+
if (typeof raw !== "string") return null;
|
|
1331
|
+
const match = raw.trim().match(/(\d+)\.(\d+)\.(\d+)/);
|
|
1332
|
+
return match ? `${match[1]}.${match[2]}.${match[3]}` : null;
|
|
1333
|
+
}
|
|
1334
|
+
function compareSemver(a, b) {
|
|
1335
|
+
const left = a.split(".").map((part) => Number(part));
|
|
1336
|
+
const right = b.split(".").map((part) => Number(part));
|
|
1337
|
+
for (let i = 0; i < 3; i += 1) {
|
|
1338
|
+
const delta = (left[i] ?? 0) - (right[i] ?? 0);
|
|
1339
|
+
if (delta !== 0) return delta;
|
|
1340
|
+
}
|
|
1341
|
+
return 0;
|
|
1342
|
+
}
|
|
1343
|
+
function parseReactSdkNamedImports(source) {
|
|
1344
|
+
const names = [];
|
|
1345
|
+
REACT_SDK_NAMED_IMPORT_RE.lastIndex = 0;
|
|
1346
|
+
let match;
|
|
1347
|
+
while ((match = REACT_SDK_NAMED_IMPORT_RE.exec(source)) !== null) {
|
|
1348
|
+
const body = match[1];
|
|
1349
|
+
if (!body) continue;
|
|
1350
|
+
for (const raw of body.split(",")) {
|
|
1351
|
+
const token = raw.trim();
|
|
1352
|
+
if (!token || token.startsWith("type ")) continue;
|
|
1353
|
+
const name = token.split(/\s+as\s+/)[0]?.trim();
|
|
1354
|
+
if (name) names.push(name);
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
return names;
|
|
1358
|
+
}
|
|
1359
|
+
function reactExportsAvailableAt(pin) {
|
|
1360
|
+
const available = new Set(STUDIO_SDK_CONTRACT.reactExports);
|
|
1361
|
+
for (const [name, since] of Object.entries(
|
|
1362
|
+
STUDIO_SDK_CONTRACT.optionalReactExports
|
|
1363
|
+
)) {
|
|
1364
|
+
if (compareSemver(pin, since) >= 0) available.add(name);
|
|
1365
|
+
}
|
|
1366
|
+
return available;
|
|
1367
|
+
}
|
|
1368
|
+
function unavailableReactImports(source, pin) {
|
|
1369
|
+
const available = reactExportsAvailableAt(pin);
|
|
1370
|
+
const missing = [];
|
|
1371
|
+
for (const name of parseReactSdkNamedImports(source)) {
|
|
1372
|
+
if (!available.has(name) && !missing.includes(name)) {
|
|
1373
|
+
missing.push(name);
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
return missing;
|
|
1377
|
+
}
|
|
1378
|
+
function studioSdkPinInstruction() {
|
|
1379
|
+
const version = STUDIO_SDK_CONTRACT.minNpmVersion;
|
|
1380
|
+
const names = STUDIO_SDK_CONTRACT.reactExports.join(", ");
|
|
1381
|
+
return `In \`package.json\` set \`"@garagem-ai/site-sdk": "${version}"\` (exact). Import only these \`${STUDIO_SDK_PACKAGE}/react\` names: ${names}.`;
|
|
1382
|
+
}
|
|
1383
|
+
function studioChromeInstruction() {
|
|
1384
|
+
const injectors = compareSemver(
|
|
1385
|
+
STUDIO_SDK_CONTRACT.minNpmVersion,
|
|
1386
|
+
STUDIO_SDK_CONTRACT.selfInjectSince
|
|
1387
|
+
) >= 0 ? "`SearchPage`, `ListingCard`, and `ResultsSkeleton`" : "`SearchPage`";
|
|
1388
|
+
return `Search chrome CSS is injected by ${injectors} (JS \`<style>\` tag). Never \`import "@garagem-ai/site-sdk/react/search.css"\` \u2014 v0 preview cannot load npm CSS. Do not copy SDK layout into the app. Theme via CSS variables in \`app/globals.css\` (\`SEARCH_CSS_RECIPE\` / \`--garagem-*\`), \`classNames\`, and \`data-slot\`.`;
|
|
1389
|
+
}
|
|
1390
|
+
function studioCodegenContractViolations(text) {
|
|
1391
|
+
const violations = [];
|
|
1392
|
+
for (const name of Object.keys(STUDIO_SDK_CONTRACT.optionalReactExports)) {
|
|
1393
|
+
if (text.includes(name)) violations.push(name);
|
|
1394
|
+
}
|
|
1395
|
+
const pin = STUDIO_SDK_CONTRACT.minNpmVersion;
|
|
1396
|
+
const available = reactExportsAvailableAt(pin);
|
|
1397
|
+
for (const name of parseReactSdkNamedImports(text)) {
|
|
1398
|
+
if (!available.has(name) && !violations.includes(name)) {
|
|
1399
|
+
violations.push(name);
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
return violations;
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1286
1405
|
// src/client.ts
|
|
1287
1406
|
function createGaragemClient(options = {}) {
|
|
1288
1407
|
const resolveSiteId = (override) => {
|
|
@@ -1421,11 +1540,15 @@ function createGaragemClient(options = {}) {
|
|
|
1421
1540
|
SEARCH_CSS_RECIPE,
|
|
1422
1541
|
SEARCH_CSS_VARS,
|
|
1423
1542
|
SEARCH_SORT_RELEVANCE,
|
|
1543
|
+
STUDIO_SDK_CONTRACT,
|
|
1544
|
+
STUDIO_SDK_PACKAGE,
|
|
1424
1545
|
TOOLBAR_PRIMARY_FILTER_IDS,
|
|
1425
1546
|
applyPathFilter,
|
|
1426
1547
|
buildQueryListingsParams,
|
|
1427
1548
|
canonicalizeSearchHref,
|
|
1428
1549
|
clearStagedPathFilters,
|
|
1550
|
+
coerceNpmVersion,
|
|
1551
|
+
compareSemver,
|
|
1429
1552
|
composeSearchPublicHref,
|
|
1430
1553
|
composeSearchPublicPath,
|
|
1431
1554
|
countFacetChoices,
|
|
@@ -1457,6 +1580,7 @@ function createGaragemClient(options = {}) {
|
|
|
1457
1580
|
paginationPages,
|
|
1458
1581
|
parseAppliedSearchQuery,
|
|
1459
1582
|
parseGroupedInteger,
|
|
1583
|
+
parseReactSdkNamedImports,
|
|
1460
1584
|
parseSearchPublicPath,
|
|
1461
1585
|
pathFilterHasOption,
|
|
1462
1586
|
pathFilterValue,
|
|
@@ -1472,8 +1596,12 @@ function createGaragemClient(options = {}) {
|
|
|
1472
1596
|
searchResultsHeading,
|
|
1473
1597
|
searchSortOptions,
|
|
1474
1598
|
serializeAppliedSearchQuery,
|
|
1599
|
+
studioChromeInstruction,
|
|
1600
|
+
studioCodegenContractViolations,
|
|
1601
|
+
studioSdkPinInstruction,
|
|
1475
1602
|
toListingCardModel,
|
|
1476
1603
|
toolbarFilterIds,
|
|
1604
|
+
unavailableReactImports,
|
|
1477
1605
|
visibleSearchFilters
|
|
1478
1606
|
});
|
|
1479
1607
|
//# sourceMappingURL=index.js.map
|