@swell/apps-sdk 1.0.172 → 1.0.174
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 +31 -1
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +31 -1
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +31 -1
- package/dist/index.mjs.map +2 -2
- package/dist/src/theme/theme-loader.d.ts +5 -0
- package/dist/src/theme.d.ts +4 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -12431,6 +12431,10 @@ function adjustProductVariants(instance, product) {
|
|
|
12431
12431
|
if (instance.supportsSwellVariants()) {
|
|
12432
12432
|
return;
|
|
12433
12433
|
}
|
|
12434
|
+
const hasOptions = Array.isArray(product.options) && product.options.length > 0;
|
|
12435
|
+
if (hasOptions) {
|
|
12436
|
+
product.options = product.options?.filter((option) => option.variant);
|
|
12437
|
+
}
|
|
12434
12438
|
const hasVariants = Array.isArray(product.variants?.results) && product.variants.results.length > 0;
|
|
12435
12439
|
if (hasVariants) {
|
|
12436
12440
|
return;
|
|
@@ -12568,6 +12572,9 @@ function ShopifyLineItem(instance, item, cart, options = {}) {
|
|
|
12568
12572
|
}
|
|
12569
12573
|
return ShopifyVariant(instance, variant, item.product);
|
|
12570
12574
|
}),
|
|
12575
|
+
variant_id: deferWith([item.product, item.variant], (product, variant) => {
|
|
12576
|
+
return variant?.id || product?.id;
|
|
12577
|
+
}),
|
|
12571
12578
|
vendor: void 0
|
|
12572
12579
|
});
|
|
12573
12580
|
}
|
|
@@ -17057,6 +17064,13 @@ var ThemeLoader = class _ThemeLoader {
|
|
|
17057
17064
|
setConfigs(themeConfigs) {
|
|
17058
17065
|
this.configs = new Map(themeConfigs);
|
|
17059
17066
|
}
|
|
17067
|
+
/**
|
|
17068
|
+
* Load theme record from internal data, typically in the editor.
|
|
17069
|
+
* Used when theme record is provided externally (e.g., from editor).
|
|
17070
|
+
*/
|
|
17071
|
+
setThemeRecord(themeRecord) {
|
|
17072
|
+
this.themeRecord = themeRecord;
|
|
17073
|
+
}
|
|
17060
17074
|
/**
|
|
17061
17075
|
* Updates KV with file_data for provided theme configs (warmup path).
|
|
17062
17076
|
* Uses the new ThemeFileStorage abstraction for optimized operations.
|
|
@@ -17567,6 +17581,14 @@ var SwellTheme3 = class {
|
|
|
17567
17581
|
this.themeLoader.setConfigs(configs);
|
|
17568
17582
|
}
|
|
17569
17583
|
}
|
|
17584
|
+
/**
|
|
17585
|
+
* Setter for theme record - directly sets theme record in the loader.
|
|
17586
|
+
*/
|
|
17587
|
+
set themeRecord(themeRecord) {
|
|
17588
|
+
if (themeRecord) {
|
|
17589
|
+
this.themeLoader.setThemeRecord(themeRecord);
|
|
17590
|
+
}
|
|
17591
|
+
}
|
|
17570
17592
|
getSwellAppThemeProps(swellConfig) {
|
|
17571
17593
|
return swellConfig?.storefront?.theme || {};
|
|
17572
17594
|
}
|
|
@@ -18689,11 +18711,14 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
|
|
|
18689
18711
|
* Get a list of sections and section groups in a page layout.
|
|
18690
18712
|
*/
|
|
18691
18713
|
async getPageSectionGroups(pageId, altTemplate) {
|
|
18692
|
-
|
|
18714
|
+
let pageConfig = this._getTemplateConfigByType(
|
|
18693
18715
|
"templates",
|
|
18694
18716
|
pageId,
|
|
18695
18717
|
altTemplate
|
|
18696
18718
|
);
|
|
18719
|
+
if (!pageConfig) {
|
|
18720
|
+
pageConfig = this._getTemplateConfigByType("templates", pageId);
|
|
18721
|
+
}
|
|
18697
18722
|
if (pageConfig === null) {
|
|
18698
18723
|
return [];
|
|
18699
18724
|
}
|
|
@@ -19698,6 +19723,11 @@ var HtmlCache = class {
|
|
|
19698
19723
|
if (request.headers.get("swell-deployment-mode") === "editor") return false;
|
|
19699
19724
|
if (request.headers.get("cache-control")?.includes("no-cache"))
|
|
19700
19725
|
return false;
|
|
19726
|
+
const storefrontId = request.headers.get("swell-storefront-id");
|
|
19727
|
+
const themeVersionHash = request.headers.get("swell-theme-version-hash");
|
|
19728
|
+
if (!storefrontId || !themeVersionHash) {
|
|
19729
|
+
return false;
|
|
19730
|
+
}
|
|
19701
19731
|
return true;
|
|
19702
19732
|
}
|
|
19703
19733
|
isResponseCacheable(response, matchedRule) {
|