basklee-nuxt 0.0.0-stage → 0.8.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.
- package/LICENSE +21 -0
- package/README.md +1190 -2
- package/bin/basklee-nuxt.mjs +173 -0
- package/package.json +69 -4
- package/runtime/api.mjs +14 -0
- package/runtime/domain.mjs +15 -0
- package/runtime/marketplace.mjs +905 -0
- package/runtime/seo.mjs +17 -0
- package/src/asset-loading-plugin.mjs +10 -0
- package/src/favicon-handler.mjs +12 -0
- package/src/install.mjs +361 -0
- package/src/migrate.mjs +124 -0
- package/src/module.d.ts +3 -0
- package/src/module.mjs +88 -0
- package/src/project-readme.mjs +702 -0
- package/src/service.mjs +186 -0
- package/src/setup.mjs +250 -0
- package/src/sitemap.mjs +93 -0
- package/src/update.mjs +54 -0
- package/src/validation.mjs +33 -0
- package/templates/.vscode/settings.json +5 -0
- package/templates/app/app.vue +52 -0
- package/templates/app/assets/css/basklee-tokens.css +21 -0
- package/templates/app/assets/css/basklee.css +28 -0
- package/templates/app/components/basklee/account/AccountActivity.README.md +31 -0
- package/templates/app/components/basklee/account/AccountActivity.vue +61 -0
- package/templates/app/components/basklee/account/AccountPromocodes.README.md +50 -0
- package/templates/app/components/basklee/account/AccountPromocodes.vue +267 -0
- package/templates/app/components/basklee/account/AccountSection.README.md +31 -0
- package/templates/app/components/basklee/account/AccountSection.vue +132 -0
- package/templates/app/components/basklee/account/ProfileAvatar.vue +139 -0
- package/templates/app/components/basklee/account/ProfileDeleteAccount.vue +161 -0
- package/templates/app/components/basklee/account/ProfileDetailsForm.vue +182 -0
- package/templates/app/components/basklee/account/ProfileEmailSettings.vue +269 -0
- package/templates/app/components/basklee/account/ProfilePasswordForm.vue +201 -0
- package/templates/app/components/basklee/account/ProfileSignIn.vue +446 -0
- package/templates/app/components/basklee/account/SignInHistory.README.md +27 -0
- package/templates/app/components/basklee/account/SignInHistory.vue +218 -0
- package/templates/app/components/basklee/account/StorefrontLogout.README.md +15 -0
- package/templates/app/components/basklee/account/StorefrontLogout.vue +109 -0
- package/templates/app/components/basklee/account/StorefrontProfile.README.md +145 -0
- package/templates/app/components/basklee/account/StorefrontProfile.vue +168 -0
- package/templates/app/components/basklee/account/account.css +1047 -0
- package/templates/app/components/basklee/account/profile.css +696 -0
- package/templates/app/components/basklee/address/AddressForm.README.md +67 -0
- package/templates/app/components/basklee/address/AddressForm.vue +537 -0
- package/templates/app/components/basklee/address/StorefrontAddresses.README.md +44 -0
- package/templates/app/components/basklee/address/StorefrontAddresses.vue +438 -0
- package/templates/app/components/basklee/banners/MainBanner.vue +171 -0
- package/templates/app/components/basklee/banners/examples/BannerExample.vue +6 -0
- package/templates/app/components/basklee/blog/BlogArticle.README.md +44 -0
- package/templates/app/components/basklee/blog/BlogArticle.vue +1023 -0
- package/templates/app/components/basklee/blog/BlogCommentForm.README.md +28 -0
- package/templates/app/components/basklee/blog/BlogCommentForm.vue +129 -0
- package/templates/app/components/basklee/blog/BlogComments.README.md +36 -0
- package/templates/app/components/basklee/blog/BlogComments.vue +373 -0
- package/templates/app/components/basklee/blog/BlogPostCard.vue +307 -0
- package/templates/app/components/basklee/blog/BlogPostGroup.vue +108 -0
- package/templates/app/components/basklee/blog/StorefrontJournal.README.md +42 -0
- package/templates/app/components/basklee/blog/StorefrontJournal.vue +670 -0
- package/templates/app/components/basklee/branding/BrandLogos.vue +25 -0
- package/templates/app/components/basklee/branding/examples/BrandLogosExample.vue +6 -0
- package/templates/app/components/basklee/cart/CartCheckoutDetails.README.md +85 -0
- package/templates/app/components/basklee/cart/CartCheckoutDetails.vue +377 -0
- package/templates/app/components/basklee/cart/CartDeliverySelector.README.md +95 -0
- package/templates/app/components/basklee/cart/CartDeliverySelector.vue +724 -0
- package/templates/app/components/basklee/cart/CartItemOptions.README.md +98 -0
- package/templates/app/components/basklee/cart/CartItemOptions.vue +693 -0
- package/templates/app/components/basklee/cart/CartLineItem.README.md +70 -0
- package/templates/app/components/basklee/cart/CartLineItem.vue +271 -0
- package/templates/app/components/basklee/cart/CartPreview.README.md +43 -0
- package/templates/app/components/basklee/cart/CartPreview.vue +263 -0
- package/templates/app/components/basklee/cart/DeliveryMap.README.md +48 -0
- package/templates/app/components/basklee/cart/DeliveryMap.vue +155 -0
- package/templates/app/components/basklee/cart/StorefrontCart.README.md +89 -0
- package/templates/app/components/basklee/cart/StorefrontCart.vue +689 -0
- package/templates/app/components/basklee/catalog/CatalogHeader.vue +681 -0
- package/templates/app/components/basklee/catalog/CatalogRepresentative.vue +59 -0
- package/templates/app/components/basklee/catalog/StorefrontCatalog.README.md +35 -0
- package/templates/app/components/basklee/catalog/StorefrontCatalog.vue +179 -0
- package/templates/app/components/basklee/catalog/examples/CatalogHeaderExample.vue +6 -0
- package/templates/app/components/basklee/categories/CategoryGroup.vue +125 -0
- package/templates/app/components/basklee/categories/StorefrontCategory.README.md +60 -0
- package/templates/app/components/basklee/categories/StorefrontCategory.vue +277 -0
- package/templates/app/components/basklee/categories/examples/CategoryGroupExample.vue +7 -0
- package/templates/app/components/basklee/contact/AboutPage.README.md +23 -0
- package/templates/app/components/basklee/contact/AboutPage.vue +409 -0
- package/templates/app/components/basklee/contact/ContactForm.README.md +29 -0
- package/templates/app/components/basklee/contact/ContactForm.vue +289 -0
- package/templates/app/components/basklee/contact/EmailUnsubscribe.README.md +27 -0
- package/templates/app/components/basklee/contact/EmailUnsubscribe.vue +95 -0
- package/templates/app/components/basklee/contact/StorefrontContact.README.md +18 -0
- package/templates/app/components/basklee/contact/StorefrontContact.vue +89 -0
- package/templates/app/components/basklee/contact/examples/ContactExample.vue +6 -0
- package/templates/app/components/basklee/currencies/MainCurrencySwitcher.vue +80 -0
- package/templates/app/components/basklee/currencies/examples/CurrencyExample.vue +6 -0
- package/templates/app/components/basklee/events/EventEnrollmentDialog.README.md +58 -0
- package/templates/app/components/basklee/events/EventEnrollmentDialog.vue +294 -0
- package/templates/app/components/basklee/events/EventsBlock.vue +138 -0
- package/templates/app/components/basklee/events/examples/EventsExample.vue +6 -0
- package/templates/app/components/basklee/legal/CookieNotice.README.md +34 -0
- package/templates/app/components/basklee/legal/CookieNotice.vue +84 -0
- package/templates/app/components/basklee/legal/StorefrontPrivacy.README.md +35 -0
- package/templates/app/components/basklee/legal/StorefrontPrivacy.vue +124 -0
- package/templates/app/components/basklee/locale/MainLanguageSwitcher.vue +506 -0
- package/templates/app/components/basklee/locale/examples/LocaleExample.vue +6 -0
- package/templates/app/components/basklee/manufacturers/ManufacturerIndex.README.md +36 -0
- package/templates/app/components/basklee/manufacturers/ManufacturerIndex.vue +495 -0
- package/templates/app/components/basklee/manufacturers/StorefrontManufacturers.README.md +30 -0
- package/templates/app/components/basklee/manufacturers/StorefrontManufacturers.vue +263 -0
- package/templates/app/components/basklee/orders/OrderDetails.README.md +39 -0
- package/templates/app/components/basklee/orders/OrderDetails.vue +1074 -0
- package/templates/app/components/basklee/orders/OrderPaymentForm.README.md +59 -0
- package/templates/app/components/basklee/orders/OrderPaymentForm.vue +73 -0
- package/templates/app/components/basklee/orders/StorefrontOrders.README.md +39 -0
- package/templates/app/components/basklee/orders/StorefrontOrders.vue +869 -0
- package/templates/app/components/basklee/orders/orders.css +612 -0
- package/templates/app/components/basklee/payments/PaymentPanel.README.md +76 -0
- package/templates/app/components/basklee/payments/PaymentPanel.vue +108 -0
- package/templates/app/components/basklee/products/HoverImageViewer.vue +190 -0
- package/templates/app/components/basklee/products/ProductCard.README.md +63 -0
- package/templates/app/components/basklee/products/ProductCard.vue +911 -0
- package/templates/app/components/basklee/products/ProductCardActions.README.md +33 -0
- package/templates/app/components/basklee/products/ProductCardActions.vue +412 -0
- package/templates/app/components/basklee/products/ProductCardBadges.vue +83 -0
- package/templates/app/components/basklee/products/ProductCardDescription.vue +46 -0
- package/templates/app/components/basklee/products/ProductCardFavorite.vue +99 -0
- package/templates/app/components/basklee/products/ProductCardPrice.vue +66 -0
- package/templates/app/components/basklee/products/ProductCardRating.vue +65 -0
- package/templates/app/components/basklee/products/ProductCardSeller.vue +66 -0
- package/templates/app/components/basklee/products/ProductCardStockNotice.vue +43 -0
- package/templates/app/components/basklee/products/ProductCardTitle.vue +46 -0
- package/templates/app/components/basklee/products/ProductCardVariants.vue +388 -0
- package/templates/app/components/basklee/products/ProductGroup.vue +259 -0
- package/templates/app/components/basklee/products/ProductPreorderDialog.README.md +22 -0
- package/templates/app/components/basklee/products/ProductPreorderDialog.vue +471 -0
- package/templates/app/components/basklee/products/ProductReviewForm.README.md +39 -0
- package/templates/app/components/basklee/products/ProductReviewForm.vue +312 -0
- package/templates/app/components/basklee/products/ProductReviewGallery.README.md +28 -0
- package/templates/app/components/basklee/products/ProductReviewGallery.vue +141 -0
- package/templates/app/components/basklee/products/ProductReviewImageViewer.README.md +52 -0
- package/templates/app/components/basklee/products/ProductReviewImageViewer.vue +425 -0
- package/templates/app/components/basklee/products/ProductReviews.README.md +70 -0
- package/templates/app/components/basklee/products/ProductReviews.vue +1025 -0
- package/templates/app/components/basklee/products/ProductSecondaryVariantModal.vue +460 -0
- package/templates/app/components/basklee/products/ProductSpecificationsDialog.README.md +65 -0
- package/templates/app/components/basklee/products/ProductSpecificationsDialog.vue +174 -0
- package/templates/app/components/basklee/products/StorefrontProduct.README.md +52 -0
- package/templates/app/components/basklee/products/StorefrontProduct.vue +1468 -0
- package/templates/app/components/basklee/products/StorefrontWishlist.README.md +33 -0
- package/templates/app/components/basklee/products/StorefrontWishlist.vue +290 -0
- package/templates/app/components/basklee/products/examples/FeaturedExample.vue +6 -0
- package/templates/app/components/basklee/products/examples/FeaturedHoverImageViewerExample.vue +14 -0
- package/templates/app/components/basklee/products/examples/FeaturedProductCardActionsExample.vue +14 -0
- package/templates/app/components/basklee/products/examples/FeaturedProductCardBadgesExample.vue +14 -0
- package/templates/app/components/basklee/products/examples/FeaturedProductCardDescriptionExample.vue +14 -0
- package/templates/app/components/basklee/products/examples/FeaturedProductCardExample.vue +14 -0
- package/templates/app/components/basklee/products/examples/FeaturedProductCardFavoriteExample.vue +14 -0
- package/templates/app/components/basklee/products/examples/FeaturedProductCardPriceExample.vue +14 -0
- package/templates/app/components/basklee/products/examples/FeaturedProductCardRatingExample.vue +14 -0
- package/templates/app/components/basklee/products/examples/FeaturedProductCardSellerExample.vue +14 -0
- package/templates/app/components/basklee/products/examples/FeaturedProductCardStockNoticeExample.vue +14 -0
- package/templates/app/components/basklee/products/examples/FeaturedProductCardTitleExample.vue +14 -0
- package/templates/app/components/basklee/products/examples/FeaturedProductCardVariantsExample.vue +14 -0
- package/templates/app/components/basklee/products/examples/ProductsExample.vue +6 -0
- package/templates/app/components/basklee/products/examples/ProductsHoverImageViewerExample.vue +13 -0
- package/templates/app/components/basklee/products/examples/ProductsProductCardActionsExample.vue +13 -0
- package/templates/app/components/basklee/products/examples/ProductsProductCardBadgesExample.vue +13 -0
- package/templates/app/components/basklee/products/examples/ProductsProductCardDescriptionExample.vue +13 -0
- package/templates/app/components/basklee/products/examples/ProductsProductCardExample.vue +13 -0
- package/templates/app/components/basklee/products/examples/ProductsProductCardFavoriteExample.vue +13 -0
- package/templates/app/components/basklee/products/examples/ProductsProductCardPriceExample.vue +13 -0
- package/templates/app/components/basklee/products/examples/ProductsProductCardRatingExample.vue +13 -0
- package/templates/app/components/basklee/products/examples/ProductsProductCardSellerExample.vue +13 -0
- package/templates/app/components/basklee/products/examples/ProductsProductCardStockNoticeExample.vue +13 -0
- package/templates/app/components/basklee/products/examples/ProductsProductCardTitleExample.vue +13 -0
- package/templates/app/components/basklee/products/examples/ProductsProductCardVariantsExample.vue +13 -0
- package/templates/app/components/basklee/promo/PromoProducts.README.md +45 -0
- package/templates/app/components/basklee/promo/PromoProducts.vue +287 -0
- package/templates/app/components/basklee/search/MainSearch.vue +340 -0
- package/templates/app/components/basklee/search/ProductSearchResults.README.md +81 -0
- package/templates/app/components/basklee/search/ProductSearchResults.vue +506 -0
- package/templates/app/components/basklee/search/SearchFilters.vue +546 -0
- package/templates/app/components/basklee/search/examples/MainSearchExample.vue +6 -0
- package/templates/app/components/basklee/sellers/SellerFilters.README.md +32 -0
- package/templates/app/components/basklee/sellers/SellerFilters.vue +317 -0
- package/templates/app/components/basklee/sellers/SellerPhotoGallery.README.md +45 -0
- package/templates/app/components/basklee/sellers/SellerPhotoGallery.vue +406 -0
- package/templates/app/components/basklee/sellers/SellerSummary.README.md +33 -0
- package/templates/app/components/basklee/sellers/SellerSummary.vue +162 -0
- package/templates/app/components/basklee/sellers/StorefrontSellers.README.md +73 -0
- package/templates/app/components/basklee/sellers/StorefrontSellers.vue +300 -0
- package/templates/app/components/basklee/shared/BaskleeAvatar.README.md +30 -0
- package/templates/app/components/basklee/shared/BaskleeAvatar.vue +83 -0
- package/templates/app/components/basklee/shared/BaskleeBreadcrumbs.README.md +65 -0
- package/templates/app/components/basklee/shared/BaskleeBreadcrumbs.vue +118 -0
- package/templates/app/components/basklee/shared/BaskleeEmptyState.README.md +38 -0
- package/templates/app/components/basklee/shared/BaskleeEmptyState.vue +143 -0
- package/templates/app/components/basklee/shared/BaskleeImage.vue +84 -0
- package/templates/app/components/basklee/shared/BaskleeInfoHint.README.md +32 -0
- package/templates/app/components/basklee/shared/BaskleeInfoHint.vue +158 -0
- package/templates/app/components/basklee/shared/BaskleePasswordInput.README.md +30 -0
- package/templates/app/components/basklee/shared/BaskleePasswordInput.vue +197 -0
- package/templates/app/components/basklee/shared/BaskleeSearchSelect.README.md +38 -0
- package/templates/app/components/basklee/shared/BaskleeSearchSelect.vue +411 -0
- package/templates/app/components/basklee/shared/BaskleeSelect.README.md +31 -0
- package/templates/app/components/basklee/shared/BaskleeSelect.vue +525 -0
- package/templates/app/components/basklee/shared/StorefrontErrorPage.README.md +55 -0
- package/templates/app/components/basklee/shared/StorefrontErrorPage.vue +151 -0
- package/templates/app/components/basklee/shared/StorefrontPagination.README.md +50 -0
- package/templates/app/components/basklee/shared/StorefrontPagination.vue +148 -0
- package/templates/app/components/basklee/shared/dialogs.css +36 -0
- package/templates/app/components/basklee/shared/features.css +364 -0
- package/templates/app/components/basklee/social/SocialLinks.vue +72 -0
- package/templates/app/components/basklee/social/examples/SocialLinksExample.vue +6 -0
- package/templates/app/components/basklee/storefront/StorefrontAccount.README.md +47 -0
- package/templates/app/components/basklee/storefront/StorefrontAccount.vue +332 -0
- package/templates/app/components/basklee/storefront/StorefrontCartButton.vue +68 -0
- package/templates/app/components/basklee/storefront/StorefrontFooter.README.md +26 -0
- package/templates/app/components/basklee/storefront/StorefrontFooter.vue +236 -0
- package/templates/app/components/basklee/storefront/StorefrontHeader.README.md +93 -0
- package/templates/app/components/basklee/storefront/StorefrontHeader.vue +509 -0
- package/templates/app/components/basklee/storefront/StorefrontHome.README.md +79 -0
- package/templates/app/components/basklee/storefront/StorefrontHome.vue +315 -0
- package/templates/app/components/basklee/storefront/StorefrontWishlistButton.vue +105 -0
- package/templates/app/components/basklee/storefront/examples/StorefrontAccountExample.vue +7 -0
- package/templates/app/components/basklee/stores/StorefrontStores.README.md +41 -0
- package/templates/app/components/basklee/stores/StorefrontStores.vue +346 -0
- package/templates/app/components/basklee/subscriptions/StorefrontSubscriptions.README.md +151 -0
- package/templates/app/components/basklee/subscriptions/StorefrontSubscriptions.vue +851 -0
- package/templates/app/components/basklee/subscriptions/StorefrontTariff.README.md +38 -0
- package/templates/app/components/basklee/subscriptions/StorefrontTariff.vue +555 -0
- package/templates/app/components/basklee/subscriptions/StorefrontTariffs.README.md +36 -0
- package/templates/app/components/basklee/subscriptions/StorefrontTariffs.vue +416 -0
- package/templates/app/components/basklee/subscriptions/SubscriptionCancelDialog.README.md +39 -0
- package/templates/app/components/basklee/subscriptions/SubscriptionCancelDialog.vue +292 -0
- package/templates/app/components/basklee/subscriptions/SubscriptionChangeDialog.README.md +85 -0
- package/templates/app/components/basklee/subscriptions/SubscriptionChangeDialog.vue +874 -0
- package/templates/app/components/basklee/subscriptions/SubscriptionExtendDialog.README.md +53 -0
- package/templates/app/components/basklee/subscriptions/SubscriptionExtendDialog.vue +536 -0
- package/templates/app/components/basklee/subscriptions/SubscriptionPlanSummary.README.md +101 -0
- package/templates/app/components/basklee/subscriptions/SubscriptionPlanSummary.vue +286 -0
- package/templates/app/components/basklee/subscriptions/SubscriptionRemoteDetails.README.md +138 -0
- package/templates/app/components/basklee/subscriptions/SubscriptionRemoteDetails.vue +134 -0
- package/templates/app/components/basklee/subscriptions/SubscriptionRenewalDialog.README.md +85 -0
- package/templates/app/components/basklee/subscriptions/SubscriptionRenewalDialog.vue +364 -0
- package/templates/app/components/basklee/support/StorefrontSupport.README.md +39 -0
- package/templates/app/components/basklee/support/StorefrontSupport.vue +484 -0
- package/templates/app/components/basklee/support/TicketConversation.README.md +38 -0
- package/templates/app/components/basklee/support/TicketConversation.vue +524 -0
- package/templates/app/components/basklee/support/TicketImage.README.md +27 -0
- package/templates/app/components/basklee/support/TicketImage.vue +186 -0
- package/templates/app/components/basklee/support/TicketItemCard.README.md +59 -0
- package/templates/app/components/basklee/support/TicketItemCard.vue +177 -0
- package/templates/app/components/basklee/support/TicketMessageForm.README.md +35 -0
- package/templates/app/components/basklee/support/TicketMessageForm.vue +258 -0
- package/templates/app/components/basklee/support/TicketSubscriptionCard.README.md +40 -0
- package/templates/app/components/basklee/support/TicketSubscriptionCard.vue +154 -0
- package/templates/app/components/basklee/tariffs/TariffCard.README.md +12 -0
- package/templates/app/components/basklee/tariffs/TariffCard.vue +251 -0
- package/templates/app/components/basklee/tariffs/TariffCardDescription.README.md +12 -0
- package/templates/app/components/basklee/tariffs/TariffCardDescription.vue +97 -0
- package/templates/app/components/basklee/tariffs/TariffCardFeatures.README.md +14 -0
- package/templates/app/components/basklee/tariffs/TariffCardFeatures.vue +172 -0
- package/templates/app/components/basklee/tariffs/TariffCardImage.README.md +12 -0
- package/templates/app/components/basklee/tariffs/TariffCardImage.vue +33 -0
- package/templates/app/components/basklee/tariffs/TariffCardPrices.README.md +12 -0
- package/templates/app/components/basklee/tariffs/TariffCardPrices.vue +300 -0
- package/templates/app/components/basklee/tariffs/TariffCardTitle.README.md +12 -0
- package/templates/app/components/basklee/tariffs/TariffCardTitle.vue +30 -0
- package/templates/app/components/basklee/tariffs/TariffCards.README.md +12 -0
- package/templates/app/components/basklee/tariffs/TariffCards.vue +94 -0
- package/templates/app/components/basklee/tariffs/TariffSubscriptionModal.README.md +31 -0
- package/templates/app/components/basklee/tariffs/TariffSubscriptionModal.vue +411 -0
- package/templates/app/components/basklee/tariffs/examples/TariffCardDescriptionExample.vue +13 -0
- package/templates/app/components/basklee/tariffs/examples/TariffCardExample.vue +13 -0
- package/templates/app/components/basklee/tariffs/examples/TariffCardFeaturesExample.vue +14 -0
- package/templates/app/components/basklee/tariffs/examples/TariffCardImageExample.vue +13 -0
- package/templates/app/components/basklee/tariffs/examples/TariffCardPricesExample.vue +13 -0
- package/templates/app/components/basklee/tariffs/examples/TariffCardTitleExample.vue +13 -0
- package/templates/app/components/basklee/tariffs/examples/TariffCardsExample.vue +6 -0
- package/templates/app/components/basklee/theme/BaskleeThemeProvider.vue +38 -0
- package/templates/app/components/basklee/units/UnitSwitcher.vue +71 -0
- package/templates/app/components/basklee/units/examples/LengthExample.vue +6 -0
- package/templates/app/components/basklee/units/examples/WeightExample.vue +6 -0
- package/templates/app/components/basklee/wallet/StorefrontWallet.README.md +117 -0
- package/templates/app/components/basklee/wallet/StorefrontWallet.vue +863 -0
- package/templates/app/components/basklee/wallet/WalletBalance.vue +47 -0
- package/templates/app/components/basklee/wallet/WalletTopUpForm.README.md +32 -0
- package/templates/app/components/basklee/wallet/WalletTopUpForm.vue +224 -0
- package/templates/app/components/basklee/wallet/examples/WalletExample.vue +6 -0
- package/templates/app/composables/useBaskleeActionMenu.ts +126 -0
- package/templates/app/composables/useBaskleeAddressEditor.ts +343 -0
- package/templates/app/composables/useBaskleeAddresses.ts +75 -0
- package/templates/app/composables/useBaskleeApi.ts +190 -0
- package/templates/app/composables/useBaskleeAppLoad.ts +83 -0
- package/templates/app/composables/useBaskleeBlogComments.ts +325 -0
- package/templates/app/composables/useBaskleeBlogReading.ts +270 -0
- package/templates/app/composables/useBaskleeCart.ts +226 -0
- package/templates/app/composables/useBaskleeCartPreview.ts +142 -0
- package/templates/app/composables/useBaskleeCategoryLink.ts +24 -0
- package/templates/app/composables/useBaskleeCategoryProducts.ts +16 -0
- package/templates/app/composables/useBaskleeFeature.ts +100 -0
- package/templates/app/composables/useBaskleeFeaturedProducts.ts +14 -0
- package/templates/app/composables/useBaskleeGeolocation.ts +28 -0
- package/templates/app/composables/useBaskleeHomeProducts.ts +90 -0
- package/templates/app/composables/useBaskleeManufacturerIndex.ts +83 -0
- package/templates/app/composables/useBaskleeMap.ts +240 -0
- package/templates/app/composables/useBaskleeMediaFormat.ts +24 -0
- package/templates/app/composables/useBaskleeMissingPage.ts +67 -0
- package/templates/app/composables/useBaskleeOrders.ts +185 -0
- package/templates/app/composables/useBaskleePageSeo.ts +133 -0
- package/templates/app/composables/useBaskleeProductActions.ts +116 -0
- package/templates/app/composables/useBaskleeProductLink.ts +24 -0
- package/templates/app/composables/useBaskleeProductSearch.ts +363 -0
- package/templates/app/composables/useBaskleeProductVariants.ts +176 -0
- package/templates/app/composables/useBaskleeProfile.ts +309 -0
- package/templates/app/composables/useBaskleeProgress.ts +89 -0
- package/templates/app/composables/useBaskleeReviews.ts +242 -0
- package/templates/app/composables/useBaskleeSearchHistory.ts +23 -0
- package/templates/app/composables/useBaskleeSearchScopeNames.ts +99 -0
- package/templates/app/composables/useBaskleeServerData.ts +72 -0
- package/templates/app/composables/useBaskleeSignIn.ts +66 -0
- package/templates/app/composables/useBaskleeStableHeight.ts +69 -0
- package/templates/app/composables/useBaskleeStorefront.ts +29 -0
- package/templates/app/composables/useBaskleeSubscriptions.ts +260 -0
- package/templates/app/composables/useBaskleeTheme.ts +27 -0
- package/templates/app/composables/useBaskleeTicketSubject.ts +180 -0
- package/templates/app/composables/useBaskleeTickets.ts +335 -0
- package/templates/app/composables/useBaskleeWallet.ts +166 -0
- package/templates/app/error.vue +108 -0
- package/templates/app/interfaces/basklee/accounts/IContact.ts +21 -0
- package/templates/app/interfaces/basklee/accounts/IEmailNotificationLocale.ts +17 -0
- package/templates/app/interfaces/basklee/accounts/IEmailVerification.ts +59 -0
- package/templates/app/interfaces/basklee/accounts/IProfileActions.ts +38 -0
- package/templates/app/interfaces/basklee/accounts/IProfileData.ts +125 -0
- package/templates/app/interfaces/basklee/accounts/IProfileMedia.ts +17 -0
- package/templates/app/interfaces/basklee/accounts/IStorefrontProfile.ts +54 -0
- package/templates/app/interfaces/basklee/address/IAddressCitySuggestion.ts +19 -0
- package/templates/app/interfaces/basklee/address/IAddressEditor.ts +9 -0
- package/templates/app/interfaces/basklee/address/IAddressLocationSuggestion.ts +22 -0
- package/templates/app/interfaces/basklee/address/IAddressRegionSearch.ts +30 -0
- package/templates/app/interfaces/basklee/address/IAddressSuggestion.ts +20 -0
- package/templates/app/interfaces/basklee/address/IUserAddress.ts +87 -0
- package/templates/app/interfaces/basklee/apiBase/TMethod.ts +1 -0
- package/templates/app/interfaces/basklee/appBase/IAppLoad.ts +16 -0
- package/templates/app/interfaces/basklee/appBase/IAppLoadCommon.ts +47 -0
- package/templates/app/interfaces/basklee/appBase/IApploadUserProfile.ts +15 -0
- package/templates/app/interfaces/basklee/appBase/IForm.ts +21 -0
- package/templates/app/interfaces/basklee/appBase/ISEO.ts +21 -0
- package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonBanner.ts +11 -0
- package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonContact.ts +8 -0
- package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonCurrency.ts +15 -0
- package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonEvents.ts +18 -0
- package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonLocale.ts +14 -0
- package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonLogos.ts +6 -0
- package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonPath.ts +22 -0
- package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonSEO.ts +26 -0
- package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonSocial.ts +15 -0
- package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonTariff.ts +7 -0
- package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonUnit.ts +12 -0
- package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonVariables.ts +8 -0
- package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonVisualSettings.ts +11 -0
- package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonWalletValue.ts +3 -0
- package/templates/app/interfaces/basklee/blog/IBlogApi.ts +247 -0
- package/templates/app/interfaces/basklee/blog/IBlogPostPreview.ts +30 -0
- package/templates/app/interfaces/basklee/cart/ICartActions.ts +67 -0
- package/templates/app/interfaces/basklee/cart/ICartData.ts +382 -0
- package/templates/app/interfaces/basklee/cart/ICartDeliveryActions.ts +68 -0
- package/templates/app/interfaces/basklee/cart/ICartModal.ts +22 -0
- package/templates/app/interfaces/basklee/cart/IDeliveryMap.ts +29 -0
- package/templates/app/interfaces/basklee/catalog/ICatalogDirectory.ts +75 -0
- package/templates/app/interfaces/basklee/category/ICategory.ts +41 -0
- package/templates/app/interfaces/basklee/domains/IDomain.ts +13 -0
- package/templates/app/interfaces/basklee/forms/ICustomerSubfilter.ts +19 -0
- package/templates/app/interfaces/basklee/index.ts +57 -0
- package/templates/app/interfaces/basklee/marketing/IPromoActions.ts +51 -0
- package/templates/app/interfaces/basklee/orders/IOrderActions.ts +99 -0
- package/templates/app/interfaces/basklee/orders/IOrderHistory.ts +259 -0
- package/templates/app/interfaces/basklee/orders/IProductPreorder.ts +31 -0
- package/templates/app/interfaces/basklee/payments/IInvoice.ts +147 -0
- package/templates/app/interfaces/basklee/products/IProduct.ts +262 -0
- package/templates/app/interfaces/basklee/products/IProductFeedbackApi.ts +218 -0
- package/templates/app/interfaces/basklee/products/IProductSearchApi.ts +146 -0
- package/templates/app/interfaces/basklee/products/IProductSearchFacets.ts +35 -0
- package/templates/app/interfaces/basklee/products/IProductSecondaryVariantRequest.ts +15 -0
- package/templates/app/interfaces/basklee/products/IProductSpecification.ts +14 -0
- package/templates/app/interfaces/basklee/products/IWishlist.ts +22 -0
- package/templates/app/interfaces/basklee/sellers/ISellerDirectory.ts +70 -0
- package/templates/app/interfaces/basklee/shared/IBreadcrumb.ts +10 -0
- package/templates/app/interfaces/basklee/shared/IGeoCoordinates.ts +4 -0
- package/templates/app/interfaces/basklee/shared/IStorefrontControls.ts +13 -0
- package/templates/app/interfaces/basklee/shared/ITransformValue.ts +3 -0
- package/templates/app/interfaces/basklee/state.ts +4 -0
- package/templates/app/interfaces/basklee/stores/IStoreDirectory.ts +63 -0
- package/templates/app/interfaces/basklee/subscribeOptions/ISubscribeOption.ts +9 -0
- package/templates/app/interfaces/basklee/subscribeTariff/ISubscribeTariff.ts +56 -0
- package/templates/app/interfaces/basklee/subscribeTariff/ITariffSelection.ts +11 -0
- package/templates/app/interfaces/basklee/subscribes/ISubscribe.ts +28 -0
- package/templates/app/interfaces/basklee/subscribes/ISubscriptionApi.ts +127 -0
- package/templates/app/interfaces/basklee/tickets/ICustomerTicketApi.ts +223 -0
- package/templates/app/interfaces/basklee/transport.ts +34 -0
- package/templates/app/layouts/default.vue +382 -0
- package/templates/app/middleware/00.basklee.global.ts +27 -0
- package/templates/app/middleware/01.basklee-sellers.global.ts +15 -0
- package/templates/app/middleware/basklee-account.ts +40 -0
- package/templates/app/pages/activity.vue +19 -0
- package/templates/app/pages/addresses.vue +23 -0
- package/templates/app/pages/browse.vue +253 -0
- package/templates/app/pages/cart.vue +20 -0
- package/templates/app/pages/catalog.vue +17 -0
- package/templates/app/pages/category/[id].vue +150 -0
- package/templates/app/pages/contact.vue +17 -0
- package/templates/app/pages/featured.vue +152 -0
- package/templates/app/pages/index.vue +194 -0
- package/templates/app/pages/journal/[id].vue +164 -0
- package/templates/app/pages/journal/index.vue +74 -0
- package/templates/app/pages/logout.vue +71 -0
- package/templates/app/pages/manufacturers.vue +33 -0
- package/templates/app/pages/orders.vue +40 -0
- package/templates/app/pages/privacy.vue +17 -0
- package/templates/app/pages/product/[id].vue +150 -0
- package/templates/app/pages/profile.vue +118 -0
- package/templates/app/pages/promo/[id].vue +67 -0
- package/templates/app/pages/promocodes.vue +21 -0
- package/templates/app/pages/sellers.vue +203 -0
- package/templates/app/pages/stores.vue +36 -0
- package/templates/app/pages/subscriptions.vue +21 -0
- package/templates/app/pages/tariffs/[slug]/[id].vue +126 -0
- package/templates/app/pages/tariffs/index.vue +50 -0
- package/templates/app/pages/tickets.vue +56 -0
- package/templates/app/pages/unsubscribe.vue +32 -0
- package/templates/app/pages/wallet.vue +23 -0
- package/templates/app/pages/wishlist.vue +48 -0
- package/templates/app/stores/basklee.ts +493 -0
- package/templates/app/stores/baskleeBrowse.ts +79 -0
- package/templates/app/stores/baskleeCatalog.ts +141 -0
- package/templates/app/stores/baskleeDomainAccess.ts +55 -0
- package/templates/app/stores/baskleeProducts.ts +249 -0
- package/templates/app/stores/baskleeSelections.ts +132 -0
- package/templates/app/themes/basklee.ts +108 -0
- package/templates/app/utils/basklee/accountLabels.ts +29 -0
- package/templates/app/utils/basklee/activityLabels.ts +96 -0
- package/templates/app/utils/basklee/activityPresentation.ts +16 -0
- package/templates/app/utils/basklee/addressChanges.ts +26 -0
- package/templates/app/utils/basklee/addressRegions.ts +17 -0
- package/templates/app/utils/basklee/api.ts +333 -0
- package/templates/app/utils/basklee/blogArticleHtml.ts +318 -0
- package/templates/app/utils/basklee/blogComments.ts +133 -0
- package/templates/app/utils/basklee/blogImageViewer.ts +84 -0
- package/templates/app/utils/basklee/blogLabels.ts +167 -0
- package/templates/app/utils/basklee/blogLayout.ts +108 -0
- package/templates/app/utils/basklee/blogProductPlacements.ts +105 -0
- package/templates/app/utils/basklee/breadcrumbLabels.ts +14 -0
- package/templates/app/utils/basklee/browseLabels.ts +145 -0
- package/templates/app/utils/basklee/cartAddress.ts +94 -0
- package/templates/app/utils/basklee/cartLabels.ts +390 -0
- package/templates/app/utils/basklee/cartOptions.ts +143 -0
- package/templates/app/utils/basklee/cartPreview.ts +123 -0
- package/templates/app/utils/basklee/cartPromo.ts +150 -0
- package/templates/app/utils/basklee/cartShipment.ts +74 -0
- package/templates/app/utils/basklee/cartSnapshot.ts +20 -0
- package/templates/app/utils/basklee/catalog.ts +106 -0
- package/templates/app/utils/basklee/category.ts +52 -0
- package/templates/app/utils/basklee/categoryLabels.ts +44 -0
- package/templates/app/utils/basklee/contactLabels.ts +152 -0
- package/templates/app/utils/basklee/currency.ts +128 -0
- package/templates/app/utils/basklee/deliveryMap.ts +89 -0
- package/templates/app/utils/basklee/directoryLabels.ts +196 -0
- package/templates/app/utils/basklee/emptyStateArt.ts +231 -0
- package/templates/app/utils/basklee/errorPageLabels.ts +95 -0
- package/templates/app/utils/basklee/featureData.ts +25 -0
- package/templates/app/utils/basklee/featureLabels.ts +406 -0
- package/templates/app/utils/basklee/featuredLabels.ts +38 -0
- package/templates/app/utils/basklee/files.ts +71 -0
- package/templates/app/utils/basklee/footerLabels.ts +53 -0
- package/templates/app/utils/basklee/guestSession.ts +50 -0
- package/templates/app/utils/basklee/headerLabels.ts +98 -0
- package/templates/app/utils/basklee/homeContent.ts +129 -0
- package/templates/app/utils/basklee/homeLabels.ts +74 -0
- package/templates/app/utils/basklee/htmlText.ts +59 -0
- package/templates/app/utils/basklee/links.ts +14 -0
- package/templates/app/utils/basklee/manufacturerIndex.ts +108 -0
- package/templates/app/utils/basklee/modalWindow.ts +109 -0
- package/templates/app/utils/basklee/nativeApp.ts +361 -0
- package/templates/app/utils/basklee/notice.ts +22 -0
- package/templates/app/utils/basklee/orderLabels.ts +454 -0
- package/templates/app/utils/basklee/orderPresentation.ts +629 -0
- package/templates/app/utils/basklee/pageSeo.ts +662 -0
- package/templates/app/utils/basklee/paginationScroll.ts +131 -0
- package/templates/app/utils/basklee/phone.ts +22 -0
- package/templates/app/utils/basklee/presentation.ts +72 -0
- package/templates/app/utils/basklee/privacyLabels.ts +273 -0
- package/templates/app/utils/basklee/productActionLabels.ts +108 -0
- package/templates/app/utils/basklee/productActions.ts +574 -0
- package/templates/app/utils/basklee/productAvailability.ts +36 -0
- package/templates/app/utils/basklee/productGallery.ts +72 -0
- package/templates/app/utils/basklee/productLabels.ts +119 -0
- package/templates/app/utils/basklee/productListLocation.ts +130 -0
- package/templates/app/utils/basklee/productManufacturer.ts +30 -0
- package/templates/app/utils/basklee/productPage.ts +46 -0
- package/templates/app/utils/basklee/productPhotos.ts +67 -0
- package/templates/app/utils/basklee/productSearchScope.ts +237 -0
- package/templates/app/utils/basklee/productSeller.ts +51 -0
- package/templates/app/utils/basklee/productStructuredData.ts +221 -0
- package/templates/app/utils/basklee/profile.ts +148 -0
- package/templates/app/utils/basklee/profileLabels.ts +229 -0
- package/templates/app/utils/basklee/promoLabels.ts +111 -0
- package/templates/app/utils/basklee/promoPresentation.ts +381 -0
- package/templates/app/utils/basklee/reviewLabels.ts +256 -0
- package/templates/app/utils/basklee/reviewScope.ts +41 -0
- package/templates/app/utils/basklee/richText.ts +13 -0
- package/templates/app/utils/basklee/searchFilters.ts +99 -0
- package/templates/app/utils/basklee/searchHistory.ts +144 -0
- package/templates/app/utils/basklee/sellerDirectory.ts +134 -0
- package/templates/app/utils/basklee/seo.ts +52 -0
- package/templates/app/utils/basklee/serverCookies.ts +88 -0
- package/templates/app/utils/basklee/sessionLabels.ts +38 -0
- package/templates/app/utils/basklee/signInReturn.ts +89 -0
- package/templates/app/utils/basklee/storeDirectory.ts +50 -0
- package/templates/app/utils/basklee/subscriptionChanges.ts +167 -0
- package/templates/app/utils/basklee/subscriptionLabels.ts +100 -0
- package/templates/app/utils/basklee/subscriptionManageLabels.ts +424 -0
- package/templates/app/utils/basklee/subscriptionPlans.ts +162 -0
- package/templates/app/utils/basklee/subscriptionRemote.ts +110 -0
- package/templates/app/utils/basklee/subscriptionUsage.ts +82 -0
- package/templates/app/utils/basklee/tariffLabels.ts +182 -0
- package/templates/app/utils/basklee/tariffPage.ts +77 -0
- package/templates/app/utils/basklee/tariffVariables.ts +203 -0
- package/templates/app/utils/basklee/tariffs.ts +333 -0
- package/templates/app/utils/basklee/ticketItems.ts +87 -0
- package/templates/app/utils/basklee/ticketLabels.ts +428 -0
- package/templates/app/utils/basklee/ticketLocation.ts +79 -0
- package/templates/app/utils/basklee/walletTransaction.ts +135 -0
- package/templates/app/utils/baskleeAppLoad.ts +83 -0
- package/templates/basklee/COMPONENT-DOWNLOAD.md +40 -0
- package/templates/basklee/COMPONENTS.md +1993 -0
- package/templates/basklee/THEMES.md +94 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
IUserAddress,
|
|
3
|
+
IUserAddressRequest,
|
|
4
|
+
} from '@/interfaces/basklee/address/IUserAddress';
|
|
5
|
+
|
|
6
|
+
// The fields an address plugin may rewrite when it recognizes the address
|
|
7
|
+
// (the backend normalizes city, street, house, second line and postcode).
|
|
8
|
+
export const refinableAddressFields = [
|
|
9
|
+
'city',
|
|
10
|
+
'line1',
|
|
11
|
+
'line2',
|
|
12
|
+
'house_number',
|
|
13
|
+
'postcode',
|
|
14
|
+
] as const;
|
|
15
|
+
|
|
16
|
+
export type RefinableAddressField = (typeof refinableAddressFields)[number];
|
|
17
|
+
|
|
18
|
+
// The fields whose saved value differs from the value the customer sent.
|
|
19
|
+
export function refinedAddressFields(
|
|
20
|
+
sent: IUserAddressRequest,
|
|
21
|
+
saved: IUserAddress,
|
|
22
|
+
): RefinableAddressField[] {
|
|
23
|
+
return refinableAddressFields.filter(
|
|
24
|
+
(name) => (sent[name] ?? '').trim() !== (saved[name] ?? '').trim(),
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { IAddressRegion } from '@/interfaces/basklee/address/IAddressRegionSearch';
|
|
2
|
+
|
|
3
|
+
// Region search compares the typed text with every translated region name, so
|
|
4
|
+
// the same region arrives once per language whose name matches. The field lists
|
|
5
|
+
// each region once, keeping its first entry in the order the search returned.
|
|
6
|
+
export function uniqueAddressRegions(regions: IAddressRegion[]) {
|
|
7
|
+
const listed = new Set<number>();
|
|
8
|
+
|
|
9
|
+
return regions.filter((region) => {
|
|
10
|
+
if (listed.has(region.id)) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
listed.add(region.id);
|
|
15
|
+
return true;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import type { IAppLoadPathObject } from '@/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonPath';
|
|
2
|
+
import type { TMethod } from '@/interfaces/basklee/apiBase/TMethod';
|
|
3
|
+
|
|
4
|
+
export interface BaskleeApiResponse {
|
|
5
|
+
body: unknown;
|
|
6
|
+
status: number;
|
|
7
|
+
cookies: string[];
|
|
8
|
+
headers?: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type BaskleeApiData = Record<string, unknown> | FormData;
|
|
12
|
+
|
|
13
|
+
export interface BaskleeApiRequest {
|
|
14
|
+
method: TMethod;
|
|
15
|
+
data: BaskleeApiData;
|
|
16
|
+
headers: Record<string, string>;
|
|
17
|
+
signal?: AbortSignal;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type BaskleeTransport = (
|
|
21
|
+
path: string,
|
|
22
|
+
request: BaskleeApiRequest,
|
|
23
|
+
) => Promise<BaskleeApiResponse>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The texts of the field errors, each once: Basklee often repeats a
|
|
27
|
+
* field's error for the whole form.
|
|
28
|
+
*/
|
|
29
|
+
export function fieldErrorText(fields: Record<string, unknown>) {
|
|
30
|
+
return [...new Set(Object.values(fields).filter(Boolean))].join(' ');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export class BaskleeApiError extends Error {
|
|
34
|
+
readonly kind: 'unavailable' | 'failed';
|
|
35
|
+
readonly fields: Record<string, string>;
|
|
36
|
+
readonly status?: number;
|
|
37
|
+
readonly data?: unknown;
|
|
38
|
+
// Error codes of the answer, such as `sign_in` when Basklee asks the visitor
|
|
39
|
+
// to sign in first.
|
|
40
|
+
readonly codes: string[];
|
|
41
|
+
|
|
42
|
+
constructor(
|
|
43
|
+
kind: 'unavailable' | 'failed',
|
|
44
|
+
fields: Record<string, string> = {},
|
|
45
|
+
status?: number,
|
|
46
|
+
data?: unknown,
|
|
47
|
+
codes: string[] = [],
|
|
48
|
+
) {
|
|
49
|
+
super(fieldErrorText(fields) || kind);
|
|
50
|
+
this.kind = kind;
|
|
51
|
+
this.fields = fields;
|
|
52
|
+
this.status = status;
|
|
53
|
+
this.data = data;
|
|
54
|
+
this.codes = codes;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Requests whose amounts the backend counts in the customer's currency: an
|
|
60
|
+
* order, a preorder and a plan purchase are priced and charged in it. The
|
|
61
|
+
* client adds the selected currency to them (unless the caller set one).
|
|
62
|
+
*/
|
|
63
|
+
export const CURRENCY_REQUESTS = new Set([
|
|
64
|
+
'orders_create',
|
|
65
|
+
'preorders_create',
|
|
66
|
+
'subscriptions_subscribe',
|
|
67
|
+
'subscriptions_renew',
|
|
68
|
+
'subscriptions_change_renew',
|
|
69
|
+
'subscriptions_change_tariff',
|
|
70
|
+
'subscriptions_change_option',
|
|
71
|
+
]);
|
|
72
|
+
|
|
73
|
+
export class BaskleeApi {
|
|
74
|
+
private renewal: Promise<void> | undefined;
|
|
75
|
+
private sessionEnding: Promise<void> | undefined;
|
|
76
|
+
private transport: BaskleeTransport;
|
|
77
|
+
private endpoints: () => IAppLoadPathObject;
|
|
78
|
+
private cookies: () => string;
|
|
79
|
+
private locale: () => string;
|
|
80
|
+
private canRequest: () => boolean;
|
|
81
|
+
private isSignedIn: () => boolean;
|
|
82
|
+
private currency: () => string | number | undefined;
|
|
83
|
+
private onSessionEnded: (() => unknown) | undefined;
|
|
84
|
+
|
|
85
|
+
constructor(options: {
|
|
86
|
+
transport: BaskleeTransport;
|
|
87
|
+
endpoints: () => IAppLoadPathObject;
|
|
88
|
+
cookies: () => string;
|
|
89
|
+
locale?: () => string;
|
|
90
|
+
canRequest?: () => boolean;
|
|
91
|
+
isSignedIn?: () => boolean;
|
|
92
|
+
currency?: () => string | number | undefined;
|
|
93
|
+
onSessionEnded?: () => unknown;
|
|
94
|
+
}) {
|
|
95
|
+
this.transport = options.transport;
|
|
96
|
+
this.endpoints = options.endpoints;
|
|
97
|
+
this.cookies = options.cookies;
|
|
98
|
+
this.locale = options.locale ?? (() => '');
|
|
99
|
+
this.canRequest = options.canRequest ?? (() => true);
|
|
100
|
+
this.isSignedIn = options.isSignedIn ?? (() => false);
|
|
101
|
+
this.currency = options.currency ?? (() => undefined);
|
|
102
|
+
this.onSessionEnded = options.onSessionEnded;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** The guest refresh started by the latest HTTP 401, while it runs. */
|
|
106
|
+
get sessionEnd() {
|
|
107
|
+
return this.sessionEnding;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
applicationLoad(signal: AbortSignal, locale = '') {
|
|
111
|
+
return this.send(
|
|
112
|
+
'/api/appload',
|
|
113
|
+
'POST',
|
|
114
|
+
{
|
|
115
|
+
detalize_mode: 'light',
|
|
116
|
+
ignore_cache: false,
|
|
117
|
+
},
|
|
118
|
+
signal,
|
|
119
|
+
locale,
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async request<T>(
|
|
124
|
+
name: string,
|
|
125
|
+
data: BaskleeApiData,
|
|
126
|
+
signal?: AbortSignal,
|
|
127
|
+
params: Record<string, number> = {},
|
|
128
|
+
): Promise<T> {
|
|
129
|
+
return this.successData<T>(
|
|
130
|
+
await this.requestResponse(name, data, signal, params),
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async requestResponse(
|
|
135
|
+
name: string,
|
|
136
|
+
data: BaskleeApiData,
|
|
137
|
+
signal?: AbortSignal,
|
|
138
|
+
params: Record<string, number> = {},
|
|
139
|
+
): Promise<BaskleeApiResponse> {
|
|
140
|
+
if (!this.canRequest()) {
|
|
141
|
+
throw new BaskleeApiError('unavailable');
|
|
142
|
+
}
|
|
143
|
+
const discovered = Object.values(this.endpoints())
|
|
144
|
+
.flatMap((section) => Object.values(section))
|
|
145
|
+
.find((entry) => entry.url_name === name);
|
|
146
|
+
const endpoint =
|
|
147
|
+
discovered ??
|
|
148
|
+
(name === 'reload_customer_app'
|
|
149
|
+
? { target: 'api/reload_customer_app', methods: ['PATCH' as const] }
|
|
150
|
+
: undefined);
|
|
151
|
+
const method = endpoint?.methods[0];
|
|
152
|
+
let path = `/${endpoint?.target.replace(/^\/+/, '') ?? ''}`;
|
|
153
|
+
path = path.replace(/\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g, (_, key: string) => {
|
|
154
|
+
const value = params[key];
|
|
155
|
+
if (!Number.isSafeInteger(value) || Number(value) <= 0) {
|
|
156
|
+
throw new BaskleeApiError('unavailable');
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return String(value);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
if (
|
|
163
|
+
!endpoint ||
|
|
164
|
+
!method ||
|
|
165
|
+
!/^\/api\/[a-zA-Z0-9_/-]+(?:\.png)?$/.test(path)
|
|
166
|
+
) {
|
|
167
|
+
throw new BaskleeApiError('unavailable');
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (method === 'GET' && data instanceof FormData) {
|
|
171
|
+
throw new BaskleeApiError('unavailable');
|
|
172
|
+
}
|
|
173
|
+
const currency = Number(this.currency());
|
|
174
|
+
if (
|
|
175
|
+
CURRENCY_REQUESTS.has(name) &&
|
|
176
|
+
!(data instanceof FormData) &&
|
|
177
|
+
data.currency === undefined &&
|
|
178
|
+
Number.isSafeInteger(currency) &&
|
|
179
|
+
currency > 0
|
|
180
|
+
) {
|
|
181
|
+
data = { ...data, currency };
|
|
182
|
+
}
|
|
183
|
+
const protectedRequest = method !== 'GET';
|
|
184
|
+
if (protectedRequest && !this.csrfToken()) {
|
|
185
|
+
await this.renewCsrf();
|
|
186
|
+
}
|
|
187
|
+
signal?.throwIfAborted();
|
|
188
|
+
|
|
189
|
+
const response = await this.send(path, method, data, signal);
|
|
190
|
+
const body = response.body as {
|
|
191
|
+
page_data?: { csrf?: boolean };
|
|
192
|
+
} | null;
|
|
193
|
+
// A CSRF rejection: Django views answer 419, API endpoints answer 403
|
|
194
|
+
// with page_data.csrf set to false. The request is not repeated.
|
|
195
|
+
const csrfRejected =
|
|
196
|
+
response.status === 419 ||
|
|
197
|
+
(response.status === 403 && body?.page_data?.csrf === false);
|
|
198
|
+
// Renew for the next explicit action and retain this request's rejection.
|
|
199
|
+
if (protectedRequest && csrfRejected) {
|
|
200
|
+
await this.renewCsrf();
|
|
201
|
+
signal?.throwIfAborted();
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
this.detectSessionEnd(response);
|
|
205
|
+
signal?.throwIfAborted();
|
|
206
|
+
return response;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/*
|
|
210
|
+
* The backend answers HTTP 401 when the request has no signed-in session:
|
|
211
|
+
* an authentication-required endpoint without a customer ({ auth: false }),
|
|
212
|
+
* or a session the backend rejected and whose cookies it deleted.
|
|
213
|
+
* A 401 while the application still shows a customer means the session
|
|
214
|
+
* ended. One handler call serves concurrent failures; a guest 401, 403 and
|
|
215
|
+
* CSRF rejection are ordinary request errors.
|
|
216
|
+
*/
|
|
217
|
+
private detectSessionEnd(response: BaskleeApiResponse) {
|
|
218
|
+
if (
|
|
219
|
+
response.status !== 401 ||
|
|
220
|
+
this.sessionEnding ||
|
|
221
|
+
!this.onSessionEnded ||
|
|
222
|
+
!this.isSignedIn()
|
|
223
|
+
) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
let ending: Promise<void>;
|
|
228
|
+
try {
|
|
229
|
+
ending = Promise.resolve(this.onSessionEnded()).then(() => undefined);
|
|
230
|
+
} catch (error) {
|
|
231
|
+
ending = Promise.reject(error);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// The failed request reports its own error; the refresh has its own state.
|
|
235
|
+
this.sessionEnding = ending
|
|
236
|
+
.catch(() => undefined)
|
|
237
|
+
.finally(() => {
|
|
238
|
+
this.sessionEnding = undefined;
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
private csrfToken() {
|
|
243
|
+
return this.cookies().match(/(?:^|;\s*)csrftoken=([^;]*)/)?.[1] ?? '';
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
private localizedPath(path: string, requestedLocale = '') {
|
|
247
|
+
const locale = (requestedLocale || this.locale()).trim();
|
|
248
|
+
if (!locale) {
|
|
249
|
+
return path;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const separator = path.includes('?') ? '&' : '?';
|
|
253
|
+
return `${path}${separator}lang=${encodeURIComponent(locale)}`;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
private async renewCsrf() {
|
|
257
|
+
if (!this.renewal) {
|
|
258
|
+
this.renewal = this.send('/api/csrf_renew', 'POST', {})
|
|
259
|
+
.then((response) => {
|
|
260
|
+
this.detectSessionEnd(response);
|
|
261
|
+
this.successData(response);
|
|
262
|
+
if (!this.csrfToken()) {
|
|
263
|
+
throw new BaskleeApiError('failed');
|
|
264
|
+
}
|
|
265
|
+
})
|
|
266
|
+
.finally(() => {
|
|
267
|
+
this.renewal = undefined;
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
await this.renewal;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
private send(
|
|
274
|
+
path: string,
|
|
275
|
+
method: TMethod,
|
|
276
|
+
data: BaskleeApiData,
|
|
277
|
+
signal?: AbortSignal,
|
|
278
|
+
locale = '',
|
|
279
|
+
) {
|
|
280
|
+
const headers: Record<string, string> = {
|
|
281
|
+
Accept: 'application/json',
|
|
282
|
+
...(data instanceof FormData
|
|
283
|
+
? {}
|
|
284
|
+
: { 'Content-Type': 'application/json' }),
|
|
285
|
+
};
|
|
286
|
+
const token = this.csrfToken();
|
|
287
|
+
if (token) {
|
|
288
|
+
headers['X-CSRFToken'] = token;
|
|
289
|
+
}
|
|
290
|
+
return this.transport(this.localizedPath(path, locale), {
|
|
291
|
+
method,
|
|
292
|
+
data,
|
|
293
|
+
headers,
|
|
294
|
+
signal,
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
private successData<T>(response: BaskleeApiResponse): T {
|
|
299
|
+
const body = response.body as {
|
|
300
|
+
form_errors?: unknown;
|
|
301
|
+
success_message?: unknown;
|
|
302
|
+
page_data?: T;
|
|
303
|
+
} | null;
|
|
304
|
+
if (
|
|
305
|
+
response.status < 200 ||
|
|
306
|
+
response.status >= 300 ||
|
|
307
|
+
body?.form_errors !== null ||
|
|
308
|
+
typeof body.success_message !== 'string' ||
|
|
309
|
+
!body.success_message
|
|
310
|
+
) {
|
|
311
|
+
const fields = Object.fromEntries(
|
|
312
|
+
Object.entries(body?.form_errors ?? {}).map(([name, entries]) => [
|
|
313
|
+
name,
|
|
314
|
+
Array.isArray(entries)
|
|
315
|
+
? entries.map((entry) => String(entry?.message ?? '')).join(' ')
|
|
316
|
+
: '',
|
|
317
|
+
]),
|
|
318
|
+
);
|
|
319
|
+
const codes = Object.values(body?.form_errors ?? {})
|
|
320
|
+
.flatMap((entries) => (Array.isArray(entries) ? entries : []))
|
|
321
|
+
.map((entry) => String(entry?.code ?? ''))
|
|
322
|
+
.filter(Boolean);
|
|
323
|
+
throw new BaskleeApiError(
|
|
324
|
+
'failed',
|
|
325
|
+
fields,
|
|
326
|
+
response.status,
|
|
327
|
+
body?.page_data,
|
|
328
|
+
codes,
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
return body.page_data as T;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import DOMPurify from 'dompurify';
|
|
2
|
+
import type {
|
|
3
|
+
Config,
|
|
4
|
+
DOMPurify as TPurifier,
|
|
5
|
+
UponSanitizeAttributeHookEvent,
|
|
6
|
+
} from 'dompurify';
|
|
7
|
+
import { htmlTextParagraphs } from '@/utils/basklee/htmlText';
|
|
8
|
+
import { appMediaUrl } from '@/utils/basklee/nativeApp';
|
|
9
|
+
|
|
10
|
+
type TStylePatterns = Record<string, RegExp>;
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
* Article HTML comes from the marketplace blog editor and is stored as-is by
|
|
14
|
+
* the backend, so the storefront sanitizes it before display. The allowlist
|
|
15
|
+
* matches what that editor writes: text formatting, headings, lists and task
|
|
16
|
+
* lists, quotes, code blocks, tables, images and galleries, videos,
|
|
17
|
+
* collapsible sections, formulas and alignment, color and size styles.
|
|
18
|
+
* The editor has no embedded frames, so iframes stay forbidden.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
export const blogArticleTags = [
|
|
22
|
+
'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
|
|
23
|
+
'p', 'br', 'hr', 'span', 'div',
|
|
24
|
+
'strong', 'b', 'em', 'i', 'u', 's', 'strike', 'del', 'ins', 'mark',
|
|
25
|
+
'sub', 'sup', 'small', 'abbr', 'cite', 'q', 'kbd', 'samp', 'var', 'time',
|
|
26
|
+
'a',
|
|
27
|
+
'ul', 'ol', 'li', 'label', 'input',
|
|
28
|
+
'blockquote', 'pre', 'code',
|
|
29
|
+
'table', 'caption', 'colgroup', 'col',
|
|
30
|
+
'thead', 'tbody', 'tfoot', 'tr', 'th', 'td',
|
|
31
|
+
'img', 'figure', 'figcaption',
|
|
32
|
+
'video', 'audio', 'source', 'track',
|
|
33
|
+
'details', 'summary',
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
const attributes = [
|
|
37
|
+
'href', 'title', 'target', 'rel', 'lang', 'dir', 'cite', 'datetime',
|
|
38
|
+
'src', 'alt', 'width', 'height', 'loading', 'decoding',
|
|
39
|
+
'poster', 'controls', 'playsinline', 'preload', 'muted', 'loop',
|
|
40
|
+
'type', 'srclang', 'kind', 'label', 'default',
|
|
41
|
+
'start', 'reversed', 'colspan', 'rowspan', 'scope', 'span',
|
|
42
|
+
'open', 'checked', 'disabled', 'class', 'style',
|
|
43
|
+
'data-type', 'data-checked', 'data-latex',
|
|
44
|
+
'data-text-color', 'data-bg-color', 'data-background',
|
|
45
|
+
'data-text-align', 'data-vertical-align', 'data-colwidth',
|
|
46
|
+
'data-code-scheme', 'data-gallery-width', 'data-list-offset',
|
|
47
|
+
'data-float', 'data-blog-video', 'data-details-content',
|
|
48
|
+
'data-product-id', 'data-product-ids', 'data-product-hidden-badges',
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
const marginLength = '(-?\\d+(\\.\\d+)?(px|em|rem|%)?|auto)';
|
|
52
|
+
|
|
53
|
+
// Classes the editor writes for galleries, code blocks and media.
|
|
54
|
+
const editorClasses = new Set([
|
|
55
|
+
'blog-image-gallery',
|
|
56
|
+
'blog-image-gallery__track',
|
|
57
|
+
'blog-code-block',
|
|
58
|
+
'blog-post-editor-image',
|
|
59
|
+
'blog-post-editor-video',
|
|
60
|
+
]);
|
|
61
|
+
|
|
62
|
+
// The editor's named text and background colors.
|
|
63
|
+
export const blogArticleColorTokens = new Set([
|
|
64
|
+
'gray',
|
|
65
|
+
'brown',
|
|
66
|
+
'orange',
|
|
67
|
+
'yellow',
|
|
68
|
+
'green',
|
|
69
|
+
'blue',
|
|
70
|
+
'purple',
|
|
71
|
+
'pink',
|
|
72
|
+
'red',
|
|
73
|
+
]);
|
|
74
|
+
|
|
75
|
+
const styleValues: TStylePatterns = {
|
|
76
|
+
'color': /^[#\w\s.,%()-]+$/,
|
|
77
|
+
'background-color': /^[#\w\s.,%()-]+$/,
|
|
78
|
+
'text-align': /^(left|right|center|justify|start|end)$/,
|
|
79
|
+
'font-size': /^\d+(\.\d+)?(px|em|rem|%|pt)$/,
|
|
80
|
+
'font-family': /^[\w\s,'"-]+$/,
|
|
81
|
+
'line-height': /^\d+(\.\d+)?(px|em|rem|%)?$/,
|
|
82
|
+
'width': /^(\d+(\.\d+)?(px|%)|auto)$/,
|
|
83
|
+
'max-width': /^(\d+(\.\d+)?(px|%)|none)$/,
|
|
84
|
+
'margin': new RegExp(`^${marginLength}(\\s+${marginLength}){0,3}$`),
|
|
85
|
+
'margin-left': new RegExp(`^${marginLength}$`),
|
|
86
|
+
'margin-right': new RegExp(`^${marginLength}$`),
|
|
87
|
+
'float': /^(left|right|none)$/,
|
|
88
|
+
'display': /^(block|inline|inline-block)$/,
|
|
89
|
+
'position': /^relative$/,
|
|
90
|
+
'left': /^-?\d+(\.\d+)?px$/,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const unsafeStyle = /url\s*\(|expression|javascript:|[\\@<>]|\/\*/i;
|
|
94
|
+
|
|
95
|
+
// Web, mail and phone links; values without a scheme, such as a path or a
|
|
96
|
+
// number, pass as well. Any other scheme, including javascript:, is removed.
|
|
97
|
+
const safeUri =
|
|
98
|
+
/^(?:(?:https?|mailto|tel):|[^a-z]|[a-z+.-]+(?:[^a-z+.\-:]|$))/i;
|
|
99
|
+
|
|
100
|
+
// The editor links other articles as /blog/<slug>/<id>, optionally after a
|
|
101
|
+
// locale prefix; the storefront opens them at /journal/<id>.
|
|
102
|
+
const editorArticlePath =
|
|
103
|
+
/^\/(?:[a-z]{2}(?:-[a-z]{2})?\/)?blog\/[^/?#]+\/([1-9]\d*)\/?$/i;
|
|
104
|
+
|
|
105
|
+
const authorRelTokens = new Set(['nofollow', 'sponsored', 'ugc']);
|
|
106
|
+
|
|
107
|
+
function normalizedHeadingText(value: string) {
|
|
108
|
+
return htmlTextParagraphs(value)
|
|
109
|
+
.join(' ')
|
|
110
|
+
.normalize('NFKC')
|
|
111
|
+
.replace(/\s+/g, ' ')
|
|
112
|
+
.trim()
|
|
113
|
+
.toLocaleLowerCase();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Removes only a first h1 whose text repeats the title rendered by the page. */
|
|
117
|
+
export function removeLeadingDuplicateBlogHeading(
|
|
118
|
+
value: string,
|
|
119
|
+
title: string,
|
|
120
|
+
) {
|
|
121
|
+
const heading = /^(\s*(?:<!--[\s\S]*?-->\s*)*)<h1(?:\s[^>]*)?>([\s\S]*?)<\/h1\s*>/i
|
|
122
|
+
.exec(value);
|
|
123
|
+
|
|
124
|
+
if (
|
|
125
|
+
!heading ||
|
|
126
|
+
!normalizedHeadingText(title) ||
|
|
127
|
+
normalizedHeadingText(heading[2] ?? '') !== normalizedHeadingText(title)
|
|
128
|
+
) {
|
|
129
|
+
return value;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return `${heading[1] ?? ''}${value.slice(heading[0].length)}`;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function safeBlogArticleStyle(value: string) {
|
|
136
|
+
const declarations = value
|
|
137
|
+
.split(';')
|
|
138
|
+
.map((declaration) => {
|
|
139
|
+
const separator = declaration.indexOf(':');
|
|
140
|
+
const name = declaration.slice(0, separator).trim().toLowerCase();
|
|
141
|
+
const property = declaration.slice(separator + 1).trim();
|
|
142
|
+
|
|
143
|
+
return { name, property, separator };
|
|
144
|
+
})
|
|
145
|
+
.filter(({ name, property, separator }) => {
|
|
146
|
+
const pattern = styleValues[name];
|
|
147
|
+
|
|
148
|
+
return (
|
|
149
|
+
separator > 0 &&
|
|
150
|
+
Boolean(pattern) &&
|
|
151
|
+
!unsafeStyle.test(property) &&
|
|
152
|
+
pattern!.test(property)
|
|
153
|
+
);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
return declarations
|
|
157
|
+
.map(({ name, property }) => `${name}: ${property}`)
|
|
158
|
+
.join('; ');
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function filterAttribute(
|
|
162
|
+
node: Element,
|
|
163
|
+
data: UponSanitizeAttributeHookEvent,
|
|
164
|
+
) {
|
|
165
|
+
if (data.attrName === 'style') {
|
|
166
|
+
data.attrValue = safeBlogArticleStyle(data.attrValue);
|
|
167
|
+
data.keepAttr = Boolean(data.attrValue);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (data.attrName === 'class') {
|
|
172
|
+
const classes = data.attrValue
|
|
173
|
+
.split(/\s+/)
|
|
174
|
+
.filter(
|
|
175
|
+
(name) => editorClasses.has(name) || /^language-[\w-]+$/.test(name),
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
data.attrValue = classes.join(' ');
|
|
179
|
+
data.keepAttr = Boolean(data.attrValue);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const isColorToken =
|
|
184
|
+
data.attrName === 'data-text-color' || data.attrName === 'data-bg-color';
|
|
185
|
+
|
|
186
|
+
if (isColorToken && !blogArticleColorTokens.has(data.attrValue)) {
|
|
187
|
+
data.keepAttr = false;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (data.attrName === 'src' && data.attrValue.trim().startsWith('data:')) {
|
|
191
|
+
data.keepAttr = false;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (node.nodeName === 'INPUT' && data.attrName === 'type') {
|
|
195
|
+
data.keepAttr = data.attrValue.toLowerCase() === 'checkbox';
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function prepareLink(link: Element) {
|
|
200
|
+
const href = link.getAttribute('href') ?? '';
|
|
201
|
+
const article = editorArticlePath.exec(href);
|
|
202
|
+
const author = (link.getAttribute('rel') ?? '')
|
|
203
|
+
.toLowerCase()
|
|
204
|
+
.split(/\s+/)
|
|
205
|
+
.filter((token) => authorRelTokens.has(token));
|
|
206
|
+
|
|
207
|
+
if (article) {
|
|
208
|
+
link.setAttribute('href', `/journal/${article[1]}`);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (/^https?:/i.test(href)) {
|
|
212
|
+
link.setAttribute('target', '_blank');
|
|
213
|
+
link.setAttribute('rel', [...author, 'noopener', 'noreferrer'].join(' '));
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
link.removeAttribute('target');
|
|
218
|
+
|
|
219
|
+
if (author.length) {
|
|
220
|
+
link.setAttribute('rel', author.join(' '));
|
|
221
|
+
} else {
|
|
222
|
+
link.removeAttribute('rel');
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// The app build's storefront origin while a sanitize call runs (Nuxt reads
|
|
227
|
+
// it from the runtime config, so BlogArticle passes it in).
|
|
228
|
+
let mediaOrigin = '';
|
|
229
|
+
|
|
230
|
+
function prepareElement(node: Element) {
|
|
231
|
+
const name = node.nodeName;
|
|
232
|
+
|
|
233
|
+
if (name === 'A') {
|
|
234
|
+
prepareLink(node);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (name === 'IMG') {
|
|
238
|
+
node.setAttribute('loading', 'lazy');
|
|
239
|
+
node.setAttribute('decoding', 'async');
|
|
240
|
+
if (!node.hasAttribute('alt')) {
|
|
241
|
+
node.setAttribute('alt', '');
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Media the backend serves itself (`/ps3/...`); see appMediaUrl.
|
|
246
|
+
for (const attribute of ['src', 'poster']) {
|
|
247
|
+
const source = node.getAttribute(attribute);
|
|
248
|
+
|
|
249
|
+
if (source) {
|
|
250
|
+
node.setAttribute(attribute, appMediaUrl(source, mediaOrigin));
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (name === 'VIDEO' || name === 'AUDIO') {
|
|
255
|
+
node.setAttribute('controls', '');
|
|
256
|
+
node.setAttribute('preload', 'metadata');
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (name === 'VIDEO') {
|
|
260
|
+
node.setAttribute('playsinline', '');
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if (name === 'INPUT') {
|
|
264
|
+
if (node.getAttribute('type') !== 'checkbox') {
|
|
265
|
+
node.remove();
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
node.setAttribute('disabled', '');
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// Formulas keep their LaTeX source as readable text.
|
|
272
|
+
const latex = node.getAttribute('data-latex');
|
|
273
|
+
|
|
274
|
+
if (latex && !node.textContent) {
|
|
275
|
+
node.textContent = latex;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function prepareElementHook(node: Node) {
|
|
280
|
+
if (node.nodeType === 1) {
|
|
281
|
+
prepareElement(node as Element);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const config: Config = {
|
|
286
|
+
ALLOWED_TAGS: blogArticleTags,
|
|
287
|
+
ALLOWED_ATTR: attributes,
|
|
288
|
+
ALLOW_DATA_ATTR: false,
|
|
289
|
+
ALLOWED_URI_REGEXP: safeUri,
|
|
290
|
+
SANITIZE_NAMED_PROPS: true,
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Returns article HTML that is safe to render with v-html. `purifier` lets a
|
|
295
|
+
* test pass its own DOMPurify instance; in the browser the default is used.
|
|
296
|
+
* Server rendering returns an empty string and the browser fills the text.
|
|
297
|
+
*/
|
|
298
|
+
export function safeBlogArticleHtml(
|
|
299
|
+
value: string,
|
|
300
|
+
purifier: TPurifier = DOMPurify,
|
|
301
|
+
appOrigin = '',
|
|
302
|
+
) {
|
|
303
|
+
if (!purifier.isSupported) {
|
|
304
|
+
return '';
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
mediaOrigin = appOrigin;
|
|
308
|
+
purifier.addHook('uponSanitizeAttribute', filterAttribute);
|
|
309
|
+
purifier.addHook('afterSanitizeAttributes', prepareElementHook);
|
|
310
|
+
|
|
311
|
+
try {
|
|
312
|
+
return purifier.sanitize(value, config) as string;
|
|
313
|
+
} finally {
|
|
314
|
+
mediaOrigin = '';
|
|
315
|
+
purifier.removeHook('uponSanitizeAttribute', filterAttribute);
|
|
316
|
+
purifier.removeHook('afterSanitizeAttributes', prepareElementHook);
|
|
317
|
+
}
|
|
318
|
+
}
|