@swell/apps-sdk 1.0.186 → 1.0.188

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
@@ -3502,7 +3502,15 @@ function resolveSectionPresets(schema) {
3502
3502
  }, {}),
3503
3503
  ...preset.settings || void 0
3504
3504
  },
3505
- blocks: preset.blocks?.map((block) => {
3505
+ blocks: resolveSectionBlockPresets(preset, schema)
3506
+ }));
3507
+ }
3508
+ function resolveSectionBlockPresets(preset, schema) {
3509
+ if (!preset.blocks) {
3510
+ return;
3511
+ }
3512
+ if (Array.isArray(preset.blocks)) {
3513
+ return preset.blocks.map((block) => {
3506
3514
  const blockDef = schema.blocks?.find((b) => b.type === block.type);
3507
3515
  return blockDef ? {
3508
3516
  ...block,
@@ -3516,8 +3524,9 @@ function resolveSectionPresets(schema) {
3516
3524
  ...block.settings || void 0
3517
3525
  }
3518
3526
  } : block;
3519
- })
3520
- }));
3527
+ });
3528
+ }
3529
+ return Object.values(preset.blocks);
3521
3530
  }
3522
3531
  async function getLayoutSectionGroups(allSections, renderTemplateSchema) {
3523
3532
  const allSectionsList = Array.from(allSections.values());
@@ -3594,7 +3603,15 @@ async function getPageSections(sectionGroup, getSchema) {
3594
3603
  };
3595
3604
  const id = sectionGroup.id ? `page__${sectionGroup.id}__${key}` : schema.id;
3596
3605
  const blockOrder = Array.isArray(section.block_order) ? section.block_order : Object.keys(section.blocks || {});
3597
- const blocks = blockOrder.map((key2) => section.blocks?.[key2]).filter(Boolean);
3606
+ const blocks = blockOrder.map((key2) => {
3607
+ const block = section.blocks?.[key2];
3608
+ if (block) {
3609
+ return {
3610
+ ...block,
3611
+ id: `${schema.id}__${key2}`
3612
+ };
3613
+ }
3614
+ }).filter(Boolean);
3598
3615
  const settings = {
3599
3616
  section: {
3600
3617
  id,
@@ -4816,12 +4833,17 @@ function transformSwellVariant(params, product, variant) {
4816
4833
  var SwellVariant = class extends SwellStorefrontRecord {
4817
4834
  product;
4818
4835
  constructor(swell, product, id, query) {
4836
+ const params = swell.queryParams;
4819
4837
  super(swell, "products:variants", id, query, async function() {
4820
4838
  const variant = await this._swell.get(
4821
- "/products:variants/{id}",
4822
- { id: this._id }
4839
+ "/products:variants/:last",
4840
+ { $or: [{ id: this._id }, { sku: this._id }] }
4841
+ );
4842
+ return transformSwellVariant(
4843
+ params,
4844
+ product instanceof SwellStorefrontRecord ? await product.resolve() : product,
4845
+ variant
4823
4846
  );
4824
- return variant ?? null;
4825
4847
  });
4826
4848
  this.product = product;
4827
4849
  }
@@ -5588,7 +5610,7 @@ function getAllSectionComponents(allSections) {
5588
5610
  // TODO: figure out how to make this work, doesn't work for collections normally
5589
5611
  defaultValue: section.presets?.reduce(
5590
5612
  (acc, preset, index) => {
5591
- if (!preset.blocks) {
5613
+ if (!preset.blocks || !Array.isArray(preset.blocks)) {
5592
5614
  return acc;
5593
5615
  }
5594
5616
  return preset.blocks.reduce(
@@ -5795,7 +5817,7 @@ function getAllSectionComponentTemplates(allSections) {
5795
5817
  custom_css: preset.settings?.["custom_css"] || "",
5796
5818
  ...processFields(section.fields, preset.settings),
5797
5819
  // Process blocks inside the preset
5798
- Blocks: (preset.blocks || []).map((block) => {
5820
+ Blocks: (Array.isArray(preset.blocks) ? preset.blocks : []).map((block) => {
5799
5821
  const blockSchema = section.blocks?.find(
5800
5822
  ({ type }) => type === block.type
5801
5823
  );
@@ -11554,16 +11576,16 @@ function ShopifyBlog(instance, blogCategory) {
11554
11576
  if (!Array.isArray(blogs?.results)) {
11555
11577
  return [];
11556
11578
  }
11557
- const set3 = blogs.results.reduce(
11558
- (set4, blog) => {
11579
+ const set4 = blogs.results.reduce(
11580
+ (set5, blog) => {
11559
11581
  for (const tag of blog.tags || []) {
11560
- set4.add(tag);
11582
+ set5.add(tag);
11561
11583
  }
11562
- return set4;
11584
+ return set5;
11563
11585
  },
11564
11586
  /* @__PURE__ */ new Set()
11565
11587
  );
11566
- return Array.from(set3.values());
11588
+ return Array.from(set4.values());
11567
11589
  });
11568
11590
  return new ShopifyResource({
11569
11591
  all_tags: allTags,
@@ -11947,18 +11969,18 @@ function ShopifyCollection(instance, category) {
11947
11969
  if (!resolved) {
11948
11970
  return [];
11949
11971
  }
11950
- const set3 = /* @__PURE__ */ new Set();
11972
+ const set4 = /* @__PURE__ */ new Set();
11951
11973
  await Promise.all(
11952
11974
  resolved.results.map(async (product) => {
11953
11975
  const tags2 = await Promise.resolve().then(() => product.tags);
11954
11976
  if (Array.isArray(tags2)) {
11955
11977
  for (const tag of tags2) {
11956
- set3.add(tag);
11978
+ set4.add(tag);
11957
11979
  }
11958
11980
  }
11959
11981
  })
11960
11982
  );
11961
- return Array.from(set3.values());
11983
+ return Array.from(set4.values());
11962
11984
  }),
11963
11985
  all_types: defer(async () => {
11964
11986
  const products = await resolveProducts();
@@ -14546,6 +14568,8 @@ ${injects.join("\n")}</script>`;
14546
14568
  return `templates/${this.getPageType(name)}`;
14547
14569
  case "sections":
14548
14570
  return `sections/${name}`;
14571
+ case "blocks":
14572
+ return `blocks/${name}`;
14549
14573
  default:
14550
14574
  throw new Error(`Theme file type not supported: ${type}`);
14551
14575
  }
@@ -14895,14 +14919,161 @@ function bind3(_liquidSwell) {
14895
14919
  };
14896
14920
  }
14897
14921
 
14922
+ // src/liquid/tags/content_for.ts
14923
+ import { Tag as Tag4 } from "liquidjs";
14924
+ import { assign } from "lodash-es";
14925
+
14926
+ // src/liquid/hash.ts
14927
+ import { set as set3 } from "lodash-es";
14928
+ import { Hash, Tokenizer as Tokenizer2, evalToken as evalToken2 } from "liquidjs";
14929
+
14930
+ // src/liquid/tokienizer.ts
14931
+ import { Tokenizer } from "liquidjs";
14932
+
14933
+ // src/liquid/tokens/identifier-token.ts
14934
+ import { Token, TokenKind } from "liquidjs";
14935
+ var IdentifierToken = class extends Token {
14936
+ constructor(input, begin, end, file) {
14937
+ super(TokenKind.Word, input, begin, end, file);
14938
+ this.input = input;
14939
+ this.begin = begin;
14940
+ this.end = end;
14941
+ this.file = file;
14942
+ this.content = this.getText();
14943
+ }
14944
+ content;
14945
+ };
14946
+
14947
+ // src/liquid/tokienizer.ts
14948
+ var isNumber2 = (c) => c >= "0" && c <= "9";
14949
+ var isCharacter = (c) => c >= "a" && c <= "z" || c >= "A" && c <= "Z";
14950
+ var isWord = (c) => "_-?".includes(c) || isCharacter(c) || isNumber2(c);
14951
+ var TokenizerSwell = class extends Tokenizer {
14952
+ readIdentifier() {
14953
+ this.skipBlank();
14954
+ const begin = this.p;
14955
+ while (!this.end()) {
14956
+ const char = this.peek();
14957
+ if (isWord(char) || char === ".") {
14958
+ this.p++;
14959
+ } else {
14960
+ break;
14961
+ }
14962
+ }
14963
+ return new IdentifierToken(this.input, begin, this.p, this.file);
14964
+ }
14965
+ };
14966
+
14967
+ // src/liquid/hash.ts
14968
+ var HashSwell = class extends Hash {
14969
+ constructor(input, jekyllStyle) {
14970
+ super(input, jekyllStyle);
14971
+ const tokenizer = input instanceof Tokenizer2 ? input : new TokenizerSwell(input, {});
14972
+ for (const hash of tokenizer.readHashes(jekyllStyle)) {
14973
+ this.hash[hash.name.content] = hash.value;
14974
+ }
14975
+ }
14976
+ *render(ctx) {
14977
+ const hash = {};
14978
+ for (const key of Object.keys(this.hash)) {
14979
+ const token = this.hash[key];
14980
+ if (token !== void 0) {
14981
+ const value = yield evalToken2(token, ctx);
14982
+ set3(hash, key, value);
14983
+ }
14984
+ }
14985
+ return hash;
14986
+ }
14987
+ };
14988
+
14989
+ // src/liquid/tags/content_for.ts
14990
+ function bind4(liquidSwell) {
14991
+ return class ContentForTag extends Tag4 {
14992
+ name;
14993
+ hash;
14994
+ constructor(token, remainTokens, liquid) {
14995
+ super(token, remainTokens, liquid);
14996
+ const tokenizer = token.tokenizer;
14997
+ this.name = tokenizer.readValue()?.content;
14998
+ this.hash = new HashSwell(tokenizer.remaining());
14999
+ }
15000
+ *render(ctx, emitter) {
15001
+ const section = yield ctx._get(["section"]);
15002
+ const block = yield ctx._get(["block"]);
15003
+ const hash = yield this.hash.render(ctx);
15004
+ const blocks = this.getBlocks(section, block, hash);
15005
+ for (const block2 of blocks) {
15006
+ if (!isObject2(block2) || typeof block2.type !== "string") {
15007
+ continue;
15008
+ }
15009
+ const blockPath = yield liquidSwell.getThemeBlockPath(
15010
+ block2.type
15011
+ );
15012
+ if (!blockPath) {
15013
+ continue;
15014
+ }
15015
+ const childCtx = ctx.spawn();
15016
+ const scope = childCtx.bottom();
15017
+ assign(scope, { section });
15018
+ assign(scope, { block: block2 });
15019
+ assign(scope, hash);
15020
+ const templates = yield this.liquid._parseFile(
15021
+ blockPath,
15022
+ childCtx.sync
15023
+ );
15024
+ yield this.liquid.renderer.renderTemplates(
15025
+ templates,
15026
+ childCtx,
15027
+ emitter
15028
+ );
15029
+ }
15030
+ }
15031
+ getBlocks(section, block, hash) {
15032
+ const blockConfigs = this.getBlockConfigs(section, block);
15033
+ if (!isObject2(hash) || !hash.type) {
15034
+ return blockConfigs;
15035
+ }
15036
+ const blockConfig = blockConfigs.find(
15037
+ (blockConfig2) => isObject2(blockConfig2) && blockConfig2.type === hash.type
15038
+ );
15039
+ return blockConfig ? [blockConfig] : [];
15040
+ }
15041
+ getBlockConfigs(section, block) {
15042
+ if (isObject2(block) && block.blocks) {
15043
+ return Object.values(block.blocks);
15044
+ }
15045
+ if (isObject2(section) && Array.isArray(section.blocks)) {
15046
+ return section.blocks;
15047
+ }
15048
+ return [];
15049
+ }
15050
+ };
15051
+ }
15052
+
15053
+ // src/liquid/tags/doc.ts
15054
+ import { Tag as Tag5 } from "liquidjs";
15055
+ function bind5() {
15056
+ return class DocTag extends Tag5 {
15057
+ constructor(token, remainTokens, liquid, parser) {
15058
+ super(token, remainTokens, liquid);
15059
+ const stream = parser.parseStream(remainTokens).on("tag:enddoc", () => {
15060
+ stream.stop();
15061
+ });
15062
+ stream.start();
15063
+ }
15064
+ render() {
15065
+ }
15066
+ };
15067
+ }
15068
+
14898
15069
  // src/liquid/tags/for.ts
14899
- import { evalToken as evalToken2, ForTag as LiquidForTag } from "liquidjs";
15070
+ import { evalToken as evalToken3, ForTag as LiquidForTag } from "liquidjs";
14900
15071
  var MODIFIERS = Object.freeze(["offset", "limit", "reversed"]);
14901
- function bind4(_liquidSwell) {
15072
+ function bind6(_liquidSwell) {
14902
15073
  return class ForTag extends LiquidForTag {
14903
15074
  *render(ctx, emitter) {
14904
15075
  const r = this.liquid.renderer;
14905
- let collection = yield evalToken2(this.collection, ctx);
15076
+ let collection = yield evalToken3(this.collection, ctx);
14906
15077
  collection = yield resolveEnumerable(collection);
14907
15078
  if (!collection.length) {
14908
15079
  yield r.renderTemplates(this.elseTemplates, ctx, emitter);
@@ -14969,10 +15140,10 @@ function limit(arr, count) {
14969
15140
  }
14970
15141
 
14971
15142
  // src/liquid/tags/form.ts
14972
- import { Tag as Tag4, Hash, TypeGuards as TypeGuards2, evalToken as evalToken3 } from "liquidjs";
15143
+ import { Tag as Tag6, Hash as Hash3, TypeGuards as TypeGuards2, evalToken as evalToken4 } from "liquidjs";
14973
15144
  var IGNORED_SHOPIFY_FORMS = Object.freeze(["new_comment", "guest_login"]);
14974
- function bind5(liquidSwell) {
14975
- return class FormTag extends Tag4 {
15145
+ function bind7(liquidSwell) {
15146
+ return class FormTag extends Tag6 {
14976
15147
  formType;
14977
15148
  formConfig;
14978
15149
  templates;
@@ -14985,7 +15156,7 @@ function bind5(liquidSwell) {
14985
15156
  this.formConfig = liquidSwell.theme.getFormConfig(this.formType);
14986
15157
  this.arg = tokenizer.readValue();
14987
15158
  this.templates = [];
14988
- this.hash = new Hash(this.tokenizer.remaining());
15159
+ this.hash = new Hash3(this.tokenizer.remaining());
14989
15160
  while (remainTokens.length > 0) {
14990
15161
  const token2 = remainTokens.shift();
14991
15162
  if (TypeGuards2.isTagToken(token2) && token2.name === "endform") {
@@ -15006,7 +15177,7 @@ function bind5(liquidSwell) {
15006
15177
  return;
15007
15178
  }
15008
15179
  const r = this.liquid.renderer;
15009
- const arg = yield evalToken3(this.arg, ctx);
15180
+ const arg = yield evalToken4(this.arg, ctx);
15010
15181
  const hash = yield this.hash.render(ctx);
15011
15182
  const scope = ctx.getAll();
15012
15183
  const attrs = " " + Object.entries({ id: `${this.formConfig.id}_form`, ...hash }).reduce((acc, [key, value]) => {
@@ -15069,12 +15240,12 @@ function bind5(liquidSwell) {
15069
15240
  // src/liquid/tags/if.ts
15070
15241
  import {
15071
15242
  assert,
15072
- Tag as Tag5,
15243
+ Tag as Tag7,
15073
15244
  Value as Value3,
15074
15245
  isTruthy as isTruthy2
15075
15246
  } from "liquidjs";
15076
- function bind6(_liquidSwell) {
15077
- return class IfTag extends Tag5 {
15247
+ function bind8(_liquidSwell) {
15248
+ return class IfTag extends Tag7 {
15078
15249
  branches = [];
15079
15250
  elseTemplates;
15080
15251
  constructor(tagToken, remainTokens, liquid, parser) {
@@ -15141,9 +15312,9 @@ function assertEmpty(predicate, message = `unexpected ${JSON.stringify(predicate
15141
15312
  }
15142
15313
 
15143
15314
  // src/liquid/tags/javascript.ts
15144
- import { Tag as Tag6, TypeGuards as TypeGuards3 } from "liquidjs";
15145
- function bind7(_liquidSwell) {
15146
- return class JavascriptTag extends Tag6 {
15315
+ import { Tag as Tag8, TypeGuards as TypeGuards3 } from "liquidjs";
15316
+ function bind9(_liquidSwell) {
15317
+ return class JavascriptTag extends Tag8 {
15147
15318
  templates;
15148
15319
  constructor(token, remainTokens, liquid, parser) {
15149
15320
  super(token, remainTokens, liquid);
@@ -15168,9 +15339,9 @@ function bind7(_liquidSwell) {
15168
15339
  }
15169
15340
 
15170
15341
  // src/liquid/tags/layout.ts
15171
- import { Tag as Tag7 } from "liquidjs";
15172
- function bind8(liquidSwell) {
15173
- return class LayoutTag extends Tag7 {
15342
+ import { Tag as Tag9 } from "liquidjs";
15343
+ function bind10(liquidSwell) {
15344
+ return class LayoutTag extends Tag9 {
15174
15345
  fileName;
15175
15346
  constructor(token, remainTokens, liquid, _parser) {
15176
15347
  super(token, remainTokens, liquid);
@@ -15186,9 +15357,9 @@ function bind8(liquidSwell) {
15186
15357
  }
15187
15358
 
15188
15359
  // src/liquid/tags/paginate.ts
15189
- import { Tag as Tag8, Hash as Hash2, evalToken as evalToken4 } from "liquidjs";
15190
- function bind9(liquidSwell) {
15191
- return class PaginateTag extends Tag8 {
15360
+ import { Tag as Tag10, Hash as Hash4, evalToken as evalToken5 } from "liquidjs";
15361
+ function bind11(liquidSwell) {
15362
+ return class PaginateTag extends Tag10 {
15192
15363
  collection;
15193
15364
  pageSize;
15194
15365
  templates;
@@ -15203,7 +15374,7 @@ function bind9(liquidSwell) {
15203
15374
  }
15204
15375
  this.templates = [];
15205
15376
  this.collection = collection;
15206
- this.hash = new Hash2(this.tokenizer.remaining());
15377
+ this.hash = new Hash4(this.tokenizer.remaining());
15207
15378
  const stream = parser.parseStream(remainTokens).on("tag:endpaginate", () => stream.stop()).on("template", (tpl) => {
15208
15379
  this.templates.push(tpl);
15209
15380
  }).on("end", () => {
@@ -15213,8 +15384,8 @@ function bind9(liquidSwell) {
15213
15384
  }
15214
15385
  *render(ctx, emitter) {
15215
15386
  const r = this.liquid.renderer;
15216
- const collection = yield evalToken4(this.collection, ctx);
15217
- const pageSize = Number(yield evalToken4(this.pageSize, ctx));
15387
+ const collection = yield evalToken5(this.collection, ctx);
15388
+ const pageSize = Number(yield evalToken5(this.pageSize, ctx));
15218
15389
  const hash = yield this.hash.render(ctx);
15219
15390
  if (!Number.isNaN(pageSize) && collection instanceof SwellStorefrontCollection && collection.limit !== pageSize) {
15220
15391
  yield collection._get({
@@ -15240,9 +15411,9 @@ function bind9(liquidSwell) {
15240
15411
  }
15241
15412
 
15242
15413
  // src/liquid/tags/render.ts
15243
- import { assign } from "lodash-es";
15244
- import { assert as assert2, evalToken as evalToken5, RenderTag as LiquidRenderTag } from "liquidjs";
15245
- function bind10(liquidSwell) {
15414
+ import { assign as assign2 } from "lodash-es";
15415
+ import { assert as assert2, evalToken as evalToken6, RenderTag as LiquidRenderTag } from "liquidjs";
15416
+ function bind12(liquidSwell) {
15246
15417
  return class RenderTag extends LiquidRenderTag {
15247
15418
  *render(ctx, emitter) {
15248
15419
  const self = this;
@@ -15259,17 +15430,20 @@ function bind10(liquidSwell) {
15259
15430
  );
15260
15431
  const childCtx = ctx.spawn();
15261
15432
  const scope = childCtx.bottom();
15262
- assign(scope, yield hash.render(ctx));
15433
+ assign2(scope, ctx.bottom());
15263
15434
  const parentSection = yield ctx._get(["section"]);
15264
- if (parentSection) assign(scope, { section: parentSection });
15435
+ if (parentSection) assign2(scope, { section: parentSection });
15436
+ const parentBlock = yield ctx._get(["block"]);
15437
+ if (parentBlock) assign2(scope, { block: parentBlock });
15438
+ assign2(scope, yield hash.render(ctx));
15265
15439
  if (self["with"]) {
15266
15440
  const { value, alias } = self["with"];
15267
15441
  const aliasName = alias || filename;
15268
- scope[aliasName] = yield evalToken5(value, ctx);
15442
+ scope[aliasName] = yield evalToken6(value, ctx);
15269
15443
  }
15270
15444
  if (self["for"]) {
15271
15445
  const { value, alias } = self["for"];
15272
- let collection = yield evalToken5(value, ctx);
15446
+ let collection = yield evalToken6(value, ctx);
15273
15447
  collection = yield resolveEnumerable(collection);
15274
15448
  scope["forloop"] = new ForloopDrop(
15275
15449
  collection.length,
@@ -15312,13 +15486,13 @@ function* renderFilePath(file, ctx, liquid) {
15312
15486
  default:
15313
15487
  break;
15314
15488
  }
15315
- return yield evalToken5(file, ctx);
15489
+ return yield evalToken6(file, ctx);
15316
15490
  }
15317
15491
 
15318
15492
  // src/liquid/tags/section.ts
15319
- import { Tag as Tag9 } from "liquidjs";
15320
- function bind11(liquidSwell) {
15321
- return class SectionTag extends Tag9 {
15493
+ import { Tag as Tag11 } from "liquidjs";
15494
+ function bind13(liquidSwell) {
15495
+ return class SectionTag extends Tag11 {
15322
15496
  fileName;
15323
15497
  constructor(token, remainTokens, liquid, _parser) {
15324
15498
  super(token, remainTokens, liquid);
@@ -15369,10 +15543,10 @@ function bind11(liquidSwell) {
15369
15543
  }
15370
15544
 
15371
15545
  // src/liquid/tags/sections.ts
15372
- import { Tag as Tag10 } from "liquidjs";
15546
+ import { Tag as Tag12 } from "liquidjs";
15373
15547
  import JSON54 from "json5";
15374
- function bind12(liquidSwell) {
15375
- return class SectionsTag extends Tag10 {
15548
+ function bind14(liquidSwell) {
15549
+ return class SectionsTag extends Tag12 {
15376
15550
  fileName;
15377
15551
  constructor(token, remainTokens, liquid, _parser) {
15378
15552
  super(token, remainTokens, liquid);
@@ -15412,9 +15586,9 @@ function bind12(liquidSwell) {
15412
15586
  }
15413
15587
 
15414
15588
  // src/liquid/tags/style.ts
15415
- import { Tag as Tag11, TypeGuards as TypeGuards4 } from "liquidjs";
15416
- function bind13(_liquidSwell) {
15417
- return class StyleTag extends Tag11 {
15589
+ import { Tag as Tag13, TypeGuards as TypeGuards4 } from "liquidjs";
15590
+ function bind15(_liquidSwell) {
15591
+ return class StyleTag extends Tag13 {
15418
15592
  templates;
15419
15593
  hash;
15420
15594
  constructor(token, remainTokens, liquid, parser) {
@@ -15446,9 +15620,9 @@ function bind13(_liquidSwell) {
15446
15620
  }
15447
15621
 
15448
15622
  // src/liquid/tags/stylesheet.ts
15449
- import { Tag as Tag12, TypeGuards as TypeGuards5 } from "liquidjs";
15450
- function bind14(_liquidSwell) {
15451
- return class StyleSheetTag extends Tag12 {
15623
+ import { Tag as Tag14, TypeGuards as TypeGuards5 } from "liquidjs";
15624
+ function bind16(_liquidSwell) {
15625
+ return class StyleSheetTag extends Tag14 {
15452
15626
  templates;
15453
15627
  constructor(token, remainTokens, liquid, parser) {
15454
15628
  super(token, remainTokens, liquid);
@@ -15471,8 +15645,8 @@ function bind14(_liquidSwell) {
15471
15645
  }
15472
15646
 
15473
15647
  // src/liquid/tags/shopify/include.ts
15474
- import { assert as assert3, evalToken as evalToken6, IncludeTag as LiquidIncludeTag } from "liquidjs";
15475
- function bind15(liquidSwell) {
15648
+ import { assert as assert3, evalToken as evalToken7, IncludeTag as LiquidIncludeTag } from "liquidjs";
15649
+ function bind17(liquidSwell) {
15476
15650
  return class IncludeTag extends LiquidIncludeTag {
15477
15651
  *render(ctx, emitter) {
15478
15652
  const { hash } = this;
@@ -15487,7 +15661,7 @@ function bind15(liquidSwell) {
15487
15661
  ctx.setRegister("blockMode", 0);
15488
15662
  const scope = yield hash.render(ctx);
15489
15663
  if (this.withVar) {
15490
- scope[filepath] = yield evalToken6(this.withVar, ctx);
15664
+ scope[filepath] = yield evalToken7(this.withVar, ctx);
15491
15665
  }
15492
15666
  ctx.push(ctx.opts.jekyllInclude ? { include: scope } : scope);
15493
15667
  const output = yield liquidSwell.getComponentPath(filepath).then((path) => liquidSwell.getThemeConfig(path)).then((themeConfig) => liquidSwell.renderTemplate(themeConfig, ctx));
@@ -15499,10 +15673,10 @@ function bind15(liquidSwell) {
15499
15673
  }
15500
15674
 
15501
15675
  // src/liquid/tags/shopify/schema.ts
15502
- import { Tag as Tag13 } from "liquidjs";
15676
+ import { Tag as Tag15 } from "liquidjs";
15503
15677
  import JSON55 from "json5";
15504
- function bind16(liquidSwell) {
15505
- return class SchemaTag extends Tag13 {
15678
+ function bind18(liquidSwell) {
15679
+ return class SchemaTag extends Tag15 {
15506
15680
  templates;
15507
15681
  constructor(token, remainTokens, liquid, parser) {
15508
15682
  super(token, remainTokens, liquid);
@@ -15524,6 +15698,7 @@ function bind16(liquidSwell) {
15524
15698
  liquidSwell.lastSchema = void 0;
15525
15699
  if (typeof jsonOutput === "string") {
15526
15700
  liquidSwell.lastSchema = JSON55.parse(jsonOutput);
15701
+ expandThemeBlocks(liquidSwell);
15527
15702
  }
15528
15703
  } catch (err) {
15529
15704
  console.warn(err);
@@ -15533,11 +15708,22 @@ function bind16(liquidSwell) {
15533
15708
  }
15534
15709
  };
15535
15710
  }
15711
+ function expandThemeBlocks(liquidSwell) {
15712
+ const blocks = liquidSwell.lastSchema?.blocks;
15713
+ if (!Array.isArray(blocks)) {
15714
+ return;
15715
+ }
15716
+ for (let i = 0; i < blocks.length; i++) {
15717
+ if (blocks[i].type === "@theme") {
15718
+ blocks.splice(i, 1, ...liquidSwell.theme.getAllThemeBlockSchemas());
15719
+ }
15720
+ }
15721
+ }
15536
15722
 
15537
15723
  // src/liquid/tags/inline_editable.ts
15538
- import { Tag as Tag14 } from "liquidjs";
15539
- function bind17(_liquidSwell) {
15540
- return class InlineEditableTag extends Tag14 {
15724
+ import { Tag as Tag16 } from "liquidjs";
15725
+ function bind19(_liquidSwell) {
15726
+ return class InlineEditableTag extends Tag16 {
15541
15727
  key;
15542
15728
  value;
15543
15729
  constructor(token, remainTokens, liquid, _parser) {
@@ -15565,129 +15751,131 @@ var tags = {
15565
15751
  assign: bind,
15566
15752
  case: bind2,
15567
15753
  comment: bind3,
15568
- for: bind4,
15569
- form: bind5,
15570
- if: bind6,
15571
- javascript: bind7,
15572
- layout: bind8,
15573
- paginate: bind9,
15574
- render: bind10,
15575
- section: bind11,
15576
- sections: bind12,
15577
- style: bind13,
15754
+ content_for: bind4,
15755
+ doc: bind5,
15756
+ for: bind6,
15757
+ form: bind7,
15758
+ if: bind8,
15759
+ javascript: bind9,
15760
+ layout: bind10,
15761
+ paginate: bind11,
15762
+ render: bind12,
15763
+ section: bind13,
15764
+ sections: bind14,
15765
+ style: bind15,
15578
15766
  // Shopify compatibility only
15579
- include: bind15,
15580
- schema: bind16,
15581
- stylesheet: bind14,
15767
+ include: bind17,
15768
+ schema: bind18,
15769
+ stylesheet: bind16,
15582
15770
  // Swell only
15583
- inline_editable: bind17
15771
+ inline_editable: bind19
15584
15772
  };
15585
15773
  function bindTags(liquidSwell) {
15586
15774
  Object.entries(tags).forEach(
15587
- ([tag, bind67]) => liquidSwell.registerTag(tag, bind67(liquidSwell))
15775
+ ([tag, bind70]) => liquidSwell.registerTag(tag, bind70(liquidSwell))
15588
15776
  );
15589
15777
  }
15590
15778
 
15591
15779
  // src/liquid/filters/asset_url.ts
15592
- function bind18(liquidSwell) {
15780
+ function bind20(liquidSwell) {
15593
15781
  return function filterAssetUrl(assetPath) {
15594
15782
  return liquidSwell.getAssetUrl(assetPath).then((url) => url || "");
15595
15783
  };
15596
15784
  }
15597
15785
 
15598
15786
  // src/liquid/filters/brightness_difference.ts
15599
- function bind19(_liquidSwell) {
15787
+ function bind21(_liquidSwell) {
15600
15788
  return (color1, color2) => {
15601
15789
  return ThemeColor.get(color1).brightnessDifference(ThemeColor.get(color2));
15602
15790
  };
15603
15791
  }
15604
15792
 
15605
15793
  // src/liquid/filters/color_brightness.ts
15606
- function bind20(_liquidSwell) {
15794
+ function bind22(_liquidSwell) {
15607
15795
  return (color) => {
15608
15796
  return ThemeColor.get(color).brightness();
15609
15797
  };
15610
15798
  }
15611
15799
 
15612
15800
  // src/liquid/filters/color_contrast.ts
15613
- function bind21(_liquidSwell) {
15801
+ function bind23(_liquidSwell) {
15614
15802
  return (color1, color2) => {
15615
15803
  return ThemeColor.get(color1).contrast(ThemeColor.get(color2));
15616
15804
  };
15617
15805
  }
15618
15806
 
15619
15807
  // src/liquid/filters/color_darken.ts
15620
- function bind22(_liquidSwell) {
15808
+ function bind24(_liquidSwell) {
15621
15809
  return (color, percent) => {
15622
15810
  return ThemeColor.get(color).darken(percent);
15623
15811
  };
15624
15812
  }
15625
15813
 
15626
15814
  // src/liquid/filters/color_desaturate.ts
15627
- function bind23(_liquidSwell) {
15815
+ function bind25(_liquidSwell) {
15628
15816
  return (color, value) => {
15629
15817
  return ThemeColor.get(color).desaturate(value);
15630
15818
  };
15631
15819
  }
15632
15820
 
15633
15821
  // src/liquid/filters/color_difference.ts
15634
- function bind24(_liquidSwell) {
15822
+ function bind26(_liquidSwell) {
15635
15823
  return (color1, color2) => {
15636
15824
  return ThemeColor.get(color1).difference(ThemeColor.get(color2));
15637
15825
  };
15638
15826
  }
15639
15827
 
15640
15828
  // src/liquid/filters/color_extract.ts
15641
- function bind25(_liquidSwell) {
15829
+ function bind27(_liquidSwell) {
15642
15830
  return (color, field) => {
15643
15831
  return ThemeColor.get(color).extract(field);
15644
15832
  };
15645
15833
  }
15646
15834
 
15647
15835
  // src/liquid/filters/color_lighten.ts
15648
- function bind26(_liquidSwell) {
15836
+ function bind28(_liquidSwell) {
15649
15837
  return (color, percent) => {
15650
15838
  return ThemeColor.get(color).lighten(percent);
15651
15839
  };
15652
15840
  }
15653
15841
 
15654
15842
  // src/liquid/filters/color_mix.ts
15655
- function bind27(_liquidSwell) {
15843
+ function bind29(_liquidSwell) {
15656
15844
  return (color1, color2, ratio) => {
15657
15845
  return ThemeColor.get(color1).mix(ThemeColor.get(color2), ratio);
15658
15846
  };
15659
15847
  }
15660
15848
 
15661
15849
  // src/liquid/filters/color_modify.ts
15662
- function bind28(_liquidSwell) {
15850
+ function bind30(_liquidSwell) {
15663
15851
  return function filterColorModify(color, field, value) {
15664
15852
  return ThemeColor.get(color).modify(field, Number(value) || 0);
15665
15853
  };
15666
15854
  }
15667
15855
 
15668
15856
  // src/liquid/filters/color_saturate.ts
15669
- function bind29(_liquidSwell) {
15857
+ function bind31(_liquidSwell) {
15670
15858
  return (color, value) => {
15671
15859
  return ThemeColor.get(color).saturate(value);
15672
15860
  };
15673
15861
  }
15674
15862
 
15675
15863
  // src/liquid/filters/color_to_hex.ts
15676
- function bind30(_liquidSwell) {
15864
+ function bind32(_liquidSwell) {
15677
15865
  return (color) => {
15678
15866
  return ThemeColor.get(color).hex();
15679
15867
  };
15680
15868
  }
15681
15869
 
15682
15870
  // src/liquid/filters/color_to_hsl.ts
15683
- function bind31(_liquidSwell) {
15871
+ function bind33(_liquidSwell) {
15684
15872
  return (color) => {
15685
15873
  return ThemeColor.get(color).hsl();
15686
15874
  };
15687
15875
  }
15688
15876
 
15689
15877
  // src/liquid/filters/color_to_rgb.ts
15690
- function bind32(_liquidSwell) {
15878
+ function bind34(_liquidSwell) {
15691
15879
  return (color, alpha) => {
15692
15880
  return alpha !== void 0 ? ThemeColor.get(color).rgba(alpha) : ThemeColor.get(color).rgb();
15693
15881
  };
@@ -15695,7 +15883,7 @@ function bind32(_liquidSwell) {
15695
15883
 
15696
15884
  // src/liquid/filters/date.ts
15697
15885
  import strftime from "strftime";
15698
- function bind33(_liquidSwell) {
15886
+ function bind35(_liquidSwell) {
15699
15887
  return (dateValue, ...params) => {
15700
15888
  const date = ensureDate(dateValue);
15701
15889
  const { format } = getDateFilterParams(params);
@@ -15753,7 +15941,7 @@ function applyStrftimeFormat(format, date) {
15753
15941
  }
15754
15942
 
15755
15943
  // src/liquid/filters/date_next_interval.ts
15756
- function bind34(_liquidSwell) {
15944
+ function bind36(_liquidSwell) {
15757
15945
  return (dateValue, interval, intervalCount) => {
15758
15946
  const date = ensureDate(dateValue);
15759
15947
  const result = getNextIntervalDate(date, interval, Number(intervalCount));
@@ -15805,7 +15993,7 @@ function time(date) {
15805
15993
  }
15806
15994
 
15807
15995
  // src/liquid/filters/default_errors.ts
15808
- function bind35(_liquidSwell) {
15996
+ function bind37(_liquidSwell) {
15809
15997
  return async function filterDefaultError(errors) {
15810
15998
  if (!errors) {
15811
15999
  return "";
@@ -15831,7 +16019,7 @@ function bind35(_liquidSwell) {
15831
16019
  }
15832
16020
 
15833
16021
  // src/liquid/filters/divided_by.ts
15834
- function bind36(_liquidSwell) {
16022
+ function bind38(_liquidSwell) {
15835
16023
  return (dividend, divisor, integerArithmetic) => {
15836
16024
  if (!isNumber(dividend) || !isNumber(divisor)) {
15837
16025
  return dividend;
@@ -15842,7 +16030,7 @@ function bind36(_liquidSwell) {
15842
16030
 
15843
16031
  // src/liquid/filters/embedded_content.ts
15844
16032
  import { unescape } from "lodash-es";
15845
- function bind37(_liquidSwell) {
16033
+ function bind39(_liquidSwell) {
15846
16034
  return (value, tag = "iframe") => {
15847
16035
  const escapeIframes = value.replaceAll(`<${tag}`, `&lt;${tag}`).replaceAll(`</${tag}`, `&lt;/${tag}`);
15848
16036
  const removeTags = escapeIframes.replaceAll(/<(.*?)>/gi, "");
@@ -15854,7 +16042,7 @@ function bind37(_liquidSwell) {
15854
16042
 
15855
16043
  // src/liquid/filters/escape.ts
15856
16044
  import { escape } from "lodash-es";
15857
- function bind38(_liquidSwell) {
16045
+ function bind40(_liquidSwell) {
15858
16046
  return function escapeTag(input) {
15859
16047
  if (!input?.startsWith) {
15860
16048
  return input;
@@ -15867,7 +16055,7 @@ function bind38(_liquidSwell) {
15867
16055
  }
15868
16056
 
15869
16057
  // src/liquid/filters/font_face.ts
15870
- function bind39(_liquidSwell) {
16058
+ function bind41(_liquidSwell) {
15871
16059
  return (fontSetting, ...params) => {
15872
16060
  if (!fontSetting) {
15873
16061
  return null;
@@ -15879,14 +16067,14 @@ function bind39(_liquidSwell) {
15879
16067
  }
15880
16068
 
15881
16069
  // src/liquid/filters/font_modify.ts
15882
- function bind40(_liquidSwell) {
16070
+ function bind42(_liquidSwell) {
15883
16071
  return (fontSetting, prop, value) => {
15884
16072
  return ThemeFont.clone(fontSetting).modify(prop, value);
15885
16073
  };
15886
16074
  }
15887
16075
 
15888
16076
  // src/liquid/filters/font_url.ts
15889
- function bind41(_liquidSwell) {
16077
+ function bind43(_liquidSwell) {
15890
16078
  return (fontSetting) => {
15891
16079
  return ThemeFont.get(fontSetting).url();
15892
16080
  };
@@ -15936,14 +16124,14 @@ var format_address_default = {
15936
16124
 
15937
16125
  // src/liquid/filters/handleize.ts
15938
16126
  import { kebabCase } from "lodash-es";
15939
- function bind42(_liquidSwell) {
16127
+ function bind44(_liquidSwell) {
15940
16128
  return function filterHandleize(handle) {
15941
16129
  return kebabCase(handle);
15942
16130
  };
15943
16131
  }
15944
16132
 
15945
16133
  // src/liquid/filters/image_tag.ts
15946
- function bind43(_liquidSwell) {
16134
+ function bind45(_liquidSwell) {
15947
16135
  return function filterImageTag(imageUrl, ...params) {
15948
16136
  imageUrl = String(imageUrl || "");
15949
16137
  let {
@@ -16107,7 +16295,7 @@ var filterDefinition = {
16107
16295
  var image_url_default = filterDefinition;
16108
16296
 
16109
16297
  // src/liquid/filters/inline_asset_content.ts
16110
- function bind44(liquidSwell) {
16298
+ function bind46(liquidSwell) {
16111
16299
  return async (assetPath) => {
16112
16300
  const config = await liquidSwell.theme.getThemeConfig(
16113
16301
  `theme/assets/${assetPath}`
@@ -16117,14 +16305,14 @@ function bind44(liquidSwell) {
16117
16305
  }
16118
16306
 
16119
16307
  // src/liquid/filters/json.ts
16120
- function bind45(_liquidSwell) {
16308
+ function bind47(_liquidSwell) {
16121
16309
  return async function filterJson(input, space = 0) {
16122
16310
  return jsonStringifyAsync(input, space);
16123
16311
  };
16124
16312
  }
16125
16313
 
16126
16314
  // src/liquid/filters/json_pretty.ts
16127
- function bind46(_liquidSwell) {
16315
+ function bind48(_liquidSwell) {
16128
16316
  return async function filterJsonPretty(input, space = 2) {
16129
16317
  const output = await jsonStringifyAsync(input, space);
16130
16318
  return `<pre>${output}</pre>`;
@@ -16134,7 +16322,7 @@ function bind46(_liquidSwell) {
16134
16322
  // src/liquid/filters/locale_flag.ts
16135
16323
  import { hasFlag } from "country-flag-icons";
16136
16324
  import * as flags from "country-flag-icons/string/1x1";
16137
- function bind47(_liquidSwell) {
16325
+ function bind49(_liquidSwell) {
16138
16326
  return (localeCode) => {
16139
16327
  if (typeof localeCode !== "string") {
16140
16328
  return flags.US;
@@ -16145,7 +16333,7 @@ function bind47(_liquidSwell) {
16145
16333
  }
16146
16334
 
16147
16335
  // src/liquid/filters/minus.ts
16148
- function bind48(_liquidSwell) {
16336
+ function bind50(_liquidSwell) {
16149
16337
  return (first, second) => {
16150
16338
  const firstValue = isNumber(first) ? first : 0;
16151
16339
  const secondValue = isNumber(second) ? second : 0;
@@ -16154,7 +16342,7 @@ function bind48(_liquidSwell) {
16154
16342
  }
16155
16343
 
16156
16344
  // src/liquid/filters/money.ts
16157
- function bind49(liquidSwell) {
16345
+ function bind51(liquidSwell) {
16158
16346
  return function filterMoney(value) {
16159
16347
  const amount = getMoneyAmount(liquidSwell, value);
16160
16348
  return liquidSwell.renderCurrency(amount);
@@ -16171,7 +16359,7 @@ function getMoneyAmount(liquidSwell, value) {
16171
16359
  }
16172
16360
 
16173
16361
  // src/liquid/filters/money_with_currency.ts
16174
- function bind50(liquidSwell) {
16362
+ function bind52(liquidSwell) {
16175
16363
  return function filterMoneyWithCurrency(value) {
16176
16364
  const { currency } = liquidSwell.theme.swell.getStorefrontLocalization();
16177
16365
  const amount = getMoneyAmount(liquidSwell, value);
@@ -16180,7 +16368,7 @@ function bind50(liquidSwell) {
16180
16368
  }
16181
16369
 
16182
16370
  // src/liquid/filters/money_without_currency.ts
16183
- function bind51(liquidSwell) {
16371
+ function bind53(liquidSwell) {
16184
16372
  return function filterMoneyWithoutCurrency(value) {
16185
16373
  const amount = getMoneyAmount(liquidSwell, value);
16186
16374
  return liquidSwell.renderCurrency(amount).replace(/[^0-9.,]/g, "");
@@ -16188,30 +16376,45 @@ function bind51(liquidSwell) {
16188
16376
  }
16189
16377
 
16190
16378
  // src/liquid/filters/money_without_trailing_zeros.ts
16191
- function bind52(liquidSwell) {
16379
+ function bind54(liquidSwell) {
16192
16380
  return function filterMoneyWithoutTrailingZeros(value) {
16193
16381
  const amount = getMoneyAmount(liquidSwell, value);
16194
16382
  return liquidSwell.renderCurrency(amount).split(".")[0].split(",")[0];
16195
16383
  };
16196
16384
  }
16197
16385
 
16386
+ // src/liquid/filters/preload_tag.ts
16387
+ function bind55(_liquidSwell) {
16388
+ return function filterPreloadTag(assetUrl, ...params) {
16389
+ if (!assetUrl) {
16390
+ return "";
16391
+ }
16392
+ const { as } = paramsToProps(params);
16393
+ let attributes = "";
16394
+ if (typeof as === "string" && as) {
16395
+ attributes += `as="${as}"`;
16396
+ }
16397
+ return `<link href="${assetUrl}" rel="preload" ${attributes} />`;
16398
+ };
16399
+ }
16400
+
16198
16401
  // src/liquid/filters/script_tag.ts
16199
- function bind53(_liquidSwell) {
16402
+ function bind56(_liquidSwell) {
16200
16403
  return function filterScriptTag(assetUrl) {
16201
16404
  return `<script src="${assetUrl}" type="text/javascript"></script>`;
16202
16405
  };
16203
16406
  }
16204
16407
 
16205
16408
  // src/liquid/filters/stylesheet_tag.ts
16206
- function bind54(_liquidSwell) {
16409
+ function bind57(_liquidSwell) {
16207
16410
  return function filterStyleSheetTag(assetUrl) {
16208
16411
  return `<link href="${assetUrl}" rel="stylesheet" type="text/css" media="all" />`;
16209
16412
  };
16210
16413
  }
16211
16414
 
16212
16415
  // src/liquid/filters/time_tag.ts
16213
- function bind55(_liquidSwell) {
16214
- const dateFilter = bind33(_liquidSwell);
16416
+ function bind58(_liquidSwell) {
16417
+ const dateFilter = bind35(_liquidSwell);
16215
16418
  return (dateValue, ...params) => {
16216
16419
  const date = ensureDate(dateValue);
16217
16420
  const formattedDate = dateFilter(dateValue, ...params);
@@ -16221,7 +16424,7 @@ function bind55(_liquidSwell) {
16221
16424
  }
16222
16425
 
16223
16426
  // src/liquid/filters/translate.ts
16224
- function bind56(liquidSwell) {
16427
+ function bind59(liquidSwell) {
16225
16428
  return async function filterTranslate(key, params) {
16226
16429
  const props = params && paramsToProps(params);
16227
16430
  const str = await liquidSwell.renderTranslation(key, props);
@@ -16230,7 +16433,7 @@ function bind56(liquidSwell) {
16230
16433
  }
16231
16434
 
16232
16435
  // src/liquid/filters/where.ts
16233
- function bind57(_liquidSwell) {
16436
+ function bind60(_liquidSwell) {
16234
16437
  return function* filterWhere(arr, property, expected) {
16235
16438
  const results = [];
16236
16439
  const list = yield resolveEnumerable(arr);
@@ -16284,7 +16487,7 @@ function getSizesFromParam(param) {
16284
16487
  height: height ? Number(height) : void 0
16285
16488
  };
16286
16489
  }
16287
- function bind58(liquidSwell) {
16490
+ function bind61(liquidSwell) {
16288
16491
  return async function filterAssetImgUrl(assetPath, size = "small") {
16289
16492
  const imageUrl = await liquidSwell.getAssetUrl(assetPath).then((url) => url || "");
16290
16493
  const sizes = getSizesFromParam(size);
@@ -16300,14 +16503,14 @@ function bind58(liquidSwell) {
16300
16503
  }
16301
16504
 
16302
16505
  // src/liquid/filters/shopify/hex_to_rgba.ts
16303
- function bind59(_liquidSwell) {
16506
+ function bind62(_liquidSwell) {
16304
16507
  return (color, alpha) => {
16305
16508
  return ThemeColor.get(color).rgba(alpha || 1);
16306
16509
  };
16307
16510
  }
16308
16511
 
16309
16512
  // src/liquid/filters/shopify/img_url.ts
16310
- function bind60(liquidSwell) {
16513
+ function bind63(liquidSwell) {
16311
16514
  return async function filterImgUrl(input, ...params) {
16312
16515
  const url = await getImageUrlFromInput(input, liquidSwell);
16313
16516
  if (typeof url !== "string" || url === "") {
@@ -16345,14 +16548,14 @@ var item_count_for_variant_default = {
16345
16548
  };
16346
16549
 
16347
16550
  // src/liquid/filters/shopify/payment_button.ts
16348
- function bind61(_liquidSwell) {
16551
+ function bind64(_liquidSwell) {
16349
16552
  return (form) => {
16350
16553
  return `<button style="display: block; visibility: hidden;"></button>`;
16351
16554
  };
16352
16555
  }
16353
16556
 
16354
16557
  // src/liquid/filters/shopify/payment_terms.ts
16355
- function bind62(_liquidSwell) {
16558
+ function bind65(_liquidSwell) {
16356
16559
  return (form) => {
16357
16560
  return null;
16358
16561
  };
@@ -16454,7 +16657,7 @@ var svgs = {
16454
16657
  var placeholder_svgs_default = svgs;
16455
16658
 
16456
16659
  // src/liquid/filters/shopify/placeholder_svg_tag.ts
16457
- function bind63(_liquidSwell) {
16660
+ function bind66(_liquidSwell) {
16458
16661
  return function filterPlaceholderSvgTag(name, className) {
16459
16662
  const svg = placeholder_svgs_default[name];
16460
16663
  if (typeof svg === "object" && svg !== null) {
@@ -16465,7 +16668,7 @@ function bind63(_liquidSwell) {
16465
16668
  }
16466
16669
 
16467
16670
  // src/liquid/filters/shopify/shopify_asset_url.ts
16468
- function bind64(_liquidSwell) {
16671
+ function bind67(_liquidSwell) {
16469
16672
  return function filterShopifyAssetUrl(input) {
16470
16673
  if (typeof input === "string") {
16471
16674
  switch (input) {
@@ -16490,7 +16693,7 @@ function bind64(_liquidSwell) {
16490
16693
  }
16491
16694
 
16492
16695
  // src/liquid/filters/shopify/structured_data.ts
16493
- function bind65(_liquidSwell) {
16696
+ function bind68(_liquidSwell) {
16494
16697
  return async function filterStructuredData(input) {
16495
16698
  let value = input;
16496
16699
  if (value instanceof StorefrontResource) {
@@ -16568,7 +16771,7 @@ function convertToSchemaOrgProductGroup(product) {
16568
16771
  }
16569
16772
 
16570
16773
  // src/liquid/filters/inline_editable.ts
16571
- function bind66(_liquidSwell) {
16774
+ function bind69(_liquidSwell) {
16572
16775
  return (value, key) => {
16573
16776
  if (typeof value === "object" && "value" in value) {
16574
16777
  value = value.value;
@@ -16579,64 +16782,65 @@ function bind66(_liquidSwell) {
16579
16782
 
16580
16783
  // src/liquid/filters/index.ts
16581
16784
  var filters = {
16582
- asset_url: bind18,
16583
- brightness_difference: bind19,
16584
- color_brightness: bind20,
16585
- color_contrast: bind21,
16586
- color_darken: bind22,
16587
- color_desaturate: bind23,
16588
- color_difference: bind24,
16589
- color_extract: bind25,
16590
- color_lighten: bind26,
16591
- color_mix: bind27,
16592
- color_modify: bind28,
16593
- color_saturate: bind29,
16594
- color_to_hex: bind30,
16595
- color_to_hsl: bind31,
16596
- color_to_rgb: bind32,
16597
- date_next_interval: bind34,
16598
- date: bind33,
16599
- default_errors: bind35,
16600
- divided_by: bind36,
16601
- embedded_content: bind37,
16602
- escape: bind38,
16603
- font_face: bind39,
16604
- font_modify: bind40,
16605
- font_url: bind41,
16785
+ asset_url: bind20,
16786
+ brightness_difference: bind21,
16787
+ color_brightness: bind22,
16788
+ color_contrast: bind23,
16789
+ color_darken: bind24,
16790
+ color_desaturate: bind25,
16791
+ color_difference: bind26,
16792
+ color_extract: bind27,
16793
+ color_lighten: bind28,
16794
+ color_mix: bind29,
16795
+ color_modify: bind30,
16796
+ color_saturate: bind31,
16797
+ color_to_hex: bind32,
16798
+ color_to_hsl: bind33,
16799
+ color_to_rgb: bind34,
16800
+ date_next_interval: bind36,
16801
+ date: bind35,
16802
+ default_errors: bind37,
16803
+ divided_by: bind38,
16804
+ embedded_content: bind39,
16805
+ escape: bind40,
16806
+ font_face: bind41,
16807
+ font_modify: bind42,
16808
+ font_url: bind43,
16606
16809
  format_address: format_address_default,
16607
- handle: bind42,
16810
+ handle: bind44,
16608
16811
  // alias
16609
- handleize: bind42,
16610
- image_tag: bind43,
16812
+ handleize: bind44,
16813
+ image_tag: bind45,
16611
16814
  image_url: image_url_default,
16612
- inline_asset_content: bind44,
16613
- json: bind45,
16614
- json_pretty: bind46,
16615
- locale_flag: bind47,
16616
- minus: bind48,
16617
- money: bind49,
16618
- money_with_currency: bind50,
16619
- money_without_currency: bind51,
16620
- money_without_trailing_zeros: bind52,
16621
- script_tag: bind53,
16622
- stylesheet_tag: bind54,
16623
- time_tag: bind55,
16624
- translate: bind56,
16625
- t: bind56,
16815
+ inline_asset_content: bind46,
16816
+ json: bind47,
16817
+ json_pretty: bind48,
16818
+ locale_flag: bind49,
16819
+ minus: bind50,
16820
+ money: bind51,
16821
+ money_with_currency: bind52,
16822
+ money_without_currency: bind53,
16823
+ money_without_trailing_zeros: bind54,
16824
+ preload_tag: bind55,
16825
+ script_tag: bind56,
16826
+ stylesheet_tag: bind57,
16827
+ time_tag: bind58,
16828
+ translate: bind59,
16829
+ t: bind59,
16626
16830
  // alias
16627
- where: bind57,
16831
+ where: bind60,
16628
16832
  // Shopify compatibility only
16629
- asset_img_url: bind58,
16630
- hex_to_rgba: bind59,
16631
- img_url: bind60,
16833
+ asset_img_url: bind61,
16834
+ hex_to_rgba: bind62,
16835
+ img_url: bind63,
16632
16836
  item_count_for_variant: item_count_for_variant_default,
16633
- payment_button: bind61,
16634
- payment_terms: bind62,
16635
- placeholder_svg_tag: bind63,
16636
- shopify_asset_url: bind64,
16637
- structured_data: bind65,
16837
+ payment_button: bind64,
16838
+ payment_terms: bind65,
16839
+ placeholder_svg_tag: bind66,
16840
+ shopify_asset_url: bind67,
16841
+ structured_data: bind68,
16638
16842
  // Swell only
16639
- inline_editable: bind66
16843
+ inline_editable: bind69
16640
16844
  };
16641
16845
  function bindFilters(liquidSwell) {
16642
16846
  for (const [tag, handler] of Object.entries(filters)) {
@@ -16650,8 +16854,8 @@ function bindFilters(liquidSwell) {
16650
16854
  }
16651
16855
  }
16652
16856
  }
16653
- function bindWithResolvedProps(liquidSwell, bind67, resolve = []) {
16654
- const handler = bind67(liquidSwell);
16857
+ function bindWithResolvedProps(liquidSwell, bind70, resolve = []) {
16858
+ const handler = bind70(liquidSwell);
16655
16859
  if (!Array.isArray(resolve)) {
16656
16860
  return handler;
16657
16861
  }
@@ -16778,10 +16982,16 @@ var ThemeColor = class _ThemeColor extends Drop16 {
16778
16982
  return this.color.darken(percent / 100).hex().toLowerCase();
16779
16983
  }
16780
16984
  rgb() {
16781
- return this.color.rgb().toString();
16985
+ return `${this.red} ${this.green} ${this.blue}`;
16782
16986
  }
16783
16987
  rgba(alpha) {
16784
- return this.color.alpha(alpha).rgb().toString();
16988
+ const colorValues = this.color.object();
16989
+ const alphaValue = alpha || colorValues.alpha;
16990
+ const rgb = this.rgb();
16991
+ if (alphaValue === void 0) {
16992
+ return rgb;
16993
+ }
16994
+ return `${rgb} / ${Number(alphaValue).toFixed(2)}`;
16785
16995
  }
16786
16996
  hsl() {
16787
16997
  return this.color.hsl().round().toString();
@@ -16886,6 +17096,7 @@ var LiquidSwell31 = class extends Liquid3 {
16886
17096
  extName;
16887
17097
  componentsDir;
16888
17098
  sectionsDir;
17099
+ blocksDir;
16889
17100
  lastSchema;
16890
17101
  constructor({
16891
17102
  theme,
@@ -16903,7 +17114,8 @@ var LiquidSwell31 = class extends Liquid3 {
16903
17114
  layoutName,
16904
17115
  extName,
16905
17116
  componentsDir,
16906
- sectionsDir
17117
+ sectionsDir,
17118
+ blocksDir
16907
17119
  }) {
16908
17120
  getThemeConfig = getThemeConfig || theme.getThemeConfig.bind(theme);
16909
17121
  extName = extName || "liquid";
@@ -16932,6 +17144,7 @@ var LiquidSwell31 = class extends Liquid3 {
16932
17144
  this.extName = extName;
16933
17145
  this.componentsDir = componentsDir || "components";
16934
17146
  this.sectionsDir = sectionsDir || "sections";
17147
+ this.blocksDir = blocksDir || "blocks";
16935
17148
  this.lastSchema = void 0;
16936
17149
  bindTags(this);
16937
17150
  bindFilters(this);
@@ -16954,6 +17167,9 @@ var LiquidSwell31 = class extends Liquid3 {
16954
17167
  async getSectionGroupPath(sectionName) {
16955
17168
  return await this.resolveFilePathByType("sections", `${sectionName}.json`) || resolveFilePath(`${this.sectionsDir}/${sectionName}`, "json");
16956
17169
  }
17170
+ async getThemeBlockPath(blockName) {
17171
+ return await this.resolveFilePathByType("blocks", blockName) || resolveFilePath(`${this.blocksDir}/${blockName}`, this.extName);
17172
+ }
16957
17173
  };
16958
17174
  function resolveFilePath(fileName, extName) {
16959
17175
  return `theme/${fileName}.${extName}`;
@@ -18665,6 +18881,30 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
18665
18881
  const configs = this.getThemeConfigsByPath("theme/sections/");
18666
18882
  return getAllSections(configs, this.getTemplateSchema.bind(this));
18667
18883
  }
18884
+ /**
18885
+ * Returns all theme block schemas from /blocks folder.
18886
+ */
18887
+ getAllThemeBlockSchemas() {
18888
+ const schemas = [];
18889
+ const configs = this.getThemeConfigsByPath("theme/blocks/");
18890
+ for (const config of configs.values()) {
18891
+ const { name, file_path: filePath, file_data: fileData } = config;
18892
+ const rawSchema = extractSchemaTag(fileData, true);
18893
+ if (!rawSchema) {
18894
+ continue;
18895
+ }
18896
+ try {
18897
+ const schema = JSON56.parse(rawSchema);
18898
+ if (!schema.type) {
18899
+ schema.type = name;
18900
+ }
18901
+ schemas.push(schema);
18902
+ } catch (error) {
18903
+ console.warn(`Invalid schema in block: ${filePath}`, error);
18904
+ }
18905
+ }
18906
+ return schemas;
18907
+ }
18668
18908
  async getPageSections(sectionGroup, resolveSettings = true) {
18669
18909
  const sectionConfigs = await getPageSections(
18670
18910
  sectionGroup,
@@ -19025,14 +19265,14 @@ function parseJsonConfig(config) {
19025
19265
  return {};
19026
19266
  }
19027
19267
  }
19028
- function extractSchemaTag(template) {
19268
+ function extractSchemaTag(template, inner = false) {
19029
19269
  const list = template.match(
19030
19270
  /\{%-?\s*schema\s*-?%\}(.*)\{%-?\s*endschema\s*-?%\}/s
19031
19271
  );
19032
19272
  if (list === null) {
19033
19273
  return template;
19034
19274
  }
19035
- return list[0];
19275
+ return inner ? list[1] : list[0];
19036
19276
  }
19037
19277
  function withSuffix(path, suffix) {
19038
19278
  return suffix ? `${path}.${suffix}` : path;