@swell/apps-sdk 1.0.140 → 1.0.141
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 +114 -97
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +114 -97
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +98 -81
- package/dist/index.mjs.map +4 -4
- package/dist/src/liquid/filters/handleize.d.ts +3 -0
- package/dist/src/liquid/filters/index.d.ts +3 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -17424,7 +17424,7 @@ var tags = {
|
|
|
17424
17424
|
};
|
|
17425
17425
|
function bindTags(liquidSwell) {
|
|
17426
17426
|
Object.entries(tags).forEach(
|
|
17427
|
-
([tag,
|
|
17427
|
+
([tag, bind63]) => liquidSwell.registerTag(tag, bind63(liquidSwell))
|
|
17428
17428
|
);
|
|
17429
17429
|
}
|
|
17430
17430
|
|
|
@@ -17708,8 +17708,16 @@ var format_address_default = {
|
|
|
17708
17708
|
]
|
|
17709
17709
|
};
|
|
17710
17710
|
|
|
17711
|
-
// src/liquid/filters/
|
|
17711
|
+
// src/liquid/filters/handleize.ts
|
|
17712
|
+
import { kebabCase } from "lodash-es";
|
|
17712
17713
|
function bind40(_liquidSwell) {
|
|
17714
|
+
return function filterHandleize(handle) {
|
|
17715
|
+
return kebabCase(handle);
|
|
17716
|
+
};
|
|
17717
|
+
}
|
|
17718
|
+
|
|
17719
|
+
// src/liquid/filters/image_tag.ts
|
|
17720
|
+
function bind41(_liquidSwell) {
|
|
17713
17721
|
return function filterImageTag(imageUrl, ...params) {
|
|
17714
17722
|
imageUrl = String(imageUrl || "");
|
|
17715
17723
|
let {
|
|
@@ -17873,7 +17881,7 @@ var filterDefinition = {
|
|
|
17873
17881
|
var image_url_default = filterDefinition;
|
|
17874
17882
|
|
|
17875
17883
|
// src/liquid/filters/inline_asset_content.ts
|
|
17876
|
-
function
|
|
17884
|
+
function bind42(liquidSwell) {
|
|
17877
17885
|
return async (assetPath) => {
|
|
17878
17886
|
const config = await liquidSwell.theme.getThemeConfig(
|
|
17879
17887
|
`theme/assets/${assetPath}`
|
|
@@ -17883,14 +17891,14 @@ function bind41(liquidSwell) {
|
|
|
17883
17891
|
}
|
|
17884
17892
|
|
|
17885
17893
|
// src/liquid/filters/json.ts
|
|
17886
|
-
function
|
|
17894
|
+
function bind43(_liquidSwell) {
|
|
17887
17895
|
return async function filterJson(input, space = 0) {
|
|
17888
17896
|
return jsonStringifyAsync(input, space);
|
|
17889
17897
|
};
|
|
17890
17898
|
}
|
|
17891
17899
|
|
|
17892
17900
|
// src/liquid/filters/json_pretty.ts
|
|
17893
|
-
function
|
|
17901
|
+
function bind44(_liquidSwell) {
|
|
17894
17902
|
return async function filterJsonPretty(input, space = 2) {
|
|
17895
17903
|
const output = await jsonStringifyAsync(input, space);
|
|
17896
17904
|
return `<pre>${output}</pre>`;
|
|
@@ -17907,7 +17915,7 @@ function getCountryCode(localCode) {
|
|
|
17907
17915
|
return localCode.toUpperCase();
|
|
17908
17916
|
}
|
|
17909
17917
|
}
|
|
17910
|
-
function
|
|
17918
|
+
function bind45(_liquidSwell) {
|
|
17911
17919
|
return (localeCode) => {
|
|
17912
17920
|
if (typeof localeCode !== "string") {
|
|
17913
17921
|
return flags.US;
|
|
@@ -17918,7 +17926,7 @@ function bind44(_liquidSwell) {
|
|
|
17918
17926
|
}
|
|
17919
17927
|
|
|
17920
17928
|
// src/liquid/filters/money.ts
|
|
17921
|
-
function
|
|
17929
|
+
function bind46(liquidSwell) {
|
|
17922
17930
|
return function filterMoney(value) {
|
|
17923
17931
|
const amount = value instanceof MoneyDrop ? value.toFloat() : Number(value || 0);
|
|
17924
17932
|
return liquidSwell.renderCurrency(amount);
|
|
@@ -17926,7 +17934,7 @@ function bind45(liquidSwell) {
|
|
|
17926
17934
|
}
|
|
17927
17935
|
|
|
17928
17936
|
// src/liquid/filters/money_with_currency.ts
|
|
17929
|
-
function
|
|
17937
|
+
function bind47(liquidSwell) {
|
|
17930
17938
|
return function filterMoneyWithCurrency(value) {
|
|
17931
17939
|
const { currency } = liquidSwell.theme.swell.getStorefrontLocalization();
|
|
17932
17940
|
const amount = value instanceof MoneyDrop ? value.toFloat() : Number(value || 0);
|
|
@@ -17935,7 +17943,7 @@ function bind46(liquidSwell) {
|
|
|
17935
17943
|
}
|
|
17936
17944
|
|
|
17937
17945
|
// src/liquid/filters/money_without_currency.ts
|
|
17938
|
-
function
|
|
17946
|
+
function bind48(liquidSwell) {
|
|
17939
17947
|
return function filterMoneyWithoutCurrency(value) {
|
|
17940
17948
|
const amount = value instanceof MoneyDrop ? value.toFloat() : Number(value || 0);
|
|
17941
17949
|
return liquidSwell.renderCurrency(amount).replace(/[^0-9.,]/g, "");
|
|
@@ -17943,7 +17951,7 @@ function bind47(liquidSwell) {
|
|
|
17943
17951
|
}
|
|
17944
17952
|
|
|
17945
17953
|
// src/liquid/filters/money_without_trailing_zeros.ts
|
|
17946
|
-
function
|
|
17954
|
+
function bind49(liquidSwell) {
|
|
17947
17955
|
return function filterMoneyWithoutTrailingZeros(value) {
|
|
17948
17956
|
const amount = value instanceof MoneyDrop ? value.toFloat() : Number(value || 0);
|
|
17949
17957
|
return liquidSwell.renderCurrency(amount).split(".")[0].split(",")[0];
|
|
@@ -17951,21 +17959,21 @@ function bind48(liquidSwell) {
|
|
|
17951
17959
|
}
|
|
17952
17960
|
|
|
17953
17961
|
// src/liquid/filters/script_tag.ts
|
|
17954
|
-
function
|
|
17962
|
+
function bind50(_liquidSwell) {
|
|
17955
17963
|
return function filterScriptTag(assetUrl) {
|
|
17956
17964
|
return `<script src="${assetUrl}" type="text/javascript"></script>`;
|
|
17957
17965
|
};
|
|
17958
17966
|
}
|
|
17959
17967
|
|
|
17960
17968
|
// src/liquid/filters/stylesheet_tag.ts
|
|
17961
|
-
function
|
|
17969
|
+
function bind51(_liquidSwell) {
|
|
17962
17970
|
return function filterStyleSheetTag(assetUrl) {
|
|
17963
17971
|
return `<link href="${assetUrl}" rel="stylesheet" type="text/css" media="all" />`;
|
|
17964
17972
|
};
|
|
17965
17973
|
}
|
|
17966
17974
|
|
|
17967
17975
|
// src/liquid/filters/time_tag.ts
|
|
17968
|
-
function
|
|
17976
|
+
function bind52(_liquidSwell) {
|
|
17969
17977
|
const dateFilter = bind33(_liquidSwell);
|
|
17970
17978
|
return (dateValue, ...params) => {
|
|
17971
17979
|
const date = ensureDate(dateValue);
|
|
@@ -17976,7 +17984,7 @@ function bind51(_liquidSwell) {
|
|
|
17976
17984
|
}
|
|
17977
17985
|
|
|
17978
17986
|
// src/liquid/filters/translate.ts
|
|
17979
|
-
function
|
|
17987
|
+
function bind53(liquidSwell) {
|
|
17980
17988
|
return async function filterTranslate(key, params) {
|
|
17981
17989
|
const props = params && paramsToProps(params);
|
|
17982
17990
|
const str = await liquidSwell.renderTranslation(key, props);
|
|
@@ -17985,7 +17993,7 @@ function bind52(liquidSwell) {
|
|
|
17985
17993
|
}
|
|
17986
17994
|
|
|
17987
17995
|
// src/liquid/filters/where.ts
|
|
17988
|
-
function
|
|
17996
|
+
function bind54(_liquidSwell) {
|
|
17989
17997
|
return function* filterWhere(arr, property, expected) {
|
|
17990
17998
|
const results = [];
|
|
17991
17999
|
const list = yield resolveEnumerable(arr);
|
|
@@ -18039,7 +18047,7 @@ function getSizesFromParam(param) {
|
|
|
18039
18047
|
height: height ? Number(height) : void 0
|
|
18040
18048
|
};
|
|
18041
18049
|
}
|
|
18042
|
-
function
|
|
18050
|
+
function bind55(liquidSwell) {
|
|
18043
18051
|
return async function filterAssetImgUrl(assetPath, size = "small") {
|
|
18044
18052
|
const imageUrl = await liquidSwell.getAssetUrl(assetPath).then((url) => url || "");
|
|
18045
18053
|
const sizes = getSizesFromParam(size);
|
|
@@ -18055,7 +18063,7 @@ function bind54(liquidSwell) {
|
|
|
18055
18063
|
}
|
|
18056
18064
|
|
|
18057
18065
|
// src/liquid/filters/shopify/hex_to_rgba.ts
|
|
18058
|
-
function
|
|
18066
|
+
function bind56(_liquidSwell) {
|
|
18059
18067
|
return (color, alpha) => {
|
|
18060
18068
|
return ThemeColor.get(color).rgba(alpha || 1);
|
|
18061
18069
|
};
|
|
@@ -18075,14 +18083,14 @@ var item_count_for_variant_default = {
|
|
|
18075
18083
|
};
|
|
18076
18084
|
|
|
18077
18085
|
// src/liquid/filters/shopify/payment_button.ts
|
|
18078
|
-
function
|
|
18086
|
+
function bind57(_liquidSwell) {
|
|
18079
18087
|
return (form) => {
|
|
18080
18088
|
return null;
|
|
18081
18089
|
};
|
|
18082
18090
|
}
|
|
18083
18091
|
|
|
18084
18092
|
// src/liquid/filters/shopify/payment_terms.ts
|
|
18085
|
-
function
|
|
18093
|
+
function bind58(_liquidSwell) {
|
|
18086
18094
|
return (form) => {
|
|
18087
18095
|
return null;
|
|
18088
18096
|
};
|
|
@@ -18184,7 +18192,7 @@ var svgs = {
|
|
|
18184
18192
|
var placeholder_svgs_default = svgs;
|
|
18185
18193
|
|
|
18186
18194
|
// src/liquid/filters/shopify/placeholder_svg_tag.ts
|
|
18187
|
-
function
|
|
18195
|
+
function bind59(_liquidSwell) {
|
|
18188
18196
|
return function filterPlaceholderSvgTag(name, className) {
|
|
18189
18197
|
const svg = placeholder_svgs_default[name];
|
|
18190
18198
|
if (typeof svg === "object" && svg !== null) {
|
|
@@ -18195,7 +18203,7 @@ function bind58(_liquidSwell) {
|
|
|
18195
18203
|
}
|
|
18196
18204
|
|
|
18197
18205
|
// src/liquid/filters/shopify/shopify_asset_url.ts
|
|
18198
|
-
function
|
|
18206
|
+
function bind60(_liquidSwell) {
|
|
18199
18207
|
return function filterShopifyAssetUrl(input) {
|
|
18200
18208
|
if (typeof input === "string") {
|
|
18201
18209
|
switch (input) {
|
|
@@ -18220,7 +18228,7 @@ function bind59(_liquidSwell) {
|
|
|
18220
18228
|
}
|
|
18221
18229
|
|
|
18222
18230
|
// src/liquid/filters/shopify/structured_data.ts
|
|
18223
|
-
function
|
|
18231
|
+
function bind61(_liquidSwell) {
|
|
18224
18232
|
return async function filterStructuredData(input) {
|
|
18225
18233
|
let value = input;
|
|
18226
18234
|
if (value instanceof StorefrontResource) {
|
|
@@ -18298,7 +18306,7 @@ function convertToSchemaOrgProductGroup(product) {
|
|
|
18298
18306
|
}
|
|
18299
18307
|
|
|
18300
18308
|
// src/liquid/filters/inline_editable.ts
|
|
18301
|
-
function
|
|
18309
|
+
function bind62(_liquidSwell) {
|
|
18302
18310
|
return (value, key) => {
|
|
18303
18311
|
if (typeof value === "object" && "value" in value) {
|
|
18304
18312
|
value = value.value;
|
|
@@ -18332,34 +18340,37 @@ var filters = {
|
|
|
18332
18340
|
font_modify: bind38,
|
|
18333
18341
|
font_url: bind39,
|
|
18334
18342
|
format_address: format_address_default,
|
|
18335
|
-
|
|
18343
|
+
handle: bind40,
|
|
18344
|
+
// alias
|
|
18345
|
+
handleize: bind40,
|
|
18346
|
+
image_tag: bind41,
|
|
18336
18347
|
image_url: image_url_default,
|
|
18337
|
-
inline_asset_content:
|
|
18338
|
-
json:
|
|
18339
|
-
json_pretty:
|
|
18340
|
-
locale_flag:
|
|
18341
|
-
money:
|
|
18342
|
-
money_with_currency:
|
|
18343
|
-
money_without_currency:
|
|
18344
|
-
money_without_trailing_zeros:
|
|
18345
|
-
script_tag:
|
|
18346
|
-
stylesheet_tag:
|
|
18347
|
-
time_tag:
|
|
18348
|
-
translate:
|
|
18349
|
-
t:
|
|
18348
|
+
inline_asset_content: bind42,
|
|
18349
|
+
json: bind43,
|
|
18350
|
+
json_pretty: bind44,
|
|
18351
|
+
locale_flag: bind45,
|
|
18352
|
+
money: bind46,
|
|
18353
|
+
money_with_currency: bind47,
|
|
18354
|
+
money_without_currency: bind48,
|
|
18355
|
+
money_without_trailing_zeros: bind49,
|
|
18356
|
+
script_tag: bind50,
|
|
18357
|
+
stylesheet_tag: bind51,
|
|
18358
|
+
time_tag: bind52,
|
|
18359
|
+
translate: bind53,
|
|
18360
|
+
t: bind53,
|
|
18350
18361
|
// alias
|
|
18351
|
-
where:
|
|
18362
|
+
where: bind54,
|
|
18352
18363
|
// Shopify compatibility only
|
|
18353
|
-
asset_img_url:
|
|
18354
|
-
hex_to_rgba:
|
|
18364
|
+
asset_img_url: bind55,
|
|
18365
|
+
hex_to_rgba: bind56,
|
|
18355
18366
|
item_count_for_variant: item_count_for_variant_default,
|
|
18356
|
-
payment_button:
|
|
18357
|
-
payment_terms:
|
|
18358
|
-
placeholder_svg_tag:
|
|
18359
|
-
shopify_asset_url:
|
|
18360
|
-
structured_data:
|
|
18367
|
+
payment_button: bind57,
|
|
18368
|
+
payment_terms: bind58,
|
|
18369
|
+
placeholder_svg_tag: bind59,
|
|
18370
|
+
shopify_asset_url: bind60,
|
|
18371
|
+
structured_data: bind61,
|
|
18361
18372
|
// Swell only
|
|
18362
|
-
inline_editable:
|
|
18373
|
+
inline_editable: bind62
|
|
18363
18374
|
};
|
|
18364
18375
|
function bindFilters(liquidSwell) {
|
|
18365
18376
|
for (const [tag, handler] of Object.entries(filters)) {
|
|
@@ -18373,8 +18384,8 @@ function bindFilters(liquidSwell) {
|
|
|
18373
18384
|
}
|
|
18374
18385
|
}
|
|
18375
18386
|
}
|
|
18376
|
-
function bindWithResolvedProps(liquidSwell,
|
|
18377
|
-
const handler =
|
|
18387
|
+
function bindWithResolvedProps(liquidSwell, bind63, resolve = []) {
|
|
18388
|
+
const handler = bind63(liquidSwell);
|
|
18378
18389
|
if (!Array.isArray(resolve)) {
|
|
18379
18390
|
return handler;
|
|
18380
18391
|
}
|
|
@@ -20567,13 +20578,20 @@ async function resolveMenuItems(theme, menuItems, options) {
|
|
|
20567
20578
|
async function resolveMenuItemUrlAndResource(theme, item, options) {
|
|
20568
20579
|
if (!item) return { url: "#invalid-link-item" };
|
|
20569
20580
|
if (typeof item === "object" && item !== null) {
|
|
20570
|
-
|
|
20571
|
-
|
|
20572
|
-
|
|
20573
|
-
|
|
20574
|
-
|
|
20575
|
-
if (
|
|
20576
|
-
|
|
20581
|
+
const { url: itemUrl, resource } = await getMenuItemUrlAndResource(
|
|
20582
|
+
theme,
|
|
20583
|
+
item
|
|
20584
|
+
);
|
|
20585
|
+
let url = itemUrl;
|
|
20586
|
+
if (url.length > 1) {
|
|
20587
|
+
const endsWithSlash = url.endsWith("/");
|
|
20588
|
+
if (options?.trailingSlash) {
|
|
20589
|
+
if (!endsWithSlash) {
|
|
20590
|
+
url = url + "/";
|
|
20591
|
+
}
|
|
20592
|
+
} else if (endsWithSlash) {
|
|
20593
|
+
url = url.slice(0, -1);
|
|
20594
|
+
}
|
|
20577
20595
|
}
|
|
20578
20596
|
return { url, resource };
|
|
20579
20597
|
} else {
|
|
@@ -20615,43 +20633,40 @@ async function getMenuItemUrlAndResource(theme, menuItem) {
|
|
|
20615
20633
|
return {
|
|
20616
20634
|
url: getMenuItemStorefrontUrl(theme, "index")
|
|
20617
20635
|
};
|
|
20618
|
-
case "category" /* Category */:
|
|
20636
|
+
case "category" /* Category */: {
|
|
20619
20637
|
if (!id) {
|
|
20620
20638
|
return {
|
|
20621
20639
|
url: getMenuItemStorefrontUrl(theme, "categories/index")
|
|
20622
20640
|
};
|
|
20623
20641
|
}
|
|
20624
|
-
return
|
|
20625
|
-
|
|
20626
|
-
|
|
20627
|
-
id
|
|
20628
|
-
);
|
|
20629
|
-
case "product" /* Product */:
|
|
20642
|
+
return deferMenuItemUrlAndResource(theme, "categories/category", id);
|
|
20643
|
+
}
|
|
20644
|
+
case "product" /* Product */: {
|
|
20630
20645
|
if (!id) {
|
|
20631
20646
|
return {
|
|
20632
20647
|
url: getMenuItemStorefrontUrl(theme, "products/index")
|
|
20633
20648
|
};
|
|
20634
20649
|
}
|
|
20635
|
-
return
|
|
20650
|
+
return deferMenuItemUrlAndResource(theme, "products/product", id);
|
|
20651
|
+
}
|
|
20652
|
+
case "product_list" /* ProductList */:
|
|
20653
|
+
return {
|
|
20654
|
+
url: getMenuItemStorefrontUrl(theme, "products/index")
|
|
20655
|
+
};
|
|
20636
20656
|
case "page" /* Page */:
|
|
20637
|
-
return
|
|
20657
|
+
return deferMenuItemUrlAndResource(theme, "pages/page", id);
|
|
20638
20658
|
case "blog" /* Blog */:
|
|
20639
|
-
return
|
|
20640
|
-
|
|
20641
|
-
|
|
20642
|
-
|
|
20643
|
-
|
|
20644
|
-
|
|
20645
|
-
|
|
20646
|
-
|
|
20647
|
-
blog.category_id
|
|
20648
|
-
);
|
|
20649
|
-
return blogCategory.slug;
|
|
20650
|
-
}
|
|
20651
|
-
);
|
|
20659
|
+
return deferMenuItemUrlAndResource(theme, "blogs/blog", id, (blog) => {
|
|
20660
|
+
const blogCategory = new SwellStorefrontRecord(
|
|
20661
|
+
theme.swell,
|
|
20662
|
+
"content/blog-categories",
|
|
20663
|
+
blog.category_id
|
|
20664
|
+
);
|
|
20665
|
+
return blogCategory.slug;
|
|
20666
|
+
});
|
|
20652
20667
|
case "blog_category" /* BlogCategory */:
|
|
20653
|
-
return
|
|
20654
|
-
case "content_list" /* ContentList */:
|
|
20668
|
+
return deferMenuItemUrlAndResource(theme, "blogs/category", id);
|
|
20669
|
+
case "content_list" /* ContentList */: {
|
|
20655
20670
|
if (model) {
|
|
20656
20671
|
const slug = model?.replace("content/", "");
|
|
20657
20672
|
return {
|
|
@@ -20660,10 +20675,11 @@ async function getMenuItemUrlAndResource(theme, menuItem) {
|
|
|
20660
20675
|
};
|
|
20661
20676
|
}
|
|
20662
20677
|
break;
|
|
20663
|
-
|
|
20678
|
+
}
|
|
20679
|
+
case "content" /* Content */: {
|
|
20664
20680
|
if (model) {
|
|
20665
20681
|
const collectionSlug = model?.replace("content/", "");
|
|
20666
|
-
return
|
|
20682
|
+
return deferMenuItemUrlAndResource(
|
|
20667
20683
|
theme,
|
|
20668
20684
|
"content/content",
|
|
20669
20685
|
id,
|
|
@@ -20671,6 +20687,7 @@ async function getMenuItemUrlAndResource(theme, menuItem) {
|
|
|
20671
20687
|
);
|
|
20672
20688
|
}
|
|
20673
20689
|
break;
|
|
20690
|
+
}
|
|
20674
20691
|
case "search" /* Search */:
|
|
20675
20692
|
return {
|
|
20676
20693
|
url: getMenuItemStorefrontUrl(theme, "search")
|