@swell/apps-sdk 1.0.182 → 1.0.184
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 +217 -162
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +217 -162
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +197 -142
- package/dist/index.mjs.map +4 -4
- package/dist/src/cache/html-cache/html-cache.d.ts +45 -14
- 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 +2 -4
package/dist/index.js
CHANGED
|
@@ -6282,11 +6282,11 @@ ${formattedMessage}`;
|
|
|
6282
6282
|
}
|
|
6283
6283
|
|
|
6284
6284
|
// src/menus.ts
|
|
6285
|
-
var
|
|
6285
|
+
var import_lodash_es15 = __require("lodash-es");
|
|
6286
6286
|
|
|
6287
6287
|
// src/theme.ts
|
|
6288
6288
|
var import_json56 = __toESM(__require("json5"), 1);
|
|
6289
|
-
var
|
|
6289
|
+
var import_lodash_es14 = __require("lodash-es");
|
|
6290
6290
|
|
|
6291
6291
|
// src/compatibility/shopify.ts
|
|
6292
6292
|
var import_lodash_es7 = __require("lodash-es");
|
|
@@ -12676,7 +12676,7 @@ ${formattedMessage}`;
|
|
|
12676
12676
|
);
|
|
12677
12677
|
}),
|
|
12678
12678
|
items_subtotal_price: defer(() => instance.toShopifyPrice(cart.sub_total)),
|
|
12679
|
-
note:
|
|
12679
|
+
note: deferWith(cart, (cart2) => cart2.comments),
|
|
12680
12680
|
original_total_price: deferWith(
|
|
12681
12681
|
cart,
|
|
12682
12682
|
(cart2) => instance.toShopifyPrice(cart2.sub_total)
|
|
@@ -13761,15 +13761,10 @@ ${formattedMessage}`;
|
|
|
13761
13761
|
switch (typeof key) {
|
|
13762
13762
|
case "string": {
|
|
13763
13763
|
if (key === "all") {
|
|
13764
|
-
|
|
13765
|
-
|
|
13766
|
-
|
|
13767
|
-
|
|
13768
|
-
new AllCategoryResource(this.#instance)
|
|
13769
|
-
);
|
|
13770
|
-
this.#map.set(key, resource);
|
|
13771
|
-
}
|
|
13772
|
-
return resource;
|
|
13764
|
+
return this.getAllCollection();
|
|
13765
|
+
}
|
|
13766
|
+
if (key === "size") {
|
|
13767
|
+
return this.getAllCollectionsSize();
|
|
13773
13768
|
}
|
|
13774
13769
|
return this.getCollection(key);
|
|
13775
13770
|
}
|
|
@@ -13799,6 +13794,21 @@ ${formattedMessage}`;
|
|
|
13799
13794
|
}
|
|
13800
13795
|
return resource;
|
|
13801
13796
|
}
|
|
13797
|
+
getAllCollection() {
|
|
13798
|
+
let resource = this.#map.get("all");
|
|
13799
|
+
if (resource === void 0) {
|
|
13800
|
+
resource = ShopifyCollection(
|
|
13801
|
+
this.#instance,
|
|
13802
|
+
new AllCategoryResource(this.#instance)
|
|
13803
|
+
);
|
|
13804
|
+
this.#map.set("all", resource);
|
|
13805
|
+
}
|
|
13806
|
+
return resource;
|
|
13807
|
+
}
|
|
13808
|
+
getAllCollectionsSize() {
|
|
13809
|
+
const count = this.#instance.theme.globals.shop?.collections_count;
|
|
13810
|
+
return count || 0;
|
|
13811
|
+
}
|
|
13802
13812
|
};
|
|
13803
13813
|
var Collections = class extends SwellStorefrontCollection {
|
|
13804
13814
|
#drop;
|
|
@@ -15568,7 +15578,7 @@ ${injects.join("\n")}<\/script>`;
|
|
|
15568
15578
|
};
|
|
15569
15579
|
function bindTags(liquidSwell) {
|
|
15570
15580
|
Object.entries(tags).forEach(
|
|
15571
|
-
([tag,
|
|
15581
|
+
([tag, bind67]) => liquidSwell.registerTag(tag, bind67(liquidSwell))
|
|
15572
15582
|
);
|
|
15573
15583
|
}
|
|
15574
15584
|
|
|
@@ -15836,8 +15846,22 @@ ${injects.join("\n")}<\/script>`;
|
|
|
15836
15846
|
};
|
|
15837
15847
|
}
|
|
15838
15848
|
|
|
15839
|
-
// src/liquid/filters/
|
|
15849
|
+
// src/liquid/filters/escape.ts
|
|
15850
|
+
var import_lodash_es11 = __require("lodash-es");
|
|
15840
15851
|
function bind38(_liquidSwell) {
|
|
15852
|
+
return function escapeTag(input) {
|
|
15853
|
+
if (!input?.startsWith) {
|
|
15854
|
+
return input;
|
|
15855
|
+
}
|
|
15856
|
+
if (input.startsWith("<img") || input.startsWith("<video")) {
|
|
15857
|
+
return input;
|
|
15858
|
+
}
|
|
15859
|
+
return (0, import_lodash_es11.escape)(input);
|
|
15860
|
+
};
|
|
15861
|
+
}
|
|
15862
|
+
|
|
15863
|
+
// src/liquid/filters/font_face.ts
|
|
15864
|
+
function bind39(_liquidSwell) {
|
|
15841
15865
|
return (fontSetting, ...params) => {
|
|
15842
15866
|
if (!fontSetting) {
|
|
15843
15867
|
return null;
|
|
@@ -15849,14 +15873,14 @@ ${injects.join("\n")}<\/script>`;
|
|
|
15849
15873
|
}
|
|
15850
15874
|
|
|
15851
15875
|
// src/liquid/filters/font_modify.ts
|
|
15852
|
-
function
|
|
15876
|
+
function bind40(_liquidSwell) {
|
|
15853
15877
|
return (fontSetting, prop, value) => {
|
|
15854
15878
|
return ThemeFont.clone(fontSetting).modify(prop, value);
|
|
15855
15879
|
};
|
|
15856
15880
|
}
|
|
15857
15881
|
|
|
15858
15882
|
// src/liquid/filters/font_url.ts
|
|
15859
|
-
function
|
|
15883
|
+
function bind41(_liquidSwell) {
|
|
15860
15884
|
return (fontSetting) => {
|
|
15861
15885
|
return ThemeFont.get(fontSetting).url();
|
|
15862
15886
|
};
|
|
@@ -15905,15 +15929,15 @@ ${injects.join("\n")}<\/script>`;
|
|
|
15905
15929
|
};
|
|
15906
15930
|
|
|
15907
15931
|
// src/liquid/filters/handleize.ts
|
|
15908
|
-
var
|
|
15909
|
-
function
|
|
15932
|
+
var import_lodash_es12 = __require("lodash-es");
|
|
15933
|
+
function bind42(_liquidSwell) {
|
|
15910
15934
|
return function filterHandleize(handle) {
|
|
15911
|
-
return (0,
|
|
15935
|
+
return (0, import_lodash_es12.kebabCase)(handle);
|
|
15912
15936
|
};
|
|
15913
15937
|
}
|
|
15914
15938
|
|
|
15915
15939
|
// src/liquid/filters/image_tag.ts
|
|
15916
|
-
function
|
|
15940
|
+
function bind43(_liquidSwell) {
|
|
15917
15941
|
return function filterImageTag(imageUrl, ...params) {
|
|
15918
15942
|
imageUrl = String(imageUrl || "");
|
|
15919
15943
|
let {
|
|
@@ -16077,7 +16101,7 @@ ${injects.join("\n")}<\/script>`;
|
|
|
16077
16101
|
var image_url_default = filterDefinition;
|
|
16078
16102
|
|
|
16079
16103
|
// src/liquid/filters/inline_asset_content.ts
|
|
16080
|
-
function
|
|
16104
|
+
function bind44(liquidSwell) {
|
|
16081
16105
|
return async (assetPath) => {
|
|
16082
16106
|
const config = await liquidSwell.theme.getThemeConfig(
|
|
16083
16107
|
`theme/assets/${assetPath}`
|
|
@@ -16087,14 +16111,14 @@ ${injects.join("\n")}<\/script>`;
|
|
|
16087
16111
|
}
|
|
16088
16112
|
|
|
16089
16113
|
// src/liquid/filters/json.ts
|
|
16090
|
-
function
|
|
16114
|
+
function bind45(_liquidSwell) {
|
|
16091
16115
|
return async function filterJson(input, space = 0) {
|
|
16092
16116
|
return jsonStringifyAsync(input, space);
|
|
16093
16117
|
};
|
|
16094
16118
|
}
|
|
16095
16119
|
|
|
16096
16120
|
// src/liquid/filters/json_pretty.ts
|
|
16097
|
-
function
|
|
16121
|
+
function bind46(_liquidSwell) {
|
|
16098
16122
|
return async function filterJsonPretty(input, space = 2) {
|
|
16099
16123
|
const output = await jsonStringifyAsync(input, space);
|
|
16100
16124
|
return `<pre>${output}</pre>`;
|
|
@@ -16104,7 +16128,7 @@ ${injects.join("\n")}<\/script>`;
|
|
|
16104
16128
|
// src/liquid/filters/locale_flag.ts
|
|
16105
16129
|
var import_country_flag_icons = __require("country-flag-icons");
|
|
16106
16130
|
var flags = __toESM(__require("country-flag-icons/string/1x1"), 1);
|
|
16107
|
-
function
|
|
16131
|
+
function bind47(_liquidSwell) {
|
|
16108
16132
|
return (localeCode) => {
|
|
16109
16133
|
if (typeof localeCode !== "string") {
|
|
16110
16134
|
return flags.US;
|
|
@@ -16115,7 +16139,7 @@ ${injects.join("\n")}<\/script>`;
|
|
|
16115
16139
|
}
|
|
16116
16140
|
|
|
16117
16141
|
// src/liquid/filters/minus.ts
|
|
16118
|
-
function
|
|
16142
|
+
function bind48(_liquidSwell) {
|
|
16119
16143
|
return (first, second) => {
|
|
16120
16144
|
const firstValue = isNumber(first) ? first : 0;
|
|
16121
16145
|
const secondValue = isNumber(second) ? second : 0;
|
|
@@ -16124,7 +16148,7 @@ ${injects.join("\n")}<\/script>`;
|
|
|
16124
16148
|
}
|
|
16125
16149
|
|
|
16126
16150
|
// src/liquid/filters/money.ts
|
|
16127
|
-
function
|
|
16151
|
+
function bind49(liquidSwell) {
|
|
16128
16152
|
return function filterMoney(value) {
|
|
16129
16153
|
const amount = getMoneyAmount(liquidSwell, value);
|
|
16130
16154
|
return liquidSwell.renderCurrency(amount);
|
|
@@ -16141,7 +16165,7 @@ ${injects.join("\n")}<\/script>`;
|
|
|
16141
16165
|
}
|
|
16142
16166
|
|
|
16143
16167
|
// src/liquid/filters/money_with_currency.ts
|
|
16144
|
-
function
|
|
16168
|
+
function bind50(liquidSwell) {
|
|
16145
16169
|
return function filterMoneyWithCurrency(value) {
|
|
16146
16170
|
const { currency } = liquidSwell.theme.swell.getStorefrontLocalization();
|
|
16147
16171
|
const amount = getMoneyAmount(liquidSwell, value);
|
|
@@ -16150,7 +16174,7 @@ ${injects.join("\n")}<\/script>`;
|
|
|
16150
16174
|
}
|
|
16151
16175
|
|
|
16152
16176
|
// src/liquid/filters/money_without_currency.ts
|
|
16153
|
-
function
|
|
16177
|
+
function bind51(liquidSwell) {
|
|
16154
16178
|
return function filterMoneyWithoutCurrency(value) {
|
|
16155
16179
|
const amount = getMoneyAmount(liquidSwell, value);
|
|
16156
16180
|
return liquidSwell.renderCurrency(amount).replace(/[^0-9.,]/g, "");
|
|
@@ -16158,7 +16182,7 @@ ${injects.join("\n")}<\/script>`;
|
|
|
16158
16182
|
}
|
|
16159
16183
|
|
|
16160
16184
|
// src/liquid/filters/money_without_trailing_zeros.ts
|
|
16161
|
-
function
|
|
16185
|
+
function bind52(liquidSwell) {
|
|
16162
16186
|
return function filterMoneyWithoutTrailingZeros(value) {
|
|
16163
16187
|
const amount = getMoneyAmount(liquidSwell, value);
|
|
16164
16188
|
return liquidSwell.renderCurrency(amount).split(".")[0].split(",")[0];
|
|
@@ -16166,21 +16190,21 @@ ${injects.join("\n")}<\/script>`;
|
|
|
16166
16190
|
}
|
|
16167
16191
|
|
|
16168
16192
|
// src/liquid/filters/script_tag.ts
|
|
16169
|
-
function
|
|
16193
|
+
function bind53(_liquidSwell) {
|
|
16170
16194
|
return function filterScriptTag(assetUrl) {
|
|
16171
16195
|
return `<script src="${assetUrl}" type="text/javascript"><\/script>`;
|
|
16172
16196
|
};
|
|
16173
16197
|
}
|
|
16174
16198
|
|
|
16175
16199
|
// src/liquid/filters/stylesheet_tag.ts
|
|
16176
|
-
function
|
|
16200
|
+
function bind54(_liquidSwell) {
|
|
16177
16201
|
return function filterStyleSheetTag(assetUrl) {
|
|
16178
16202
|
return `<link href="${assetUrl}" rel="stylesheet" type="text/css" media="all" />`;
|
|
16179
16203
|
};
|
|
16180
16204
|
}
|
|
16181
16205
|
|
|
16182
16206
|
// src/liquid/filters/time_tag.ts
|
|
16183
|
-
function
|
|
16207
|
+
function bind55(_liquidSwell) {
|
|
16184
16208
|
const dateFilter = bind33(_liquidSwell);
|
|
16185
16209
|
return (dateValue, ...params) => {
|
|
16186
16210
|
const date = ensureDate(dateValue);
|
|
@@ -16191,7 +16215,7 @@ ${injects.join("\n")}<\/script>`;
|
|
|
16191
16215
|
}
|
|
16192
16216
|
|
|
16193
16217
|
// src/liquid/filters/translate.ts
|
|
16194
|
-
function
|
|
16218
|
+
function bind56(liquidSwell) {
|
|
16195
16219
|
return async function filterTranslate(key, params) {
|
|
16196
16220
|
const props = params && paramsToProps(params);
|
|
16197
16221
|
const str = await liquidSwell.renderTranslation(key, props);
|
|
@@ -16200,7 +16224,7 @@ ${injects.join("\n")}<\/script>`;
|
|
|
16200
16224
|
}
|
|
16201
16225
|
|
|
16202
16226
|
// src/liquid/filters/where.ts
|
|
16203
|
-
function
|
|
16227
|
+
function bind57(_liquidSwell) {
|
|
16204
16228
|
return function* filterWhere(arr, property, expected) {
|
|
16205
16229
|
const results = [];
|
|
16206
16230
|
const list = yield resolveEnumerable(arr);
|
|
@@ -16254,7 +16278,7 @@ ${injects.join("\n")}<\/script>`;
|
|
|
16254
16278
|
height: height ? Number(height) : void 0
|
|
16255
16279
|
};
|
|
16256
16280
|
}
|
|
16257
|
-
function
|
|
16281
|
+
function bind58(liquidSwell) {
|
|
16258
16282
|
return async function filterAssetImgUrl(assetPath, size = "small") {
|
|
16259
16283
|
const imageUrl = await liquidSwell.getAssetUrl(assetPath).then((url) => url || "");
|
|
16260
16284
|
const sizes = getSizesFromParam(size);
|
|
@@ -16270,14 +16294,14 @@ ${injects.join("\n")}<\/script>`;
|
|
|
16270
16294
|
}
|
|
16271
16295
|
|
|
16272
16296
|
// src/liquid/filters/shopify/hex_to_rgba.ts
|
|
16273
|
-
function
|
|
16297
|
+
function bind59(_liquidSwell) {
|
|
16274
16298
|
return (color, alpha) => {
|
|
16275
16299
|
return ThemeColor.get(color).rgba(alpha || 1);
|
|
16276
16300
|
};
|
|
16277
16301
|
}
|
|
16278
16302
|
|
|
16279
16303
|
// src/liquid/filters/shopify/img_url.ts
|
|
16280
|
-
function
|
|
16304
|
+
function bind60(liquidSwell) {
|
|
16281
16305
|
return async function filterImgUrl(input, ...params) {
|
|
16282
16306
|
const url = await getImageUrlFromInput(input, liquidSwell);
|
|
16283
16307
|
if (typeof url !== "string" || url === "") {
|
|
@@ -16315,14 +16339,14 @@ ${injects.join("\n")}<\/script>`;
|
|
|
16315
16339
|
};
|
|
16316
16340
|
|
|
16317
16341
|
// src/liquid/filters/shopify/payment_button.ts
|
|
16318
|
-
function
|
|
16342
|
+
function bind61(_liquidSwell) {
|
|
16319
16343
|
return (form) => {
|
|
16320
16344
|
return `<button style="display: block; visibility: hidden;"></button>`;
|
|
16321
16345
|
};
|
|
16322
16346
|
}
|
|
16323
16347
|
|
|
16324
16348
|
// src/liquid/filters/shopify/payment_terms.ts
|
|
16325
|
-
function
|
|
16349
|
+
function bind62(_liquidSwell) {
|
|
16326
16350
|
return (form) => {
|
|
16327
16351
|
return null;
|
|
16328
16352
|
};
|
|
@@ -16424,7 +16448,7 @@ ${injects.join("\n")}<\/script>`;
|
|
|
16424
16448
|
var placeholder_svgs_default = svgs;
|
|
16425
16449
|
|
|
16426
16450
|
// src/liquid/filters/shopify/placeholder_svg_tag.ts
|
|
16427
|
-
function
|
|
16451
|
+
function bind63(_liquidSwell) {
|
|
16428
16452
|
return function filterPlaceholderSvgTag(name, className) {
|
|
16429
16453
|
const svg = placeholder_svgs_default[name];
|
|
16430
16454
|
if (typeof svg === "object" && svg !== null) {
|
|
@@ -16435,7 +16459,7 @@ ${injects.join("\n")}<\/script>`;
|
|
|
16435
16459
|
}
|
|
16436
16460
|
|
|
16437
16461
|
// src/liquid/filters/shopify/shopify_asset_url.ts
|
|
16438
|
-
function
|
|
16462
|
+
function bind64(_liquidSwell) {
|
|
16439
16463
|
return function filterShopifyAssetUrl(input) {
|
|
16440
16464
|
if (typeof input === "string") {
|
|
16441
16465
|
switch (input) {
|
|
@@ -16460,7 +16484,7 @@ ${injects.join("\n")}<\/script>`;
|
|
|
16460
16484
|
}
|
|
16461
16485
|
|
|
16462
16486
|
// src/liquid/filters/shopify/structured_data.ts
|
|
16463
|
-
function
|
|
16487
|
+
function bind65(_liquidSwell) {
|
|
16464
16488
|
return async function filterStructuredData(input) {
|
|
16465
16489
|
let value = input;
|
|
16466
16490
|
if (value instanceof StorefrontResource) {
|
|
@@ -16538,7 +16562,7 @@ ${injects.join("\n")}<\/script>`;
|
|
|
16538
16562
|
}
|
|
16539
16563
|
|
|
16540
16564
|
// src/liquid/filters/inline_editable.ts
|
|
16541
|
-
function
|
|
16565
|
+
function bind66(_liquidSwell) {
|
|
16542
16566
|
return (value, key) => {
|
|
16543
16567
|
if (typeof value === "object" && "value" in value) {
|
|
16544
16568
|
value = value.value;
|
|
@@ -16569,43 +16593,44 @@ ${injects.join("\n")}<\/script>`;
|
|
|
16569
16593
|
default_errors: bind35,
|
|
16570
16594
|
divided_by: bind36,
|
|
16571
16595
|
embedded_content: bind37,
|
|
16572
|
-
|
|
16573
|
-
|
|
16574
|
-
|
|
16596
|
+
escape: bind38,
|
|
16597
|
+
font_face: bind39,
|
|
16598
|
+
font_modify: bind40,
|
|
16599
|
+
font_url: bind41,
|
|
16575
16600
|
format_address: format_address_default,
|
|
16576
|
-
handle:
|
|
16601
|
+
handle: bind42,
|
|
16577
16602
|
// alias
|
|
16578
|
-
handleize:
|
|
16579
|
-
image_tag:
|
|
16603
|
+
handleize: bind42,
|
|
16604
|
+
image_tag: bind43,
|
|
16580
16605
|
image_url: image_url_default,
|
|
16581
|
-
inline_asset_content:
|
|
16582
|
-
json:
|
|
16583
|
-
json_pretty:
|
|
16584
|
-
locale_flag:
|
|
16585
|
-
minus:
|
|
16586
|
-
money:
|
|
16587
|
-
money_with_currency:
|
|
16588
|
-
money_without_currency:
|
|
16589
|
-
money_without_trailing_zeros:
|
|
16590
|
-
script_tag:
|
|
16591
|
-
stylesheet_tag:
|
|
16592
|
-
time_tag:
|
|
16593
|
-
translate:
|
|
16594
|
-
t:
|
|
16606
|
+
inline_asset_content: bind44,
|
|
16607
|
+
json: bind45,
|
|
16608
|
+
json_pretty: bind46,
|
|
16609
|
+
locale_flag: bind47,
|
|
16610
|
+
minus: bind48,
|
|
16611
|
+
money: bind49,
|
|
16612
|
+
money_with_currency: bind50,
|
|
16613
|
+
money_without_currency: bind51,
|
|
16614
|
+
money_without_trailing_zeros: bind52,
|
|
16615
|
+
script_tag: bind53,
|
|
16616
|
+
stylesheet_tag: bind54,
|
|
16617
|
+
time_tag: bind55,
|
|
16618
|
+
translate: bind56,
|
|
16619
|
+
t: bind56,
|
|
16595
16620
|
// alias
|
|
16596
|
-
where:
|
|
16621
|
+
where: bind57,
|
|
16597
16622
|
// Shopify compatibility only
|
|
16598
|
-
asset_img_url:
|
|
16599
|
-
hex_to_rgba:
|
|
16600
|
-
img_url:
|
|
16623
|
+
asset_img_url: bind58,
|
|
16624
|
+
hex_to_rgba: bind59,
|
|
16625
|
+
img_url: bind60,
|
|
16601
16626
|
item_count_for_variant: item_count_for_variant_default,
|
|
16602
|
-
payment_button:
|
|
16603
|
-
payment_terms:
|
|
16604
|
-
placeholder_svg_tag:
|
|
16605
|
-
shopify_asset_url:
|
|
16606
|
-
structured_data:
|
|
16627
|
+
payment_button: bind61,
|
|
16628
|
+
payment_terms: bind62,
|
|
16629
|
+
placeholder_svg_tag: bind63,
|
|
16630
|
+
shopify_asset_url: bind64,
|
|
16631
|
+
structured_data: bind65,
|
|
16607
16632
|
// Swell only
|
|
16608
|
-
inline_editable:
|
|
16633
|
+
inline_editable: bind66
|
|
16609
16634
|
};
|
|
16610
16635
|
function bindFilters(liquidSwell) {
|
|
16611
16636
|
for (const [tag, handler] of Object.entries(filters)) {
|
|
@@ -16619,8 +16644,8 @@ ${injects.join("\n")}<\/script>`;
|
|
|
16619
16644
|
}
|
|
16620
16645
|
}
|
|
16621
16646
|
}
|
|
16622
|
-
function bindWithResolvedProps(liquidSwell,
|
|
16623
|
-
const handler =
|
|
16647
|
+
function bindWithResolvedProps(liquidSwell, bind67, resolve = []) {
|
|
16648
|
+
const handler = bind67(liquidSwell);
|
|
16624
16649
|
if (!Array.isArray(resolve)) {
|
|
16625
16650
|
return handler;
|
|
16626
16651
|
}
|
|
@@ -17322,7 +17347,7 @@ ${injects.join("\n")}<\/script>`;
|
|
|
17322
17347
|
};
|
|
17323
17348
|
|
|
17324
17349
|
// src/globals.ts
|
|
17325
|
-
var
|
|
17350
|
+
var import_lodash_es13 = __require("lodash-es");
|
|
17326
17351
|
|
|
17327
17352
|
// src/compatibility/drops/robots-rule.ts
|
|
17328
17353
|
var import_liquidjs35 = __require("liquidjs");
|
|
@@ -17422,7 +17447,7 @@ ${injects.join("\n")}<\/script>`;
|
|
|
17422
17447
|
}).filter(Boolean).join("\n");
|
|
17423
17448
|
}
|
|
17424
17449
|
function getRobotsGlobals(canonicalUrl) {
|
|
17425
|
-
const sitemapUrl = `${(0,
|
|
17450
|
+
const sitemapUrl = `${(0, import_lodash_es13.trimEnd)(canonicalUrl, "/")}/sitemap.xml`;
|
|
17426
17451
|
const defaultRules = [
|
|
17427
17452
|
{ directive: "Disallow", value: "/admin" },
|
|
17428
17453
|
{ directive: "Disallow", value: "/cart" },
|
|
@@ -17435,14 +17460,14 @@ ${injects.join("\n")}<\/script>`;
|
|
|
17435
17460
|
default_groups: [
|
|
17436
17461
|
{
|
|
17437
17462
|
user_agent: RobotsRule.from("User-agent", "*"),
|
|
17438
|
-
|
|
17463
|
+
sitemap: RobotsRule.from("Sitemap", sitemapUrl),
|
|
17439
17464
|
rules: defaultRules.map(
|
|
17440
17465
|
(rule) => RobotsRule.from(rule.directive, rule.value)
|
|
17441
17466
|
)
|
|
17442
17467
|
},
|
|
17443
17468
|
{
|
|
17444
17469
|
user_agent: RobotsRule.from("User-agent", "AhrefsBot"),
|
|
17445
|
-
|
|
17470
|
+
sitemap: RobotsRule.from("Sitemap", sitemapUrl),
|
|
17446
17471
|
rules: [
|
|
17447
17472
|
RobotsRule.from("Crawl-delay", "10"),
|
|
17448
17473
|
...defaultRules.map(
|
|
@@ -17452,7 +17477,7 @@ ${injects.join("\n")}<\/script>`;
|
|
|
17452
17477
|
},
|
|
17453
17478
|
{
|
|
17454
17479
|
user_agent: RobotsRule.from("User-agent", "AhrefsSiteAudit"),
|
|
17455
|
-
|
|
17480
|
+
sitemap: RobotsRule.from("Sitemap", sitemapUrl),
|
|
17456
17481
|
rules: [
|
|
17457
17482
|
RobotsRule.from("Crawl-delay", "10"),
|
|
17458
17483
|
...defaultRules.map(
|
|
@@ -17917,7 +17942,7 @@ ${injects.join("\n")}<\/script>`;
|
|
|
17917
17942
|
return languageConfig;
|
|
17918
17943
|
}
|
|
17919
17944
|
const localeShortCode = locale.split("-")[0];
|
|
17920
|
-
return (0,
|
|
17945
|
+
return (0, import_lodash_es14.reduce)(
|
|
17921
17946
|
languageConfig,
|
|
17922
17947
|
(acc, value, key) => {
|
|
17923
17948
|
if (isObject2(value)) {
|
|
@@ -17941,15 +17966,15 @@ ${injects.join("\n")}<\/script>`;
|
|
|
17941
17966
|
const translationEnd = translationParts.pop();
|
|
17942
17967
|
const translationPath = translationParts.join(".");
|
|
17943
17968
|
const translationConfigGlobal = this.globals.language;
|
|
17944
|
-
acc[key] = (0,
|
|
17969
|
+
acc[key] = (0, import_lodash_es14.get)(
|
|
17945
17970
|
translationConfigGlobal,
|
|
17946
17971
|
`${translationPath}.$locale.${locale}.${translationEnd}`
|
|
17947
|
-
) || (0,
|
|
17972
|
+
) || (0, import_lodash_es14.get)(
|
|
17948
17973
|
translationConfigGlobal,
|
|
17949
17974
|
`${translationPath}.$locale.${localeShortCode}.${translationEnd}`
|
|
17950
|
-
) || (0,
|
|
17975
|
+
) || (0, import_lodash_es14.get)(translationConfigGlobal, translationKey) || value;
|
|
17951
17976
|
} else {
|
|
17952
|
-
acc[key] = (0,
|
|
17977
|
+
acc[key] = (0, import_lodash_es14.get)(languageConfig, `$locale.${locale}.${key}`) || (0, import_lodash_es14.get)(languageConfig, `$locale.${localeShortCode}.${key}`) || value;
|
|
17953
17978
|
}
|
|
17954
17979
|
}
|
|
17955
17980
|
return acc;
|
|
@@ -18785,8 +18810,8 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
|
|
|
18785
18810
|
const keyParts = key?.split(".") || [];
|
|
18786
18811
|
const keyName = keyParts.pop() || "";
|
|
18787
18812
|
const keyPath = keyParts.join(".");
|
|
18788
|
-
const langObject = (0,
|
|
18789
|
-
let localeValue = (0,
|
|
18813
|
+
const langObject = (0, import_lodash_es14.get)(langConfig, keyPath);
|
|
18814
|
+
let localeValue = (0, import_lodash_es14.get)(langObject?.[localeCode], keyName) || (0, import_lodash_es14.get)(langObject?.[localeCode.split("-")[0]], keyName) || langObject?.[keyName];
|
|
18790
18815
|
if (data?.count !== void 0 && localeValue?.one) {
|
|
18791
18816
|
localeValue = data.count === 1 ? localeValue.one : localeValue.other;
|
|
18792
18817
|
}
|
|
@@ -18866,7 +18891,7 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
|
|
|
18866
18891
|
}
|
|
18867
18892
|
}
|
|
18868
18893
|
function resolveThemeSettings(theme, themeSettings, editorSchemaSettings) {
|
|
18869
|
-
const settings = (0,
|
|
18894
|
+
const settings = (0, import_lodash_es14.cloneDeep)(themeSettings);
|
|
18870
18895
|
if (settings.$locale) {
|
|
18871
18896
|
const { locale } = theme.swell.getStorefrontLocalization();
|
|
18872
18897
|
const localeConfig = settings.$locale[locale] || {};
|
|
@@ -18876,16 +18901,16 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
|
|
|
18876
18901
|
}
|
|
18877
18902
|
}
|
|
18878
18903
|
}
|
|
18879
|
-
(0,
|
|
18904
|
+
(0, import_lodash_es14.each)(settings, (value, key) => {
|
|
18880
18905
|
const setting = (editorSchemaSettings && findEditorSetting(editorSchemaSettings, key)) ?? null;
|
|
18881
18906
|
if (isObject2(value) && !(value instanceof StorefrontResource)) {
|
|
18882
18907
|
switch (setting?.type) {
|
|
18883
18908
|
case "color_scheme_group": {
|
|
18884
|
-
(0,
|
|
18909
|
+
(0, import_lodash_es14.each)(value, (scheme, schemeId) => {
|
|
18885
18910
|
if (isObject2(scheme) && typeof scheme.settings === "object" && scheme.settings) {
|
|
18886
18911
|
const settings2 = scheme.settings;
|
|
18887
|
-
(0,
|
|
18888
|
-
const fieldDef = (0,
|
|
18912
|
+
(0, import_lodash_es14.each)(settings2, (colorValue, colorId) => {
|
|
18913
|
+
const fieldDef = (0, import_lodash_es14.find)(setting.fields, { id: colorId });
|
|
18889
18914
|
if (fieldDef?.type === "color" && colorValue) {
|
|
18890
18915
|
scheme.id = schemeId;
|
|
18891
18916
|
settings2[colorId] = new ThemeColor(colorValue);
|
|
@@ -18936,7 +18961,7 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
|
|
|
18936
18961
|
}
|
|
18937
18962
|
function findThemeSettingsByType(type, themeSettings, editorSchemaSettings) {
|
|
18938
18963
|
const foundSettings = [];
|
|
18939
|
-
(0,
|
|
18964
|
+
(0, import_lodash_es14.each)(themeSettings, (value, key) => {
|
|
18940
18965
|
if (isObject2(value) && !(value instanceof ThemeFont) && !(value instanceof StorefrontResource)) {
|
|
18941
18966
|
foundSettings.push(
|
|
18942
18967
|
...findThemeSettingsByType(type, value, editorSchemaSettings)
|
|
@@ -19110,7 +19135,7 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
|
|
|
19110
19135
|
}
|
|
19111
19136
|
function getMenuItemValueId(value) {
|
|
19112
19137
|
const fallback = typeof value === "string" ? value : "";
|
|
19113
|
-
const slug = (0,
|
|
19138
|
+
const slug = (0, import_lodash_es15.get)(value, "id", (0, import_lodash_es15.get)(value, "slug", fallback)) || "";
|
|
19114
19139
|
return slug;
|
|
19115
19140
|
}
|
|
19116
19141
|
async function getMenuItemUrlAndResource(theme, menuItem) {
|
|
@@ -19412,6 +19437,35 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
|
|
|
19412
19437
|
},
|
|
19413
19438
|
pathRules: [{ path: "/checkout/*", skip: true }]
|
|
19414
19439
|
};
|
|
19440
|
+
var SANITIZE_CLIENT_HEADERS = Object.freeze([
|
|
19441
|
+
"connection",
|
|
19442
|
+
"proxy-connection",
|
|
19443
|
+
"keep-alive",
|
|
19444
|
+
"transfer-encoding",
|
|
19445
|
+
"upgrade",
|
|
19446
|
+
"proxy-authenticate",
|
|
19447
|
+
"proxy-authorization",
|
|
19448
|
+
"te",
|
|
19449
|
+
"trailers",
|
|
19450
|
+
"via",
|
|
19451
|
+
"alt-svc",
|
|
19452
|
+
"content-length",
|
|
19453
|
+
"content-encoding",
|
|
19454
|
+
// Also strip any legacy internal metadata keys
|
|
19455
|
+
"x-original-ttl",
|
|
19456
|
+
"x-original-swr",
|
|
19457
|
+
"x-cache-time"
|
|
19458
|
+
]);
|
|
19459
|
+
var CACHE_KEY_HEADERS = Object.freeze([
|
|
19460
|
+
"cookie",
|
|
19461
|
+
"swell-storefront-id",
|
|
19462
|
+
"swell-app-id",
|
|
19463
|
+
"swell-access-token",
|
|
19464
|
+
"swell-theme-version-hash",
|
|
19465
|
+
"swell-cache-modified",
|
|
19466
|
+
"x-locale",
|
|
19467
|
+
"swell-storefront-context"
|
|
19468
|
+
]);
|
|
19415
19469
|
var HtmlCache = class {
|
|
19416
19470
|
epoch;
|
|
19417
19471
|
backend;
|
|
@@ -19419,7 +19473,23 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
|
|
|
19419
19473
|
constructor(epoch, backend, cacheRules = DEFAULT_CACHE_RULES) {
|
|
19420
19474
|
this.epoch = epoch;
|
|
19421
19475
|
this.backend = backend;
|
|
19422
|
-
this.cacheRules =
|
|
19476
|
+
this.cacheRules = {
|
|
19477
|
+
...cacheRules,
|
|
19478
|
+
pathRules: cacheRules.pathRules?.map((rule) => ({
|
|
19479
|
+
...rule,
|
|
19480
|
+
regex: this.convertPathToRegex(rule.path)
|
|
19481
|
+
}))
|
|
19482
|
+
};
|
|
19483
|
+
}
|
|
19484
|
+
/**
|
|
19485
|
+
* Converts wildcard pattern to regex and tests against path.
|
|
19486
|
+
*
|
|
19487
|
+
* - `*` matches any characters except `/`
|
|
19488
|
+
* - `**` matches any characters including `/`
|
|
19489
|
+
*/
|
|
19490
|
+
convertPathToRegex(pattern) {
|
|
19491
|
+
const regex = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, "___DOUBLE_STAR___").replace(/\*/g, "[^/]*").replace(/___DOUBLE_STAR___/g, ".*");
|
|
19492
|
+
return new RegExp(`^${regex}$`);
|
|
19423
19493
|
}
|
|
19424
19494
|
async get(request) {
|
|
19425
19495
|
const trace = createTraceId();
|
|
@@ -19510,18 +19580,18 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
|
|
|
19510
19580
|
);
|
|
19511
19581
|
return;
|
|
19512
19582
|
}
|
|
19513
|
-
const
|
|
19583
|
+
const date = /* @__PURE__ */ new Date();
|
|
19514
19584
|
const headers = this.normalizeHeaders(response.headers);
|
|
19515
19585
|
const entry = {
|
|
19516
19586
|
status: response.status,
|
|
19517
19587
|
statusText: response.statusText,
|
|
19518
19588
|
headers,
|
|
19519
19589
|
body,
|
|
19520
|
-
cacheTimeISO,
|
|
19590
|
+
cacheTimeISO: date.toISOString(),
|
|
19521
19591
|
ttl,
|
|
19522
19592
|
swr,
|
|
19523
19593
|
etag: this.quoteETag(headers["etag"] || md5(body)),
|
|
19524
|
-
lastModifiedUTC: headers["last-modified"] ||
|
|
19594
|
+
lastModifiedUTC: headers["last-modified"] || date.toUTCString()
|
|
19525
19595
|
};
|
|
19526
19596
|
const hardExpireSeconds = ttl + swr;
|
|
19527
19597
|
await this.backend.write(cacheKey, entry, hardExpireSeconds);
|
|
@@ -19546,8 +19616,13 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
|
|
|
19546
19616
|
}
|
|
19547
19617
|
}
|
|
19548
19618
|
canReadFromCache(request) {
|
|
19549
|
-
|
|
19550
|
-
|
|
19619
|
+
switch (request.method.toUpperCase()) {
|
|
19620
|
+
case "GET":
|
|
19621
|
+
case "HEAD":
|
|
19622
|
+
break;
|
|
19623
|
+
default:
|
|
19624
|
+
return false;
|
|
19625
|
+
}
|
|
19551
19626
|
const res = this.resolvePathRule(request);
|
|
19552
19627
|
if (res.skip) return false;
|
|
19553
19628
|
return this.isRequestCacheable(request);
|
|
@@ -19613,7 +19688,7 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
|
|
|
19613
19688
|
try {
|
|
19614
19689
|
const ifModDate = new Date(ifModifiedSince);
|
|
19615
19690
|
const lastModDate = new Date(lastModified);
|
|
19616
|
-
if (isNaN(ifModDate.getTime()) || isNaN(lastModDate.getTime())) {
|
|
19691
|
+
if (Number.isNaN(ifModDate.getTime()) || Number.isNaN(lastModDate.getTime())) {
|
|
19617
19692
|
return false;
|
|
19618
19693
|
}
|
|
19619
19694
|
return ifModDate >= lastModDate;
|
|
@@ -19643,31 +19718,25 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
|
|
|
19643
19718
|
return `"${value}"`;
|
|
19644
19719
|
}
|
|
19645
19720
|
sanitizeClientHeaders(headers) {
|
|
19646
|
-
const
|
|
19647
|
-
|
|
19648
|
-
|
|
19649
|
-
|
|
19650
|
-
|
|
19651
|
-
|
|
19652
|
-
|
|
19653
|
-
|
|
19654
|
-
|
|
19655
|
-
|
|
19656
|
-
|
|
19657
|
-
|
|
19658
|
-
|
|
19659
|
-
];
|
|
19660
|
-
for (const h of HOP_BY_HOP) headers.delete(h);
|
|
19661
|
-
headers.delete("content-encoding");
|
|
19662
|
-
headers.delete("x-original-ttl");
|
|
19663
|
-
headers.delete("x-original-swr");
|
|
19664
|
-
headers.delete("x-cache-time");
|
|
19721
|
+
for (const name of SANITIZE_CLIENT_HEADERS) {
|
|
19722
|
+
headers.delete(name);
|
|
19723
|
+
}
|
|
19724
|
+
}
|
|
19725
|
+
getCacheKeyHeaders(headers) {
|
|
19726
|
+
const acc = new Headers();
|
|
19727
|
+
for (const name of CACHE_KEY_HEADERS) {
|
|
19728
|
+
const value = headers.get(name);
|
|
19729
|
+
if (value) {
|
|
19730
|
+
acc.set(name, value);
|
|
19731
|
+
}
|
|
19732
|
+
}
|
|
19733
|
+
return acc;
|
|
19665
19734
|
}
|
|
19666
19735
|
generateVersionHash(headers) {
|
|
19667
|
-
const swellData = this.extractSwellData(headers);
|
|
19736
|
+
const swellData = this.extractSwellData(headers.get("cookie"));
|
|
19668
19737
|
const versionFactors = {
|
|
19669
19738
|
store: headers.get("swell-storefront-id") || "",
|
|
19670
|
-
app:
|
|
19739
|
+
app: headers.get("swell-app-id") || "",
|
|
19671
19740
|
auth: headers.get("swell-access-token") || "",
|
|
19672
19741
|
theme: headers.get("swell-theme-version-hash") || "",
|
|
19673
19742
|
modified: headers.get("swell-cache-modified") || "",
|
|
@@ -19678,8 +19747,7 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
|
|
|
19678
19747
|
};
|
|
19679
19748
|
return md5(JSON.stringify(versionFactors));
|
|
19680
19749
|
}
|
|
19681
|
-
extractSwellData(
|
|
19682
|
-
const cookie = headers.get("cookie");
|
|
19750
|
+
extractSwellData(cookie) {
|
|
19683
19751
|
if (!cookie) return {};
|
|
19684
19752
|
const swellDataMatch = cookie.match(/swell-data=([^;]+)/);
|
|
19685
19753
|
if (!swellDataMatch) return {};
|
|
@@ -19731,15 +19799,6 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
|
|
|
19731
19799
|
const age = (Date.now() - t) / 1e3;
|
|
19732
19800
|
return age < 0 ? 0 : age;
|
|
19733
19801
|
}
|
|
19734
|
-
/**
|
|
19735
|
-
* Converts wildcard pattern to regex and tests against path.
|
|
19736
|
-
* - * matches any characters except /
|
|
19737
|
-
* - ** matches any characters including /
|
|
19738
|
-
*/
|
|
19739
|
-
pathMatches(pattern, path) {
|
|
19740
|
-
const regex = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, "___DOUBLE_STAR___").replace(/\*/g, "[^/]*").replace(/___DOUBLE_STAR___/g, ".*");
|
|
19741
|
-
return new RegExp(`^${regex}$`).test(path);
|
|
19742
|
-
}
|
|
19743
19802
|
normalizeHeaders(headers) {
|
|
19744
19803
|
const normalized = {};
|
|
19745
19804
|
headers.forEach((value, key) => {
|
|
@@ -19750,16 +19809,10 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
|
|
|
19750
19809
|
resolvePathRule(request) {
|
|
19751
19810
|
const url = new URL(request.url);
|
|
19752
19811
|
const mode = this.getDeploymentMode(request.headers);
|
|
19753
|
-
const defaults = this.cacheRules.defaults?.[mode] ?? DEFAULT_CACHE_RULES.defaults[mode];
|
|
19754
|
-
|
|
19755
|
-
|
|
19756
|
-
|
|
19757
|
-
if (this.pathMatches(r.path, url.pathname)) {
|
|
19758
|
-
rule = r;
|
|
19759
|
-
break;
|
|
19760
|
-
}
|
|
19761
|
-
}
|
|
19762
|
-
}
|
|
19812
|
+
const defaults = this.cacheRules.defaults?.[mode] ?? DEFAULT_CACHE_RULES.defaults?.[mode];
|
|
19813
|
+
const rule = this.cacheRules.pathRules?.find(
|
|
19814
|
+
(r) => r.regex.test(url.pathname)
|
|
19815
|
+
);
|
|
19763
19816
|
const effectiveTTL = (rule?.ttl !== void 0 ? rule.ttl : defaults?.ttl) ?? defaults.ttl;
|
|
19764
19817
|
const effectiveSWR = (rule?.swr !== void 0 ? rule.swr : defaults?.swr) ?? defaults.swr;
|
|
19765
19818
|
return {
|
|
@@ -19771,27 +19824,29 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
|
|
|
19771
19824
|
};
|
|
19772
19825
|
}
|
|
19773
19826
|
normalizeSearchParams(searchParams) {
|
|
19774
|
-
const ignoredParams = [
|
|
19775
|
-
"utm_source",
|
|
19776
|
-
"utm_medium",
|
|
19777
|
-
"utm_campaign",
|
|
19778
|
-
"utm_content",
|
|
19779
|
-
"utm_term",
|
|
19780
|
-
"fbclid",
|
|
19781
|
-
"gclid",
|
|
19782
|
-
"gbraid",
|
|
19783
|
-
"wbraid",
|
|
19784
|
-
"ref",
|
|
19785
|
-
"source",
|
|
19786
|
-
"mc_cid",
|
|
19787
|
-
"mc_eid"
|
|
19788
|
-
];
|
|
19789
19827
|
const relevantParams = [];
|
|
19790
19828
|
searchParams.forEach((value, key) => {
|
|
19791
|
-
|
|
19792
|
-
|
|
19793
|
-
|
|
19794
|
-
|
|
19829
|
+
switch (key) {
|
|
19830
|
+
case "utm_source":
|
|
19831
|
+
case "utm_medium":
|
|
19832
|
+
case "utm_campaign":
|
|
19833
|
+
case "utm_content":
|
|
19834
|
+
case "utm_term":
|
|
19835
|
+
case "fbclid":
|
|
19836
|
+
case "gclid":
|
|
19837
|
+
case "gbraid":
|
|
19838
|
+
case "wbraid":
|
|
19839
|
+
case "ref":
|
|
19840
|
+
case "source":
|
|
19841
|
+
case "mc_cid":
|
|
19842
|
+
case "mc_eid":
|
|
19843
|
+
break;
|
|
19844
|
+
default: {
|
|
19845
|
+
relevantParams.push(
|
|
19846
|
+
`${encodeURIComponent(key)}=${encodeURIComponent(value)}`
|
|
19847
|
+
);
|
|
19848
|
+
break;
|
|
19849
|
+
}
|
|
19795
19850
|
}
|
|
19796
19851
|
});
|
|
19797
19852
|
return relevantParams.sort().join("&");
|