@swell/apps-sdk 1.0.174 → 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 +70 -59
- package/dist/index.cjs.map +3 -3
- package/dist/index.js +70 -59
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +70 -59
- 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.mjs
CHANGED
|
@@ -3871,7 +3871,7 @@ var Cache = class {
|
|
|
3871
3871
|
/**
|
|
3872
3872
|
* Always fetches fresh data and updates cache
|
|
3873
3873
|
* Deduplicates concurrent requests with the same key
|
|
3874
|
-
*
|
|
3874
|
+
*
|
|
3875
3875
|
* @param key Cache key
|
|
3876
3876
|
* @param fetchFn Function to fetch fresh data
|
|
3877
3877
|
* @param ttl Time to live in milliseconds (default: DEFAULT_SWR_TTL)
|
|
@@ -14617,6 +14617,14 @@ var RenderDrop = class extends Drop14 {
|
|
|
14617
14617
|
// src/liquid/index.ts
|
|
14618
14618
|
import { Liquid as Liquid3 } from "liquidjs";
|
|
14619
14619
|
|
|
14620
|
+
// src/utils/escape.ts
|
|
14621
|
+
function replacerUnescape(match) {
|
|
14622
|
+
return match.includes('\\"') ? JSON.parse(`"${match}"`) : match;
|
|
14623
|
+
}
|
|
14624
|
+
function unescapeLiquidSyntax(template) {
|
|
14625
|
+
return template.replace(/\{\{.*?\}\}/g, replacerUnescape);
|
|
14626
|
+
}
|
|
14627
|
+
|
|
14620
14628
|
// src/liquid/tags/assign.ts
|
|
14621
14629
|
import {
|
|
14622
14630
|
Value,
|
|
@@ -15133,28 +15141,30 @@ import { assert as assert2, evalToken as evalToken5, RenderTag as LiquidRenderTa
|
|
|
15133
15141
|
function bind10(liquidSwell) {
|
|
15134
15142
|
return class RenderTag extends LiquidRenderTag {
|
|
15135
15143
|
*render(ctx, emitter) {
|
|
15136
|
-
const
|
|
15137
|
-
const
|
|
15138
|
-
|
|
15144
|
+
const self = this;
|
|
15145
|
+
const { liquid } = this;
|
|
15146
|
+
const { hash } = self;
|
|
15147
|
+
const filename = yield renderFilePath(
|
|
15148
|
+
self["file"],
|
|
15139
15149
|
ctx,
|
|
15140
15150
|
liquid
|
|
15141
15151
|
);
|
|
15142
|
-
assert2(
|
|
15143
|
-
const
|
|
15144
|
-
|
|
15152
|
+
assert2(filename, () => `illegal file path "${filename}"`);
|
|
15153
|
+
const configPath = yield liquidSwell.getComponentPath(
|
|
15154
|
+
filename
|
|
15145
15155
|
);
|
|
15146
15156
|
const childCtx = ctx.spawn();
|
|
15147
15157
|
const scope = childCtx.bottom();
|
|
15148
15158
|
assign(scope, yield hash.render(ctx));
|
|
15149
15159
|
const parentSection = yield ctx._get(["section"]);
|
|
15150
15160
|
if (parentSection) assign(scope, { section: parentSection });
|
|
15151
|
-
if (
|
|
15152
|
-
const { value, alias } =
|
|
15153
|
-
const aliasName = alias ||
|
|
15161
|
+
if (self["with"]) {
|
|
15162
|
+
const { value, alias } = self["with"];
|
|
15163
|
+
const aliasName = alias || filename;
|
|
15154
15164
|
scope[aliasName] = yield evalToken5(value, ctx);
|
|
15155
15165
|
}
|
|
15156
|
-
if (
|
|
15157
|
-
const { value, alias } =
|
|
15166
|
+
if (self["for"]) {
|
|
15167
|
+
const { value, alias } = self["for"];
|
|
15158
15168
|
let collection = yield evalToken5(value, ctx);
|
|
15159
15169
|
collection = yield resolveEnumerable(collection);
|
|
15160
15170
|
scope["forloop"] = new ForloopDrop(
|
|
@@ -15164,13 +15174,23 @@ function bind10(liquidSwell) {
|
|
|
15164
15174
|
);
|
|
15165
15175
|
for (const item of collection) {
|
|
15166
15176
|
scope[alias] = item;
|
|
15167
|
-
const
|
|
15168
|
-
|
|
15177
|
+
const templates = yield liquid._parseFile(
|
|
15178
|
+
configPath,
|
|
15179
|
+
childCtx.sync,
|
|
15180
|
+
void 0,
|
|
15181
|
+
self["currentFile"]
|
|
15182
|
+
);
|
|
15183
|
+
yield liquid.renderer.renderTemplates(templates, childCtx, emitter);
|
|
15169
15184
|
scope["forloop"].next();
|
|
15170
15185
|
}
|
|
15171
15186
|
} else {
|
|
15172
|
-
const
|
|
15173
|
-
|
|
15187
|
+
const templates = yield liquid._parseFile(
|
|
15188
|
+
configPath,
|
|
15189
|
+
childCtx.sync,
|
|
15190
|
+
void 0,
|
|
15191
|
+
self["currentFile"]
|
|
15192
|
+
);
|
|
15193
|
+
yield liquid.renderer.renderTemplates(templates, childCtx, emitter);
|
|
15174
15194
|
}
|
|
15175
15195
|
}
|
|
15176
15196
|
};
|
|
@@ -16770,13 +16790,15 @@ var LiquidSwell30 = class extends Liquid3 {
|
|
|
16770
16790
|
}) {
|
|
16771
16791
|
getThemeConfig = getThemeConfig || theme.getThemeConfig.bind(theme);
|
|
16772
16792
|
extName = extName || "liquid";
|
|
16793
|
+
const fs = new LiquidFS(extName);
|
|
16773
16794
|
super({
|
|
16774
|
-
cache:
|
|
16795
|
+
cache: true,
|
|
16775
16796
|
relativeReference: false,
|
|
16776
|
-
fs
|
|
16797
|
+
fs,
|
|
16777
16798
|
ownPropertyOnly: false,
|
|
16778
16799
|
operators: swellOperators
|
|
16779
16800
|
});
|
|
16801
|
+
fs.liquidSwell = this;
|
|
16780
16802
|
this.theme = theme;
|
|
16781
16803
|
this.getThemeConfig = getThemeConfig;
|
|
16782
16804
|
this.getThemeTemplateConfigByType = getThemeTemplateConfigByType || theme.getThemeTemplateConfigByType.bind(theme);
|
|
@@ -16819,41 +16841,36 @@ var LiquidSwell30 = class extends Liquid3 {
|
|
|
16819
16841
|
function resolveFilePath(fileName, extName) {
|
|
16820
16842
|
return `theme/${fileName}.${extName}`;
|
|
16821
16843
|
}
|
|
16822
|
-
|
|
16823
|
-
|
|
16824
|
-
|
|
16825
|
-
|
|
16826
|
-
|
|
16827
|
-
|
|
16828
|
-
|
|
16829
|
-
|
|
16830
|
-
|
|
16831
|
-
|
|
16832
|
-
|
|
16833
|
-
|
|
16834
|
-
|
|
16835
|
-
|
|
16836
|
-
|
|
16837
|
-
|
|
16838
|
-
|
|
16839
|
-
|
|
16840
|
-
|
|
16841
|
-
|
|
16842
|
-
|
|
16843
|
-
|
|
16844
|
-
|
|
16845
|
-
|
|
16846
|
-
|
|
16847
|
-
|
|
16848
|
-
|
|
16849
|
-
|
|
16850
|
-
|
|
16851
|
-
|
|
16852
|
-
fallback(_filePath) {
|
|
16853
|
-
return;
|
|
16854
|
-
}
|
|
16855
|
-
};
|
|
16856
|
-
}
|
|
16844
|
+
var LiquidFS = class {
|
|
16845
|
+
liquidSwell;
|
|
16846
|
+
constructor(_extName) {
|
|
16847
|
+
}
|
|
16848
|
+
async readFile(filePath) {
|
|
16849
|
+
const template = await this.liquidSwell.getThemeConfig(filePath);
|
|
16850
|
+
return unescapeLiquidSyntax(
|
|
16851
|
+
template?.file_data || `<!-- theme template not found: ${filePath} -->`
|
|
16852
|
+
);
|
|
16853
|
+
}
|
|
16854
|
+
async exists(filePath) {
|
|
16855
|
+
const template = await this.liquidSwell.getThemeConfig(filePath);
|
|
16856
|
+
return Boolean(template);
|
|
16857
|
+
}
|
|
16858
|
+
readFileSync(_filePath) {
|
|
16859
|
+
return "";
|
|
16860
|
+
}
|
|
16861
|
+
existsSync(_filePath) {
|
|
16862
|
+
return false;
|
|
16863
|
+
}
|
|
16864
|
+
contains(_root, _file) {
|
|
16865
|
+
return true;
|
|
16866
|
+
}
|
|
16867
|
+
resolve(_dir, file, _ext) {
|
|
16868
|
+
return file;
|
|
16869
|
+
}
|
|
16870
|
+
fallback(_filePath) {
|
|
16871
|
+
return;
|
|
16872
|
+
}
|
|
16873
|
+
};
|
|
16857
16874
|
|
|
16858
16875
|
// src/theme/theme-loader.ts
|
|
16859
16876
|
var MAX_INDIVIDUAL_CONFIGS_TO_FETCH = 50;
|
|
@@ -18877,12 +18894,6 @@ function parseJsonConfig(config) {
|
|
|
18877
18894
|
return {};
|
|
18878
18895
|
}
|
|
18879
18896
|
}
|
|
18880
|
-
function replacerUnescape(match) {
|
|
18881
|
-
return match.includes('\\"') ? JSON.parse(`"${match}"`) : match;
|
|
18882
|
-
}
|
|
18883
|
-
function unescapeLiquidSyntax(template) {
|
|
18884
|
-
return template.replace(/\{\{.*?\}\}/g, replacerUnescape);
|
|
18885
|
-
}
|
|
18886
18897
|
function extractSchemaTag(template) {
|
|
18887
18898
|
const list = template.match(
|
|
18888
18899
|
/\{%-?\s*schema\s*-?%\}(.*)\{%-?\s*endschema\s*-?%\}/s
|