@swell/apps-sdk 1.0.164 → 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 CHANGED
@@ -20269,12 +20269,15 @@ var ThemeLoader = class _ThemeLoader {
20269
20269
  logger.warn("[ThemeLoader] No configs found");
20270
20270
  return;
20271
20271
  }
20272
+ const eligibleConfigs = this.filterConfigsForDataInclusion(configMetadata);
20272
20273
  logger.debug("[ThemeLoader] Loading configs", {
20273
- total: configMetadata.length
20274
+ total: configMetadata.length,
20275
+ eligible: eligibleConfigs.length,
20276
+ filtered: configMetadata.length - eligibleConfigs.length
20274
20277
  });
20275
20278
  const flavor = getKVFlavor(this.swell.workerEnv);
20276
20279
  const storage = new ThemeFileCache(this.swell.workerEnv, flavor);
20277
- const kvHydrated = await storage.getFiles(configMetadata);
20280
+ const kvHydrated = await storage.getFiles(eligibleConfigs);
20278
20281
  const completeConfigs = await this.ensureConfigsHaveData(kvHydrated);
20279
20282
  for (const config of completeConfigs) {
20280
20283
  this.configs.set(config.file_path, config);
@@ -20414,6 +20417,26 @@ var ThemeLoader = class _ThemeLoader {
20414
20417
  preview: swellHeaders["deployment-mode"] === "editor" || swellHeaders["deployment-mode"] === "preview" ? true : { $ne: true }
20415
20418
  };
20416
20419
  }
20420
+ /**
20421
+ * Check if a config should have file_data based on FILE_DATA_INCLUDE_QUERY rules.
20422
+ * This mirrors the server-side logic to avoid fetching data for configs that won't have it.
20423
+ */
20424
+ shouldIncludeFileData(config) {
20425
+ const { file_path, file } = config;
20426
+ const pathConditionMet = !/^theme\/assets\//.test(file_path) || // NOT in theme/assets/
20427
+ /\.liquid$/.test(file_path) || // ends with .liquid
20428
+ /\.(css|js|svg)$/.test(file_path);
20429
+ const contentTypeMet = !file.content_type?.startsWith("image") && !file.content_type?.startsWith("video") || // NOT image AND NOT video
20430
+ file.content_type?.startsWith("image/svg");
20431
+ return pathConditionMet && contentTypeMet;
20432
+ }
20433
+ /**
20434
+ * Filter configs to only those eligible for file_data.
20435
+ * Aligns with FILE_DATA_INCLUDE_QUERY server-side logic.
20436
+ */
20437
+ filterConfigsForDataInclusion(configs) {
20438
+ return configs.filter((config) => this.shouldIncludeFileData(config));
20439
+ }
20417
20440
  /**
20418
20441
  * Build cache key with tenant isolation for metadata
20419
20442
  */
@@ -22749,7 +22772,6 @@ var HtmlCache = class {
22749
22772
  generateVersionHash(headers) {
22750
22773
  const swellData = this.extractSwellData(headers);
22751
22774
  const acceptLang = headers.get("accept-language") || "";
22752
- const accept = headers.get("accept") || "";
22753
22775
  const versionFactors = {
22754
22776
  store: headers.get("swell-storefront-id") || "",
22755
22777
  app: (headers.get("swell-app-id") || "") + "@" + (headers.get("host") || ""),
@@ -22759,7 +22781,6 @@ var HtmlCache = class {
22759
22781
  currency: swellData["swell-currency"] || "USD",
22760
22782
  locale: headers.get("x-locale") || acceptLang.split(",")[0].trim().toLowerCase() || "default",
22761
22783
  context: headers.get("swell-storefront-context"),
22762
- accept,
22763
22784
  epoch: this.epoch
22764
22785
  };
22765
22786
  return md5(JSON.stringify(versionFactors));