@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.js CHANGED
@@ -13647,7 +13647,10 @@ ${formattedMessage}`;
13647
13647
  blogCategory = cloneStorefrontResource(blogCategory);
13648
13648
  }
13649
13649
  const allTags = deferWith(blogCategory.blogs, (blogs) => {
13650
- const set = blogs?.results?.reduce(
13650
+ if (!Array.isArray(blogs?.results)) {
13651
+ return [];
13652
+ }
13653
+ const set = blogs.results.reduce(
13651
13654
  (set2, blog) => {
13652
13655
  for (const tag of blog.tags || []) {
13653
13656
  set2.add(tag);
@@ -17104,11 +17107,12 @@ ${injects.join("\n")}<\/script>`;
17104
17107
  hash;
17105
17108
  constructor(token, remainTokens, liquid, parser) {
17106
17109
  super(token, remainTokens, liquid);
17107
- this.hash = md5(token.input);
17108
17110
  this.templates = [];
17111
+ const tagBegin = token.begin;
17109
17112
  while (remainTokens.length > 0) {
17110
17113
  const token2 = remainTokens.shift();
17111
17114
  if (import_liquidjs18.TypeGuards.isTagToken(token2) && token2.name === "endstyle") {
17115
+ this.hash = md5(token2.input.slice(tagBegin, token2.end));
17112
17116
  return;
17113
17117
  }
17114
17118
  this.templates.push(parser.parseToken(token2, remainTokens));
@@ -19557,14 +19561,36 @@ ${injects.join("\n")}<\/script>`;
19557
19561
  "layouts",
19558
19562
  name
19559
19563
  );
19560
- if (templateConfig) {
19561
- const content = await this.renderThemeTemplate(
19562
- templateConfig.file_path,
19563
- data
19564
- );
19565
- return typeof content === "string" ? content : `<!-- invalid layout: ${name}--> {{ content_for_layout }}`;
19564
+ if (!templateConfig) {
19565
+ throw new Error(`Layout template not found: ${name}`);
19566
19566
  }
19567
- throw new Error(`Layout template not found: ${name}`);
19567
+ let content = await this.renderThemeTemplate(
19568
+ templateConfig.file_path,
19569
+ data
19570
+ );
19571
+ if (typeof content !== "string") {
19572
+ return `<!-- invalid layout: ${name}--> {{ content_for_layout }}`;
19573
+ }
19574
+ if (!this.globals.request.is_editor) {
19575
+ let customCss = this.globals.settings.custom_css || "";
19576
+ if (Array.isArray(customCss)) {
19577
+ customCss = customCss.join("\n").trim();
19578
+ }
19579
+ if (customCss) {
19580
+ let pos = -1;
19581
+ let match = null;
19582
+ const regex = /<\/body\s*?>/gi;
19583
+ while ((match = regex.exec(content)) !== null) {
19584
+ pos = match.index;
19585
+ }
19586
+ if (pos !== -1) {
19587
+ content = `${content.slice(0, pos)}
19588
+ <style>${customCss}</style>
19589
+ ${content.slice(pos)}`;
19590
+ }
19591
+ }
19592
+ }
19593
+ return content;
19568
19594
  }
19569
19595
  async renderPageTemplate(name, data, altTemplateId) {
19570
19596
  let templateConfig = null;