@swell/apps-sdk 1.0.125 → 1.0.127

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
@@ -13751,7 +13751,10 @@ function ShopifyBlog(instance, blogCategory) {
13751
13751
  blogCategory = cloneStorefrontResource(blogCategory);
13752
13752
  }
13753
13753
  const allTags = deferWith(blogCategory.blogs, (blogs) => {
13754
- const set = blogs?.results?.reduce(
13754
+ if (!Array.isArray(blogs?.results)) {
13755
+ return [];
13756
+ }
13757
+ const set = blogs.results.reduce(
13755
13758
  (set2, blog) => {
13756
13759
  for (const tag of blog.tags || []) {
13757
13760
  set2.add(tag);
@@ -17208,11 +17211,12 @@ function bind13(_liquidSwell) {
17208
17211
  hash;
17209
17212
  constructor(token, remainTokens, liquid, parser) {
17210
17213
  super(token, remainTokens, liquid);
17211
- this.hash = md5(token.input);
17212
17214
  this.templates = [];
17215
+ const tagBegin = token.begin;
17213
17216
  while (remainTokens.length > 0) {
17214
17217
  const token2 = remainTokens.shift();
17215
17218
  if (import_liquidjs18.TypeGuards.isTagToken(token2) && token2.name === "endstyle") {
17219
+ this.hash = md5(token2.input.slice(tagBegin, token2.end));
17216
17220
  return;
17217
17221
  }
17218
17222
  this.templates.push(parser.parseToken(token2, remainTokens));
@@ -19661,14 +19665,36 @@ var SwellTheme3 = class {
19661
19665
  "layouts",
19662
19666
  name
19663
19667
  );
19664
- if (templateConfig) {
19665
- const content = await this.renderThemeTemplate(
19666
- templateConfig.file_path,
19667
- data
19668
- );
19669
- return typeof content === "string" ? content : `<!-- invalid layout: ${name}--> {{ content_for_layout }}`;
19668
+ if (!templateConfig) {
19669
+ throw new Error(`Layout template not found: ${name}`);
19670
19670
  }
19671
- throw new Error(`Layout template not found: ${name}`);
19671
+ let content = await this.renderThemeTemplate(
19672
+ templateConfig.file_path,
19673
+ data
19674
+ );
19675
+ if (typeof content !== "string") {
19676
+ return `<!-- invalid layout: ${name}--> {{ content_for_layout }}`;
19677
+ }
19678
+ if (!this.globals.request.is_editor) {
19679
+ let customCss = this.globals.settings.custom_css || "";
19680
+ if (Array.isArray(customCss)) {
19681
+ customCss = customCss.join("\n").trim();
19682
+ }
19683
+ if (customCss) {
19684
+ let pos = -1;
19685
+ let match = null;
19686
+ const regex = /<\/body\s*?>/gi;
19687
+ while ((match = regex.exec(content)) !== null) {
19688
+ pos = match.index;
19689
+ }
19690
+ if (pos !== -1) {
19691
+ content = `${content.slice(0, pos)}
19692
+ <style>${customCss}</style>
19693
+ ${content.slice(pos)}`;
19694
+ }
19695
+ }
19696
+ }
19697
+ return content;
19672
19698
  }
19673
19699
  async renderPageTemplate(name, data, altTemplateId) {
19674
19700
  let templateConfig = null;