@shopware/helpers 1.7.0 → 1.7.1
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 +7 -6
- package/dist/index.d.mts +16 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.mjs +29 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -125,12 +125,13 @@ Returns an empty string if `src` is falsy. Returns the original `src` if URL par
|
|
|
125
125
|
|
|
126
126
|
Full changelog for stable version is available [here](https://github.com/shopware/frontends/blob/main/packages/helpers/CHANGELOG.md)
|
|
127
127
|
|
|
128
|
-
### Latest changes: 1.7.
|
|
129
|
-
|
|
130
|
-
### Minor Changes
|
|
131
|
-
|
|
132
|
-
- [#2287](https://github.com/shopware/frontends/pull/2287) [`c9bde38`](https://github.com/shopware/frontends/commit/c9bde38d497d5c6c2fbd97700a362eb44ce8881f) Thanks [@mkucmus](https://github.com/mkucmus)! - Add generateCdnSrcSet and buildCdnImageUrl helpers for synthetic responsive image srcset generation via CDN query params
|
|
128
|
+
### Latest changes: 1.7.1
|
|
133
129
|
|
|
134
130
|
### Patch Changes
|
|
135
131
|
|
|
136
|
-
- [#
|
|
132
|
+
- [#2372](https://github.com/shopware/frontends/pull/2372) [`22fc8a7`](https://github.com/shopware/frontends/commit/22fc8a7301f6a7d2612d907ab73555978b651c00) Thanks [@patzick](https://github.com/patzick)! - Improve technical URL resolution for SSR and CSR page rendering.
|
|
133
|
+
|
|
134
|
+
This adds helpers to detect and normalize technical Shopware paths and updates
|
|
135
|
+
`useNavigationSearch` to resolve `/navigation/*`, `/detail/*`, and
|
|
136
|
+
`/landingPage/*` routes more reliably, including fallback behavior when no SEO
|
|
137
|
+
mapping row is returned.
|
package/dist/index.d.mts
CHANGED
|
@@ -526,6 +526,20 @@ declare function isLandingPage<T extends {
|
|
|
526
526
|
apiAlias: string;
|
|
527
527
|
}>(entity: T | LandingPage): entity is LandingPage;
|
|
528
528
|
|
|
529
|
+
declare const TECHNICAL_ROUTE_MAP: {
|
|
530
|
+
readonly "/navigation/": "frontend.navigation.page";
|
|
531
|
+
readonly "/detail/": "frontend.detail.page";
|
|
532
|
+
readonly "/landingPage/": "frontend.landing.page";
|
|
533
|
+
};
|
|
534
|
+
type RouteNameFromPathInfo = (typeof TECHNICAL_ROUTE_MAP)[keyof typeof TECHNICAL_ROUTE_MAP];
|
|
535
|
+
type RouteInfoFromPathInfo = {
|
|
536
|
+
routeName: RouteNameFromPathInfo;
|
|
537
|
+
foreignKey: string;
|
|
538
|
+
};
|
|
539
|
+
declare function normalizePath(path: string): string;
|
|
540
|
+
declare function isTechnicalPath(path: string): boolean;
|
|
541
|
+
declare function getRouteFromPathInfo(path: string): RouteInfoFromPathInfo | null;
|
|
542
|
+
|
|
529
543
|
/**
|
|
530
544
|
* Get translated property from the given object.
|
|
531
545
|
*
|
|
@@ -755,4 +769,5 @@ declare function canUseQuoteActions<T extends {
|
|
|
755
769
|
};
|
|
756
770
|
}>(quote: T): boolean;
|
|
757
771
|
|
|
758
|
-
export {
|
|
772
|
+
export { buildCdnImageUrl, buildUrlPrefix, canUseQuoteActions, downloadFile, encodeUrlPath, generateCdnSrcSet, getBackgroundImageUrl, getBiggestThumbnailUrl, getCategoryBreadcrumbs, getCategoryImageUrl, getCategoryRoute, getCategoryUrl, getCmsBreadcrumbs, getCmsEntityObject, getCmsLayoutConfiguration, getCmsTranslate, getFormattedPrice, getLanguageName, getListingFilters, getMainImageUrl, getMedia, getPaymentMethodIcon, getProductCalculatedListingPrice, getProductFreeShipping, getProductFromPrice, getProductListingFromCmsPage, getProductManufacturerName, getProductName, getProductRatingAverage, getProductReviews, getProductRoute, getProductTierPrices, getProductUrl, getRouteFromPathInfo, getShippingMethodDeliveryTime, getShippingMethodIcon, getSmallestThumbnailUrl, getSrcSetForMedia, getTranslatedProperty, helpersCssClasses, isCategory, isLandingPage, isMaintenanceMode, isProduct, isProductOnSale, isProductTopSeller, isTechnicalPath, normalizePath, relativeUrlSlash, urlIsAbsolute };
|
|
773
|
+
export type { BackgroundImageOptions, HelpersCssClasses, LayoutConfiguration, RouteInfoFromPathInfo, RouteNameFromPathInfo, TierPrice, UiMediaGalleryItem, UiMediaGalleryItemUrl, UiProductOption, UiProductProperty, UiProductReview, UrlRouteOutput };
|
package/dist/index.d.ts
CHANGED
|
@@ -526,6 +526,20 @@ declare function isLandingPage<T extends {
|
|
|
526
526
|
apiAlias: string;
|
|
527
527
|
}>(entity: T | LandingPage): entity is LandingPage;
|
|
528
528
|
|
|
529
|
+
declare const TECHNICAL_ROUTE_MAP: {
|
|
530
|
+
readonly "/navigation/": "frontend.navigation.page";
|
|
531
|
+
readonly "/detail/": "frontend.detail.page";
|
|
532
|
+
readonly "/landingPage/": "frontend.landing.page";
|
|
533
|
+
};
|
|
534
|
+
type RouteNameFromPathInfo = (typeof TECHNICAL_ROUTE_MAP)[keyof typeof TECHNICAL_ROUTE_MAP];
|
|
535
|
+
type RouteInfoFromPathInfo = {
|
|
536
|
+
routeName: RouteNameFromPathInfo;
|
|
537
|
+
foreignKey: string;
|
|
538
|
+
};
|
|
539
|
+
declare function normalizePath(path: string): string;
|
|
540
|
+
declare function isTechnicalPath(path: string): boolean;
|
|
541
|
+
declare function getRouteFromPathInfo(path: string): RouteInfoFromPathInfo | null;
|
|
542
|
+
|
|
529
543
|
/**
|
|
530
544
|
* Get translated property from the given object.
|
|
531
545
|
*
|
|
@@ -755,4 +769,5 @@ declare function canUseQuoteActions<T extends {
|
|
|
755
769
|
};
|
|
756
770
|
}>(quote: T): boolean;
|
|
757
771
|
|
|
758
|
-
export {
|
|
772
|
+
export { buildCdnImageUrl, buildUrlPrefix, canUseQuoteActions, downloadFile, encodeUrlPath, generateCdnSrcSet, getBackgroundImageUrl, getBiggestThumbnailUrl, getCategoryBreadcrumbs, getCategoryImageUrl, getCategoryRoute, getCategoryUrl, getCmsBreadcrumbs, getCmsEntityObject, getCmsLayoutConfiguration, getCmsTranslate, getFormattedPrice, getLanguageName, getListingFilters, getMainImageUrl, getMedia, getPaymentMethodIcon, getProductCalculatedListingPrice, getProductFreeShipping, getProductFromPrice, getProductListingFromCmsPage, getProductManufacturerName, getProductName, getProductRatingAverage, getProductReviews, getProductRoute, getProductTierPrices, getProductUrl, getRouteFromPathInfo, getShippingMethodDeliveryTime, getShippingMethodIcon, getSmallestThumbnailUrl, getSrcSetForMedia, getTranslatedProperty, helpersCssClasses, isCategory, isLandingPage, isMaintenanceMode, isProduct, isProductOnSale, isProductTopSeller, isTechnicalPath, normalizePath, relativeUrlSlash, urlIsAbsolute };
|
|
773
|
+
export type { BackgroundImageOptions, HelpersCssClasses, LayoutConfiguration, RouteInfoFromPathInfo, RouteNameFromPathInfo, TierPrice, UiMediaGalleryItem, UiMediaGalleryItemUrl, UiProductOption, UiProductProperty, UiProductReview, UrlRouteOutput };
|
package/dist/index.mjs
CHANGED
|
@@ -352,6 +352,34 @@ function isLandingPage(entity) {
|
|
|
352
352
|
return entity.apiAlias === "landing_page";
|
|
353
353
|
}
|
|
354
354
|
|
|
355
|
+
const TECHNICAL_ROUTE_MAP = {
|
|
356
|
+
"/navigation/": "frontend.navigation.page",
|
|
357
|
+
"/detail/": "frontend.detail.page",
|
|
358
|
+
"/landingPage/": "frontend.landing.page"
|
|
359
|
+
};
|
|
360
|
+
function normalizePath(path) {
|
|
361
|
+
return path.endsWith("/") && path !== "/" ? path.slice(0, -1) : path;
|
|
362
|
+
}
|
|
363
|
+
function isTechnicalPath(path) {
|
|
364
|
+
const normalizedPath = normalizePath(path);
|
|
365
|
+
return Object.keys(TECHNICAL_ROUTE_MAP).some(
|
|
366
|
+
(prefix) => normalizedPath.startsWith(prefix)
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
function getRouteFromPathInfo(path) {
|
|
370
|
+
const normalizedPath = normalizePath(path);
|
|
371
|
+
for (const [prefix, routeName] of Object.entries(TECHNICAL_ROUTE_MAP)) {
|
|
372
|
+
if (!normalizedPath.startsWith(prefix)) continue;
|
|
373
|
+
const foreignKey = normalizedPath.slice(prefix.length);
|
|
374
|
+
if (!foreignKey || foreignKey.includes("/")) return null;
|
|
375
|
+
return {
|
|
376
|
+
routeName,
|
|
377
|
+
foreignKey
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
return null;
|
|
381
|
+
}
|
|
382
|
+
|
|
355
383
|
const getFilter = (code, aggregation) => {
|
|
356
384
|
return {
|
|
357
385
|
label: getTranslatedProperty(aggregation, "name") || code,
|
|
@@ -536,4 +564,4 @@ function canUseQuoteActions(quote) {
|
|
|
536
564
|
return ["replied"].includes(quote.stateMachineState?.technicalName ?? "");
|
|
537
565
|
}
|
|
538
566
|
|
|
539
|
-
export { buildCdnImageUrl, buildUrlPrefix, canUseQuoteActions, downloadFile, encodeUrlPath, generateCdnSrcSet, getBackgroundImageUrl, getBiggestThumbnailUrl, getCategoryBreadcrumbs, getCategoryImageUrl, getCategoryRoute, getCategoryUrl, getCmsBreadcrumbs, getCmsEntityObject, getCmsLayoutConfiguration, getCmsTranslate, getFormattedPrice, getLanguageName, getListingFilters, getMainImageUrl, getMedia, getPaymentMethodIcon, getProductCalculatedListingPrice, getProductFreeShipping, getProductFromPrice, getProductListingFromCmsPage, getProductManufacturerName, getProductName, getProductRatingAverage, getProductReviews, getProductRoute, getProductTierPrices, getProductUrl, getShippingMethodDeliveryTime, getShippingMethodIcon, getSmallestThumbnailUrl, getSrcSetForMedia, getTranslatedProperty, helpersCssClasses, isCategory, isLandingPage, isMaintenanceMode, isProduct, isProductOnSale, isProductTopSeller, relativeUrlSlash, urlIsAbsolute };
|
|
567
|
+
export { buildCdnImageUrl, buildUrlPrefix, canUseQuoteActions, downloadFile, encodeUrlPath, generateCdnSrcSet, getBackgroundImageUrl, getBiggestThumbnailUrl, getCategoryBreadcrumbs, getCategoryImageUrl, getCategoryRoute, getCategoryUrl, getCmsBreadcrumbs, getCmsEntityObject, getCmsLayoutConfiguration, getCmsTranslate, getFormattedPrice, getLanguageName, getListingFilters, getMainImageUrl, getMedia, getPaymentMethodIcon, getProductCalculatedListingPrice, getProductFreeShipping, getProductFromPrice, getProductListingFromCmsPage, getProductManufacturerName, getProductName, getProductRatingAverage, getProductReviews, getProductRoute, getProductTierPrices, getProductUrl, getRouteFromPathInfo, getShippingMethodDeliveryTime, getShippingMethodIcon, getSmallestThumbnailUrl, getSrcSetForMedia, getTranslatedProperty, helpersCssClasses, isCategory, isLandingPage, isMaintenanceMode, isProduct, isProductOnSale, isProductTopSeller, isTechnicalPath, normalizePath, relativeUrlSlash, urlIsAbsolute };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopware/helpers",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "Shopware helpers for accessing API data",
|
|
5
5
|
"author": "Shopware",
|
|
6
6
|
"type": "module",
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@biomejs/biome": "1.8.3",
|
|
36
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
37
|
-
"@vitest/coverage-v8": "4.
|
|
38
|
-
"happy-dom": "20.
|
|
36
|
+
"@typescript/native-preview": "7.0.0-dev.20260205.1",
|
|
37
|
+
"@vitest/coverage-v8": "4.1.5",
|
|
38
|
+
"happy-dom": "20.9.0",
|
|
39
39
|
"unbuild": "2.0.0",
|
|
40
|
-
"vitest": "4.
|
|
40
|
+
"vitest": "4.1.5",
|
|
41
41
|
"tsconfig": "0.0.0"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|