@swell/apps-sdk 1.0.163 → 1.0.165
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 +26 -5
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +26 -5
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +26 -5
- package/dist/index.mjs.map +2 -2
- package/dist/src/theme/theme-loader.d.ts +10 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -20129,12 +20129,15 @@ var ThemeLoader = class _ThemeLoader {
|
|
|
20129
20129
|
logger.warn("[ThemeLoader] No configs found");
|
|
20130
20130
|
return;
|
|
20131
20131
|
}
|
|
20132
|
+
const eligibleConfigs = this.filterConfigsForDataInclusion(configMetadata);
|
|
20132
20133
|
logger.debug("[ThemeLoader] Loading configs", {
|
|
20133
|
-
total: configMetadata.length
|
|
20134
|
+
total: configMetadata.length,
|
|
20135
|
+
eligible: eligibleConfigs.length,
|
|
20136
|
+
filtered: configMetadata.length - eligibleConfigs.length
|
|
20134
20137
|
});
|
|
20135
20138
|
const flavor = getKVFlavor(this.swell.workerEnv);
|
|
20136
20139
|
const storage = new ThemeFileCache(this.swell.workerEnv, flavor);
|
|
20137
|
-
const kvHydrated = await storage.getFiles(
|
|
20140
|
+
const kvHydrated = await storage.getFiles(eligibleConfigs);
|
|
20138
20141
|
const completeConfigs = await this.ensureConfigsHaveData(kvHydrated);
|
|
20139
20142
|
for (const config of completeConfigs) {
|
|
20140
20143
|
this.configs.set(config.file_path, config);
|
|
@@ -20274,6 +20277,26 @@ var ThemeLoader = class _ThemeLoader {
|
|
|
20274
20277
|
preview: swellHeaders["deployment-mode"] === "editor" || swellHeaders["deployment-mode"] === "preview" ? true : { $ne: true }
|
|
20275
20278
|
};
|
|
20276
20279
|
}
|
|
20280
|
+
/**
|
|
20281
|
+
* Check if a config should have file_data based on FILE_DATA_INCLUDE_QUERY rules.
|
|
20282
|
+
* This mirrors the server-side logic to avoid fetching data for configs that won't have it.
|
|
20283
|
+
*/
|
|
20284
|
+
shouldIncludeFileData(config) {
|
|
20285
|
+
const { file_path, file } = config;
|
|
20286
|
+
const pathConditionMet = !/^theme\/assets\//.test(file_path) || // NOT in theme/assets/
|
|
20287
|
+
/\.liquid$/.test(file_path) || // ends with .liquid
|
|
20288
|
+
/\.(css|js|svg)$/.test(file_path);
|
|
20289
|
+
const contentTypeMet = !file.content_type?.startsWith("image") && !file.content_type?.startsWith("video") || // NOT image AND NOT video
|
|
20290
|
+
file.content_type?.startsWith("image/svg");
|
|
20291
|
+
return pathConditionMet && contentTypeMet;
|
|
20292
|
+
}
|
|
20293
|
+
/**
|
|
20294
|
+
* Filter configs to only those eligible for file_data.
|
|
20295
|
+
* Aligns with FILE_DATA_INCLUDE_QUERY server-side logic.
|
|
20296
|
+
*/
|
|
20297
|
+
filterConfigsForDataInclusion(configs) {
|
|
20298
|
+
return configs.filter((config) => this.shouldIncludeFileData(config));
|
|
20299
|
+
}
|
|
20277
20300
|
/**
|
|
20278
20301
|
* Build cache key with tenant isolation for metadata
|
|
20279
20302
|
*/
|
|
@@ -22609,17 +22632,15 @@ var HtmlCache = class {
|
|
|
22609
22632
|
generateVersionHash(headers) {
|
|
22610
22633
|
const swellData = this.extractSwellData(headers);
|
|
22611
22634
|
const acceptLang = headers.get("accept-language") || "";
|
|
22612
|
-
const accept = headers.get("accept") || "";
|
|
22613
22635
|
const versionFactors = {
|
|
22614
22636
|
store: headers.get("swell-storefront-id") || "",
|
|
22615
|
-
app: (headers.get("swell-app-id") || "") + "@" + (
|
|
22637
|
+
app: (headers.get("swell-app-id") || "") + "@" + (headers.get("host") || ""),
|
|
22616
22638
|
auth: headers.get("swell-access-token") || "",
|
|
22617
22639
|
theme: headers.get("swell-theme-version-hash") || "",
|
|
22618
22640
|
modified: headers.get("swell-cache-modified") || "",
|
|
22619
22641
|
currency: swellData["swell-currency"] || "USD",
|
|
22620
22642
|
locale: headers.get("x-locale") || acceptLang.split(",")[0].trim().toLowerCase() || "default",
|
|
22621
22643
|
context: headers.get("swell-storefront-context"),
|
|
22622
|
-
accept,
|
|
22623
22644
|
epoch: this.epoch
|
|
22624
22645
|
};
|
|
22625
22646
|
return md5(JSON.stringify(versionFactors));
|