@namiml/sdk-core 3.4.10-dev.202608212120 → 3.4.10-dev.202608230147

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -106,7 +106,7 @@ const {
106
106
  // version — stamped by scripts/version.sh
107
107
  NAMI_SDK_VERSION: exports.NAMI_SDK_VERSION = "3.4.10",
108
108
  // full package version including dev suffix — stamped by scripts/version.sh
109
- NAMI_SDK_PACKAGE_VERSION: exports.NAMI_SDK_PACKAGE_VERSION = "3.4.10-dev.202608212120",
109
+ NAMI_SDK_PACKAGE_VERSION: exports.NAMI_SDK_PACKAGE_VERSION = "3.4.10-dev.202608230147",
110
110
  // environments
111
111
  PRODUCTION: exports.PRODUCTION = "production", DEVELOPMENT: exports.DEVELOPMENT = "development",
112
112
  // error messages
@@ -59753,12 +59753,32 @@ function skuItems(productDetails, skuMenus, currentGroupId) {
59753
59753
  });
59754
59754
  return skuItems;
59755
59755
  }
59756
+ /**
59757
+ * Flattens an array of entitlement objects (`{ entitlement_ref_id, name, ... }`) to a plain
59758
+ * array of `entitlement_ref_id` strings, so `${sku.entitlements}` works with contains /
59759
+ * notContains assertions and renders as text rather than `[object Object]`. A non-array, or
59760
+ * an array that is not entitlement objects, passes through unchanged.
59761
+ *
59762
+ * Matches Apple (`NamiSmartText`, joined reference ids) and Roku
59763
+ * (`flattenEntitlementRefIds`). Web was the only SDK leaking the raw objects into the shared
59764
+ * SKU context, which made every `contains` assertion against `${sku.entitlements}` fail for
59765
+ * components resolved outside a product card (NAM-3607).
59766
+ */
59767
+ function flattenEntitlementRefIds(value) {
59768
+ if (!Array.isArray(value))
59769
+ return value;
59770
+ const refIds = value
59771
+ .filter((item) => item && typeof item === 'object' && 'entitlement_ref_id' in item)
59772
+ .map((item) => item.entitlement_ref_id);
59773
+ return refIds.length ? refIds : value;
59774
+ }
59756
59775
  function getSkuSmartTextValue(productDetail, sku, skus) {
59757
59776
  if (!sku)
59758
59777
  return {};
59778
+ const entitlements = flattenEntitlementRefIds(sku.entitlements);
59759
59779
  const variables = sku.variables;
59760
59780
  if (!variables) {
59761
- return { ...sku };
59781
+ return { ...sku, entitlements };
59762
59782
  }
59763
59783
  Object.keys(variables).forEach(key => {
59764
59784
  if (isSmartTextString(variables[key])) {
@@ -59775,7 +59795,7 @@ function getSkuSmartTextValue(productDetail, sku, skus) {
59775
59795
  }
59776
59796
  }
59777
59797
  });
59778
- return { ...sku, ...productDetailValues, ...variables };
59798
+ return { ...sku, ...productDetailValues, ...variables, entitlements };
59779
59799
  }
59780
59800
  function isSmartTextString(value) {
59781
59801
  return typeof value === "string" && value.includes(exports.SMART_TEXT_PATTERN);
@@ -60781,8 +60801,13 @@ class PaywallState extends SimpleEventTarget {
60781
60801
  return this.state.formStates[formId];
60782
60802
  }
60783
60803
  setSelectedProducts(products) {
60784
- const currentGroupSku = currentSku(this.productDetails, this.state, this.filteredSkuMenus, skuItems(this.productDetails, this.filteredSkuMenus, this.state.currentGroupId));
60785
- this.setState({ ...this.state, selectedProducts: products, sku: currentGroupSku });
60804
+ // Resolve the SKU from the NEW selection map. Reading `this.state` here resolved the
60805
+ // *previous* selection; that only looked correct while callers mutated the live map in
60806
+ // place, and left `state.sku` one selection behind for any caller passing a fresh map
60807
+ // (NAM-3607).
60808
+ const nextState = { ...this.state, selectedProducts: products };
60809
+ const currentGroupSku = currentSku(this.productDetails, nextState, this.filteredSkuMenus, skuItems(this.productDetails, this.filteredSkuMenus, nextState.currentGroupId));
60810
+ this.setState({ ...nextState, sku: currentGroupSku });
60786
60811
  }
60787
60812
  selectedProducts() {
60788
60813
  return this.state.selectedProducts;
package/dist/index.mjs CHANGED
@@ -104,7 +104,7 @@ const {
104
104
  // version — stamped by scripts/version.sh
105
105
  NAMI_SDK_VERSION = "3.4.10",
106
106
  // full package version including dev suffix — stamped by scripts/version.sh
107
- NAMI_SDK_PACKAGE_VERSION = "3.4.10-dev.202608212120",
107
+ NAMI_SDK_PACKAGE_VERSION = "3.4.10-dev.202608230147",
108
108
  // environments
109
109
  PRODUCTION = "production", DEVELOPMENT = "development",
110
110
  // error messages
@@ -59751,12 +59751,32 @@ function skuItems(productDetails, skuMenus, currentGroupId) {
59751
59751
  });
59752
59752
  return skuItems;
59753
59753
  }
59754
+ /**
59755
+ * Flattens an array of entitlement objects (`{ entitlement_ref_id, name, ... }`) to a plain
59756
+ * array of `entitlement_ref_id` strings, so `${sku.entitlements}` works with contains /
59757
+ * notContains assertions and renders as text rather than `[object Object]`. A non-array, or
59758
+ * an array that is not entitlement objects, passes through unchanged.
59759
+ *
59760
+ * Matches Apple (`NamiSmartText`, joined reference ids) and Roku
59761
+ * (`flattenEntitlementRefIds`). Web was the only SDK leaking the raw objects into the shared
59762
+ * SKU context, which made every `contains` assertion against `${sku.entitlements}` fail for
59763
+ * components resolved outside a product card (NAM-3607).
59764
+ */
59765
+ function flattenEntitlementRefIds(value) {
59766
+ if (!Array.isArray(value))
59767
+ return value;
59768
+ const refIds = value
59769
+ .filter((item) => item && typeof item === 'object' && 'entitlement_ref_id' in item)
59770
+ .map((item) => item.entitlement_ref_id);
59771
+ return refIds.length ? refIds : value;
59772
+ }
59754
59773
  function getSkuSmartTextValue(productDetail, sku, skus) {
59755
59774
  if (!sku)
59756
59775
  return {};
59776
+ const entitlements = flattenEntitlementRefIds(sku.entitlements);
59757
59777
  const variables = sku.variables;
59758
59778
  if (!variables) {
59759
- return { ...sku };
59779
+ return { ...sku, entitlements };
59760
59780
  }
59761
59781
  Object.keys(variables).forEach(key => {
59762
59782
  if (isSmartTextString(variables[key])) {
@@ -59773,7 +59793,7 @@ function getSkuSmartTextValue(productDetail, sku, skus) {
59773
59793
  }
59774
59794
  }
59775
59795
  });
59776
- return { ...sku, ...productDetailValues, ...variables };
59796
+ return { ...sku, ...productDetailValues, ...variables, entitlements };
59777
59797
  }
59778
59798
  function isSmartTextString(value) {
59779
59799
  return typeof value === "string" && value.includes(SMART_TEXT_PATTERN);
@@ -60779,8 +60799,13 @@ class PaywallState extends SimpleEventTarget {
60779
60799
  return this.state.formStates[formId];
60780
60800
  }
60781
60801
  setSelectedProducts(products) {
60782
- const currentGroupSku = currentSku(this.productDetails, this.state, this.filteredSkuMenus, skuItems(this.productDetails, this.filteredSkuMenus, this.state.currentGroupId));
60783
- this.setState({ ...this.state, selectedProducts: products, sku: currentGroupSku });
60802
+ // Resolve the SKU from the NEW selection map. Reading `this.state` here resolved the
60803
+ // *previous* selection; that only looked correct while callers mutated the live map in
60804
+ // place, and left `state.sku` one selection behind for any caller passing a fresh map
60805
+ // (NAM-3607).
60806
+ const nextState = { ...this.state, selectedProducts: products };
60807
+ const currentGroupSku = currentSku(this.productDetails, nextState, this.filteredSkuMenus, skuItems(this.productDetails, this.filteredSkuMenus, nextState.currentGroupId));
60808
+ this.setState({ ...nextState, sku: currentGroupSku });
60784
60809
  }
60785
60810
  selectedProducts() {
60786
60811
  return this.state.selectedProducts;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@namiml/sdk-core",
3
- "version": "3.4.10-dev.202608212120",
3
+ "version": "3.4.10-dev.202608230147",
4
4
  "description": "Platform-agnostic core for the Nami SDK — business logic, API, types, and state management",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",