@swell/apps-sdk 1.0.182 → 1.0.183
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 +116 -91
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +116 -91
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +96 -71
- package/dist/index.mjs.map +4 -4
- package/dist/src/compatibility/drops/collections.d.ts +2 -0
- package/dist/src/liquid/filters/escape.d.ts +3 -0
- package/dist/src/liquid/filters/index.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -12649,7 +12649,7 @@ function ShopifyCart(instance, cart) {
|
|
|
12649
12649
|
);
|
|
12650
12650
|
}),
|
|
12651
12651
|
items_subtotal_price: defer(() => instance.toShopifyPrice(cart.sub_total)),
|
|
12652
|
-
note:
|
|
12652
|
+
note: deferWith(cart, (cart2) => cart2.comments),
|
|
12653
12653
|
original_total_price: deferWith(
|
|
12654
12654
|
cart,
|
|
12655
12655
|
(cart2) => instance.toShopifyPrice(cart2.sub_total)
|
|
@@ -13734,15 +13734,10 @@ var CollectionsDrop = class extends Drop10 {
|
|
|
13734
13734
|
switch (typeof key) {
|
|
13735
13735
|
case "string": {
|
|
13736
13736
|
if (key === "all") {
|
|
13737
|
-
|
|
13738
|
-
|
|
13739
|
-
|
|
13740
|
-
|
|
13741
|
-
new AllCategoryResource(this.#instance)
|
|
13742
|
-
);
|
|
13743
|
-
this.#map.set(key, resource);
|
|
13744
|
-
}
|
|
13745
|
-
return resource;
|
|
13737
|
+
return this.getAllCollection();
|
|
13738
|
+
}
|
|
13739
|
+
if (key === "size") {
|
|
13740
|
+
return this.getAllCollectionsSize();
|
|
13746
13741
|
}
|
|
13747
13742
|
return this.getCollection(key);
|
|
13748
13743
|
}
|
|
@@ -13772,6 +13767,21 @@ var CollectionsDrop = class extends Drop10 {
|
|
|
13772
13767
|
}
|
|
13773
13768
|
return resource;
|
|
13774
13769
|
}
|
|
13770
|
+
getAllCollection() {
|
|
13771
|
+
let resource = this.#map.get("all");
|
|
13772
|
+
if (resource === void 0) {
|
|
13773
|
+
resource = ShopifyCollection(
|
|
13774
|
+
this.#instance,
|
|
13775
|
+
new AllCategoryResource(this.#instance)
|
|
13776
|
+
);
|
|
13777
|
+
this.#map.set("all", resource);
|
|
13778
|
+
}
|
|
13779
|
+
return resource;
|
|
13780
|
+
}
|
|
13781
|
+
getAllCollectionsSize() {
|
|
13782
|
+
const count = this.#instance.theme.globals.shop?.collections_count;
|
|
13783
|
+
return count || 0;
|
|
13784
|
+
}
|
|
13775
13785
|
};
|
|
13776
13786
|
var Collections = class extends SwellStorefrontCollection {
|
|
13777
13787
|
#drop;
|
|
@@ -15549,7 +15559,7 @@ var tags = {
|
|
|
15549
15559
|
};
|
|
15550
15560
|
function bindTags(liquidSwell) {
|
|
15551
15561
|
Object.entries(tags).forEach(
|
|
15552
|
-
([tag,
|
|
15562
|
+
([tag, bind67]) => liquidSwell.registerTag(tag, bind67(liquidSwell))
|
|
15553
15563
|
);
|
|
15554
15564
|
}
|
|
15555
15565
|
|
|
@@ -15817,8 +15827,22 @@ function bind37(_liquidSwell) {
|
|
|
15817
15827
|
};
|
|
15818
15828
|
}
|
|
15819
15829
|
|
|
15820
|
-
// src/liquid/filters/
|
|
15830
|
+
// src/liquid/filters/escape.ts
|
|
15831
|
+
import { escape } from "lodash-es";
|
|
15821
15832
|
function bind38(_liquidSwell) {
|
|
15833
|
+
return function escapeTag(input) {
|
|
15834
|
+
if (!input?.startsWith) {
|
|
15835
|
+
return input;
|
|
15836
|
+
}
|
|
15837
|
+
if (input.startsWith("<img") || input.startsWith("<video")) {
|
|
15838
|
+
return input;
|
|
15839
|
+
}
|
|
15840
|
+
return escape(input);
|
|
15841
|
+
};
|
|
15842
|
+
}
|
|
15843
|
+
|
|
15844
|
+
// src/liquid/filters/font_face.ts
|
|
15845
|
+
function bind39(_liquidSwell) {
|
|
15822
15846
|
return (fontSetting, ...params) => {
|
|
15823
15847
|
if (!fontSetting) {
|
|
15824
15848
|
return null;
|
|
@@ -15830,14 +15854,14 @@ function bind38(_liquidSwell) {
|
|
|
15830
15854
|
}
|
|
15831
15855
|
|
|
15832
15856
|
// src/liquid/filters/font_modify.ts
|
|
15833
|
-
function
|
|
15857
|
+
function bind40(_liquidSwell) {
|
|
15834
15858
|
return (fontSetting, prop, value) => {
|
|
15835
15859
|
return ThemeFont.clone(fontSetting).modify(prop, value);
|
|
15836
15860
|
};
|
|
15837
15861
|
}
|
|
15838
15862
|
|
|
15839
15863
|
// src/liquid/filters/font_url.ts
|
|
15840
|
-
function
|
|
15864
|
+
function bind41(_liquidSwell) {
|
|
15841
15865
|
return (fontSetting) => {
|
|
15842
15866
|
return ThemeFont.get(fontSetting).url();
|
|
15843
15867
|
};
|
|
@@ -15887,14 +15911,14 @@ var format_address_default = {
|
|
|
15887
15911
|
|
|
15888
15912
|
// src/liquid/filters/handleize.ts
|
|
15889
15913
|
import { kebabCase } from "lodash-es";
|
|
15890
|
-
function
|
|
15914
|
+
function bind42(_liquidSwell) {
|
|
15891
15915
|
return function filterHandleize(handle) {
|
|
15892
15916
|
return kebabCase(handle);
|
|
15893
15917
|
};
|
|
15894
15918
|
}
|
|
15895
15919
|
|
|
15896
15920
|
// src/liquid/filters/image_tag.ts
|
|
15897
|
-
function
|
|
15921
|
+
function bind43(_liquidSwell) {
|
|
15898
15922
|
return function filterImageTag(imageUrl, ...params) {
|
|
15899
15923
|
imageUrl = String(imageUrl || "");
|
|
15900
15924
|
let {
|
|
@@ -16058,7 +16082,7 @@ var filterDefinition = {
|
|
|
16058
16082
|
var image_url_default = filterDefinition;
|
|
16059
16083
|
|
|
16060
16084
|
// src/liquid/filters/inline_asset_content.ts
|
|
16061
|
-
function
|
|
16085
|
+
function bind44(liquidSwell) {
|
|
16062
16086
|
return async (assetPath) => {
|
|
16063
16087
|
const config = await liquidSwell.theme.getThemeConfig(
|
|
16064
16088
|
`theme/assets/${assetPath}`
|
|
@@ -16068,14 +16092,14 @@ function bind43(liquidSwell) {
|
|
|
16068
16092
|
}
|
|
16069
16093
|
|
|
16070
16094
|
// src/liquid/filters/json.ts
|
|
16071
|
-
function
|
|
16095
|
+
function bind45(_liquidSwell) {
|
|
16072
16096
|
return async function filterJson(input, space = 0) {
|
|
16073
16097
|
return jsonStringifyAsync(input, space);
|
|
16074
16098
|
};
|
|
16075
16099
|
}
|
|
16076
16100
|
|
|
16077
16101
|
// src/liquid/filters/json_pretty.ts
|
|
16078
|
-
function
|
|
16102
|
+
function bind46(_liquidSwell) {
|
|
16079
16103
|
return async function filterJsonPretty(input, space = 2) {
|
|
16080
16104
|
const output = await jsonStringifyAsync(input, space);
|
|
16081
16105
|
return `<pre>${output}</pre>`;
|
|
@@ -16085,7 +16109,7 @@ function bind45(_liquidSwell) {
|
|
|
16085
16109
|
// src/liquid/filters/locale_flag.ts
|
|
16086
16110
|
import { hasFlag } from "country-flag-icons";
|
|
16087
16111
|
import * as flags from "country-flag-icons/string/1x1";
|
|
16088
|
-
function
|
|
16112
|
+
function bind47(_liquidSwell) {
|
|
16089
16113
|
return (localeCode) => {
|
|
16090
16114
|
if (typeof localeCode !== "string") {
|
|
16091
16115
|
return flags.US;
|
|
@@ -16096,7 +16120,7 @@ function bind46(_liquidSwell) {
|
|
|
16096
16120
|
}
|
|
16097
16121
|
|
|
16098
16122
|
// src/liquid/filters/minus.ts
|
|
16099
|
-
function
|
|
16123
|
+
function bind48(_liquidSwell) {
|
|
16100
16124
|
return (first, second) => {
|
|
16101
16125
|
const firstValue = isNumber(first) ? first : 0;
|
|
16102
16126
|
const secondValue = isNumber(second) ? second : 0;
|
|
@@ -16105,7 +16129,7 @@ function bind47(_liquidSwell) {
|
|
|
16105
16129
|
}
|
|
16106
16130
|
|
|
16107
16131
|
// src/liquid/filters/money.ts
|
|
16108
|
-
function
|
|
16132
|
+
function bind49(liquidSwell) {
|
|
16109
16133
|
return function filterMoney(value) {
|
|
16110
16134
|
const amount = getMoneyAmount(liquidSwell, value);
|
|
16111
16135
|
return liquidSwell.renderCurrency(amount);
|
|
@@ -16122,7 +16146,7 @@ function getMoneyAmount(liquidSwell, value) {
|
|
|
16122
16146
|
}
|
|
16123
16147
|
|
|
16124
16148
|
// src/liquid/filters/money_with_currency.ts
|
|
16125
|
-
function
|
|
16149
|
+
function bind50(liquidSwell) {
|
|
16126
16150
|
return function filterMoneyWithCurrency(value) {
|
|
16127
16151
|
const { currency } = liquidSwell.theme.swell.getStorefrontLocalization();
|
|
16128
16152
|
const amount = getMoneyAmount(liquidSwell, value);
|
|
@@ -16131,7 +16155,7 @@ function bind49(liquidSwell) {
|
|
|
16131
16155
|
}
|
|
16132
16156
|
|
|
16133
16157
|
// src/liquid/filters/money_without_currency.ts
|
|
16134
|
-
function
|
|
16158
|
+
function bind51(liquidSwell) {
|
|
16135
16159
|
return function filterMoneyWithoutCurrency(value) {
|
|
16136
16160
|
const amount = getMoneyAmount(liquidSwell, value);
|
|
16137
16161
|
return liquidSwell.renderCurrency(amount).replace(/[^0-9.,]/g, "");
|
|
@@ -16139,7 +16163,7 @@ function bind50(liquidSwell) {
|
|
|
16139
16163
|
}
|
|
16140
16164
|
|
|
16141
16165
|
// src/liquid/filters/money_without_trailing_zeros.ts
|
|
16142
|
-
function
|
|
16166
|
+
function bind52(liquidSwell) {
|
|
16143
16167
|
return function filterMoneyWithoutTrailingZeros(value) {
|
|
16144
16168
|
const amount = getMoneyAmount(liquidSwell, value);
|
|
16145
16169
|
return liquidSwell.renderCurrency(amount).split(".")[0].split(",")[0];
|
|
@@ -16147,21 +16171,21 @@ function bind51(liquidSwell) {
|
|
|
16147
16171
|
}
|
|
16148
16172
|
|
|
16149
16173
|
// src/liquid/filters/script_tag.ts
|
|
16150
|
-
function
|
|
16174
|
+
function bind53(_liquidSwell) {
|
|
16151
16175
|
return function filterScriptTag(assetUrl) {
|
|
16152
16176
|
return `<script src="${assetUrl}" type="text/javascript"></script>`;
|
|
16153
16177
|
};
|
|
16154
16178
|
}
|
|
16155
16179
|
|
|
16156
16180
|
// src/liquid/filters/stylesheet_tag.ts
|
|
16157
|
-
function
|
|
16181
|
+
function bind54(_liquidSwell) {
|
|
16158
16182
|
return function filterStyleSheetTag(assetUrl) {
|
|
16159
16183
|
return `<link href="${assetUrl}" rel="stylesheet" type="text/css" media="all" />`;
|
|
16160
16184
|
};
|
|
16161
16185
|
}
|
|
16162
16186
|
|
|
16163
16187
|
// src/liquid/filters/time_tag.ts
|
|
16164
|
-
function
|
|
16188
|
+
function bind55(_liquidSwell) {
|
|
16165
16189
|
const dateFilter = bind33(_liquidSwell);
|
|
16166
16190
|
return (dateValue, ...params) => {
|
|
16167
16191
|
const date = ensureDate(dateValue);
|
|
@@ -16172,7 +16196,7 @@ function bind54(_liquidSwell) {
|
|
|
16172
16196
|
}
|
|
16173
16197
|
|
|
16174
16198
|
// src/liquid/filters/translate.ts
|
|
16175
|
-
function
|
|
16199
|
+
function bind56(liquidSwell) {
|
|
16176
16200
|
return async function filterTranslate(key, params) {
|
|
16177
16201
|
const props = params && paramsToProps(params);
|
|
16178
16202
|
const str = await liquidSwell.renderTranslation(key, props);
|
|
@@ -16181,7 +16205,7 @@ function bind55(liquidSwell) {
|
|
|
16181
16205
|
}
|
|
16182
16206
|
|
|
16183
16207
|
// src/liquid/filters/where.ts
|
|
16184
|
-
function
|
|
16208
|
+
function bind57(_liquidSwell) {
|
|
16185
16209
|
return function* filterWhere(arr, property, expected) {
|
|
16186
16210
|
const results = [];
|
|
16187
16211
|
const list = yield resolveEnumerable(arr);
|
|
@@ -16235,7 +16259,7 @@ function getSizesFromParam(param) {
|
|
|
16235
16259
|
height: height ? Number(height) : void 0
|
|
16236
16260
|
};
|
|
16237
16261
|
}
|
|
16238
|
-
function
|
|
16262
|
+
function bind58(liquidSwell) {
|
|
16239
16263
|
return async function filterAssetImgUrl(assetPath, size = "small") {
|
|
16240
16264
|
const imageUrl = await liquidSwell.getAssetUrl(assetPath).then((url) => url || "");
|
|
16241
16265
|
const sizes = getSizesFromParam(size);
|
|
@@ -16251,14 +16275,14 @@ function bind57(liquidSwell) {
|
|
|
16251
16275
|
}
|
|
16252
16276
|
|
|
16253
16277
|
// src/liquid/filters/shopify/hex_to_rgba.ts
|
|
16254
|
-
function
|
|
16278
|
+
function bind59(_liquidSwell) {
|
|
16255
16279
|
return (color, alpha) => {
|
|
16256
16280
|
return ThemeColor.get(color).rgba(alpha || 1);
|
|
16257
16281
|
};
|
|
16258
16282
|
}
|
|
16259
16283
|
|
|
16260
16284
|
// src/liquid/filters/shopify/img_url.ts
|
|
16261
|
-
function
|
|
16285
|
+
function bind60(liquidSwell) {
|
|
16262
16286
|
return async function filterImgUrl(input, ...params) {
|
|
16263
16287
|
const url = await getImageUrlFromInput(input, liquidSwell);
|
|
16264
16288
|
if (typeof url !== "string" || url === "") {
|
|
@@ -16296,14 +16320,14 @@ var item_count_for_variant_default = {
|
|
|
16296
16320
|
};
|
|
16297
16321
|
|
|
16298
16322
|
// src/liquid/filters/shopify/payment_button.ts
|
|
16299
|
-
function
|
|
16323
|
+
function bind61(_liquidSwell) {
|
|
16300
16324
|
return (form) => {
|
|
16301
16325
|
return `<button style="display: block; visibility: hidden;"></button>`;
|
|
16302
16326
|
};
|
|
16303
16327
|
}
|
|
16304
16328
|
|
|
16305
16329
|
// src/liquid/filters/shopify/payment_terms.ts
|
|
16306
|
-
function
|
|
16330
|
+
function bind62(_liquidSwell) {
|
|
16307
16331
|
return (form) => {
|
|
16308
16332
|
return null;
|
|
16309
16333
|
};
|
|
@@ -16405,7 +16429,7 @@ var svgs = {
|
|
|
16405
16429
|
var placeholder_svgs_default = svgs;
|
|
16406
16430
|
|
|
16407
16431
|
// src/liquid/filters/shopify/placeholder_svg_tag.ts
|
|
16408
|
-
function
|
|
16432
|
+
function bind63(_liquidSwell) {
|
|
16409
16433
|
return function filterPlaceholderSvgTag(name, className) {
|
|
16410
16434
|
const svg = placeholder_svgs_default[name];
|
|
16411
16435
|
if (typeof svg === "object" && svg !== null) {
|
|
@@ -16416,7 +16440,7 @@ function bind62(_liquidSwell) {
|
|
|
16416
16440
|
}
|
|
16417
16441
|
|
|
16418
16442
|
// src/liquid/filters/shopify/shopify_asset_url.ts
|
|
16419
|
-
function
|
|
16443
|
+
function bind64(_liquidSwell) {
|
|
16420
16444
|
return function filterShopifyAssetUrl(input) {
|
|
16421
16445
|
if (typeof input === "string") {
|
|
16422
16446
|
switch (input) {
|
|
@@ -16441,7 +16465,7 @@ function bind63(_liquidSwell) {
|
|
|
16441
16465
|
}
|
|
16442
16466
|
|
|
16443
16467
|
// src/liquid/filters/shopify/structured_data.ts
|
|
16444
|
-
function
|
|
16468
|
+
function bind65(_liquidSwell) {
|
|
16445
16469
|
return async function filterStructuredData(input) {
|
|
16446
16470
|
let value = input;
|
|
16447
16471
|
if (value instanceof StorefrontResource) {
|
|
@@ -16519,7 +16543,7 @@ function convertToSchemaOrgProductGroup(product) {
|
|
|
16519
16543
|
}
|
|
16520
16544
|
|
|
16521
16545
|
// src/liquid/filters/inline_editable.ts
|
|
16522
|
-
function
|
|
16546
|
+
function bind66(_liquidSwell) {
|
|
16523
16547
|
return (value, key) => {
|
|
16524
16548
|
if (typeof value === "object" && "value" in value) {
|
|
16525
16549
|
value = value.value;
|
|
@@ -16550,43 +16574,44 @@ var filters = {
|
|
|
16550
16574
|
default_errors: bind35,
|
|
16551
16575
|
divided_by: bind36,
|
|
16552
16576
|
embedded_content: bind37,
|
|
16553
|
-
|
|
16554
|
-
|
|
16555
|
-
|
|
16577
|
+
escape: bind38,
|
|
16578
|
+
font_face: bind39,
|
|
16579
|
+
font_modify: bind40,
|
|
16580
|
+
font_url: bind41,
|
|
16556
16581
|
format_address: format_address_default,
|
|
16557
|
-
handle:
|
|
16582
|
+
handle: bind42,
|
|
16558
16583
|
// alias
|
|
16559
|
-
handleize:
|
|
16560
|
-
image_tag:
|
|
16584
|
+
handleize: bind42,
|
|
16585
|
+
image_tag: bind43,
|
|
16561
16586
|
image_url: image_url_default,
|
|
16562
|
-
inline_asset_content:
|
|
16563
|
-
json:
|
|
16564
|
-
json_pretty:
|
|
16565
|
-
locale_flag:
|
|
16566
|
-
minus:
|
|
16567
|
-
money:
|
|
16568
|
-
money_with_currency:
|
|
16569
|
-
money_without_currency:
|
|
16570
|
-
money_without_trailing_zeros:
|
|
16571
|
-
script_tag:
|
|
16572
|
-
stylesheet_tag:
|
|
16573
|
-
time_tag:
|
|
16574
|
-
translate:
|
|
16575
|
-
t:
|
|
16587
|
+
inline_asset_content: bind44,
|
|
16588
|
+
json: bind45,
|
|
16589
|
+
json_pretty: bind46,
|
|
16590
|
+
locale_flag: bind47,
|
|
16591
|
+
minus: bind48,
|
|
16592
|
+
money: bind49,
|
|
16593
|
+
money_with_currency: bind50,
|
|
16594
|
+
money_without_currency: bind51,
|
|
16595
|
+
money_without_trailing_zeros: bind52,
|
|
16596
|
+
script_tag: bind53,
|
|
16597
|
+
stylesheet_tag: bind54,
|
|
16598
|
+
time_tag: bind55,
|
|
16599
|
+
translate: bind56,
|
|
16600
|
+
t: bind56,
|
|
16576
16601
|
// alias
|
|
16577
|
-
where:
|
|
16602
|
+
where: bind57,
|
|
16578
16603
|
// Shopify compatibility only
|
|
16579
|
-
asset_img_url:
|
|
16580
|
-
hex_to_rgba:
|
|
16581
|
-
img_url:
|
|
16604
|
+
asset_img_url: bind58,
|
|
16605
|
+
hex_to_rgba: bind59,
|
|
16606
|
+
img_url: bind60,
|
|
16582
16607
|
item_count_for_variant: item_count_for_variant_default,
|
|
16583
|
-
payment_button:
|
|
16584
|
-
payment_terms:
|
|
16585
|
-
placeholder_svg_tag:
|
|
16586
|
-
shopify_asset_url:
|
|
16587
|
-
structured_data:
|
|
16608
|
+
payment_button: bind61,
|
|
16609
|
+
payment_terms: bind62,
|
|
16610
|
+
placeholder_svg_tag: bind63,
|
|
16611
|
+
shopify_asset_url: bind64,
|
|
16612
|
+
structured_data: bind65,
|
|
16588
16613
|
// Swell only
|
|
16589
|
-
inline_editable:
|
|
16614
|
+
inline_editable: bind66
|
|
16590
16615
|
};
|
|
16591
16616
|
function bindFilters(liquidSwell) {
|
|
16592
16617
|
for (const [tag, handler] of Object.entries(filters)) {
|
|
@@ -16600,8 +16625,8 @@ function bindFilters(liquidSwell) {
|
|
|
16600
16625
|
}
|
|
16601
16626
|
}
|
|
16602
16627
|
}
|
|
16603
|
-
function bindWithResolvedProps(liquidSwell,
|
|
16604
|
-
const handler =
|
|
16628
|
+
function bindWithResolvedProps(liquidSwell, bind67, resolve = []) {
|
|
16629
|
+
const handler = bind67(liquidSwell);
|
|
16605
16630
|
if (!Array.isArray(resolve)) {
|
|
16606
16631
|
return handler;
|
|
16607
16632
|
}
|