@swell/apps-sdk 1.0.173 → 1.0.175
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 +79 -60
- package/dist/index.cjs.map +3 -3
- package/dist/index.js +79 -60
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +79 -60
- package/dist/index.mjs.map +3 -3
- package/dist/src/api.d.ts +2 -2
- package/dist/src/compatibility/drops/template.d.ts +1 -1
- package/dist/src/compatibility/shopify-objects/order.d.ts +1 -1
- package/dist/src/utils/escape.d.ts +1 -0
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -4020,7 +4020,7 @@ var Cache = class {
|
|
|
4020
4020
|
/**
|
|
4021
4021
|
* Always fetches fresh data and updates cache
|
|
4022
4022
|
* Deduplicates concurrent requests with the same key
|
|
4023
|
-
*
|
|
4023
|
+
*
|
|
4024
4024
|
* @param key Cache key
|
|
4025
4025
|
* @param fetchFn Function to fetch fresh data
|
|
4026
4026
|
* @param ttl Time to live in milliseconds (default: DEFAULT_SWR_TTL)
|
|
@@ -14766,6 +14766,14 @@ var RenderDrop = class extends import_liquidjs14.Drop {
|
|
|
14766
14766
|
// src/liquid/index.ts
|
|
14767
14767
|
var import_liquidjs34 = require("liquidjs");
|
|
14768
14768
|
|
|
14769
|
+
// src/utils/escape.ts
|
|
14770
|
+
function replacerUnescape(match) {
|
|
14771
|
+
return match.includes('\\"') ? JSON.parse(`"${match}"`) : match;
|
|
14772
|
+
}
|
|
14773
|
+
function unescapeLiquidSyntax(template) {
|
|
14774
|
+
return template.replace(/\{\{.*?\}\}/g, replacerUnescape);
|
|
14775
|
+
}
|
|
14776
|
+
|
|
14769
14777
|
// src/liquid/tags/assign.ts
|
|
14770
14778
|
var import_liquidjs15 = require("liquidjs");
|
|
14771
14779
|
function bind(_liquidSwell) {
|
|
@@ -15274,28 +15282,30 @@ var import_liquidjs24 = require("liquidjs");
|
|
|
15274
15282
|
function bind10(liquidSwell) {
|
|
15275
15283
|
return class RenderTag extends import_liquidjs24.RenderTag {
|
|
15276
15284
|
*render(ctx, emitter) {
|
|
15277
|
-
const
|
|
15278
|
-
const
|
|
15279
|
-
|
|
15285
|
+
const self = this;
|
|
15286
|
+
const { liquid } = this;
|
|
15287
|
+
const { hash } = self;
|
|
15288
|
+
const filename = yield renderFilePath(
|
|
15289
|
+
self["file"],
|
|
15280
15290
|
ctx,
|
|
15281
15291
|
liquid
|
|
15282
15292
|
);
|
|
15283
|
-
(0, import_liquidjs24.assert)(
|
|
15284
|
-
const
|
|
15285
|
-
|
|
15293
|
+
(0, import_liquidjs24.assert)(filename, () => `illegal file path "${filename}"`);
|
|
15294
|
+
const configPath = yield liquidSwell.getComponentPath(
|
|
15295
|
+
filename
|
|
15286
15296
|
);
|
|
15287
15297
|
const childCtx = ctx.spawn();
|
|
15288
15298
|
const scope = childCtx.bottom();
|
|
15289
15299
|
(0, import_lodash_es9.assign)(scope, yield hash.render(ctx));
|
|
15290
15300
|
const parentSection = yield ctx._get(["section"]);
|
|
15291
15301
|
if (parentSection) (0, import_lodash_es9.assign)(scope, { section: parentSection });
|
|
15292
|
-
if (
|
|
15293
|
-
const { value, alias } =
|
|
15294
|
-
const aliasName = alias ||
|
|
15302
|
+
if (self["with"]) {
|
|
15303
|
+
const { value, alias } = self["with"];
|
|
15304
|
+
const aliasName = alias || filename;
|
|
15295
15305
|
scope[aliasName] = yield (0, import_liquidjs24.evalToken)(value, ctx);
|
|
15296
15306
|
}
|
|
15297
|
-
if (
|
|
15298
|
-
const { value, alias } =
|
|
15307
|
+
if (self["for"]) {
|
|
15308
|
+
const { value, alias } = self["for"];
|
|
15299
15309
|
let collection = yield (0, import_liquidjs24.evalToken)(value, ctx);
|
|
15300
15310
|
collection = yield resolveEnumerable(collection);
|
|
15301
15311
|
scope["forloop"] = new ForloopDrop(
|
|
@@ -15305,13 +15315,23 @@ function bind10(liquidSwell) {
|
|
|
15305
15315
|
);
|
|
15306
15316
|
for (const item of collection) {
|
|
15307
15317
|
scope[alias] = item;
|
|
15308
|
-
const
|
|
15309
|
-
|
|
15318
|
+
const templates = yield liquid._parseFile(
|
|
15319
|
+
configPath,
|
|
15320
|
+
childCtx.sync,
|
|
15321
|
+
void 0,
|
|
15322
|
+
self["currentFile"]
|
|
15323
|
+
);
|
|
15324
|
+
yield liquid.renderer.renderTemplates(templates, childCtx, emitter);
|
|
15310
15325
|
scope["forloop"].next();
|
|
15311
15326
|
}
|
|
15312
15327
|
} else {
|
|
15313
|
-
const
|
|
15314
|
-
|
|
15328
|
+
const templates = yield liquid._parseFile(
|
|
15329
|
+
configPath,
|
|
15330
|
+
childCtx.sync,
|
|
15331
|
+
void 0,
|
|
15332
|
+
self["currentFile"]
|
|
15333
|
+
);
|
|
15334
|
+
yield liquid.renderer.renderTemplates(templates, childCtx, emitter);
|
|
15315
15335
|
}
|
|
15316
15336
|
}
|
|
15317
15337
|
};
|
|
@@ -16911,13 +16931,15 @@ var LiquidSwell30 = class extends import_liquidjs34.Liquid {
|
|
|
16911
16931
|
}) {
|
|
16912
16932
|
getThemeConfig = getThemeConfig || theme.getThemeConfig.bind(theme);
|
|
16913
16933
|
extName = extName || "liquid";
|
|
16934
|
+
const fs = new LiquidFS(extName);
|
|
16914
16935
|
super({
|
|
16915
|
-
cache:
|
|
16936
|
+
cache: true,
|
|
16916
16937
|
relativeReference: false,
|
|
16917
|
-
fs
|
|
16938
|
+
fs,
|
|
16918
16939
|
ownPropertyOnly: false,
|
|
16919
16940
|
operators: swellOperators
|
|
16920
16941
|
});
|
|
16942
|
+
fs.liquidSwell = this;
|
|
16921
16943
|
this.theme = theme;
|
|
16922
16944
|
this.getThemeConfig = getThemeConfig;
|
|
16923
16945
|
this.getThemeTemplateConfigByType = getThemeTemplateConfigByType || theme.getThemeTemplateConfigByType.bind(theme);
|
|
@@ -16960,41 +16982,36 @@ var LiquidSwell30 = class extends import_liquidjs34.Liquid {
|
|
|
16960
16982
|
function resolveFilePath(fileName, extName) {
|
|
16961
16983
|
return `theme/${fileName}.${extName}`;
|
|
16962
16984
|
}
|
|
16963
|
-
|
|
16964
|
-
|
|
16965
|
-
|
|
16966
|
-
|
|
16967
|
-
|
|
16968
|
-
|
|
16969
|
-
|
|
16970
|
-
|
|
16971
|
-
|
|
16972
|
-
|
|
16973
|
-
|
|
16974
|
-
|
|
16975
|
-
|
|
16976
|
-
|
|
16977
|
-
|
|
16978
|
-
|
|
16979
|
-
|
|
16980
|
-
|
|
16981
|
-
|
|
16982
|
-
|
|
16983
|
-
|
|
16984
|
-
|
|
16985
|
-
|
|
16986
|
-
|
|
16987
|
-
|
|
16988
|
-
|
|
16989
|
-
|
|
16990
|
-
|
|
16991
|
-
|
|
16992
|
-
|
|
16993
|
-
fallback(_filePath) {
|
|
16994
|
-
return;
|
|
16995
|
-
}
|
|
16996
|
-
};
|
|
16997
|
-
}
|
|
16985
|
+
var LiquidFS = class {
|
|
16986
|
+
liquidSwell;
|
|
16987
|
+
constructor(_extName) {
|
|
16988
|
+
}
|
|
16989
|
+
async readFile(filePath) {
|
|
16990
|
+
const template = await this.liquidSwell.getThemeConfig(filePath);
|
|
16991
|
+
return unescapeLiquidSyntax(
|
|
16992
|
+
template?.file_data || `<!-- theme template not found: ${filePath} -->`
|
|
16993
|
+
);
|
|
16994
|
+
}
|
|
16995
|
+
async exists(filePath) {
|
|
16996
|
+
const template = await this.liquidSwell.getThemeConfig(filePath);
|
|
16997
|
+
return Boolean(template);
|
|
16998
|
+
}
|
|
16999
|
+
readFileSync(_filePath) {
|
|
17000
|
+
return "";
|
|
17001
|
+
}
|
|
17002
|
+
existsSync(_filePath) {
|
|
17003
|
+
return false;
|
|
17004
|
+
}
|
|
17005
|
+
contains(_root, _file) {
|
|
17006
|
+
return true;
|
|
17007
|
+
}
|
|
17008
|
+
resolve(_dir, file, _ext) {
|
|
17009
|
+
return file;
|
|
17010
|
+
}
|
|
17011
|
+
fallback(_filePath) {
|
|
17012
|
+
return;
|
|
17013
|
+
}
|
|
17014
|
+
};
|
|
16998
17015
|
|
|
16999
17016
|
// src/theme/theme-loader.ts
|
|
17000
17017
|
var MAX_INDIVIDUAL_CONFIGS_TO_FETCH = 50;
|
|
@@ -18711,11 +18728,14 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
|
|
|
18711
18728
|
* Get a list of sections and section groups in a page layout.
|
|
18712
18729
|
*/
|
|
18713
18730
|
async getPageSectionGroups(pageId, altTemplate) {
|
|
18714
|
-
|
|
18731
|
+
let pageConfig = this._getTemplateConfigByType(
|
|
18715
18732
|
"templates",
|
|
18716
18733
|
pageId,
|
|
18717
18734
|
altTemplate
|
|
18718
18735
|
);
|
|
18736
|
+
if (!pageConfig) {
|
|
18737
|
+
pageConfig = this._getTemplateConfigByType("templates", pageId);
|
|
18738
|
+
}
|
|
18719
18739
|
if (pageConfig === null) {
|
|
18720
18740
|
return [];
|
|
18721
18741
|
}
|
|
@@ -19015,12 +19035,6 @@ function parseJsonConfig(config) {
|
|
|
19015
19035
|
return {};
|
|
19016
19036
|
}
|
|
19017
19037
|
}
|
|
19018
|
-
function replacerUnescape(match) {
|
|
19019
|
-
return match.includes('\\"') ? JSON.parse(`"${match}"`) : match;
|
|
19020
|
-
}
|
|
19021
|
-
function unescapeLiquidSyntax(template) {
|
|
19022
|
-
return template.replace(/\{\{.*?\}\}/g, replacerUnescape);
|
|
19023
|
-
}
|
|
19024
19038
|
function extractSchemaTag(template) {
|
|
19025
19039
|
const list = template.match(
|
|
19026
19040
|
/\{%-?\s*schema\s*-?%\}(.*)\{%-?\s*endschema\s*-?%\}/s
|
|
@@ -19720,6 +19734,11 @@ var HtmlCache = class {
|
|
|
19720
19734
|
if (request.headers.get("swell-deployment-mode") === "editor") return false;
|
|
19721
19735
|
if (request.headers.get("cache-control")?.includes("no-cache"))
|
|
19722
19736
|
return false;
|
|
19737
|
+
const storefrontId = request.headers.get("swell-storefront-id");
|
|
19738
|
+
const themeVersionHash = request.headers.get("swell-theme-version-hash");
|
|
19739
|
+
if (!storefrontId || !themeVersionHash) {
|
|
19740
|
+
return false;
|
|
19741
|
+
}
|
|
19723
19742
|
return true;
|
|
19724
19743
|
}
|
|
19725
19744
|
isResponseCacheable(response, matchedRule) {
|