@swell/apps-sdk 1.0.155 → 1.0.156

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
@@ -36,7 +36,7 @@ __export(index_exports, {
36
36
  FILE_DATA_INCLUDE_QUERY: () => FILE_DATA_INCLUDE_QUERY,
37
37
  GEO_DATA: () => GEO_DATA,
38
38
  LANG_TO_COUNTRY_CODES: () => LANG_TO_COUNTRY_CODES,
39
- LiquidSwell: () => LiquidSwell29,
39
+ LiquidSwell: () => LiquidSwell30,
40
40
  MAX_QUERY_PAGE_LIMIT: () => MAX_QUERY_PAGE_LIMIT,
41
41
  MockRecordResource: () => MockRecordResource,
42
42
  MockRecordSingleton: () => MockRecordSingleton,
@@ -19199,7 +19199,7 @@ var tags = {
19199
19199
  };
19200
19200
  function bindTags(liquidSwell) {
19201
19201
  Object.entries(tags).forEach(
19202
- ([tag, bind63]) => liquidSwell.registerTag(tag, bind63(liquidSwell))
19202
+ ([tag, bind64]) => liquidSwell.registerTag(tag, bind64(liquidSwell))
19203
19203
  );
19204
19204
  }
19205
19205
 
@@ -19367,8 +19367,60 @@ function applyStrftimeFormat(format, date) {
19367
19367
  return (0, import_strftime.default)(format, date);
19368
19368
  }
19369
19369
 
19370
- // src/liquid/filters/default_errors.ts
19370
+ // src/liquid/filters/date_next_interval.ts
19371
19371
  function bind34(_liquidSwell) {
19372
+ return (dateValue, interval, intervalCount) => {
19373
+ const date = ensureDate(dateValue);
19374
+ const result = getNextIntervalDate(date, interval, Number(intervalCount));
19375
+ return result ? new Date(result).toISOString() : (/* @__PURE__ */ new Date()).toISOString();
19376
+ };
19377
+ }
19378
+ function getNextIntervalDate(date, interval, intervalCount) {
19379
+ if (!interval || !date) {
19380
+ return;
19381
+ }
19382
+ if (interval === "monthly" || interval === 30) {
19383
+ return dateNextMonth(date, intervalCount);
19384
+ }
19385
+ let intervalDays = 0;
19386
+ if (typeof interval === "string") {
19387
+ if (interval === "daily") {
19388
+ intervalDays = 1;
19389
+ } else if (interval === "weekly") {
19390
+ intervalDays = 7;
19391
+ } else if (interval === "yearly") {
19392
+ intervalDays = 365;
19393
+ }
19394
+ }
19395
+ if (intervalDays <= 0) {
19396
+ return;
19397
+ }
19398
+ return time(date) + intervalDays * intervalCount * 86400 * 1e3;
19399
+ }
19400
+ function dateNextMonth(startDate, intervalCount) {
19401
+ const date = new Date(startDate);
19402
+ const nextDate = new Date(date);
19403
+ nextDate.setUTCMonth(date.getMonth() + (intervalCount || 1));
19404
+ if (nextDate.getDate() !== date.getDate()) {
19405
+ nextDate.setDate(nextDate.getDate() - nextDate.getDate());
19406
+ }
19407
+ return nextDate.getTime();
19408
+ }
19409
+ function time(date) {
19410
+ if (date === void 0) {
19411
+ return Date.now();
19412
+ }
19413
+ if (typeof date === "number" || typeof date === "string") {
19414
+ return new Date(date).getTime();
19415
+ }
19416
+ if (date instanceof Date) {
19417
+ return date.getTime();
19418
+ }
19419
+ return Date.now();
19420
+ }
19421
+
19422
+ // src/liquid/filters/default_errors.ts
19423
+ function bind35(_liquidSwell) {
19372
19424
  return async function filterDefaultError(errors) {
19373
19425
  if (!errors) {
19374
19426
  return "";
@@ -19394,7 +19446,7 @@ function bind34(_liquidSwell) {
19394
19446
  }
19395
19447
 
19396
19448
  // src/liquid/filters/divided_by.ts
19397
- function bind35(_liquidSwell) {
19449
+ function bind36(_liquidSwell) {
19398
19450
  return (dividend, divisor, integerArithmetic) => {
19399
19451
  if (!isNumber(dividend) || !isNumber(divisor)) {
19400
19452
  return dividend;
@@ -19405,7 +19457,7 @@ function bind35(_liquidSwell) {
19405
19457
 
19406
19458
  // src/liquid/filters/embedded_content.ts
19407
19459
  var import_lodash_es10 = require("lodash-es");
19408
- function bind36(_liquidSwell) {
19460
+ function bind37(_liquidSwell) {
19409
19461
  return (value, tag = "iframe") => {
19410
19462
  const escapeIframes = value.replaceAll(`<${tag}`, `&lt;${tag}`).replaceAll(`</${tag}`, `&lt;/${tag}`);
19411
19463
  const removeTags = escapeIframes.replaceAll(/<(.*?)>/gi, "");
@@ -19416,7 +19468,7 @@ function bind36(_liquidSwell) {
19416
19468
  }
19417
19469
 
19418
19470
  // src/liquid/filters/font_face.ts
19419
- function bind37(_liquidSwell) {
19471
+ function bind38(_liquidSwell) {
19420
19472
  return (fontSetting, ...params) => {
19421
19473
  if (!fontSetting) {
19422
19474
  return null;
@@ -19428,14 +19480,14 @@ function bind37(_liquidSwell) {
19428
19480
  }
19429
19481
 
19430
19482
  // src/liquid/filters/font_modify.ts
19431
- function bind38(_liquidSwell) {
19483
+ function bind39(_liquidSwell) {
19432
19484
  return (fontSetting, prop, value) => {
19433
19485
  return ThemeFont.clone(fontSetting).modify(prop, value);
19434
19486
  };
19435
19487
  }
19436
19488
 
19437
19489
  // src/liquid/filters/font_url.ts
19438
- function bind39(_liquidSwell) {
19490
+ function bind40(_liquidSwell) {
19439
19491
  return (fontSetting) => {
19440
19492
  return ThemeFont.get(fontSetting).url();
19441
19493
  };
@@ -19485,14 +19537,14 @@ var format_address_default = {
19485
19537
 
19486
19538
  // src/liquid/filters/handleize.ts
19487
19539
  var import_lodash_es11 = require("lodash-es");
19488
- function bind40(_liquidSwell) {
19540
+ function bind41(_liquidSwell) {
19489
19541
  return function filterHandleize(handle) {
19490
19542
  return (0, import_lodash_es11.kebabCase)(handle);
19491
19543
  };
19492
19544
  }
19493
19545
 
19494
19546
  // src/liquid/filters/image_tag.ts
19495
- function bind41(_liquidSwell) {
19547
+ function bind42(_liquidSwell) {
19496
19548
  return function filterImageTag(imageUrl, ...params) {
19497
19549
  imageUrl = String(imageUrl || "");
19498
19550
  let {
@@ -19656,7 +19708,7 @@ var filterDefinition = {
19656
19708
  var image_url_default = filterDefinition;
19657
19709
 
19658
19710
  // src/liquid/filters/inline_asset_content.ts
19659
- function bind42(liquidSwell) {
19711
+ function bind43(liquidSwell) {
19660
19712
  return async (assetPath) => {
19661
19713
  const config = await liquidSwell.theme.getThemeConfig(
19662
19714
  `theme/assets/${assetPath}`
@@ -19666,14 +19718,14 @@ function bind42(liquidSwell) {
19666
19718
  }
19667
19719
 
19668
19720
  // src/liquid/filters/json.ts
19669
- function bind43(_liquidSwell) {
19721
+ function bind44(_liquidSwell) {
19670
19722
  return async function filterJson(input, space = 0) {
19671
19723
  return jsonStringifyAsync(input, space);
19672
19724
  };
19673
19725
  }
19674
19726
 
19675
19727
  // src/liquid/filters/json_pretty.ts
19676
- function bind44(_liquidSwell) {
19728
+ function bind45(_liquidSwell) {
19677
19729
  return async function filterJsonPretty(input, space = 2) {
19678
19730
  const output = await jsonStringifyAsync(input, space);
19679
19731
  return `<pre>${output}</pre>`;
@@ -19690,7 +19742,7 @@ function getCountryCode(localCode) {
19690
19742
  return localCode.toUpperCase();
19691
19743
  }
19692
19744
  }
19693
- function bind45(_liquidSwell) {
19745
+ function bind46(_liquidSwell) {
19694
19746
  return (localeCode) => {
19695
19747
  if (typeof localeCode !== "string") {
19696
19748
  return flags.US;
@@ -19701,7 +19753,7 @@ function bind45(_liquidSwell) {
19701
19753
  }
19702
19754
 
19703
19755
  // src/liquid/filters/money.ts
19704
- function bind46(liquidSwell) {
19756
+ function bind47(liquidSwell) {
19705
19757
  return function filterMoney(value) {
19706
19758
  const amount = value instanceof MoneyDrop ? value.toFloat() : Number(value || 0);
19707
19759
  return liquidSwell.renderCurrency(amount);
@@ -19709,7 +19761,7 @@ function bind46(liquidSwell) {
19709
19761
  }
19710
19762
 
19711
19763
  // src/liquid/filters/money_with_currency.ts
19712
- function bind47(liquidSwell) {
19764
+ function bind48(liquidSwell) {
19713
19765
  return function filterMoneyWithCurrency(value) {
19714
19766
  const { currency } = liquidSwell.theme.swell.getStorefrontLocalization();
19715
19767
  const amount = value instanceof MoneyDrop ? value.toFloat() : Number(value || 0);
@@ -19718,7 +19770,7 @@ function bind47(liquidSwell) {
19718
19770
  }
19719
19771
 
19720
19772
  // src/liquid/filters/money_without_currency.ts
19721
- function bind48(liquidSwell) {
19773
+ function bind49(liquidSwell) {
19722
19774
  return function filterMoneyWithoutCurrency(value) {
19723
19775
  const amount = value instanceof MoneyDrop ? value.toFloat() : Number(value || 0);
19724
19776
  return liquidSwell.renderCurrency(amount).replace(/[^0-9.,]/g, "");
@@ -19726,7 +19778,7 @@ function bind48(liquidSwell) {
19726
19778
  }
19727
19779
 
19728
19780
  // src/liquid/filters/money_without_trailing_zeros.ts
19729
- function bind49(liquidSwell) {
19781
+ function bind50(liquidSwell) {
19730
19782
  return function filterMoneyWithoutTrailingZeros(value) {
19731
19783
  const amount = value instanceof MoneyDrop ? value.toFloat() : Number(value || 0);
19732
19784
  return liquidSwell.renderCurrency(amount).split(".")[0].split(",")[0];
@@ -19734,21 +19786,21 @@ function bind49(liquidSwell) {
19734
19786
  }
19735
19787
 
19736
19788
  // src/liquid/filters/script_tag.ts
19737
- function bind50(_liquidSwell) {
19789
+ function bind51(_liquidSwell) {
19738
19790
  return function filterScriptTag(assetUrl) {
19739
19791
  return `<script src="${assetUrl}" type="text/javascript"></script>`;
19740
19792
  };
19741
19793
  }
19742
19794
 
19743
19795
  // src/liquid/filters/stylesheet_tag.ts
19744
- function bind51(_liquidSwell) {
19796
+ function bind52(_liquidSwell) {
19745
19797
  return function filterStyleSheetTag(assetUrl) {
19746
19798
  return `<link href="${assetUrl}" rel="stylesheet" type="text/css" media="all" />`;
19747
19799
  };
19748
19800
  }
19749
19801
 
19750
19802
  // src/liquid/filters/time_tag.ts
19751
- function bind52(_liquidSwell) {
19803
+ function bind53(_liquidSwell) {
19752
19804
  const dateFilter = bind33(_liquidSwell);
19753
19805
  return (dateValue, ...params) => {
19754
19806
  const date = ensureDate(dateValue);
@@ -19759,7 +19811,7 @@ function bind52(_liquidSwell) {
19759
19811
  }
19760
19812
 
19761
19813
  // src/liquid/filters/translate.ts
19762
- function bind53(liquidSwell) {
19814
+ function bind54(liquidSwell) {
19763
19815
  return async function filterTranslate(key, params) {
19764
19816
  const props = params && paramsToProps(params);
19765
19817
  const str = await liquidSwell.renderTranslation(key, props);
@@ -19768,7 +19820,7 @@ function bind53(liquidSwell) {
19768
19820
  }
19769
19821
 
19770
19822
  // src/liquid/filters/where.ts
19771
- function bind54(_liquidSwell) {
19823
+ function bind55(_liquidSwell) {
19772
19824
  return function* filterWhere(arr, property, expected) {
19773
19825
  const results = [];
19774
19826
  const list = yield resolveEnumerable(arr);
@@ -19822,7 +19874,7 @@ function getSizesFromParam(param) {
19822
19874
  height: height ? Number(height) : void 0
19823
19875
  };
19824
19876
  }
19825
- function bind55(liquidSwell) {
19877
+ function bind56(liquidSwell) {
19826
19878
  return async function filterAssetImgUrl(assetPath, size = "small") {
19827
19879
  const imageUrl = await liquidSwell.getAssetUrl(assetPath).then((url) => url || "");
19828
19880
  const sizes = getSizesFromParam(size);
@@ -19838,7 +19890,7 @@ function bind55(liquidSwell) {
19838
19890
  }
19839
19891
 
19840
19892
  // src/liquid/filters/shopify/hex_to_rgba.ts
19841
- function bind56(_liquidSwell) {
19893
+ function bind57(_liquidSwell) {
19842
19894
  return (color, alpha) => {
19843
19895
  return ThemeColor.get(color).rgba(alpha || 1);
19844
19896
  };
@@ -19858,14 +19910,14 @@ var item_count_for_variant_default = {
19858
19910
  };
19859
19911
 
19860
19912
  // src/liquid/filters/shopify/payment_button.ts
19861
- function bind57(_liquidSwell) {
19913
+ function bind58(_liquidSwell) {
19862
19914
  return (form) => {
19863
19915
  return null;
19864
19916
  };
19865
19917
  }
19866
19918
 
19867
19919
  // src/liquid/filters/shopify/payment_terms.ts
19868
- function bind58(_liquidSwell) {
19920
+ function bind59(_liquidSwell) {
19869
19921
  return (form) => {
19870
19922
  return null;
19871
19923
  };
@@ -19967,7 +20019,7 @@ var svgs = {
19967
20019
  var placeholder_svgs_default = svgs;
19968
20020
 
19969
20021
  // src/liquid/filters/shopify/placeholder_svg_tag.ts
19970
- function bind59(_liquidSwell) {
20022
+ function bind60(_liquidSwell) {
19971
20023
  return function filterPlaceholderSvgTag(name, className) {
19972
20024
  const svg = placeholder_svgs_default[name];
19973
20025
  if (typeof svg === "object" && svg !== null) {
@@ -19978,7 +20030,7 @@ function bind59(_liquidSwell) {
19978
20030
  }
19979
20031
 
19980
20032
  // src/liquid/filters/shopify/shopify_asset_url.ts
19981
- function bind60(_liquidSwell) {
20033
+ function bind61(_liquidSwell) {
19982
20034
  return function filterShopifyAssetUrl(input) {
19983
20035
  if (typeof input === "string") {
19984
20036
  switch (input) {
@@ -20003,7 +20055,7 @@ function bind60(_liquidSwell) {
20003
20055
  }
20004
20056
 
20005
20057
  // src/liquid/filters/shopify/structured_data.ts
20006
- function bind61(_liquidSwell) {
20058
+ function bind62(_liquidSwell) {
20007
20059
  return async function filterStructuredData(input) {
20008
20060
  let value = input;
20009
20061
  if (value instanceof StorefrontResource) {
@@ -20081,7 +20133,7 @@ function convertToSchemaOrgProductGroup(product) {
20081
20133
  }
20082
20134
 
20083
20135
  // src/liquid/filters/inline_editable.ts
20084
- function bind62(_liquidSwell) {
20136
+ function bind63(_liquidSwell) {
20085
20137
  return (value, key) => {
20086
20138
  if (typeof value === "object" && "value" in value) {
20087
20139
  value = value.value;
@@ -20107,45 +20159,46 @@ var filters = {
20107
20159
  color_to_hex: bind30,
20108
20160
  color_to_hsl: bind31,
20109
20161
  color_to_rgb: bind32,
20162
+ date_next_interval: bind34,
20110
20163
  date: bind33,
20111
- default_errors: bind34,
20112
- divided_by: bind35,
20113
- embedded_content: bind36,
20114
- font_face: bind37,
20115
- font_modify: bind38,
20116
- font_url: bind39,
20164
+ default_errors: bind35,
20165
+ divided_by: bind36,
20166
+ embedded_content: bind37,
20167
+ font_face: bind38,
20168
+ font_modify: bind39,
20169
+ font_url: bind40,
20117
20170
  format_address: format_address_default,
20118
- handle: bind40,
20171
+ handle: bind41,
20119
20172
  // alias
20120
- handleize: bind40,
20121
- image_tag: bind41,
20173
+ handleize: bind41,
20174
+ image_tag: bind42,
20122
20175
  image_url: image_url_default,
20123
- inline_asset_content: bind42,
20124
- json: bind43,
20125
- json_pretty: bind44,
20126
- locale_flag: bind45,
20127
- money: bind46,
20128
- money_with_currency: bind47,
20129
- money_without_currency: bind48,
20130
- money_without_trailing_zeros: bind49,
20131
- script_tag: bind50,
20132
- stylesheet_tag: bind51,
20133
- time_tag: bind52,
20134
- translate: bind53,
20135
- t: bind53,
20176
+ inline_asset_content: bind43,
20177
+ json: bind44,
20178
+ json_pretty: bind45,
20179
+ locale_flag: bind46,
20180
+ money: bind47,
20181
+ money_with_currency: bind48,
20182
+ money_without_currency: bind49,
20183
+ money_without_trailing_zeros: bind50,
20184
+ script_tag: bind51,
20185
+ stylesheet_tag: bind52,
20186
+ time_tag: bind53,
20187
+ translate: bind54,
20188
+ t: bind54,
20136
20189
  // alias
20137
- where: bind54,
20190
+ where: bind55,
20138
20191
  // Shopify compatibility only
20139
- asset_img_url: bind55,
20140
- hex_to_rgba: bind56,
20192
+ asset_img_url: bind56,
20193
+ hex_to_rgba: bind57,
20141
20194
  item_count_for_variant: item_count_for_variant_default,
20142
- payment_button: bind57,
20143
- payment_terms: bind58,
20144
- placeholder_svg_tag: bind59,
20145
- shopify_asset_url: bind60,
20146
- structured_data: bind61,
20195
+ payment_button: bind58,
20196
+ payment_terms: bind59,
20197
+ placeholder_svg_tag: bind60,
20198
+ shopify_asset_url: bind61,
20199
+ structured_data: bind62,
20147
20200
  // Swell only
20148
- inline_editable: bind62
20201
+ inline_editable: bind63
20149
20202
  };
20150
20203
  function bindFilters(liquidSwell) {
20151
20204
  for (const [tag, handler] of Object.entries(filters)) {
@@ -20159,8 +20212,8 @@ function bindFilters(liquidSwell) {
20159
20212
  }
20160
20213
  }
20161
20214
  }
20162
- function bindWithResolvedProps(liquidSwell, bind63, resolve = []) {
20163
- const handler = bind63(liquidSwell);
20215
+ function bindWithResolvedProps(liquidSwell, bind64, resolve = []) {
20216
+ const handler = bind64(liquidSwell);
20164
20217
  if (!Array.isArray(resolve)) {
20165
20218
  return handler;
20166
20219
  }
@@ -20377,7 +20430,7 @@ function isThemeColorLike(value) {
20377
20430
  }
20378
20431
 
20379
20432
  // src/liquid/index.ts
20380
- var LiquidSwell29 = class extends import_liquidjs30.Liquid {
20433
+ var LiquidSwell30 = class extends import_liquidjs30.Liquid {
20381
20434
  theme;
20382
20435
  getThemeConfig;
20383
20436
  getThemeTemplateConfigByType;
@@ -20965,7 +21018,7 @@ var SwellTheme3 = class {
20965
21018
  this.forms = forms;
20966
21019
  this.resources = resources;
20967
21020
  this.shopifyCompatibilityClass = shopifyCompatibilityClass || ShopifyCompatibility2;
20968
- this.liquidSwell = new LiquidSwell29({
21021
+ this.liquidSwell = new LiquidSwell30({
20969
21022
  theme: this,
20970
21023
  getThemeConfig: this.getThemeConfig.bind(this),
20971
21024
  getAssetUrl: this.getAssetUrl.bind(this),