orionplace-svelte 0.7.0 → 0.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orionplace-svelte",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "description": "SvelteKit 2 storefront for your Orionplace marketplace: setup CLI, server API gateway, typed store and ready-made catalog, cart, checkout and account components in English and Russian, plus an Android app build.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -405,11 +405,10 @@ out; the journal and other pages stay indexable. Leave it empty on a live shop.
405
405
 
406
406
  Every product page carries schema.org product data for Google and Yandex: the
407
407
  price, the crossed-out old price, stock, photos, brand, seller, rating and the
408
- return terms the page shows. To include the return terms, set
409
- \`ORIONPLACE_SHIPPING_COUNTRIES\` in \`.env\` to the countries you ship to, as
410
- ISO codes separated by spaces, for example
411
- \`ORIONPLACE_SHIPPING_COUNTRIES="RU BY"\`; without it the return terms are left
412
- out. The delivery cost is not included: it depends on the buyer's address.
408
+ return terms the page shows. The return terms name the shop's shipping
409
+ countries, which Application Load sends in \`init.shipping_countries\`; without
410
+ a shipping country they are left out. The delivery cost is not included: it
411
+ depends on the buyer's address.
413
412
 
414
413
  This setup does not add analytics.
415
414
 
@@ -24,6 +24,8 @@ export interface IAppLoadCommon {
24
24
  weights: Record<string, IAppLoadCommonUnit>;
25
25
  lengths: Record<string, IAppLoadCommonUnit>;
26
26
  geo_location_enabled: boolean;
27
+ /** ISO codes of the shop's shipping countries, sorted. */
28
+ shipping_countries?: string[];
27
29
  is_authenticated: boolean;
28
30
  wallet?: Record<string, IAppLoadCommonWalletValue>;
29
31
  logos: IAppLoadCommonLogos;
@@ -45,7 +45,7 @@ export interface StorefrontProductDataOptions {
45
45
  /** The currency the page shows prices in (its ID and code). */
46
46
  currencyId: string;
47
47
  currencyCode: string | undefined;
48
- /** ORIONPLACE_SHIPPING_COUNTRIES, parsed by shippingCountryCodes(). */
48
+ /** App Load `init.shipping_countries`, parsed by shippingCountryCodes(). */
49
49
  shippingCountries: string[];
50
50
  /** False when the page hides the seller (single-seller storefront). */
51
51
  showSeller: boolean;
@@ -54,11 +54,12 @@ export interface StorefrontProductDataOptions {
54
54
  }
55
55
 
56
56
  /**
57
- * The countries the shop ships to, from ORIONPLACE_SHIPPING_COUNTRIES:
58
- * ISO 3166-1 alpha-2 codes separated by spaces or commas, e.g. "RU BY".
57
+ * The countries the shop ships to: App Load `init.shipping_countries` (the
58
+ * backend's countries marked as shipping countries), as valid ISO 3166-1
59
+ * alpha-2 codes.
59
60
  */
60
61
  export function shippingCountryCodes(value: unknown): string[] {
61
- const codes = String(value ?? '')
62
+ const codes = (Array.isArray(value) ? value.join(' ') : String(value ?? ''))
62
63
  .split(/[\s,;]+/)
63
64
  .map((code) => code.trim().toUpperCase())
64
65
  .filter((code) => /^[A-Z]{2}$/.test(code));
@@ -1,4 +1,3 @@
1
- import { env } from '$env/dynamic/private';
2
1
  import { loadOrionplaceAppLoad } from '@/lib/orionplace/appLoadServer';
3
2
  import { OrionplaceStore } from '@/lib/orionplace/store.svelte';
4
3
  import { storefrontErrorLocale } from '@/lib/utils/orionplace/errorPageLabels';
@@ -34,8 +33,5 @@ export const load: LayoutServerLoad = async (event) => {
34
33
  return {
35
34
  orionplace: { result, failure },
36
35
  orionplaceLocale: store.localeCode,
37
- // The countries the shop ships to, for the return terms in the product
38
- // page's schema.org data.
39
- orionplaceShippingCountries: env.ORIONPLACE_SHIPPING_COUNTRIES ?? '',
40
36
  };
41
37
  };
@@ -1,5 +1,4 @@
1
1
  <script lang="ts">
2
- import { page } from '$app/state';
3
2
  import { useOrionplaceStore } from '@/lib/stores/orionplace.svelte';
4
3
  import { computed, ref, watch } from '@/lib/orionplace/reactivity.svelte';
5
4
  import { navigateTo, useRoute } from '@/lib/orionplace/navigation.svelte';
@@ -78,11 +77,6 @@
78
77
  return images?.full?.[0] ?? images?.small?.[0];
79
78
  });
80
79
 
81
- // ORIONPLACE_SHIPPING_COUNTRIES from the server's .env (+layout.server.ts),
82
- // for the return terms in the page's schema.org data.
83
- const shippingCountries = computed(() =>
84
- shippingCountryCodes(page.data.orionplaceShippingCountries),
85
- );
86
80
  const productName = computed(() =>
87
81
  getAvailableNestedValueFromObject(
88
82
  product.value?.locale,
@@ -117,7 +111,10 @@
117
111
  description: productSummary.value,
118
112
  currencyId: store.currencyId,
119
113
  currencyCode: store.currentCurrency?.currency_code,
120
- shippingCountries: shippingCountries.value,
114
+ // The backend's shipping countries, for the return terms.
115
+ shippingCountries: shippingCountryCodes(
116
+ store.init?.shipping_countries,
117
+ ),
121
118
  showSeller: !store.init?.visual_settings?.single_seller_mode,
122
119
  absoluteUrl: (value) => storefrontAbsoluteUrl(value, origin),
123
120
  }),