@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.mjs CHANGED
@@ -13620,7 +13620,10 @@ function ShopifyBlog(instance, blogCategory) {
13620
13620
  blogCategory = cloneStorefrontResource(blogCategory);
13621
13621
  }
13622
13622
  const allTags = deferWith(blogCategory.blogs, (blogs) => {
13623
- const set = blogs?.results?.reduce(
13623
+ if (!Array.isArray(blogs?.results)) {
13624
+ return [];
13625
+ }
13626
+ const set = blogs.results.reduce(
13624
13627
  (set2, blog) => {
13625
13628
  for (const tag of blog.tags || []) {
13626
13629
  set2.add(tag);
@@ -17085,11 +17088,12 @@ function bind13(_liquidSwell) {
17085
17088
  hash;
17086
17089
  constructor(token, remainTokens, liquid, parser) {
17087
17090
  super(token, remainTokens, liquid);
17088
- this.hash = md5(token.input);
17089
17091
  this.templates = [];
17092
+ const tagBegin = token.begin;
17090
17093
  while (remainTokens.length > 0) {
17091
17094
  const token2 = remainTokens.shift();
17092
17095
  if (TypeGuards4.isTagToken(token2) && token2.name === "endstyle") {
17096
+ this.hash = md5(token2.input.slice(tagBegin, token2.end));
17093
17097
  return;
17094
17098
  }
17095
17099
  this.templates.push(parser.parseToken(token2, remainTokens));
@@ -19538,14 +19542,36 @@ var SwellTheme3 = class {
19538
19542
  "layouts",
19539
19543
  name
19540
19544
  );
19541
- if (templateConfig) {
19542
- const content = await this.renderThemeTemplate(
19543
- templateConfig.file_path,
19544
- data
19545
- );
19546
- return typeof content === "string" ? content : `<!-- invalid layout: ${name}--> {{ content_for_layout }}`;
19545
+ if (!templateConfig) {
19546
+ throw new Error(`Layout template not found: ${name}`);
19547
19547
  }
19548
- throw new Error(`Layout template not found: ${name}`);
19548
+ let content = await this.renderThemeTemplate(
19549
+ templateConfig.file_path,
19550
+ data
19551
+ );
19552
+ if (typeof content !== "string") {
19553
+ return `<!-- invalid layout: ${name}--> {{ content_for_layout }}`;
19554
+ }
19555
+ if (!this.globals.request.is_editor) {
19556
+ let customCss = this.globals.settings.custom_css || "";
19557
+ if (Array.isArray(customCss)) {
19558
+ customCss = customCss.join("\n").trim();
19559
+ }
19560
+ if (customCss) {
19561
+ let pos = -1;
19562
+ let match = null;
19563
+ const regex = /<\/body\s*?>/gi;
19564
+ while ((match = regex.exec(content)) !== null) {
19565
+ pos = match.index;
19566
+ }
19567
+ if (pos !== -1) {
19568
+ content = `${content.slice(0, pos)}
19569
+ <style>${customCss}</style>
19570
+ ${content.slice(pos)}`;
19571
+ }
19572
+ }
19573
+ }
19574
+ return content;
19549
19575
  }
19550
19576
  async renderPageTemplate(name, data, altTemplateId) {
19551
19577
  let templateConfig = null;